diff --git a/CHANGELOG.md b/CHANGELOG.md index 26ad82b2..05d6f927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,16 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) ## [Unreleased] +## [1.1.1] - 2020-05-30 +### Added +* Add "netlify-config-path" input to specify path to `netlify.toml` +* Support GitHub Deployments + +### Changed +* Update dependencies + ## [1.1.0] - 2020-05-10 -## Added +### Added * Add "overwrites-pull-request-comment" input ### Changed @@ -18,7 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) ### Changed * Update dependencies -## Added +### Added * Add "enable-pull-request-comment" input * Add "enable-commit-comment" input @@ -95,7 +103,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) * Deploy to Netlify * Comment on GitHub PR -[Unreleased]: https://github.com/nwtgck/actions-netlify/compare/v1.1.0...HEAD +[Unreleased]: https://github.com/nwtgck/actions-netlify/compare/v1.1.1...HEAD +[1.1.1]: https://github.com/nwtgck/actions-netlify/compare/v1.1.0...v1.1.1 [1.1.0]: https://github.com/nwtgck/actions-netlify/compare/v1.0.13...v1.1.0 [1.0.13]: https://github.com/nwtgck/actions-netlify/compare/v1.0.12...v1.0.13 [1.0.12]: https://github.com/nwtgck/actions-netlify/compare/v1.0.11...v1.0.12 diff --git a/README.md b/README.md index c89ee57f..01efffbd 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ GitHub Actions for deploying to Netlify Deploy URLs are commented on your pull requests and commit comments! + + +GitHub Deployments are also supported! + ## Usage ```yaml @@ -22,8 +26,7 @@ jobs: steps: - uses: actions/checkout@v2 - # Build to ./dist or other directory - # ... + # ( Build to ./dist or other directory... ) - name: Deploy to Netlify uses: nwtgck/actions-netlify@v1.1 @@ -53,7 +56,8 @@ jobs: - `deploy-message` A custom deploy message to see on Netlify deployment (e.g. `${{ github.event.pull_request.title }}`) - `enable-pull-request-comment: true` Comment on pull request (default: true) - `enable-commit-comment: true` Comment on GitHub commit (default: true) -- `overwrites-pull-request-comment: true` Overwirtes comment on pull request (default: true) +- `overwrites-pull-request-comment: true` Overwrites comment on pull request (default: true) +- `netlify-config-path: ./netlify.toml` Path to `netlify.toml` (default: undefined) ### Outputs - `deploy-url` A deployment URL generated by Netlify diff --git a/action.yml b/action.yml index 4b2f2e32..ef6a85c1 100644 --- a/action.yml +++ b/action.yml @@ -23,6 +23,9 @@ inputs: overwrites-pull-request-comment: description: Overwrites pull request comment required: false + netlify-config-path: + description: Path to netlify.toml + required: false outputs: deploy-url: description: Deploy URL diff --git a/dist/index.js b/dist/index.js index 1eff73d4..d79be448 100644 --- a/dist/index.js +++ b/dist/index.js @@ -19,7 +19,13 @@ module.exports = /******/ }; /******/ /******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ var threw = true; +/******/ try { +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ threw = false; +/******/ } finally { +/******/ if(threw) delete installedModules[moduleId]; +/******/ } /******/ /******/ // Flag the module as loaded /******/ module.l = true; @@ -4033,8 +4039,49 @@ module.exports = { /***/ }), -/* 32 */, -/* 33 */, +/* 32 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const patch = (a, loose) => new SemVer(a, loose).patch +module.exports = patch + + +/***/ }), +/* 33 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// Copyright (c) 2012 Mathieu Turcotte +// Licensed under the MIT license. + +var util = __webpack_require__(669); + +var BackoffStrategy = __webpack_require__(105); + +// Fibonacci backoff strategy. +function FibonacciBackoffStrategy(options) { + BackoffStrategy.call(this, options); + this.backoffDelay_ = 0; + this.nextBackoffDelay_ = this.getInitialDelay(); +} +util.inherits(FibonacciBackoffStrategy, BackoffStrategy); + +FibonacciBackoffStrategy.prototype.next_ = function() { + var backoffDelay = Math.min(this.nextBackoffDelay_, this.getMaxDelay()); + this.nextBackoffDelay_ += this.backoffDelay_; + this.backoffDelay_ = backoffDelay; + return backoffDelay; +}; + +FibonacciBackoffStrategy.prototype.reset_ = function() { + this.nextBackoffDelay_ = this.getInitialDelay(); + this.backoffDelay_ = 0; +}; + +module.exports = FibonacciBackoffStrategy; + + +/***/ }), /* 34 */ /***/ (function(module, exports, __webpack_require__) { @@ -5534,7 +5581,19 @@ module.exports = windowsRelease; /***/ }), -/* 50 */, +/* 50 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const compareBuild = (a, b, loose) => { + const versionA = new SemVer(a, loose) + const versionB = new SemVer(b, loose) + return versionA.compare(versionB) || versionA.compareBuild(versionB) +} +module.exports = compareBuild + + +/***/ }), /* 51 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -6620,7 +6679,18 @@ module.exports = { }; /***/ }), -/* 64 */, +/* 64 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(658) +const valid = (version, options) => { + const v = parse(version, options) + return v ? v.version : null +} +module.exports = valid + + +/***/ }), /* 65 */, /* 66 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -6991,7 +7061,15 @@ module.exports = Object.freeze({ /***/ }), -/* 79 */, +/* 79 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const patch = (a, loose) => new SemVer(a, loose).patch +module.exports = patch + + +/***/ }), /* 80 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -8179,7 +8257,15 @@ formatters.O = function (v) { /***/ }), -/* 83 */, +/* 83 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const major = (a, loose) => new SemVer(a, loose).major +module.exports = major + + +/***/ }), /* 84 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -8887,7 +8973,7 @@ module.exports = class Parser { Object.defineProperty(exports, "__esModule", { value: true }); const ts = __webpack_require__(752); const type_1 = __webpack_require__(144); -const util_1 = __webpack_require__(833); +const util_1 = __webpack_require__(713); const node_1 = __webpack_require__(10); function isEmptyObjectType(type) { if (type_1.isObjectType(type) && @@ -10244,7 +10330,60 @@ function regExpEscape (s) { /***/ }), -/* 94 */, +/* 94 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// just pre-load all the stuff that index.js lazily exports +const internalRe = __webpack_require__(331) +module.exports = { + re: internalRe.re, + src: internalRe.src, + tokens: internalRe.t, + SEMVER_SPEC_VERSION: __webpack_require__(749).SEMVER_SPEC_VERSION, + SemVer: __webpack_require__(243), + compareIdentifiers: __webpack_require__(513).compareIdentifiers, + rcompareIdentifiers: __webpack_require__(513).rcompareIdentifiers, + parse: __webpack_require__(147), + valid: __webpack_require__(803), + clean: __webpack_require__(435), + inc: __webpack_require__(989), + diff: __webpack_require__(119), + major: __webpack_require__(83), + minor: __webpack_require__(610), + patch: __webpack_require__(79), + prerelease: __webpack_require__(193), + compare: __webpack_require__(570), + rcompare: __webpack_require__(586), + compareLoose: __webpack_require__(970), + compareBuild: __webpack_require__(50), + sort: __webpack_require__(899), + rsort: __webpack_require__(281), + gt: __webpack_require__(738), + lt: __webpack_require__(375), + eq: __webpack_require__(528), + neq: __webpack_require__(291), + gte: __webpack_require__(790), + lte: __webpack_require__(546), + cmp: __webpack_require__(308), + coerce: __webpack_require__(159), + Comparator: __webpack_require__(456), + Range: __webpack_require__(635), + satisfies: __webpack_require__(171), + toComparators: __webpack_require__(931), + maxSatisfying: __webpack_require__(426), + minSatisfying: __webpack_require__(693), + minVersion: __webpack_require__(491), + validRange: __webpack_require__(397), + outside: __webpack_require__(776), + gtr: __webpack_require__(258), + ltr: __webpack_require__(163), + intersects: __webpack_require__(927), + simplifyRange: __webpack_require__(632), + subset: __webpack_require__(578), +} + + +/***/ }), /* 95 */, /* 96 */, /* 97 */, @@ -12336,7 +12475,35 @@ module.exports.default = macosRelease; /***/ }), -/* 119 */, +/* 119 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(147) +const eq = __webpack_require__(528) + +const diff = (version1, version2) => { + if (eq(version1, version2)) { + return null + } else { + const v1 = parse(version1) + const v2 = parse(version2) + const hasPre = v1.prerelease.length || v2.prerelease.length + const prefix = hasPre ? 'pre' : '' + const defaultResult = hasPre ? 'prerelease' : '' + for (const key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key + } + } + } + return defaultResult // may be undefined + } +} +module.exports = diff + + +/***/ }), /* 120 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -13134,9 +13301,19 @@ Glob.prototype._stat2 = function (f, abs, er, stat, cb) { /***/ }), /* 121 */ -/***/ (function(module) { +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(986) +const satisfies = (version, range, options) => { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) +} +module.exports = satisfies -module.exports = {"assert":true,"async_hooks":">= 8","buffer_ieee754":"< 0.9.7","buffer":true,"child_process":true,"cluster":true,"console":true,"constants":true,"crypto":true,"_debug_agent":">= 1 && < 8","_debugger":"< 8","dgram":true,"dns":true,"domain":true,"events":true,"freelist":"< 6","fs":true,"fs/promises":">= 10 && < 10.1","_http_agent":">= 0.11.1","_http_client":">= 0.11.1","_http_common":">= 0.11.1","_http_incoming":">= 0.11.1","_http_outgoing":">= 0.11.1","_http_server":">= 0.11.1","http":true,"http2":">= 8.8","https":true,"inspector":">= 8.0.0","_linklist":"< 8","module":true,"net":true,"node-inspect/lib/_inspect":">= 7.6.0 && < 12","node-inspect/lib/internal/inspect_client":">= 7.6.0 && < 12","node-inspect/lib/internal/inspect_repl":">= 7.6.0 && < 12","os":true,"path":true,"perf_hooks":">= 8.5","process":">= 1","punycode":true,"querystring":true,"readline":true,"repl":true,"smalloc":">= 0.11.5 && < 3","_stream_duplex":">= 0.9.4","_stream_transform":">= 0.9.4","_stream_wrap":">= 1.4.1","_stream_passthrough":">= 0.9.4","_stream_readable":">= 0.9.4","_stream_writable":">= 0.9.4","stream":true,"string_decoder":true,"sys":true,"timers":true,"_tls_common":">= 0.11.13","_tls_legacy":">= 0.11.3 && < 10","_tls_wrap":">= 0.11.3","tls":true,"trace_events":">= 10","tty":true,"url":true,"util":true,"v8/tools/arguments":">= 10 && < 12","v8/tools/codemap":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/consarray":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/csvparser":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/logreader":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/profile_view":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/splaytree":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8":">= 1","vm":true,"wasi":">= 13.4 && < 13.5","worker_threads":">= 11.7","zlib":true}; /***/ }), /* 122 */ @@ -13360,7 +13537,151 @@ module.exports = class Node { /***/ }), -/* 123 */, +/* 123 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const ANY = Symbol('SemVer ANY') +// hoisted class for cyclic dependency +class Comparator { + static get ANY () { + return ANY + } + constructor (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } + + debug('comparator', comp, options) + this.options = options + this.loose = !!options.loose + this.parse(comp) + + if (this.semver === ANY) { + this.value = '' + } else { + this.value = this.operator + this.semver.version + } + + debug('comp', this) + } + + parse (comp) { + const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + const m = comp.match(r) + + if (!m) { + throw new TypeError(`Invalid comparator: ${comp}`) + } + + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } + + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY + } else { + this.semver = new SemVer(m[2], this.options.loose) + } + } + + toString () { + return this.value + } + + test (version) { + debug('Comparator.test', version, this.options.loose) + + if (this.semver === ANY || version === ANY) { + return true + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + return cmp(version, this.operator, this.semver, this.options) + } + + intersects (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (this.operator === '') { + if (this.value === '') { + return true + } + return new Range(comp.value, options).test(this.value) + } else if (comp.operator === '') { + if (comp.value === '') { + return true + } + return new Range(this.value, options).test(comp.semver) + } + + const sameDirectionIncreasing = + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '>=' || comp.operator === '>') + const sameDirectionDecreasing = + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '<=' || comp.operator === '<') + const sameSemVer = this.semver.version === comp.semver.version + const differentDirectionsInclusive = + (this.operator === '>=' || this.operator === '<=') && + (comp.operator === '>=' || comp.operator === '<=') + const oppositeDirectionsLessThan = + cmp(this.semver, '<', comp.semver, options) && + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '<=' || comp.operator === '<') + const oppositeDirectionsGreaterThan = + cmp(this.semver, '>', comp.semver, options) && + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '>=' || comp.operator === '>') + + return ( + sameDirectionIncreasing || + sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || + oppositeDirectionsGreaterThan + ) + } +} + +module.exports = Comparator + +const {re, t} = __webpack_require__(590) +const cmp = __webpack_require__(134) +const debug = __webpack_require__(487) +const SemVer = __webpack_require__(369) +const Range = __webpack_require__(986) + + +/***/ }), /* 124 */, /* 125 */, /* 126 */ @@ -14359,7 +14680,60 @@ exports.isTupleTypeReference = isTupleTypeReference; /***/ }), /* 133 */, -/* 134 */, +/* 134 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const eq = __webpack_require__(804) +const neq = __webpack_require__(335) +const gt = __webpack_require__(136) +const gte = __webpack_require__(618) +const lt = __webpack_require__(342) +const lte = __webpack_require__(495) + +const cmp = (a, op, b, loose) => { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a === b + + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b + + case '': + case '=': + case '==': + return eq(a, b, loose) + + case '!=': + return neq(a, b, loose) + + case '>': + return gt(a, b, loose) + + case '>=': + return gte(a, b, loose) + + case '<': + return lt(a, b, loose) + + case '<=': + return lte(a, b, loose) + + default: + throw new TypeError(`Invalid operator: ${op}`) + } +} +module.exports = cmp + + +/***/ }), /* 135 */ /***/ (function(module) { @@ -36795,7 +37169,15 @@ return /******/ (function(modules) { // webpackBootstrap ; /***/ }), -/* 136 */, +/* 136 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(682) +const gt = (a, b, loose) => compare(a, b, loose) > 0 +module.exports = gt + + +/***/ }), /* 137 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -36999,7 +37381,7 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); const ts = __importStar(__webpack_require__(752)); -const util_1 = __webpack_require__(833); +const util_1 = __webpack_require__(713); const node_utils_1 = __webpack_require__(277); const ts_estree_1 = __webpack_require__(372); /** @@ -37428,7 +37810,49 @@ module.exports = { /***/ }), -/* 147 */, +/* 147 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const {MAX_LENGTH} = __webpack_require__(749) +const { re, t } = __webpack_require__(331) +const SemVer = __webpack_require__(243) + +const parse = (version, options) => { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (version instanceof SemVer) { + return version + } + + if (typeof version !== 'string') { + return null + } + + if (version.length > MAX_LENGTH) { + return null + } + + const r = options.loose ? re[t.LOOSE] : re[t.FULL] + if (!r.test(version)) { + return null + } + + try { + return new SemVer(version, options) + } catch (er) { + return null + } +} + +module.exports = parse + + +/***/ }), /* 148 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -37510,7 +37934,15 @@ SafeBuffer.allocUnsafeSlow = function (size) { /***/ }), -/* 150 */, +/* 150 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compareBuild = __webpack_require__(805) +const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) +module.exports = rsort + + +/***/ }), /* 151 */, /* 152 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -37523,7 +37955,7 @@ var precond = __webpack_require__(450); var util = __webpack_require__(669); var Backoff = __webpack_require__(650); -var FibonacciBackoffStrategy = __webpack_require__(435); +var FibonacciBackoffStrategy = __webpack_require__(33); // Wraps a function to be called in a backoff loop. function FunctionCall(fn, args, callback) { @@ -38049,7 +38481,12 @@ module.exports = ProgressEmitter; /***/ }), -/* 156 */, +/* 156 */ +/***/ (function(module) { + +module.exports = {"_from":"@typescript-eslint/typescript-estree@2.34.0","_id":"@typescript-eslint/typescript-estree@2.34.0","_inBundle":false,"_integrity":"sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg==","_location":"/@typescript-eslint/typescript-estree","_phantomChildren":{},"_requested":{"type":"version","registry":true,"raw":"@typescript-eslint/typescript-estree@2.34.0","name":"@typescript-eslint/typescript-estree","escapedName":"@typescript-eslint%2ftypescript-estree","scope":"@typescript-eslint","rawSpec":"2.34.0","saveSpec":null,"fetchSpec":"2.34.0"},"_requiredBy":["/@typescript-eslint/experimental-utils","/@typescript-eslint/parser","/detective-typescript"],"_resolved":"https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz","_shasum":"14aeb6353b39ef0732cc7f1b8285294937cf37d5","_spec":"@typescript-eslint/typescript-estree@2.34.0","_where":"/Users/ryo/dev/actions/actions-netlify/node_modules/@typescript-eslint/parser","bugs":{"url":"https://github.com/typescript-eslint/typescript-eslint/issues"},"bundleDependencies":false,"dependencies":{"debug":"^4.1.1","eslint-visitor-keys":"^1.1.0","glob":"^7.1.6","is-glob":"^4.0.1","lodash":"^4.17.15","semver":"^7.3.2","tsutils":"^3.17.1"},"deprecated":false,"description":"A parser that converts TypeScript source code into an ESTree compatible form","devDependencies":{"@babel/code-frame":"^7.8.3","@babel/parser":"^7.8.3","@babel/types":"^7.8.3","@types/babel__code-frame":"^7.0.1","@types/debug":"^4.1.5","@types/glob":"^7.1.1","@types/is-glob":"^4.0.1","@types/lodash":"^4.14.149","@types/semver":"^7.1.0","@types/tmp":"^0.2.0","@typescript-eslint/shared-fixtures":"2.34.0","tmp":"^0.2.1","typescript":"*"},"engines":{"node":"^8.10.0 || ^10.13.0 || >=11.10.1"},"files":["dist","README.md","LICENSE"],"funding":{"type":"opencollective","url":"https://opencollective.com/typescript-eslint"},"gitHead":"f18890166146d8c6b8804ef705c04b15da269926","homepage":"https://github.com/typescript-eslint/typescript-eslint#readme","keywords":["ast","estree","ecmascript","javascript","typescript","parser","syntax"],"license":"BSD-2-Clause","main":"dist/parser.js","name":"@typescript-eslint/typescript-estree","peerDependenciesMeta":{"typescript":{"optional":true}},"repository":{"type":"git","url":"git+https://github.com/typescript-eslint/typescript-eslint.git","directory":"packages/typescript-estree"},"scripts":{"build":"tsc -b tsconfig.build.json","clean":"tsc -b tsconfig.build.json --clean","format":"prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore","lint":"eslint . --ext .js,.ts --ignore-path='../../.eslintignore'","test":"jest --coverage","typecheck":"tsc -p tsconfig.json --noEmit"},"types":"dist/parser.d.ts","version":"2.34.0"}; + +/***/ }), /* 157 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -38109,7 +38546,63 @@ async function hashFns(dir, opts) { /***/ }), /* 158 */, -/* 159 */, +/* 159 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const parse = __webpack_require__(147) +const {re, t} = __webpack_require__(331) + +const coerce = (version, options) => { + if (version instanceof SemVer) { + return version + } + + if (typeof version === 'number') { + version = String(version) + } + + if (typeof version !== 'string') { + return null + } + + options = options || {} + + let match = null + if (!options.rtl) { + match = version.match(re[t.COERCE]) + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + let next + while ((next = re[t.COERCERTL].exec(version)) && + (!match || match.index + match[0].length !== version.length) + ) { + if (!match || + next.index + next[0].length !== match.index + match[0].length) { + match = next + } + re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + } + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 + } + + if (match === null) + return null + + return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) +} +module.exports = coerce + + +/***/ }), /* 160 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -38157,7 +38650,16 @@ exports.default = crc16ccitt; /***/ }), /* 161 */, /* 162 */, -/* 163 */, +/* 163 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const outside = __webpack_require__(776) +// Determine if version is less than all the versions possible in the range +const ltr = (version, range, options) => outside(version, range, '<', options) +module.exports = ltr + + +/***/ }), /* 164 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -38532,7 +39034,22 @@ module.exports = { }; /***/ }), -/* 171 */, +/* 171 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(635) +const satisfies = (version, range, options) => { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) +} +module.exports = satisfies + + +/***/ }), /* 172 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -41749,7 +42266,18 @@ module.exports = __webpack_require__(316).default; /***/ }), /* 192 */, -/* 193 */, +/* 193 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(147) +const prerelease = (version, options) => { + const parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} +module.exports = prerelease + + +/***/ }), /* 194 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -41852,6 +42380,25 @@ function checkMode (stat, options) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -41861,13 +42408,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -41896,6 +42436,30 @@ function findIssueComment(githubClient) { return undefined; }); } +function createGitHubDeployment(githubClient, environmentUrl, environment) { + return __awaiter(this, void 0, void 0, function* () { + const { ref } = github_1.context; + const deployment = yield githubClient.repos.createDeployment({ + // eslint-disable-next-line @typescript-eslint/camelcase + auto_merge: false, + owner: github_1.context.repo.owner, + repo: github_1.context.repo.repo, + ref, + environment, + // eslint-disable-next-line @typescript-eslint/camelcase + required_contexts: [] + }); + yield githubClient.repos.createDeploymentStatus({ + state: 'success', + // eslint-disable-next-line @typescript-eslint/camelcase + environment_url: environmentUrl, + owner: github_1.context.repo.owner, + repo: github_1.context.repo.repo, + // eslint-disable-next-line @typescript-eslint/camelcase + deployment_id: deployment.data.id + }); + }); +} function run(inputs) { return __awaiter(this, void 0, void 0, function* () { try { @@ -41912,6 +42476,7 @@ function run(inputs) { const enablePullRequestComment = inputs.enablePullRequestComment(); const enableCommitComment = inputs.enableCommitComment(); const overwritesPullRequestComment = inputs.overwritesPullRequestComment(); + const netlifyConfigPath = inputs.netlifyConfigPath(); const isDraft = productionBranch === undefined || github_1.context.ref !== `refs/heads/${productionBranch}`; // Create Netlify API client @@ -41921,7 +42486,8 @@ function run(inputs) { // Deploy to Netlify const deploy = yield netlifyClient.deploy(siteId, deployFolder, { draft: isDraft, - message: deployMessage + message: deployMessage, + configPath: netlifyConfigPath }); // Create a message const message = isDraft @@ -41956,33 +42522,59 @@ function run(inputs) { console.error(err, JSON.stringify(commitCommentParams, null, 2)); } } + if (github_1.context.issue.number === undefined) { + try { + const environmentUrl = isDraft + ? deploy.deploy.deploy_ssl_url + : deploy.deploy.ssl_url; + const environment = isDraft ? 'commit' : 'production'; + // Create GitHub Deployment + yield createGitHubDeployment(githubClient, environmentUrl, environment); + } + catch (err) { + // eslint-disable-next-line no-console + console.error(err); + } + } // If it is a pull request and enable comment on pull request - if (github_1.context.issue.number !== undefined && enablePullRequestComment) { - let commentId = undefined; - if (overwritesPullRequestComment) { - // Find issue comment - commentId = yield findIssueComment(githubClient); - } - // NOTE: if not overwrite, commentId is always undefined - if (commentId !== undefined) { - // Update comment of the deploy URL - yield githubClient.issues.updateComment({ - owner: github_1.context.issue.owner, - repo: github_1.context.issue.repo, - // eslint-disable-next-line @typescript-eslint/camelcase - comment_id: commentId, - body: markdownComment - }); - return; + if (github_1.context.issue.number !== undefined) { + if (enablePullRequestComment) { + let commentId = undefined; + if (overwritesPullRequestComment) { + // Find issue comment + commentId = yield findIssueComment(githubClient); + } + // NOTE: if not overwrite, commentId is always undefined + if (commentId !== undefined) { + // Update comment of the deploy URL + yield githubClient.issues.updateComment({ + owner: github_1.context.issue.owner, + repo: github_1.context.issue.repo, + // eslint-disable-next-line @typescript-eslint/camelcase + comment_id: commentId, + body: markdownComment + }); + } + else { + // Comment the deploy URL + yield githubClient.issues.createComment({ + // eslint-disable-next-line @typescript-eslint/camelcase + issue_number: github_1.context.issue.number, + owner: github_1.context.repo.owner, + repo: github_1.context.repo.repo, + body: markdownComment + }); + } + } + try { + const environmentUrl = deploy.deploy.deploy_ssl_url; + // Create GitHub Deployment + yield createGitHubDeployment(githubClient, environmentUrl, 'pull request'); + } + catch (err) { + // eslint-disable-next-line no-console + console.error(err); } - // Comment the deploy URL - yield githubClient.issues.createComment({ - // eslint-disable-next-line @typescript-eslint/camelcase - issue_number: github_1.context.issue.number, - owner: github_1.context.repo.owner, - repo: github_1.context.repo.repo, - body: markdownComment - }); } } } @@ -41995,7 +42587,611 @@ run(inputs_1.defaultInputs); /***/ }), -/* 199 */, +/* 199 */ +/***/ (function(module) { + +/** + * lodash (Custom Build) + * Build: `lodash modularize exports="npm" -o ./` + * Copyright jQuery Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ + +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0; + +/** `Object#toString` result references. */ +var symbolTag = '[object Symbol]'; + +/** Used to match words composed of alphanumeric characters. */ +var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; + +/** Used to match Latin Unicode letters (excluding mathematical operators). */ +var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; + +/** Used to compose unicode character classes. */ +var rsAstralRange = '\\ud800-\\udfff', + rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0', + rsDingbatRange = '\\u2700-\\u27bf', + rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', + rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', + rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', + rsPunctuationRange = '\\u2000-\\u206f', + rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', + rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', + rsVarRange = '\\ufe0e\\ufe0f', + rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; + +/** Used to compose unicode capture groups. */ +var rsApos = "['\u2019]", + rsAstral = '[' + rsAstralRange + ']', + rsBreak = '[' + rsBreakRange + ']', + rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']', + rsDigits = '\\d+', + rsDingbat = '[' + rsDingbatRange + ']', + rsLower = '[' + rsLowerRange + ']', + rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', + rsNonAstral = '[^' + rsAstralRange + ']', + rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', + rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', + rsUpper = '[' + rsUpperRange + ']', + rsZWJ = '\\u200d'; + +/** Used to compose unicode regexes. */ +var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')', + rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')', + rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', + rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', + reOptMod = rsModifier + '?', + rsOptVar = '[' + rsVarRange + ']?', + rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', + rsSeq = rsOptVar + reOptMod + rsOptJoin, + rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, + rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; + +/** Used to match apostrophes. */ +var reApos = RegExp(rsApos, 'g'); + +/** + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ +var reComboMark = RegExp(rsCombo, 'g'); + +/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ +var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); + +/** Used to match complex or compound words. */ +var reUnicodeWord = RegExp([ + rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', + rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')', + rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr, + rsUpper + '+' + rsOptUpperContr, + rsDigits, + rsEmoji +].join('|'), 'g'); + +/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ +var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); + +/** Used to detect strings that need a more robust regexp to match words. */ +var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; + +/** Used to map Latin Unicode letters to basic Latin letters. */ +var deburredLetters = { + // Latin-1 Supplement block. + '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', + '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', + '\xc7': 'C', '\xe7': 'c', + '\xd0': 'D', '\xf0': 'd', + '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', + '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', + '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', + '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', + '\xd1': 'N', '\xf1': 'n', + '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', + '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', + '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', + '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', + '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', + '\xc6': 'Ae', '\xe6': 'ae', + '\xde': 'Th', '\xfe': 'th', + '\xdf': 'ss', + // Latin Extended-A block. + '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', + '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', + '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', + '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', + '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', + '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', + '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', + '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', + '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', + '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', + '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', + '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', + '\u0134': 'J', '\u0135': 'j', + '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', + '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', + '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', + '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', + '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', + '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', + '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', + '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', + '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', + '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', + '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', + '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', + '\u0163': 't', '\u0165': 't', '\u0167': 't', + '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', + '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', + '\u0174': 'W', '\u0175': 'w', + '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', + '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', + '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', + '\u0132': 'IJ', '\u0133': 'ij', + '\u0152': 'Oe', '\u0153': 'oe', + '\u0149': "'n", '\u017f': 'ss' +}; + +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +/** + * A specialized version of `_.reduce` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {*} [accumulator] The initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as + * the initial value. + * @returns {*} Returns the accumulated value. + */ +function arrayReduce(array, iteratee, accumulator, initAccum) { + var index = -1, + length = array ? array.length : 0; + + if (initAccum && length) { + accumulator = array[++index]; + } + while (++index < length) { + accumulator = iteratee(accumulator, array[index], index, array); + } + return accumulator; +} + +/** + * Converts an ASCII `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function asciiToArray(string) { + return string.split(''); +} + +/** + * Splits an ASCII `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ +function asciiWords(string) { + return string.match(reAsciiWord) || []; +} + +/** + * The base implementation of `_.propertyOf` without support for deep paths. + * + * @private + * @param {Object} object The object to query. + * @returns {Function} Returns the new accessor function. + */ +function basePropertyOf(object) { + return function(key) { + return object == null ? undefined : object[key]; + }; +} + +/** + * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A + * letters to basic Latin letters. + * + * @private + * @param {string} letter The matched letter to deburr. + * @returns {string} Returns the deburred letter. + */ +var deburrLetter = basePropertyOf(deburredLetters); + +/** + * Checks if `string` contains Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a symbol is found, else `false`. + */ +function hasUnicode(string) { + return reHasUnicode.test(string); +} + +/** + * Checks if `string` contains a word composed of Unicode symbols. + * + * @private + * @param {string} string The string to inspect. + * @returns {boolean} Returns `true` if a word is found, else `false`. + */ +function hasUnicodeWord(string) { + return reHasUnicodeWord.test(string); +} + +/** + * Converts `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function stringToArray(string) { + return hasUnicode(string) + ? unicodeToArray(string) + : asciiToArray(string); +} + +/** + * Converts a Unicode `string` to an array. + * + * @private + * @param {string} string The string to convert. + * @returns {Array} Returns the converted array. + */ +function unicodeToArray(string) { + return string.match(reUnicode) || []; +} + +/** + * Splits a Unicode `string` into an array of its words. + * + * @private + * @param {string} The string to inspect. + * @returns {Array} Returns the words of `string`. + */ +function unicodeWords(string) { + return string.match(reUnicodeWord) || []; +} + +/** Used for built-in method references. */ +var objectProto = Object.prototype; + +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var objectToString = objectProto.toString; + +/** Built-in value references. */ +var Symbol = root.Symbol; + +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; + +/** + * The base implementation of `_.slice` without an iteratee call guard. + * + * @private + * @param {Array} array The array to slice. + * @param {number} [start=0] The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the slice of `array`. + */ +function baseSlice(array, start, end) { + var index = -1, + length = array.length; + + if (start < 0) { + start = -start > length ? 0 : (length + start); + } + end = end > length ? length : end; + if (end < 0) { + end += length; + } + length = start > end ? 0 : ((end - start) >>> 0); + start >>>= 0; + + var result = Array(length); + while (++index < length) { + result[index] = array[index + start]; + } + return result; +} + +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; + } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} + +/** + * Casts `array` to a slice if it's needed. + * + * @private + * @param {Array} array The array to inspect. + * @param {number} start The start position. + * @param {number} [end=array.length] The end position. + * @returns {Array} Returns the cast slice. + */ +function castSlice(array, start, end) { + var length = array.length; + end = end === undefined ? length : end; + return (!start && end >= length) ? array : baseSlice(array, start, end); +} + +/** + * Creates a function like `_.lowerFirst`. + * + * @private + * @param {string} methodName The name of the `String` case method to use. + * @returns {Function} Returns the new case function. + */ +function createCaseFirst(methodName) { + return function(string) { + string = toString(string); + + var strSymbols = hasUnicode(string) + ? stringToArray(string) + : undefined; + + var chr = strSymbols + ? strSymbols[0] + : string.charAt(0); + + var trailing = strSymbols + ? castSlice(strSymbols, 1).join('') + : string.slice(1); + + return chr[methodName]() + trailing; + }; +} + +/** + * Creates a function like `_.camelCase`. + * + * @private + * @param {Function} callback The function to combine each word. + * @returns {Function} Returns the new compounder function. + */ +function createCompounder(callback) { + return function(string) { + return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); + }; +} + +/** + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false + */ +function isObjectLike(value) { + return !!value && typeof value == 'object'; +} + +/** + * Checks if `value` is classified as a `Symbol` primitive or object. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false + */ +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && objectToString.call(value) == symbolTag); +} + +/** + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {string} Returns the string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' + */ +function toString(value) { + return value == null ? '' : baseToString(value); +} + +/** + * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the camel cased string. + * @example + * + * _.camelCase('Foo Bar'); + * // => 'fooBar' + * + * _.camelCase('--foo-bar--'); + * // => 'fooBar' + * + * _.camelCase('__FOO_BAR__'); + * // => 'fooBar' + */ +var camelCase = createCompounder(function(result, word, index) { + word = word.toLowerCase(); + return result + (index ? capitalize(word) : word); +}); + +/** + * Converts the first character of `string` to upper case and the remaining + * to lower case. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to capitalize. + * @returns {string} Returns the capitalized string. + * @example + * + * _.capitalize('FRED'); + * // => 'Fred' + */ +function capitalize(string) { + return upperFirst(toString(string).toLowerCase()); +} + +/** + * Deburrs `string` by converting + * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) + * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) + * letters to basic Latin letters and removing + * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to deburr. + * @returns {string} Returns the deburred string. + * @example + * + * _.deburr('déjà vu'); + * // => 'deja vu' + */ +function deburr(string) { + string = toString(string); + return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); +} + +/** + * Converts the first character of `string` to upper case. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category String + * @param {string} [string=''] The string to convert. + * @returns {string} Returns the converted string. + * @example + * + * _.upperFirst('fred'); + * // => 'Fred' + * + * _.upperFirst('FRED'); + * // => 'FRED' + */ +var upperFirst = createCaseFirst('toUpperCase'); + +/** + * Splits `string` into an array of its words. + * + * @static + * @memberOf _ + * @since 3.0.0 + * @category String + * @param {string} [string=''] The string to inspect. + * @param {RegExp|string} [pattern] The pattern to match words. + * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. + * @returns {Array} Returns the words of `string`. + * @example + * + * _.words('fred, barney, & pebbles'); + * // => ['fred', 'barney', 'pebbles'] + * + * _.words('fred, barney, & pebbles', /[^, ]+/g); + * // => ['fred', 'barney', '&', 'pebbles'] + */ +function words(string, pattern, guard) { + string = toString(string); + pattern = guard ? undefined : pattern; + + if (pattern === undefined) { + return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); + } + return string.match(pattern) || []; +} + +module.exports = camelCase; + + +/***/ }), /* 200 */ /***/ (function(__unusedmodule, exports) { @@ -42325,7 +43521,7 @@ function astConverter(ast, extra, shouldPreserveNodeMaps) { /** * Optionally remove range and loc if specified */ - if (extra.range || extra.loc) { + if (!extra.range || !extra.loc) { simple_traverse_1.simpleTraverse(estree, { enter: node => { if (!extra.range) { @@ -43076,7 +44272,36 @@ rimraf.sync = rimrafSync /***/ }), -/* 217 */, +/* 217 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const Range = __webpack_require__(986) +const minSatisfying = (versions, range, options) => { + let min = null + let minSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) + } + } + }) + return min +} +module.exports = minSatisfying + + +/***/ }), /* 218 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -43207,7 +44432,7 @@ function versionIncluded(specifierValue) { return matchesRange(specifierValue); } -var data = __webpack_require__(121); +var data = __webpack_require__(815); var core = {}; for (var mod in data) { // eslint-disable-line no-restricted-syntax @@ -53294,7 +54519,302 @@ Writable.prototype._destroy = function (err, cb) { /***/ }), /* 242 */, -/* 243 */, +/* 243 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const debug = __webpack_require__(509) +const { MAX_LENGTH, MAX_SAFE_INTEGER } = __webpack_require__(749) +const { re, t } = __webpack_require__(331) + +const { compareIdentifiers } = __webpack_require__(513) +class SemVer { + constructor (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + if (version instanceof SemVer) { + if (version.loose === !!options.loose && + version.includePrerelease === !!options.includePrerelease) { + return version + } else { + version = version.version + } + } else if (typeof version !== 'string') { + throw new TypeError(`Invalid Version: ${version}`) + } + + if (version.length > MAX_LENGTH) { + throw new TypeError( + `version is longer than ${MAX_LENGTH} characters` + ) + } + + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + // this isn't actually relevant for versions, but keep it so that we + // don't run into trouble passing this.options around. + this.includePrerelease = !!options.includePrerelease + + const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) + + if (!m) { + throw new TypeError(`Invalid Version: ${version}`) + } + + this.raw = version + + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] + + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } + + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } + + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } + + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = [] + } else { + this.prerelease = m[4].split('.').map((id) => { + if (/^[0-9]+$/.test(id)) { + const num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } + + this.build = m[5] ? m[5].split('.') : [] + this.format() + } + + format () { + this.version = `${this.major}.${this.minor}.${this.patch}` + if (this.prerelease.length) { + this.version += `-${this.prerelease.join('.')}` + } + return this.version + } + + toString () { + return this.version + } + + compare (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + if (typeof other === 'string' && other === this.version) { + return 0 + } + other = new SemVer(other, this.options) + } + + if (other.version === this.version) { + return 0 + } + + return this.compareMain(other) || this.comparePre(other) + } + + compareMain (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return ( + compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) + ) + } + + comparePre (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1 + } else if (!this.prerelease.length && other.prerelease.length) { + return 1 + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0 + } + + let i = 0 + do { + const a = this.prerelease[i] + const b = other.prerelease[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } + + compareBuild (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + let i = 0 + do { + const a = this.build[i] + const b = other.build[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } + + // preminor will bump the version up to the next minor release, and immediately + // down to pre-release. premajor and prepatch work the same way. + inc (release, identifier) { + switch (release) { + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier) + break + case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0 + this.inc('patch', identifier) + this.inc('pre', identifier) + break + // If the input is a non-prerelease version, this acts the same as + // prepatch. + case 'prerelease': + if (this.prerelease.length === 0) { + this.inc('patch', identifier) + } + this.inc('pre', identifier) + break + + case 'major': + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if ( + this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0 + ) { + this.major++ + } + this.minor = 0 + this.patch = 0 + this.prerelease = [] + break + case 'minor': + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++ + } + this.patch = 0 + this.prerelease = [] + break + case 'patch': + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++ + } + this.prerelease = [] + break + // This probably shouldn't be used publicly. + // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. + case 'pre': + if (this.prerelease.length === 0) { + this.prerelease = [0] + } else { + let i = this.prerelease.length + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++ + i = -2 + } + } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0) + } + } + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0] + } + } else { + this.prerelease = [identifier, 0] + } + } + break + + default: + throw new Error(`invalid increment argument: ${release}`) + } + this.format() + this.raw = this.version + return this + } +} + +module.exports = SemVer + + +/***/ }), /* 244 */ /***/ (function(module) { @@ -54667,7 +56187,16 @@ module.exports = (string, count = 1, options) => { /***/ }), -/* 258 */, +/* 258 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// Determine if version is greater than all the versions possible in the range. +const outside = __webpack_require__(776) +const gtr = (version, range, options) => outside(version, range, '>', options) +module.exports = gtr + + +/***/ }), /* 259 */ /***/ (function(module) { @@ -58728,7 +60257,15 @@ function coerce (version) { /***/ }), -/* 281 */, +/* 281 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compareBuild = __webpack_require__(50) +const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) +module.exports = rsort + + +/***/ }), /* 282 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -59119,8 +60656,32 @@ module.exports = function(fileContent) { /***/ }), /* 290 */, -/* 291 */, -/* 292 */, +/* 291 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(570) +const neq = (a, b, loose) => compare(a, b, loose) !== 0 +module.exports = neq + + +/***/ }), +/* 292 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(986) +const validRange = (range, options) => { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' + } catch (er) { + return null + } +} +module.exports = validRange + + +/***/ }), /* 293 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -60044,7 +61605,60 @@ function expand(str, isTop) { /***/ }), /* 307 */, -/* 308 */, +/* 308 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const eq = __webpack_require__(528) +const neq = __webpack_require__(291) +const gt = __webpack_require__(738) +const gte = __webpack_require__(790) +const lt = __webpack_require__(375) +const lte = __webpack_require__(546) + +const cmp = (a, op, b, loose) => { + switch (op) { + case '===': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a === b + + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b + + case '': + case '=': + case '==': + return eq(a, b, loose) + + case '!=': + return neq(a, b, loose) + + case '>': + return gt(a, b, loose) + + case '>=': + return gte(a, b, loose) + + case '<': + return lt(a, b, loose) + + case '<=': + return lte(a, b, loose) + + default: + throw new TypeError(`Invalid operator: ${op}`) + } +} +module.exports = cmp + + +/***/ }), /* 309 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -62174,7 +63788,167 @@ module.exports = { }; /***/ }), -/* 321 */, +/* 321 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(986) +const { ANY } = __webpack_require__(123) +const satisfies = __webpack_require__(121) +const compare = __webpack_require__(682) + +// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff: +// - Every simple range `r1, r2, ...` is a subset of some `R1, R2, ...` +// +// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff: +// - If c is only the ANY comparator +// - If C is only the ANY comparator, return true +// - Else return false +// - Let EQ be the set of = comparators in c +// - If EQ is more than one, return true (null set) +// - Let GT be the highest > or >= comparator in c +// - Let LT be the lowest < or <= comparator in c +// - If GT and LT, and GT.semver > LT.semver, return true (null set) +// - If EQ +// - If GT, and EQ does not satisfy GT, return true (null set) +// - If LT, and EQ does not satisfy LT, return true (null set) +// - If EQ satisfies every C, return true +// - Else return false +// - If GT +// - If GT is lower than any > or >= comp in C, return false +// - If GT is >=, and GT.semver does not satisfy every C, return false +// - If LT +// - If LT.semver is greater than that of any > comp in C, return false +// - If LT is <=, and LT.semver does not satisfy every C, return false +// - If any C is a = range, and GT or LT are set, return false +// - Else return true + +const subset = (sub, dom, options) => { + sub = new Range(sub, options) + dom = new Range(dom, options) + let sawNonNull = false + + OUTER: for (const simpleSub of sub.set) { + for (const simpleDom of dom.set) { + const isSub = simpleSubset(simpleSub, simpleDom, options) + sawNonNull = sawNonNull || isSub !== null + if (isSub) + continue OUTER + } + // the null set is a subset of everything, but null simple ranges in + // a complex range should be ignored. so if we saw a non-null range, + // then we know this isn't a subset, but if EVERY simple range was null, + // then it is a subset. + if (sawNonNull) + return false + } + return true +} + +const simpleSubset = (sub, dom, options) => { + if (sub.length === 1 && sub[0].semver === ANY) + return dom.length === 1 && dom[0].semver === ANY + + const eqSet = new Set() + let gt, lt + for (const c of sub) { + if (c.operator === '>' || c.operator === '>=') + gt = higherGT(gt, c, options) + else if (c.operator === '<' || c.operator === '<=') + lt = lowerLT(lt, c, options) + else + eqSet.add(c.semver) + } + + if (eqSet.size > 1) + return null + + let gtltComp + if (gt && lt) { + gtltComp = compare(gt.semver, lt.semver, options) + if (gtltComp > 0) + return null + else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + return null + } + + // will iterate one or zero times + for (const eq of eqSet) { + if (gt && !satisfies(eq, String(gt), options)) + return null + + if (lt && !satisfies(eq, String(lt), options)) + return null + + for (const c of dom) { + if (!satisfies(eq, String(c), options)) + return false + } + return true + } + + let higher, lower + let hasDomLT, hasDomGT + for (const c of dom) { + hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=' + hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=' + if (gt) { + if (c.operator === '>' || c.operator === '>=') { + higher = higherGT(gt, c, options) + if (higher === c) + return false + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + return false + } + if (lt) { + if (c.operator === '<' || c.operator === '<=') { + lower = lowerLT(lt, c, options) + if (lower === c) + return false + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + return false + } + if (!c.operator && (lt || gt) && gtltComp !== 0) + return false + } + + // if there was a < or >, and nothing in the dom, then must be false + // UNLESS it was limited by another range in the other direction. + // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 + if (gt && hasDomLT && !lt && gtltComp !== 0) + return false + + if (lt && hasDomGT && !gt && gtltComp !== 0) + return false + + return true +} + +// >=1.2.3 is lower than >1.2.3 +const higherGT = (a, b, options) => { + if (!a) + return b + const comp = compare(a.semver, b.semver, options) + return comp > 0 ? a + : comp < 0 ? b + : b.operator === '>' && a.operator === '>=' ? b + : a +} + +// <=1.2.3 is higher than <1.2.3 +const lowerLT = (a, b, options) => { + if (!a) + return b + const comp = compare(a.semver, b.semver, options) + return comp < 0 ? a + : comp > 0 ? b + : b.operator === '<' && a.operator === '<=' ? b + : a +} + +module.exports = subset + + +/***/ }), /* 322 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -62481,33 +64255,191 @@ module.exports = __webpack_require__(413); /***/ }), /* 330 */, /* 331 */ -/***/ (function(module, __unusedexports, __webpack_require__) { +/***/ (function(module, exports, __webpack_require__) { -/* - * Copyright (c) 2012 Mathieu Turcotte - * Licensed under the MIT license. - */ +const { MAX_SAFE_COMPONENT_LENGTH } = __webpack_require__(749) +const debug = __webpack_require__(509) +exports = module.exports = {} -var util = __webpack_require__(669); +// The actual regexps go on exports.re +const re = exports.re = [] +const src = exports.src = [] +const t = exports.t = {} +let R = 0 -function IllegalArgumentError(message) { - Error.call(this, message); - this.message = message; +const createToken = (name, value, isGlobal) => { + const index = R++ + debug(index, value) + t[name] = index + src[index] = value + re[index] = new RegExp(value, isGlobal ? 'g' : undefined) } -util.inherits(IllegalArgumentError, Error); -IllegalArgumentError.prototype.name = 'IllegalArgumentError'; +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. -function IllegalStateError(message) { - Error.call(this, message); - this.message = message; -} -util.inherits(IllegalStateError, Error); +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. -IllegalStateError.prototype.name = 'IllegalStateError'; +createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*') +createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+') + +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. + +createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*') + +// ## Main Version +// Three dot-separated numeric identifiers. + +createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})`) + +createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})`) + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] +}|${src[t.NONNUMERICIDENTIFIER]})`) + +createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] +}|${src[t.NONNUMERICIDENTIFIER]})`) + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] +}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`) + +createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] +}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`) + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+') + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] +}(?:\\.${src[t.BUILDIDENTIFIER]})*))`) + +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. + +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. + +createToken('FULLPLAIN', `v?${src[t.MAINVERSION] +}${src[t.PRERELEASE]}?${ + src[t.BUILD]}?`) + +createToken('FULL', `^${src[t.FULLPLAIN]}$`) + +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] +}${src[t.PRERELEASELOOSE]}?${ + src[t.BUILD]}?`) + +createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`) + +createToken('GTLT', '((?:<|>)?=?)') + +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`) +createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`) + +createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:${src[t.PRERELEASE]})?${ + src[t.BUILD]}?` + + `)?)?`) + +createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:${src[t.PRERELEASELOOSE]})?${ + src[t.BUILD]}?` + + `)?)?`) + +createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`) +createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) + +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +createToken('COERCE', `${'(^|[^\\d])' + + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:$|[^\\d])`) +createToken('COERCERTL', src[t.COERCE], true) + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +createToken('LONETILDE', '(?:~>?)') + +createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true) +exports.tildeTrimReplace = '$1~' + +createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`) +createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`) + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +createToken('LONECARET', '(?:\\^)') + +createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true) +exports.caretTrimReplace = '$1^' + +createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`) +createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`) + +// A simple gt/lt/eq thing, or just "" to indicate "any version" +createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`) +createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`) + +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] +}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true) +exports.comparatorTrimReplace = '$1$2$3' + +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAIN]})` + + `\\s*$`) + +createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAINLOOSE]})` + + `\\s*$`) + +// Star ranges basically just allow anything at all. +createToken('STAR', '(<|>)?=?\\s*\\*') +// >=0.0.0 is like a star +createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$') -module.exports.IllegalStateError = IllegalStateError; -module.exports.IllegalArgumentError = IllegalArgumentError; /***/ }), /* 332 */ @@ -62539,7 +64471,15 @@ function extract(isBase, str) { /***/ }), /* 333 */, /* 334 */, -/* 335 */, +/* 335 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(682) +const neq = (a, b, loose) => compare(a, b, loose) !== 0 +module.exports = neq + + +/***/ }), /* 336 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -63285,40 +65225,11 @@ exports.isBigIntLiteral = isBigIntLiteral; /***/ }), /* 342 */ -/***/ (function(module) { - -// When the API is rate limiting, the request is retried later -const shouldRetry = function(response, index) { - return response.status === RATE_LIMIT_STATUS && index !== MAX_RETRY -} - -const waitForRetry = async function(response) { - const delay = getDelay(response) - await sleep(delay) -} - -const getDelay = function({ headers }) { - const rateLimitReset = headers.get(RATE_LIMIT_HEADER) - - if (!rateLimitReset) { - return DEFAULT_RETRY_DELAY - } - - return Math.max(Number(rateLimitReset) * SECS_TO_MSECS - Date.now(), MIN_RETRY_DELAY) -} - -const sleep = function(ms) { - return new Promise(resolve => setTimeout(resolve, ms)) -} - -const DEFAULT_RETRY_DELAY = 5e3 -const MIN_RETRY_DELAY = 1e3 -const SECS_TO_MSECS = 1e3 -const MAX_RETRY = 10 -const RATE_LIMIT_STATUS = 429 -const RATE_LIMIT_HEADER = 'X-RateLimit-Reset' +/***/ (function(module, __unusedexports, __webpack_require__) { -module.exports = { shouldRetry, waitForRetry, MAX_RETRY } +const compare = __webpack_require__(682) +const lt = (a, b, loose) => compare(a, b, loose) < 0 +module.exports = lt /***/ }), @@ -65518,7 +67429,302 @@ module.exports = function atob(str) { /***/ }), -/* 369 */, +/* 369 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const debug = __webpack_require__(487) +const { MAX_LENGTH, MAX_SAFE_INTEGER } = __webpack_require__(627) +const { re, t } = __webpack_require__(590) + +const { compareIdentifiers } = __webpack_require__(853) +class SemVer { + constructor (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + if (version instanceof SemVer) { + if (version.loose === !!options.loose && + version.includePrerelease === !!options.includePrerelease) { + return version + } else { + version = version.version + } + } else if (typeof version !== 'string') { + throw new TypeError(`Invalid Version: ${version}`) + } + + if (version.length > MAX_LENGTH) { + throw new TypeError( + `version is longer than ${MAX_LENGTH} characters` + ) + } + + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + // this isn't actually relevant for versions, but keep it so that we + // don't run into trouble passing this.options around. + this.includePrerelease = !!options.includePrerelease + + const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) + + if (!m) { + throw new TypeError(`Invalid Version: ${version}`) + } + + this.raw = version + + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] + + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') + } + + if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { + throw new TypeError('Invalid minor version') + } + + if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { + throw new TypeError('Invalid patch version') + } + + // numberify any prerelease numeric ids + if (!m[4]) { + this.prerelease = [] + } else { + this.prerelease = m[4].split('.').map((id) => { + if (/^[0-9]+$/.test(id)) { + const num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } + + this.build = m[5] ? m[5].split('.') : [] + this.format() + } + + format () { + this.version = `${this.major}.${this.minor}.${this.patch}` + if (this.prerelease.length) { + this.version += `-${this.prerelease.join('.')}` + } + return this.version + } + + toString () { + return this.version + } + + compare (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + if (typeof other === 'string' && other === this.version) { + return 0 + } + other = new SemVer(other, this.options) + } + + if (other.version === this.version) { + return 0 + } + + return this.compareMain(other) || this.comparePre(other) + } + + compareMain (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return ( + compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) + ) + } + + comparePre (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + // NOT having a prerelease is > having one + if (this.prerelease.length && !other.prerelease.length) { + return -1 + } else if (!this.prerelease.length && other.prerelease.length) { + return 1 + } else if (!this.prerelease.length && !other.prerelease.length) { + return 0 + } + + let i = 0 + do { + const a = this.prerelease[i] + const b = other.prerelease[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } + + compareBuild (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + let i = 0 + do { + const a = this.build[i] + const b = other.build[i] + debug('prerelease compare', i, a, b) + if (a === undefined && b === undefined) { + return 0 + } else if (b === undefined) { + return 1 + } else if (a === undefined) { + return -1 + } else if (a === b) { + continue + } else { + return compareIdentifiers(a, b) + } + } while (++i) + } + + // preminor will bump the version up to the next minor release, and immediately + // down to pre-release. premajor and prepatch work the same way. + inc (release, identifier) { + switch (release) { + case 'premajor': + this.prerelease.length = 0 + this.patch = 0 + this.minor = 0 + this.major++ + this.inc('pre', identifier) + break + case 'preminor': + this.prerelease.length = 0 + this.patch = 0 + this.minor++ + this.inc('pre', identifier) + break + case 'prepatch': + // If this is already a prerelease, it will bump to the next version + // drop any prereleases that might already exist, since they are not + // relevant at this point. + this.prerelease.length = 0 + this.inc('patch', identifier) + this.inc('pre', identifier) + break + // If the input is a non-prerelease version, this acts the same as + // prepatch. + case 'prerelease': + if (this.prerelease.length === 0) { + this.inc('patch', identifier) + } + this.inc('pre', identifier) + break + + case 'major': + // If this is a pre-major version, bump up to the same major version. + // Otherwise increment major. + // 1.0.0-5 bumps to 1.0.0 + // 1.1.0 bumps to 2.0.0 + if ( + this.minor !== 0 || + this.patch !== 0 || + this.prerelease.length === 0 + ) { + this.major++ + } + this.minor = 0 + this.patch = 0 + this.prerelease = [] + break + case 'minor': + // If this is a pre-minor version, bump up to the same minor version. + // Otherwise increment minor. + // 1.2.0-5 bumps to 1.2.0 + // 1.2.1 bumps to 1.3.0 + if (this.patch !== 0 || this.prerelease.length === 0) { + this.minor++ + } + this.patch = 0 + this.prerelease = [] + break + case 'patch': + // If this is not a pre-release version, it will increment the patch. + // If it is a pre-release it will bump up to the same patch version. + // 1.2.0-5 patches to 1.2.0 + // 1.2.0 patches to 1.2.1 + if (this.prerelease.length === 0) { + this.patch++ + } + this.prerelease = [] + break + // This probably shouldn't be used publicly. + // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. + case 'pre': + if (this.prerelease.length === 0) { + this.prerelease = [0] + } else { + let i = this.prerelease.length + while (--i >= 0) { + if (typeof this.prerelease[i] === 'number') { + this.prerelease[i]++ + i = -2 + } + } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0) + } + } + if (identifier) { + // 1.2.0-beta.1 bumps to 1.2.0-beta.2, + // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 + if (this.prerelease[0] === identifier) { + if (isNaN(this.prerelease[1])) { + this.prerelease = [identifier, 0] + } + } else { + this.prerelease = [identifier, 0] + } + } + break + + default: + throw new Error(`invalid increment argument: ${release}`) + } + this.format() + this.raw = this.version + return this + } +} + +module.exports = SemVer + + +/***/ }), /* 370 */ /***/ (function(module) { @@ -65636,7 +67842,15 @@ module.exports = exports.default; /***/ }), -/* 375 */, +/* 375 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(570) +const lt = (a, b, loose) => compare(a, b, loose) < 0 +module.exports = lt + + +/***/ }), /* 376 */, /* 377 */, /* 378 */ @@ -67126,7 +69340,7 @@ module.exports = Pack /* 384 */ /***/ (function(module) { -module.exports = {"swagger":"2.0","info":{"version":"0.14.0","title":"Netlify's API documentation","description":"Netlify is a hosting service for the programmable web. It understands your documents and provides an API to handle atomic deploys of websites, manage form submissions, inject JavaScript snippets, and much more. This is a REST-style API that uses JSON for serialization and OAuth 2 for authentication.\n\nThis document is an OpenAPI reference for the Netlify API that you can explore. For more detailed instructions for common uses, please visit the [online documentation](https://www.netlify.com/docs/api/). Visit our Community forum to join the conversation about [understanding and using Netlify’s API](https://community.netlify.com/t/common-issue-understanding-and-using-netlifys-api/160).\n\nAdditionally, we have two API clients for your convenience:\n- [Go Client](https://github.com/netlify/open-api#go-client)\n- [JS Client](https://github.com/netlify/js-client)","termsOfService":"https://www.netlify.com/legal/terms-of-use/","x-logo":{"url":"netlify-logo.png","href":"https://www.netlify.com/docs/","altText":"Netlify"}},"externalDocs":{"url":"https://www.netlify.com/docs/api/","description":"Online documentation"},"securityDefinitions":{"netlifyAuth":{"type":"oauth2","flow":"implicit","authorizationUrl":"https://app.netlify.com/authorize"}},"security":[{"netlifyAuth":[]}],"consumes":["application/json"],"produces":["application/json"],"schemes":["https"],"responses":{"error":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}},"host":"api.netlify.com","basePath":"/api/v1","paths":{"/sites":{"get":{"operationId":"listSites","tags":["site"],"parameters":[{"name":"name","in":"query","type":"string"},{"name":"filter","in":"query","type":"string","enum":["all","owner","guest"]}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSite","tags":["site"],"consumes":["application/json"],"parameters":[{"name":"site","in":"body","schema":{"allOf":[{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},{"properties":{"repo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}}}}]},"required":true},{"name":"configure_dns","type":"boolean","in":"query"}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSite","tags":["site"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"patch":{"operationId":"updateSite","tags":["site"],"consumes":["application/json"],"parameters":[{"name":"site","in":"body","schema":{"allOf":[{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},{"properties":{"repo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}}}}]},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSite","tags":["site"],"responses":{"204":{"description":"Deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/ssl":{"post":{"operationId":"provisionSiteTLSCertificate","tags":["sniCertificate"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"certificate","type":"string","in":"query"},{"name":"key","type":"string","in":"query"},{"name":"ca_certificates","type":"string","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"state":{"type":"string"},"domains":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"expires_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"showSiteTLSCertificate","tags":["sniCertificate"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"state":{"type":"string"},"domains":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"expires_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/forms":{"get":{"operationId":"listSiteForms","tags":["form"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"paths":{"type":"array","items":{"type":"string"}},"submission_count":{"type":"integer","format":"int32"},"fields":{"type":"array","items":{"type":"object"}},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/submissions":{"get":{"operationId":"listSiteSubmissions","tags":["submission"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer","format":"int32"},"email":{"type":"string"},"name":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"company":{"type":"string"},"summary":{"type":"string"},"body":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"site_url":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/files":{"get":{"operationId":"listSiteFiles","tags":["file"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"path":{"type":"string"},"sha":{"type":"string"},"mime_type":{"type":"string"},"size":{"type":"integer","format":"int64"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/assets":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteAssets","tags":["asset"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteAsset","tags":["asset"],"parameters":[{"name":"name","type":"string","in":"query","required":true},{"name":"size","type":"integer","format":"int64","in":"query","required":true},{"name":"content_type","type":"string","in":"query","required":true},{"name":"visibility","type":"string","in":"query"}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"form":{"type":"object","properties":{"url":{"type":"string"},"fields":{"type":"object","additionalProperties":{"type":"string"}}}},"asset":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/assets/{asset_id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"asset_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteAssetInfo","tags":["asset"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteAsset","tags":["asset"],"parameters":[{"name":"state","type":"string","in":"query","required":true}],"responses":{"200":{"description":"Updated","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSiteAsset","tags":["asset"],"responses":{"204":{"description":"Deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/assets/{asset_id}/public_signature":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"asset_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteAssetPublicSignature","tags":["assetPublicSignature"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"url":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/files/{file_path}":{"get":{"operationId":"getSiteFileByPathName","tags":["file"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"file_path","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"path":{"type":"string"},"sha":{"type":"string"},"mime_type":{"type":"string"},"size":{"type":"integer","format":"int64"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/snippets":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteSnippets","tags":["snippet"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteSnippet","tags":["snippet"],"consumes":["application/json"],"parameters":[{"name":"snippet","in":"body","schema":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}},"required":true}],"responses":{"201":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/snippets/{snippet_id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"snippet_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteSnippet","tags":["snippet"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteSnippet","tags":["snippet"],"consumes":["application/json"],"parameters":[{"name":"snippet","in":"body","schema":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}},"required":true}],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSiteSnippet","tags":["snippet"],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/metadata":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteMetadata","tags":["metadata"],"responses":{"200":{"description":"OK","schema":{"type":"object"}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteMetadata","tags":["metadata"],"parameters":[{"name":"metadata","in":"body","schema":{"type":"object"},"required":true}],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/build_hooks":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteBuildHooks","tags":["buildHook"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteBuildHook","tags":["buildHook"],"consumes":["application/json"],"parameters":[{"name":"buildHook","in":"body","schema":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"required":true}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/build_hooks/{id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteBuildHook","tags":["buildHook"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteBuildHook","tags":["buildHook"],"consumes":["application/json"],"parameters":[{"name":"buildHook","in":"body","schema":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"required":true}],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSiteBuildHook","tags":["buildHook"],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/deploys":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteDeploys","tags":["deploy"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteDeploy","tags":["deploy"],"parameters":[{"name":"title","type":"string","in":"query"},{"name":"deploy","in":"body","schema":{"type":"object","properties":{"files":{"type":"object"},"draft":{"type":"boolean"},"async":{"type":"boolean"},"functions":{"type":"object"}}},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/deploys/{deploy_id}":{"get":{"operationId":"getSiteDeploy","tags":["deploy"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteDeploy","tags":["deploy"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"deploy_id","type":"string","in":"path","required":true},{"name":"deploy","in":"body","schema":{"type":"object","properties":{"files":{"type":"object"},"draft":{"type":"boolean"},"async":{"type":"boolean"},"functions":{"type":"object"}}},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/cancel":{"post":{"operationId":"cancelSiteDeploy","tags":["deploy"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"201":{"description":"Cancelled","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/deploys/{deploy_id}/restore":{"post":{"operationId":"restoreSiteDeploy","tags":["deploy"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/builds":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteBuilds","tags":["build"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"sha":{"type":"string"},"done":{"type":"boolean"},"error":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteBuild","tags":["build"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"sha":{"type":"string"},"done":{"type":"boolean"},"error":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/deployed-branches":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteDeployedBranches","tags":["deployedBranch"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/builds/{build_id}":{"parameters":[{"name":"build_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteBuild","tags":["build"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"sha":{"type":"string"},"done":{"type":"boolean"},"error":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/builds/{build_id}/log":{"parameters":[{"name":"build_id","type":"string","in":"path","required":true},{"name":"msg","in":"body","schema":{"type":"object","properties":{"message":{"type":"string"},"error":{"type":"boolean"}}},"required":true}],"post":{"operationId":"updateSiteBuildLog","tags":["buildLogMsg"],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/builds/{build_id}/start":{"parameters":[{"name":"build_id","type":"string","in":"path","required":true}],"post":{"operationId":"notifyBuildStart","tags":["build"],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/dns":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"getDNSForSite","tags":["dnsZone"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"configureDNSForSite","tags":["dnsZone"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}":{"get":{"operationId":"getDeploy","tags":["deploy"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/lock":{"post":{"operationId":"lockDeploy","tags":["deploy"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/unlock":{"post":{"operationId":"unlockDeploy","tags":["deploy"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/files/{path}":{"put":{"operationId":"uploadDeployFile","tags":["file"],"consumes":["application/octet-stream"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true},{"name":"path","type":"string","in":"path","required":true},{"name":"size","type":"integer","in":"query"},{"name":"file_body","in":"body","schema":{"type":"string","format":"binary"},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"path":{"type":"string"},"sha":{"type":"string"},"mime_type":{"type":"string"},"size":{"type":"integer","format":"int64"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/functions/{name}":{"put":{"operationId":"uploadDeployFunction","tags":["function"],"consumes":["application/octet-stream"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true},{"name":"name","type":"string","in":"path","required":true},{"name":"runtime","type":"string","in":"query"},{"name":"size","type":"integer","in":"query"},{"name":"file_body","in":"body","schema":{"type":"string","format":"binary"},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"sha":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/forms":{"get":{"operationId":"listForms","tags":["form"],"parameters":[{"name":"site_id","in":"query","type":"string"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"paths":{"type":"array","items":{"type":"string"}},"submission_count":{"type":"integer","format":"int32"},"fields":{"type":"array","items":{"type":"object"}},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/forms/{form_id}/submissions":{"get":{"operationId":"listFormSubmissions","tags":["submission"],"parameters":[{"name":"form_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer","format":"int32"},"email":{"type":"string"},"name":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"company":{"type":"string"},"summary":{"type":"string"},"body":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"site_url":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/hooks":{"get":{"operationId":"listHooksBySiteId","tags":["hook"],"parameters":[{"name":"site_id","in":"query","type":"string","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createHookBySiteId","tags":["hook"],"consumes":["application/json"],"parameters":[{"name":"site_id","type":"string","in":"query","required":true},{"name":"hook","in":"body","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}},"required":true}],"responses":{"201":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/hooks/{hook_id}":{"parameters":[{"name":"hook_id","type":"string","in":"path","required":true}],"get":{"operationId":"getHook","tags":["hook"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateHook","tags":["hook"],"parameters":[{"name":"hook","in":"body","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteHook","tags":["hook"],"responses":{"204":{"description":"No content"}}}},"/hooks/{hook_id}/enable":{"parameters":[{"name":"hook_id","type":"string","in":"path","required":true}],"post":{"operationId":"enableHook","tags":["hook"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/hooks/types":{"get":{"operationId":"listHookTypes","tags":["hookType"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"fields":{"type":"array","items":{"type":"object"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/oauth/tickets":{"post":{"operationId":"createTicket","tags":["ticket"],"parameters":[{"name":"client_id","type":"string","in":"query","required":true}],"responses":{"201":{"description":"ok","schema":{"type":"object","properties":{"id":{"type":"string"},"client_id":{"type":"string"},"authorized":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/oauth/tickets/{ticket_id}":{"get":{"operationId":"showTicket","tags":["ticket"],"parameters":[{"name":"ticket_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"ok","schema":{"type":"object","properties":{"id":{"type":"string"},"client_id":{"type":"string"},"authorized":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/oauth/tickets/{ticket_id}/exchange":{"post":{"operationId":"exchangeTicket","tags":["accessToken"],"parameters":[{"name":"ticket_id","type":"string","in":"path","required":true}],"responses":{"201":{"description":"ok","schema":{"type":"object","properties":{"id":{"type":"string"},"access_token":{"type":"string"},"user_id":{"type":"string"},"user_email":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploy_keys":{"get":{"operationId":"listDeployKeys","tags":["deployKey"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"public_key":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createDeployKey","tags":["deployKey"],"consumes":["application/json"],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"public_key":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploy_keys/{key_id}":{"parameters":[{"name":"key_id","type":"string","in":"path","required":true}],"get":{"operationId":"getDeployKey","tags":["deployKey"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"public_key":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteDeployKey","tags":["deployKey"],"responses":{"204":{"description":"Not Content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/{account_slug}/sites":{"post":{"operationId":"createSiteInTeam","tags":["site"],"consumes":["application/json"],"parameters":[{"name":"site","in":"body","schema":{"allOf":[{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},{"properties":{"repo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}}}}]}},{"name":"configure_dns","type":"boolean","in":"query"},{"name":"account_slug","in":"path","type":"string","required":true}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"listSitesForAccount","tags":["site"],"parameters":[{"name":"name","in":"query","type":"string"},{"name":"account_slug","in":"path","type":"string","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/{account_slug}/members":{"parameters":[{"name":"account_slug","in":"path","type":"string","required":true}],"get":{"operationId":"listMembersForAccount","tags":["member"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"full_name":{"type":"string"},"email":{"type":"string"},"avatar":{"type":"string"},"role":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"addMemberToAccount","tags":["member"],"parameters":[{"name":"role","in":"query","type":"string","enum":["Owner","Collaborator","Controller"]},{"name":"email","in":"query","type":"string","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"full_name":{"type":"string"},"email":{"type":"string"},"avatar":{"type":"string"},"role":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/billing/payment_methods":{"get":{"operationId":"listPaymentMethodsForUser","tags":["paymentMethod"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"method_name":{"type":"string"},"type":{"type":"string"},"state":{"type":"string"},"data":{"type":"object","properties":{"card_type":{"type":"string"},"last4":{"type":"string"},"email":{"type":"string"}}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/accounts/types":{"get":{"operationId":"listAccountTypesForUser","tags":["accountType"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"capabilities":{"type":"object"},"monthly_dollar_price":{"type":"integer"},"yearly_dollar_price":{"type":"integer"},"monthly_seats_addon_dollar_price":{"type":"integer"},"yearly_seats_addon_dollar_price":{"type":"integer"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/accounts":{"get":{"operationId":"listAccountsForUser","tags":["accountMembership"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createAccount","tags":["accountMembership"],"parameters":[{"name":"accountSetup","in":"body","schema":{"type":"object","required":["name","type_id"],"properties":{"name":{"type":"string"},"type_id":{"type":"string"},"payment_method_id":{"type":"string"},"period":{"type":"string","enum":["monthly","yearly"]},"extra_seats_block":{"type":"integer"}}},"required":true}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/accounts/{account_id}":{"parameters":[{"name":"account_id","type":"string","in":"path","required":true}],"get":{"operationId":"getAccount","tags":["accountMembership"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateAccount","tags":["accountMembership"],"parameters":[{"name":"accountUpdateSetup","in":"body","schema":{"type":"object","properties":{"name":{"type":"string"},"slug":{"type":"string"},"type_id":{"type":"string"},"extra_seats_block":{"type":"integer"},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"}}}}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"cancelAccount","tags":["accountMembership"],"responses":{"204":{"description":"Not Content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/accounts/{account_id}/audit":{"parameters":[{"name":"account_id","type":"string","in":"path","required":true}],"get":{"operationId":"listAccountAuditEvents","tags":["auditLog"],"parameters":[{"name":"query","type":"string","in":"query"},{"name":"log_type","type":"string","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"account_id":{"type":"string"},"payload":{"type":"object","properties":{"actor_id":{"type":"string"},"actor_name":{"type":"string"},"actor_email":{"type":"string"},"action":{"type":"string"},"timestamp":{"type":"string","format":"dateTime"},"log_type":{"type":"string"}},"additionalProperties":{"type":"object"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/submissions/{submission_id}":{"parameters":[{"name":"submission_id","type":"string","in":"path","required":true}],"get":{"operationId":"listFormSubmission","tags":["submission"],"parameters":[{"name":"query","type":"string","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer","format":"int32"},"email":{"type":"string"},"name":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"company":{"type":"string"},"summary":{"type":"string"},"body":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"site_url":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSubmission","tags":["submission"],"responses":{"204":{"description":"Deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/services/{addon}/instances":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"addon","type":"string","in":"path","required":true}],"post":{"operationId":"createServiceInstance","tags":["serviceInstance"],"consumes":["application/json"],"parameters":[{"name":"config","in":"body","required":true,"schema":{"type":"object"}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"object"},"external_attributes":{"type":"object"},"service_slug":{"type":"string"},"service_path":{"type":"string"},"service_name":{"type":"string"},"env":{"type":"object"},"snippets":{"type":"array","items":{"type":"object"}},"auth_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"showServiceInstance","tags":["serviceInstance"],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"object"},"external_attributes":{"type":"object"},"service_slug":{"type":"string"},"service_path":{"type":"string"},"service_name":{"type":"string"},"env":{"type":"object"},"snippets":{"type":"array","items":{"type":"object"}},"auth_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateServiceInstance","tags":["serviceInstance"],"consumes":["application/json"],"parameters":[{"name":"config","in":"body","required":true,"schema":{"type":"object"}}],"responses":{"204":{"description":"Created"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteServiceInstance","tags":["serviceInstance"],"responses":{"204":{"description":"Deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/services/":{"parameters":[{"name":"search","type":"string","in":"query"}],"get":{"operationId":"getServices","tags":["service"],"responses":{"200":{"description":"services","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"service_path":{"type":"string"},"long_description":{"type":"string"},"description":{"type":"string"},"events":{"type":"array","items":{"type":"object"}},"tags":{"type":"array","items":{"type":"string"}},"icon":{"type":"string"},"manifest_url":{"type":"string"},"environments":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/services/{addonName}":{"parameters":[{"name":"addonName","type":"string","in":"path","required":true}],"get":{"operationId":"showService","tags":["service"],"responses":{"200":{"description":"services","schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"object"},"external_attributes":{"type":"object"},"service_slug":{"type":"string"},"service_path":{"type":"string"},"service_name":{"type":"string"},"env":{"type":"object"},"snippets":{"type":"array","items":{"type":"object"}},"auth_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/services/{addonName}/manifest":{"parameters":[{"name":"addonName","type":"string","in":"path","required":true}],"get":{"operationId":"showServiceManifest","tags":["service"],"responses":{"201":{"description":"retrieving from provider","schema":{"type":"object"}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/user":{"get":{"operationId":"getCurrentUser","tags":["user"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"uid":{"type":"string"},"full_name":{"type":"string"},"avatar_url":{"type":"string"},"email":{"type":"string"},"affiliate_id":{"type":"string"},"site_count":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"last_login":{"type":"string","format":"dateTime"},"login_providers":{"type":"array","items":{"type":"string"}},"onboarding_progress":{"type":"object","properties":{"slides":{"type":"string"}}},"support_priority":{"type":"integer","format":"int64"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/site/{site_id}/traffic_splits":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"post":{"operationId":"createSplitTest","tags":["splitTest"],"consumes":["application/json"],"parameters":[{"name":"branch_tests","in":"body","required":true,"schema":{"type":"object","properties":{"branch_tests":{"type":"object"}}}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"getSplitTests","tags":["splitTest"],"responses":{"200":{"description":"split_tests","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/site/{site_id}/traffic_splits/{split_test_id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"split_test_id","type":"string","in":"path","required":true}],"put":{"operationId":"updateSplitTest","tags":["splitTest"],"consumes":["application/json"],"parameters":[{"name":"branch_tests","in":"body","required":true,"schema":{"type":"object","properties":{"branch_tests":{"type":"object"}}}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"getSplitTest","tags":["splitTest"],"responses":{"200":{"description":"split_test","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/site/{site_id}/traffic_splits/{split_test_id}/publish":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"split_test_id","type":"string","in":"path","required":true}],"post":{"operationId":"enableSplitTest","tags":["splitTest"],"responses":{"204":{"description":"enable"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/site/{site_id}/traffic_splits/{split_test_id}/unpublish":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"split_test_id","type":"string","in":"path","required":true}],"post":{"operationId":"disableSplitTest","tags":["splitTest"],"responses":{"204":{"description":"disabled"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones":{"post":{"operationId":"createDnsZone","tags":["dnsZone"],"consumes":["application/json"],"parameters":[{"name":"DnsZoneParams","in":"body","required":true,"schema":{"type":"object","properties":{"account_slug":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"}}}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"getDnsZones","tags":["dnsZone"],"parameters":[{"name":"account_slug","in":"query","type":"string","required":false}],"responses":{"200":{"description":"get all DNS zones the user has access to","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones/{zone_id}":{"parameters":[{"name":"zone_id","type":"string","in":"path","required":true}],"get":{"operationId":"getDnsZone","tags":["dnsZone"],"responses":{"200":{"description":"get a single DNS zone","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteDnsZone","tags":["dnsZone"],"responses":{"204":{"description":"delete a single DNS zone"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones/{zone_id}/transfer":{"parameters":[{"name":"zone_id","type":"string","in":"path","required":true},{"name":"account_id","type":"string","in":"query","description":"the account of the dns zone","required":true},{"name":"transfer_account_id","type":"string","in":"query","description":"the account you want to transfer the dns zone to","required":true},{"name":"transfer_user_id","type":"string","in":"query","description":"the user you want to transfer the dns zone to","required":true}],"put":{"operationId":"transferDnsZone","tags":["dnsZone"],"responses":{"200":{"description":"transfer a DNS zone to another account","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones/{zone_id}/dns_records":{"parameters":[{"name":"zone_id","type":"string","in":"path","required":true}],"get":{"operationId":"getDnsRecords","tags":["dnsZone"],"responses":{"200":{"description":"get all DNS records for a single DNS zone","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createDnsRecord","tags":["dnsZone"],"consumes":["application/json"],"parameters":[{"name":"dns_record","in":"body","required":true,"schema":{"type":"object","properties":{"type":{"type":"string"},"hostname":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"weight":{"type":"integer","format":"int64"},"port":{"type":"integer","format":"int64"},"flag":{"type":"integer","format":"int64"},"tag":{"type":"string"}}}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones/{zone_id}/dns_records/{dns_record_id}":{"parameters":[{"name":"zone_id","type":"string","in":"path","required":true},{"name":"dns_record_id","type":"string","in":"path","required":true}],"get":{"operationId":"getIndividualDnsRecord","tags":["dnsZone"],"responses":{"200":{"description":"get a single DNS record","schema":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteDnsRecord","tags":["dnsZone"],"responses":{"204":{"description":"record deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}}},"definitions":{"splitTestSetup":{"type":"object","properties":{"branch_tests":{"type":"object"}}},"splitTests":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}},"splitTest":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}},"serviceInstance":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"object"},"external_attributes":{"type":"object"},"service_slug":{"type":"string"},"service_path":{"type":"string"},"service_name":{"type":"string"},"env":{"type":"object"},"snippets":{"type":"array","items":{"type":"object"}},"auth_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"service":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"service_path":{"type":"string"},"long_description":{"type":"string"},"description":{"type":"string"},"events":{"type":"array","items":{"type":"object"}},"tags":{"type":"array","items":{"type":"string"}},"icon":{"type":"string"},"manifest_url":{"type":"string"},"environments":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"site":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},"siteSetup":{"allOf":[{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},{"properties":{"repo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}}}}]},"repoInfo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"submission":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer","format":"int32"},"email":{"type":"string"},"name":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"company":{"type":"string"},"summary":{"type":"string"},"body":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"site_url":{"type":"string"}}},"form":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"paths":{"type":"array","items":{"type":"string"}},"submission_count":{"type":"integer","format":"int32"},"fields":{"type":"array","items":{"type":"object"}},"created_at":{"type":"string","format":"dateTime"}}},"hookType":{"type":"object","properties":{"name":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"fields":{"type":"array","items":{"type":"object"}}}},"hook":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}},"file":{"type":"object","properties":{"id":{"type":"string"},"path":{"type":"string"},"sha":{"type":"string"},"mime_type":{"type":"string"},"size":{"type":"integer","format":"int64"}}},"function":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"sha":{"type":"string"}}},"snippet":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}},"deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"deployFiles":{"type":"object","properties":{"files":{"type":"object"},"draft":{"type":"boolean"},"async":{"type":"boolean"},"functions":{"type":"object"}}},"build":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"sha":{"type":"string"},"done":{"type":"boolean"},"error":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"buildLogMsg":{"type":"object","properties":{"message":{"type":"string"},"error":{"type":"boolean"}}},"metadata":{"type":"object"},"dnsZoneSetup":{"type":"object","properties":{"account_slug":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"}}},"dnsZones":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}},"dnsZone":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}},"dnsRecordCreate":{"type":"object","properties":{"type":{"type":"string"},"hostname":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"weight":{"type":"integer","format":"int64"},"port":{"type":"integer","format":"int64"},"flag":{"type":"integer","format":"int64"},"tag":{"type":"string"}}},"dnsRecords":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dnsRecord":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}},"sniCertificate":{"type":"object","properties":{"state":{"type":"string"},"domains":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"expires_at":{"type":"string","format":"dateTime"}}},"ticket":{"type":"object","properties":{"id":{"type":"string"},"client_id":{"type":"string"},"authorized":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"}}},"accessToken":{"type":"object","properties":{"id":{"type":"string"},"access_token":{"type":"string"},"user_id":{"type":"string"},"user_email":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"asset":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"assetForm":{"type":"object","properties":{"url":{"type":"string"},"fields":{"type":"object","additionalProperties":{"type":"string"}}}},"assetSignature":{"type":"object","properties":{"form":{"type":"object","properties":{"url":{"type":"string"},"fields":{"type":"object","additionalProperties":{"type":"string"}}}},"asset":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"assetPublicSignature":{"type":"object","properties":{"url":{"type":"string"}}},"deployKey":{"type":"object","properties":{"id":{"type":"string"},"public_key":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"member":{"type":"object","properties":{"id":{"type":"string"},"full_name":{"type":"string"},"email":{"type":"string"},"avatar":{"type":"string"},"role":{"type":"string"}}},"paymentMethod":{"type":"object","properties":{"id":{"type":"string"},"method_name":{"type":"string"},"type":{"type":"string"},"state":{"type":"string"},"data":{"type":"object","properties":{"card_type":{"type":"string"},"last4":{"type":"string"},"email":{"type":"string"}}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"accountType":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"capabilities":{"type":"object"},"monthly_dollar_price":{"type":"integer"},"yearly_dollar_price":{"type":"integer"},"monthly_seats_addon_dollar_price":{"type":"integer"},"yearly_seats_addon_dollar_price":{"type":"integer"}}},"accountSetup":{"type":"object","required":["name","type_id"],"properties":{"name":{"type":"string"},"type_id":{"type":"string"},"payment_method_id":{"type":"string"},"period":{"type":"string","enum":["monthly","yearly"]},"extra_seats_block":{"type":"integer"}}},"accountUpdateSetup":{"type":"object","properties":{"name":{"type":"string"},"slug":{"type":"string"},"type_id":{"type":"string"},"extra_seats_block":{"type":"integer"},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"}}},"accountMembership":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"auditLog":{"type":"object","properties":{"id":{"type":"string"},"account_id":{"type":"string"},"payload":{"type":"object","properties":{"actor_id":{"type":"string"},"actor_name":{"type":"string"},"actor_email":{"type":"string"},"action":{"type":"string"},"timestamp":{"type":"string","format":"dateTime"},"log_type":{"type":"string"}},"additionalProperties":{"type":"object"}}}},"accountUsageCapability":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"minifyOptions":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"buildHook":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"deployedBranch":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"}}},"user":{"type":"object","properties":{"id":{"type":"string"},"uid":{"type":"string"},"full_name":{"type":"string"},"avatar_url":{"type":"string"},"email":{"type":"string"},"affiliate_id":{"type":"string"},"site_count":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"last_login":{"type":"string","format":"dateTime"},"login_providers":{"type":"array","items":{"type":"string"}},"onboarding_progress":{"type":"object","properties":{"slides":{"type":"string"}}},"support_priority":{"type":"integer","format":"int64"}}},"error":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}},"x-tagGroups":[{"name":"OAuth","tags":["ticket","accessToken"]},{"name":"User accounts","tags":["user","accountMembership","member","accountType","paymentMethod","auditLog"]},{"name":"Site","tags":["site","file","metadata","snippet"]},{"name":"Domain names","tags":["dnsZone","sniCertificate"]},{"name":"Deploys","tags":["deploy","deployedBranch","deployKey"]},{"name":"Builds","tags":["build","buildLogMsg"]},{"name":"Webhooks and notifications","tags":["hook","hookType","buildHook"]},{"name":"Services","tags":["service","serviceInstance"]},{"name":"Functions","tags":["function"]},{"name":"Forms","tags":["form","submission"]},{"name":"Split tests","tags":["splitTest"]},{"name":"Large media","tags":["asset","assetPublicSignature"]}],"tags":[{"name":"ticket","x-displayName":"Ticket"},{"name":"accessToken","x-displayName":"Access token"},{"name":"user","x-displayName":"User"},{"name":"accountMembership","x-displayName":"Accounts"},{"name":"member","x-displayName":"Member"},{"name":"accountType","x-displayName":"Access type"},{"name":"paymentMethod","x-displayName":"Payment method"},{"name":"auditLog","x-displayName":"Audit log"},{"name":"site","x-displayName":"Site"},{"name":"file","x-displayName":"File"},{"name":"metadata","x-displayName":"Metadata"},{"name":"snippet","x-displayName":"Snippet"},{"name":"dnsZone","x-displayName":"DNS zone"},{"name":"sniCertificate","x-displayName":"SNI certificate"},{"name":"deploy","x-displayName":"Deploy"},{"name":"deployedBranch","x-displayName":"Deployed branch"},{"name":"deployKey","x-displayName":"Deploy key"},{"name":"build","x-displayName":"Build"},{"name":"buildLogMsg","x-displayName":"Build log message"},{"name":"hook","x-displayName":"Hook"},{"name":"hookType","x-displayName":"Hook type"},{"name":"buildHook","x-displayName":"Build hook"},{"name":"service","x-displayName":"Service"},{"name":"serviceInstance","x-displayName":"Service instance"},{"name":"function","x-displayName":"Function"},{"name":"form","x-displayName":"Form"},{"name":"submission","x-displayName":"Form submission"},{"name":"splitTest","x-displayName":"Split test"},{"name":"asset","x-displayName":"Asset"},{"name":"assetPublicSignature","x-displayName":"Asset public signature"}]}; +module.exports = {"swagger":"2.0","info":{"version":"0.15.0","title":"Netlify's API documentation","description":"Netlify is a hosting service for the programmable web. It understands your documents and provides an API to handle atomic deploys of websites, manage form submissions, inject JavaScript snippets, and much more. This is a REST-style API that uses JSON for serialization and OAuth 2 for authentication.\n\nThis document is an OpenAPI reference for the Netlify API that you can explore. For more detailed instructions for common uses, please visit the [online documentation](https://www.netlify.com/docs/api/). Visit our Community forum to join the conversation about [understanding and using Netlify’s API](https://community.netlify.com/t/common-issue-understanding-and-using-netlifys-api/160).\n\nAdditionally, we have two API clients for your convenience:\n- [Go Client](https://github.com/netlify/open-api#go-client)\n- [JS Client](https://github.com/netlify/js-client)","termsOfService":"https://www.netlify.com/legal/terms-of-use/","x-logo":{"url":"netlify-logo.png","href":"https://www.netlify.com/docs/","altText":"Netlify"}},"externalDocs":{"url":"https://www.netlify.com/docs/api/","description":"Online documentation"},"securityDefinitions":{"netlifyAuth":{"type":"oauth2","flow":"implicit","authorizationUrl":"https://app.netlify.com/authorize"}},"security":[{"netlifyAuth":[]}],"consumes":["application/json"],"produces":["application/json"],"schemes":["https"],"responses":{"error":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}},"host":"api.netlify.com","basePath":"/api/v1","paths":{"/sites":{"get":{"operationId":"listSites","tags":["site"],"parameters":[{"name":"name","in":"query","type":"string"},{"name":"filter","in":"query","type":"string","enum":["all","owner","guest"]}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSite","tags":["site"],"consumes":["application/json"],"parameters":[{"name":"site","in":"body","schema":{"allOf":[{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},{"properties":{"repo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}}}}]},"required":true},{"name":"configure_dns","type":"boolean","in":"query"}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSite","tags":["site"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"patch":{"operationId":"updateSite","tags":["site"],"consumes":["application/json"],"parameters":[{"name":"site","in":"body","schema":{"allOf":[{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},{"properties":{"repo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}}}}]},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSite","tags":["site"],"responses":{"204":{"description":"Deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/ssl":{"post":{"operationId":"provisionSiteTLSCertificate","tags":["sniCertificate"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"certificate","type":"string","in":"query"},{"name":"key","type":"string","in":"query"},{"name":"ca_certificates","type":"string","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"state":{"type":"string"},"domains":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"expires_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"showSiteTLSCertificate","tags":["sniCertificate"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"state":{"type":"string"},"domains":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"expires_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/forms":{"get":{"operationId":"listSiteForms","tags":["form"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"paths":{"type":"array","items":{"type":"string"}},"submission_count":{"type":"integer","format":"int32"},"fields":{"type":"array","items":{"type":"object"}},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/submissions":{"get":{"operationId":"listSiteSubmissions","tags":["submission"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer","format":"int32"},"email":{"type":"string"},"name":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"company":{"type":"string"},"summary":{"type":"string"},"body":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"site_url":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/files":{"get":{"operationId":"listSiteFiles","tags":["file"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"path":{"type":"string"},"sha":{"type":"string"},"mime_type":{"type":"string"},"size":{"type":"integer","format":"int64"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/assets":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteAssets","tags":["asset"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteAsset","tags":["asset"],"parameters":[{"name":"name","type":"string","in":"query","required":true},{"name":"size","type":"integer","format":"int64","in":"query","required":true},{"name":"content_type","type":"string","in":"query","required":true},{"name":"visibility","type":"string","in":"query"}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"form":{"type":"object","properties":{"url":{"type":"string"},"fields":{"type":"object","additionalProperties":{"type":"string"}}}},"asset":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/assets/{asset_id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"asset_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteAssetInfo","tags":["asset"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteAsset","tags":["asset"],"parameters":[{"name":"state","type":"string","in":"query","required":true}],"responses":{"200":{"description":"Updated","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSiteAsset","tags":["asset"],"responses":{"204":{"description":"Deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/assets/{asset_id}/public_signature":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"asset_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteAssetPublicSignature","tags":["assetPublicSignature"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"url":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/files/{file_path}":{"get":{"operationId":"getSiteFileByPathName","tags":["file"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"file_path","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"path":{"type":"string"},"sha":{"type":"string"},"mime_type":{"type":"string"},"size":{"type":"integer","format":"int64"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/snippets":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteSnippets","tags":["snippet"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteSnippet","tags":["snippet"],"consumes":["application/json"],"parameters":[{"name":"snippet","in":"body","schema":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}},"required":true}],"responses":{"201":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/snippets/{snippet_id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"snippet_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteSnippet","tags":["snippet"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteSnippet","tags":["snippet"],"consumes":["application/json"],"parameters":[{"name":"snippet","in":"body","schema":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}},"required":true}],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSiteSnippet","tags":["snippet"],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/metadata":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteMetadata","tags":["metadata"],"responses":{"200":{"description":"OK","schema":{"type":"object"}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteMetadata","tags":["metadata"],"parameters":[{"name":"metadata","in":"body","schema":{"type":"object"},"required":true}],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/build_hooks":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteBuildHooks","tags":["buildHook"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteBuildHook","tags":["buildHook"],"consumes":["application/json"],"parameters":[{"name":"buildHook","in":"body","schema":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"required":true}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/build_hooks/{id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteBuildHook","tags":["buildHook"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteBuildHook","tags":["buildHook"],"consumes":["application/json"],"parameters":[{"name":"buildHook","in":"body","schema":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"required":true}],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSiteBuildHook","tags":["buildHook"],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/deploys":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteDeploys","tags":["deploy"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteDeploy","tags":["deploy"],"parameters":[{"name":"title","type":"string","in":"query"},{"name":"deploy","in":"body","schema":{"type":"object","properties":{"files":{"type":"object"},"draft":{"type":"boolean"},"async":{"type":"boolean"},"functions":{"type":"object"}}},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/deploys/{deploy_id}":{"get":{"operationId":"getSiteDeploy","tags":["deploy"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateSiteDeploy","tags":["deploy"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"deploy_id","type":"string","in":"path","required":true},{"name":"deploy","in":"body","schema":{"type":"object","properties":{"files":{"type":"object"},"draft":{"type":"boolean"},"async":{"type":"boolean"},"functions":{"type":"object"}}},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/cancel":{"post":{"operationId":"cancelSiteDeploy","tags":["deploy"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"201":{"description":"Cancelled","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/deploys/{deploy_id}/restore":{"post":{"operationId":"restoreSiteDeploy","tags":["deploy"],"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/builds":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteBuilds","tags":["build"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"sha":{"type":"string"},"done":{"type":"boolean"},"error":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createSiteBuild","tags":["build"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"sha":{"type":"string"},"done":{"type":"boolean"},"error":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/deployed-branches":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"listSiteDeployedBranches","tags":["deployedBranch"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/builds/{build_id}":{"parameters":[{"name":"build_id","type":"string","in":"path","required":true}],"get":{"operationId":"getSiteBuild","tags":["build"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"sha":{"type":"string"},"done":{"type":"boolean"},"error":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/builds/{build_id}/log":{"parameters":[{"name":"build_id","type":"string","in":"path","required":true},{"name":"msg","in":"body","schema":{"type":"object","properties":{"message":{"type":"string"},"error":{"type":"boolean"}}},"required":true}],"post":{"operationId":"updateSiteBuildLog","tags":["buildLogMsg"],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/builds/{build_id}/start":{"parameters":[{"name":"build_id","type":"string","in":"path","required":true}],"post":{"operationId":"notifyBuildStart","tags":["build"],"responses":{"204":{"description":"No content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/dns":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"get":{"operationId":"getDNSForSite","tags":["dnsZone"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"configureDNSForSite","tags":["dnsZone"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}":{"get":{"operationId":"getDeploy","tags":["deploy"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/lock":{"post":{"operationId":"lockDeploy","tags":["deploy"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/unlock":{"post":{"operationId":"unlockDeploy","tags":["deploy"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/files/{path}":{"put":{"operationId":"uploadDeployFile","tags":["file"],"consumes":["application/octet-stream"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true},{"name":"path","type":"string","in":"path","required":true},{"name":"size","type":"integer","in":"query"},{"name":"file_body","in":"body","schema":{"type":"string","format":"binary"},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"path":{"type":"string"},"sha":{"type":"string"},"mime_type":{"type":"string"},"size":{"type":"integer","format":"int64"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/functions/{name}":{"put":{"operationId":"uploadDeployFunction","tags":["function"],"consumes":["application/octet-stream"],"parameters":[{"name":"deploy_id","type":"string","in":"path","required":true},{"name":"name","type":"string","in":"path","required":true},{"name":"runtime","type":"string","in":"query"},{"name":"size","type":"integer","in":"query"},{"name":"file_body","in":"body","schema":{"type":"string","format":"binary"},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"sha":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploys/{deploy_id}/plugin_runs":{"post":{"operationId":"createPluginRun","tags":["x-internal"],"description":"This is an internal-only endpoint.","parameters":[{"name":"deploy_id","type":"string","in":"path","required":true},{"name":"plugin_run","in":"body","schema":{"type":"object","properties":{"package":{"type":"string"},"version":{"type":"string"},"state":{"type":"string"},"reporting_event":{"type":"string"},"title":{"type":"string"},"summary":{"type":"string"},"text":{"type":"string"}}}}],"responses":{"201":{"description":"CREATED","schema":{"allOf":[{"type":"object","properties":{"package":{"type":"string"},"version":{"type":"string"},"state":{"type":"string"},"reporting_event":{"type":"string"},"title":{"type":"string"},"summary":{"type":"string"},"text":{"type":"string"}}},{"type":"object","properties":{"deploy_id":{"type":"string"}}}]}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/forms":{"get":{"operationId":"listForms","tags":["form"],"parameters":[{"name":"site_id","in":"query","type":"string"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"paths":{"type":"array","items":{"type":"string"}},"submission_count":{"type":"integer","format":"int32"},"fields":{"type":"array","items":{"type":"object"}},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/forms/{form_id}/submissions":{"get":{"operationId":"listFormSubmissions","tags":["submission"],"parameters":[{"name":"form_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer","format":"int32"},"email":{"type":"string"},"name":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"company":{"type":"string"},"summary":{"type":"string"},"body":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"site_url":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/hooks":{"get":{"operationId":"listHooksBySiteId","tags":["hook"],"parameters":[{"name":"site_id","in":"query","type":"string","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createHookBySiteId","tags":["hook"],"consumes":["application/json"],"parameters":[{"name":"site_id","type":"string","in":"query","required":true},{"name":"hook","in":"body","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}},"required":true}],"responses":{"201":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/hooks/{hook_id}":{"parameters":[{"name":"hook_id","type":"string","in":"path","required":true}],"get":{"operationId":"getHook","tags":["hook"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateHook","tags":["hook"],"parameters":[{"name":"hook","in":"body","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}},"required":true}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteHook","tags":["hook"],"responses":{"204":{"description":"No content"}}}},"/hooks/{hook_id}/enable":{"parameters":[{"name":"hook_id","type":"string","in":"path","required":true}],"post":{"operationId":"enableHook","tags":["hook"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/hooks/types":{"get":{"operationId":"listHookTypes","tags":["hookType"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"fields":{"type":"array","items":{"type":"object"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/oauth/tickets":{"post":{"operationId":"createTicket","tags":["ticket"],"parameters":[{"name":"client_id","type":"string","in":"query","required":true}],"responses":{"201":{"description":"ok","schema":{"type":"object","properties":{"id":{"type":"string"},"client_id":{"type":"string"},"authorized":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/oauth/tickets/{ticket_id}":{"get":{"operationId":"showTicket","tags":["ticket"],"parameters":[{"name":"ticket_id","type":"string","in":"path","required":true}],"responses":{"200":{"description":"ok","schema":{"type":"object","properties":{"id":{"type":"string"},"client_id":{"type":"string"},"authorized":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/oauth/tickets/{ticket_id}/exchange":{"post":{"operationId":"exchangeTicket","tags":["accessToken"],"parameters":[{"name":"ticket_id","type":"string","in":"path","required":true}],"responses":{"201":{"description":"ok","schema":{"type":"object","properties":{"id":{"type":"string"},"access_token":{"type":"string"},"user_id":{"type":"string"},"user_email":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploy_keys":{"get":{"operationId":"listDeployKeys","tags":["deployKey"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"public_key":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createDeployKey","tags":["deployKey"],"consumes":["application/json"],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"public_key":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/deploy_keys/{key_id}":{"parameters":[{"name":"key_id","type":"string","in":"path","required":true}],"get":{"operationId":"getDeployKey","tags":["deployKey"],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"public_key":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteDeployKey","tags":["deployKey"],"responses":{"204":{"description":"Not Content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/{account_slug}/sites":{"post":{"operationId":"createSiteInTeam","tags":["site"],"consumes":["application/json"],"parameters":[{"name":"site","in":"body","schema":{"allOf":[{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},{"properties":{"repo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}}}}]}},{"name":"configure_dns","type":"boolean","in":"query"},{"name":"account_slug","in":"path","type":"string","required":true}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"listSitesForAccount","tags":["site"],"parameters":[{"name":"name","in":"query","type":"string"},{"name":"account_slug","in":"path","type":"string","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/{account_slug}/members":{"parameters":[{"name":"account_slug","in":"path","type":"string","required":true}],"get":{"operationId":"listMembersForAccount","tags":["member"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"full_name":{"type":"string"},"email":{"type":"string"},"avatar":{"type":"string"},"role":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"addMemberToAccount","tags":["member"],"parameters":[{"name":"role","in":"query","type":"string","enum":["Owner","Collaborator","Controller"]},{"name":"email","in":"query","type":"string","required":true}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"full_name":{"type":"string"},"email":{"type":"string"},"avatar":{"type":"string"},"role":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/billing/payment_methods":{"get":{"operationId":"listPaymentMethodsForUser","tags":["paymentMethod"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"method_name":{"type":"string"},"type":{"type":"string"},"state":{"type":"string"},"data":{"type":"object","properties":{"card_type":{"type":"string"},"last4":{"type":"string"},"email":{"type":"string"}}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/accounts/types":{"get":{"operationId":"listAccountTypesForUser","tags":["accountType"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"capabilities":{"type":"object"},"monthly_dollar_price":{"type":"integer"},"yearly_dollar_price":{"type":"integer"},"monthly_seats_addon_dollar_price":{"type":"integer"},"yearly_seats_addon_dollar_price":{"type":"integer"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/accounts":{"get":{"operationId":"listAccountsForUser","tags":["accountMembership"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createAccount","tags":["accountMembership"],"parameters":[{"name":"accountSetup","in":"body","schema":{"type":"object","required":["name","type_id"],"properties":{"name":{"type":"string"},"type_id":{"type":"string"},"payment_method_id":{"type":"string"},"period":{"type":"string","enum":["monthly","yearly"]},"extra_seats_block":{"type":"integer"}}},"required":true}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/accounts/{account_id}":{"parameters":[{"name":"account_id","type":"string","in":"path","required":true}],"get":{"operationId":"getAccount","tags":["accountMembership"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateAccount","tags":["accountMembership"],"parameters":[{"name":"accountUpdateSetup","in":"body","schema":{"type":"object","properties":{"name":{"type":"string"},"slug":{"type":"string"},"type_id":{"type":"string"},"extra_seats_block":{"type":"integer"},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"}}}}],"responses":{"200":{"description":"OK","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"cancelAccount","tags":["accountMembership"],"responses":{"204":{"description":"Not Content"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/accounts/{account_id}/audit":{"parameters":[{"name":"account_id","type":"string","in":"path","required":true}],"get":{"operationId":"listAccountAuditEvents","tags":["auditLog"],"parameters":[{"name":"query","type":"string","in":"query"},{"name":"log_type","type":"string","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"account_id":{"type":"string"},"payload":{"type":"object","properties":{"actor_id":{"type":"string"},"actor_name":{"type":"string"},"actor_email":{"type":"string"},"action":{"type":"string"},"timestamp":{"type":"string","format":"dateTime"},"log_type":{"type":"string"}},"additionalProperties":{"type":"object"}}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/submissions/{submission_id}":{"parameters":[{"name":"submission_id","type":"string","in":"path","required":true}],"get":{"operationId":"listFormSubmission","tags":["submission"],"parameters":[{"name":"query","type":"string","in":"query"}],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer","format":"int32"},"email":{"type":"string"},"name":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"company":{"type":"string"},"summary":{"type":"string"},"body":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"site_url":{"type":"string"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteSubmission","tags":["submission"],"responses":{"204":{"description":"Deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/sites/{site_id}/services/{addon}/instances":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"addon","type":"string","in":"path","required":true}],"post":{"operationId":"createServiceInstance","tags":["serviceInstance"],"consumes":["application/json"],"parameters":[{"name":"config","in":"body","required":true,"schema":{"type":"object"}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"object"},"external_attributes":{"type":"object"},"service_slug":{"type":"string"},"service_path":{"type":"string"},"service_name":{"type":"string"},"env":{"type":"object"},"snippets":{"type":"array","items":{"type":"object"}},"auth_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"showServiceInstance","tags":["serviceInstance"],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"object"},"external_attributes":{"type":"object"},"service_slug":{"type":"string"},"service_path":{"type":"string"},"service_name":{"type":"string"},"env":{"type":"object"},"snippets":{"type":"array","items":{"type":"object"}},"auth_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"put":{"operationId":"updateServiceInstance","tags":["serviceInstance"],"consumes":["application/json"],"parameters":[{"name":"config","in":"body","required":true,"schema":{"type":"object"}}],"responses":{"204":{"description":"Created"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteServiceInstance","tags":["serviceInstance"],"responses":{"204":{"description":"Deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/services/":{"parameters":[{"name":"search","type":"string","in":"query"}],"get":{"operationId":"getServices","tags":["service"],"responses":{"200":{"description":"services","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"service_path":{"type":"string"},"long_description":{"type":"string"},"description":{"type":"string"},"events":{"type":"array","items":{"type":"object"}},"tags":{"type":"array","items":{"type":"string"}},"icon":{"type":"string"},"manifest_url":{"type":"string"},"environments":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/services/{addonName}":{"parameters":[{"name":"addonName","type":"string","in":"path","required":true}],"get":{"operationId":"showService","tags":["service"],"responses":{"200":{"description":"services","schema":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"object"},"external_attributes":{"type":"object"},"service_slug":{"type":"string"},"service_path":{"type":"string"},"service_name":{"type":"string"},"env":{"type":"object"},"snippets":{"type":"array","items":{"type":"object"}},"auth_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/services/{addonName}/manifest":{"parameters":[{"name":"addonName","type":"string","in":"path","required":true}],"get":{"operationId":"showServiceManifest","tags":["service"],"responses":{"201":{"description":"retrieving from provider","schema":{"type":"object"}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/user":{"get":{"operationId":"getCurrentUser","tags":["user"],"responses":{"200":{"description":"OK","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"uid":{"type":"string"},"full_name":{"type":"string"},"avatar_url":{"type":"string"},"email":{"type":"string"},"affiliate_id":{"type":"string"},"site_count":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"last_login":{"type":"string","format":"dateTime"},"login_providers":{"type":"array","items":{"type":"string"}},"onboarding_progress":{"type":"object","properties":{"slides":{"type":"string"}}},"support_priority":{"type":"integer","format":"int64"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/site/{site_id}/traffic_splits":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true}],"post":{"operationId":"createSplitTest","tags":["splitTest"],"consumes":["application/json"],"parameters":[{"name":"branch_tests","in":"body","required":true,"schema":{"type":"object","properties":{"branch_tests":{"type":"object"}}}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"getSplitTests","tags":["splitTest"],"responses":{"200":{"description":"split_tests","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/site/{site_id}/traffic_splits/{split_test_id}":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"split_test_id","type":"string","in":"path","required":true}],"put":{"operationId":"updateSplitTest","tags":["splitTest"],"consumes":["application/json"],"parameters":[{"name":"branch_tests","in":"body","required":true,"schema":{"type":"object","properties":{"branch_tests":{"type":"object"}}}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"getSplitTest","tags":["splitTest"],"responses":{"200":{"description":"split_test","schema":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/site/{site_id}/traffic_splits/{split_test_id}/publish":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"split_test_id","type":"string","in":"path","required":true}],"post":{"operationId":"enableSplitTest","tags":["splitTest"],"responses":{"204":{"description":"enable"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/site/{site_id}/traffic_splits/{split_test_id}/unpublish":{"parameters":[{"name":"site_id","type":"string","in":"path","required":true},{"name":"split_test_id","type":"string","in":"path","required":true}],"post":{"operationId":"disableSplitTest","tags":["splitTest"],"responses":{"204":{"description":"disabled"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones":{"post":{"operationId":"createDnsZone","tags":["dnsZone"],"consumes":["application/json"],"parameters":[{"name":"DnsZoneParams","in":"body","required":true,"schema":{"type":"object","properties":{"account_slug":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"}}}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"get":{"operationId":"getDnsZones","tags":["dnsZone"],"parameters":[{"name":"account_slug","in":"query","type":"string","required":false}],"responses":{"200":{"description":"get all DNS zones the user has access to","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones/{zone_id}":{"parameters":[{"name":"zone_id","type":"string","in":"path","required":true}],"get":{"operationId":"getDnsZone","tags":["dnsZone"],"responses":{"200":{"description":"get a single DNS zone","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteDnsZone","tags":["dnsZone"],"responses":{"204":{"description":"delete a single DNS zone"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones/{zone_id}/transfer":{"parameters":[{"name":"zone_id","type":"string","in":"path","required":true},{"name":"account_id","type":"string","in":"query","description":"the account of the dns zone","required":true},{"name":"transfer_account_id","type":"string","in":"query","description":"the account you want to transfer the dns zone to","required":true},{"name":"transfer_user_id","type":"string","in":"query","description":"the user you want to transfer the dns zone to","required":true}],"put":{"operationId":"transferDnsZone","tags":["dnsZone"],"responses":{"200":{"description":"transfer a DNS zone to another account","schema":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones/{zone_id}/dns_records":{"parameters":[{"name":"zone_id","type":"string","in":"path","required":true}],"get":{"operationId":"getDnsRecords","tags":["dnsZone"],"responses":{"200":{"description":"get all DNS records for a single DNS zone","schema":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"post":{"operationId":"createDnsRecord","tags":["dnsZone"],"consumes":["application/json"],"parameters":[{"name":"dns_record","in":"body","required":true,"schema":{"type":"object","properties":{"type":{"type":"string"},"hostname":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"weight":{"type":"integer","format":"int64"},"port":{"type":"integer","format":"int64"},"flag":{"type":"integer","format":"int64"},"tag":{"type":"string"}}}}],"responses":{"201":{"description":"Created","schema":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}},"/dns_zones/{zone_id}/dns_records/{dns_record_id}":{"parameters":[{"name":"zone_id","type":"string","in":"path","required":true},{"name":"dns_record_id","type":"string","in":"path","required":true}],"get":{"operationId":"getIndividualDnsRecord","tags":["dnsZone"],"responses":{"200":{"description":"get a single DNS record","schema":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}},"delete":{"operationId":"deleteDnsRecord","tags":["dnsZone"],"responses":{"204":{"description":"record deleted"},"default":{"description":"error","schema":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}}}}}},"definitions":{"splitTestSetup":{"type":"object","properties":{"branch_tests":{"type":"object"}}},"splitTests":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}}},"splitTest":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"path":{"type":"string"},"branches":{"type":"array","items":{"type":"object"}},"active":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"unpublished_at":{"type":"string","format":"dateTime"}}},"serviceInstance":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"config":{"type":"object"},"external_attributes":{"type":"object"},"service_slug":{"type":"string"},"service_path":{"type":"string"},"service_name":{"type":"string"},"env":{"type":"object"},"snippets":{"type":"array","items":{"type":"object"}},"auth_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"service":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"service_path":{"type":"string"},"long_description":{"type":"string"},"description":{"type":"string"},"events":{"type":"array","items":{"type":"object"}},"tags":{"type":"array","items":{"type":"string"}},"icon":{"type":"string"},"manifest_url":{"type":"string"},"environments":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"site":{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},"siteSetup":{"allOf":[{"type":"object","properties":{"id":{"type":"string"},"state":{"type":"string"},"plan":{"type":"string"},"name":{"type":"string"},"custom_domain":{"type":"string"},"domain_aliases":{"type":"array","items":{"type":"string"}},"password":{"type":"string"},"notification_email":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"screenshot_url":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"user_id":{"type":"string"},"session_id":{"type":"string"},"ssl":{"type":"boolean"},"force_ssl":{"type":"boolean"},"managed_dns":{"type":"boolean"},"deploy_url":{"type":"string"},"published_deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"account_name":{"type":"string"},"account_slug":{"type":"string"},"git_provider":{"type":"string"},"deploy_hook":{"type":"string"},"capabilities":{"type":"object","additionalProperties":{"type":"object"}},"processing_settings":{"type":"object","properties":{"skip":{"type":"boolean"},"css":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"js":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"images":{"type":"object","properties":{"optimize":{"type":"boolean"}}},"html":{"type":"object","properties":{"pretty_urls":{"type":"boolean"}}}}},"build_settings":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"id_domain":{"type":"string"},"default_hooks_data":{"type":"object","properties":{"access_token":{"type":"string"}}},"build_image":{"type":"string"}}},{"properties":{"repo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}}}}]},"repoInfo":{"type":"object","properties":{"id":{"type":"integer"},"provider":{"type":"string"},"deploy_key_id":{"type":"string"},"repo_path":{"type":"string"},"repo_branch":{"type":"string"},"dir":{"type":"string"},"cmd":{"type":"string"},"allowed_branches":{"type":"array","items":{"type":"string"}},"public_repo":{"type":"boolean"},"private_logs":{"type":"boolean"},"repo_url":{"type":"string"},"env":{"type":"object","additionalProperties":{"type":"string"}},"installation_id":{"type":"integer"},"stop_builds":{"type":"boolean"}}},"submission":{"type":"object","properties":{"id":{"type":"string"},"number":{"type":"integer","format":"int32"},"email":{"type":"string"},"name":{"type":"string"},"first_name":{"type":"string"},"last_name":{"type":"string"},"company":{"type":"string"},"summary":{"type":"string"},"body":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"site_url":{"type":"string"}}},"form":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"},"paths":{"type":"array","items":{"type":"string"}},"submission_count":{"type":"integer","format":"int32"},"fields":{"type":"array","items":{"type":"object"}},"created_at":{"type":"string","format":"dateTime"}}},"hookType":{"type":"object","properties":{"name":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"fields":{"type":"array","items":{"type":"object"}}}},"hook":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"type":{"type":"string"},"event":{"type":"string"},"data":{"type":"object"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"disabled":{"type":"boolean"}}},"file":{"type":"object","properties":{"id":{"type":"string"},"path":{"type":"string"},"sha":{"type":"string"},"mime_type":{"type":"string"},"size":{"type":"integer","format":"int64"}}},"function":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"sha":{"type":"string"}}},"snippet":{"type":"object","properties":{"id":{"type":"integer","format":"int32"},"site_id":{"type":"string"},"title":{"type":"string"},"general":{"type":"string"},"general_position":{"type":"string"},"goal":{"type":"string"},"goal_position":{"type":"string"}}},"deploy":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"user_id":{"type":"string"},"build_id":{"type":"string"},"state":{"type":"string"},"name":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"},"admin_url":{"type":"string"},"deploy_url":{"type":"string"},"deploy_ssl_url":{"type":"string"},"screenshot_url":{"type":"string"},"review_id":{"type":"number"},"draft":{"type":"boolean"},"required":{"type":"array","items":{"type":"string"}},"required_functions":{"type":"array","items":{"type":"string"}},"error_message":{"type":"string"},"branch":{"type":"string"},"commit_ref":{"type":"string"},"commit_url":{"type":"string"},"skipped":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"published_at":{"type":"string","format":"dateTime"},"title":{"type":"string"},"context":{"type":"string"},"locked":{"type":"boolean"},"review_url":{"type":"string"},"site_capabilities":{"type":"object","properties":{"large_media_enabled":{"type":"boolean"}}}}},"deployFiles":{"type":"object","properties":{"files":{"type":"object"},"draft":{"type":"boolean"},"async":{"type":"boolean"},"functions":{"type":"object"}}},"build":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"sha":{"type":"string"},"done":{"type":"boolean"},"error":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"buildLogMsg":{"type":"object","properties":{"message":{"type":"string"},"error":{"type":"boolean"}}},"pluginRunData":{"type":"object","properties":{"package":{"type":"string"},"version":{"type":"string"},"state":{"type":"string"},"reporting_event":{"type":"string"},"title":{"type":"string"},"summary":{"type":"string"},"text":{"type":"string"}}},"pluginRun":{"allOf":[{"type":"object","properties":{"package":{"type":"string"},"version":{"type":"string"},"state":{"type":"string"},"reporting_event":{"type":"string"},"title":{"type":"string"},"summary":{"type":"string"},"text":{"type":"string"}}},{"type":"object","properties":{"deploy_id":{"type":"string"}}}]},"metadata":{"type":"object"},"dnsZoneSetup":{"type":"object","properties":{"account_slug":{"type":"string"},"site_id":{"type":"string"},"name":{"type":"string"}}},"dnsZones":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}}},"dnsZone":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"errors":{"type":"array","items":{"type":"string"}},"supported_record_types":{"type":"array","items":{"type":"string"}},"user_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"records":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dns_servers":{"type":"array","items":{"type":"string"}},"account_id":{"type":"string"},"site_id":{"type":"string"},"account_slug":{"type":"string"},"account_name":{"type":"string"},"domain":{"type":"string"},"ipv6_enabled":{"type":"boolean"},"dedicated":{"type":"boolean"}}},"dnsRecordCreate":{"type":"object","properties":{"type":{"type":"string"},"hostname":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"weight":{"type":"integer","format":"int64"},"port":{"type":"integer","format":"int64"},"flag":{"type":"integer","format":"int64"},"tag":{"type":"string"}}},"dnsRecords":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}}},"dnsRecord":{"type":"object","properties":{"id":{"type":"string"},"hostname":{"type":"string"},"type":{"type":"string"},"value":{"type":"string"},"ttl":{"type":"integer","format":"int64"},"priority":{"type":"integer","format":"int64"},"dns_zone_id":{"type":"string"},"site_id":{"type":"string"},"flag":{"type":"integer"},"tag":{"type":"string"},"managed":{"type":"boolean"}}},"sniCertificate":{"type":"object","properties":{"state":{"type":"string"},"domains":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"},"expires_at":{"type":"string","format":"dateTime"}}},"ticket":{"type":"object","properties":{"id":{"type":"string"},"client_id":{"type":"string"},"authorized":{"type":"boolean"},"created_at":{"type":"string","format":"dateTime"}}},"accessToken":{"type":"object","properties":{"id":{"type":"string"},"access_token":{"type":"string"},"user_id":{"type":"string"},"user_email":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"asset":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"assetForm":{"type":"object","properties":{"url":{"type":"string"},"fields":{"type":"object","additionalProperties":{"type":"string"}}}},"assetSignature":{"type":"object","properties":{"form":{"type":"object","properties":{"url":{"type":"string"},"fields":{"type":"object","additionalProperties":{"type":"string"}}}},"asset":{"type":"object","properties":{"id":{"type":"string"},"site_id":{"type":"string"},"creator_id":{"type":"string"},"name":{"type":"string"},"state":{"type":"string"},"content_type":{"type":"string"},"url":{"type":"string"},"key":{"type":"string"},"visibility":{"type":"string"},"size":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}}}},"assetPublicSignature":{"type":"object","properties":{"url":{"type":"string"}}},"deployKey":{"type":"object","properties":{"id":{"type":"string"},"public_key":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"member":{"type":"object","properties":{"id":{"type":"string"},"full_name":{"type":"string"},"email":{"type":"string"},"avatar":{"type":"string"},"role":{"type":"string"}}},"paymentMethod":{"type":"object","properties":{"id":{"type":"string"},"method_name":{"type":"string"},"type":{"type":"string"},"state":{"type":"string"},"data":{"type":"object","properties":{"card_type":{"type":"string"},"last4":{"type":"string"},"email":{"type":"string"}}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"accountType":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"description":{"type":"string"},"capabilities":{"type":"object"},"monthly_dollar_price":{"type":"integer"},"yearly_dollar_price":{"type":"integer"},"monthly_seats_addon_dollar_price":{"type":"integer"},"yearly_seats_addon_dollar_price":{"type":"integer"}}},"accountSetup":{"type":"object","required":["name","type_id"],"properties":{"name":{"type":"string"},"type_id":{"type":"string"},"payment_method_id":{"type":"string"},"period":{"type":"string","enum":["monthly","yearly"]},"extra_seats_block":{"type":"integer"}}},"accountUpdateSetup":{"type":"object","properties":{"name":{"type":"string"},"slug":{"type":"string"},"type_id":{"type":"string"},"extra_seats_block":{"type":"integer"},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"}}},"accountMembership":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"type":{"type":"string"},"capabilities":{"type":"object","properties":{"sites":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"collaborators":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}}}},"billing_name":{"type":"string"},"billing_email":{"type":"string"},"billing_details":{"type":"string"},"billing_period":{"type":"string"},"payment_method_id":{"type":"string"},"type_name":{"type":"string"},"type_id":{"type":"string"},"owner_ids":{"type":"array","items":{"type":"string"}},"roles_allowed":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"dateTime"},"updated_at":{"type":"string","format":"dateTime"}}},"auditLog":{"type":"object","properties":{"id":{"type":"string"},"account_id":{"type":"string"},"payload":{"type":"object","properties":{"actor_id":{"type":"string"},"actor_name":{"type":"string"},"actor_email":{"type":"string"},"action":{"type":"string"},"timestamp":{"type":"string","format":"dateTime"},"log_type":{"type":"string"}},"additionalProperties":{"type":"object"}}}},"accountUsageCapability":{"type":"object","properties":{"included":{"type":"integer"},"used":{"type":"integer"}}},"minifyOptions":{"type":"object","properties":{"bundle":{"type":"boolean"},"minify":{"type":"boolean"}}},"buildHook":{"type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"branch":{"type":"string"},"url":{"type":"string"},"site_id":{"type":"string"},"created_at":{"type":"string","format":"dateTime"}}},"deployedBranch":{"type":"object","properties":{"id":{"type":"string"},"deploy_id":{"type":"string"},"name":{"type":"string"},"slug":{"type":"string"},"url":{"type":"string"},"ssl_url":{"type":"string"}}},"user":{"type":"object","properties":{"id":{"type":"string"},"uid":{"type":"string"},"full_name":{"type":"string"},"avatar_url":{"type":"string"},"email":{"type":"string"},"affiliate_id":{"type":"string"},"site_count":{"type":"integer","format":"int64"},"created_at":{"type":"string","format":"dateTime"},"last_login":{"type":"string","format":"dateTime"},"login_providers":{"type":"array","items":{"type":"string"}},"onboarding_progress":{"type":"object","properties":{"slides":{"type":"string"}}},"support_priority":{"type":"integer","format":"int64"}}},"error":{"type":"object","required":["message"],"properties":{"code":{"type":"integer","format":"int64"},"message":{"type":"string","x-nullable":false}}}},"x-tagGroups":[{"name":"OAuth","tags":["ticket","accessToken"]},{"name":"User accounts","tags":["user","accountMembership","member","accountType","paymentMethod","auditLog"]},{"name":"Site","tags":["site","file","metadata","snippet"]},{"name":"Domain names","tags":["dnsZone","sniCertificate"]},{"name":"Deploys","tags":["deploy","deployedBranch","deployKey"]},{"name":"Builds","tags":["build","buildLogMsg"]},{"name":"Webhooks and notifications","tags":["hook","hookType","buildHook"]},{"name":"Services","tags":["service","serviceInstance"]},{"name":"Functions","tags":["function"]},{"name":"Forms","tags":["form","submission"]},{"name":"Split tests","tags":["splitTest"]},{"name":"Large media","tags":["asset","assetPublicSignature"]}],"tags":[{"name":"ticket","x-displayName":"Ticket"},{"name":"accessToken","x-displayName":"Access token"},{"name":"user","x-displayName":"User"},{"name":"accountMembership","x-displayName":"Accounts"},{"name":"member","x-displayName":"Member"},{"name":"accountType","x-displayName":"Access type"},{"name":"paymentMethod","x-displayName":"Payment method"},{"name":"auditLog","x-displayName":"Audit log"},{"name":"site","x-displayName":"Site"},{"name":"file","x-displayName":"File"},{"name":"metadata","x-displayName":"Metadata"},{"name":"snippet","x-displayName":"Snippet"},{"name":"dnsZone","x-displayName":"DNS zone"},{"name":"sniCertificate","x-displayName":"SNI certificate"},{"name":"deploy","x-displayName":"Deploy"},{"name":"deployedBranch","x-displayName":"Deployed branch"},{"name":"deployKey","x-displayName":"Deploy key"},{"name":"build","x-displayName":"Build"},{"name":"buildLogMsg","x-displayName":"Build log message"},{"name":"hook","x-displayName":"Hook"},{"name":"hookType","x-displayName":"Hook type"},{"name":"buildHook","x-displayName":"Build hook"},{"name":"service","x-displayName":"Service"},{"name":"serviceInstance","x-displayName":"Service instance"},{"name":"function","x-displayName":"Function"},{"name":"form","x-displayName":"Form"},{"name":"submission","x-displayName":"Form submission"},{"name":"splitTest","x-displayName":"Split test"},{"name":"asset","x-displayName":"Asset"},{"name":"assetPublicSignature","x-displayName":"Asset public signature"}]}; /***/ }), /* 385 */ @@ -67490,7 +69704,7 @@ function withDefaults(oldDefaults, newDefaults) { }); } -const VERSION = "6.0.1"; +const VERSION = "6.0.2"; const userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}`; // DEFAULTS has all properties set that EndpointOptions has, except url. // So we use RequestParameters and add method as additional required property. @@ -67515,7 +69729,18 @@ exports.endpoint = endpoint; /***/ }), -/* 386 */, +/* 386 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(658) +const clean = (version, options) => { + const s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} +module.exports = clean + + +/***/ }), /* 387 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -67681,7 +69906,7 @@ module.exports = SectionHeader; /* 393 */ /***/ (function(module, __unusedexports, __webpack_require__) { -const camelCase = __webpack_require__(931) +const camelCase = __webpack_require__(199) const queryString = __webpack_require__(597) // Replace path parameters and query parameters in the URI, using the OpenAPI @@ -67859,7 +70084,23 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { /***/ }), /* 396 */, -/* 397 */, +/* 397 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(635) +const validRange = (range, options) => { + try { + // Return '*' instead of '' so that truthiness works. + // This will throw if it's invalid anyway + return new Range(range, options).range || '*' + } catch (er) { + return null + } +} +module.exports = validRange + + +/***/ }), /* 398 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -68513,7 +70754,7 @@ const { getOperations } = __webpack_require__(759) const { addBody } = __webpack_require__(409) const { parseResponse, getFetchError } = __webpack_require__(415) -const { shouldRetry, waitForRetry, MAX_RETRY } = __webpack_require__(342) +const { shouldRetry, waitForRetry, MAX_RETRY } = __webpack_require__(708) const { getUrl } = __webpack_require__(393) // For each OpenAPI operation, add a corresponding method. @@ -68623,7 +70864,37 @@ module.exports = function CheckObjectCoercible(value, optMessage) { /***/ }), /* 425 */, -/* 426 */, +/* 426 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const Range = __webpack_require__(635) + +const maxSatisfying = (versions, range, options) => { + let max = null + let maxSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } + } + }) + return max +} +module.exports = maxSatisfying + + +/***/ }), /* 427 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -69271,34 +71542,12 @@ module.exports = function () { /* 435 */ /***/ (function(module, __unusedexports, __webpack_require__) { -// Copyright (c) 2012 Mathieu Turcotte -// Licensed under the MIT license. - -var util = __webpack_require__(669); - -var BackoffStrategy = __webpack_require__(105); - -// Fibonacci backoff strategy. -function FibonacciBackoffStrategy(options) { - BackoffStrategy.call(this, options); - this.backoffDelay_ = 0; - this.nextBackoffDelay_ = this.getInitialDelay(); +const parse = __webpack_require__(147) +const clean = (version, options) => { + const s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null } -util.inherits(FibonacciBackoffStrategy, BackoffStrategy); - -FibonacciBackoffStrategy.prototype.next_ = function() { - var backoffDelay = Math.min(this.nextBackoffDelay_, this.getMaxDelay()); - this.nextBackoffDelay_ += this.backoffDelay_; - this.backoffDelay_ = backoffDelay; - return backoffDelay; -}; - -FibonacciBackoffStrategy.prototype.reset_ = function() { - this.nextBackoffDelay_ = this.getInitialDelay(); - this.backoffDelay_ = 0; -}; - -module.exports = FibonacciBackoffStrategy; +module.exports = clean /***/ }), @@ -70164,7 +72413,7 @@ module.exports = ELFHeader; var Backoff = __webpack_require__(650); var ExponentialBackoffStrategy = __webpack_require__(646); -var FibonacciBackoffStrategy = __webpack_require__(435); +var FibonacciBackoffStrategy = __webpack_require__(33); var FunctionCall = __webpack_require__(152); module.exports.Backoff = Backoff; @@ -72969,7 +75218,151 @@ function indexOf(xs, x) { } /***/ }), -/* 456 */, +/* 456 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const ANY = Symbol('SemVer ANY') +// hoisted class for cyclic dependency +class Comparator { + static get ANY () { + return ANY + } + constructor (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } + + debug('comparator', comp, options) + this.options = options + this.loose = !!options.loose + this.parse(comp) + + if (this.semver === ANY) { + this.value = '' + } else { + this.value = this.operator + this.semver.version + } + + debug('comp', this) + } + + parse (comp) { + const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + const m = comp.match(r) + + if (!m) { + throw new TypeError(`Invalid comparator: ${comp}`) + } + + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } + + // if it literally is just '>' or '' then allow anything. + if (!m[2]) { + this.semver = ANY + } else { + this.semver = new SemVer(m[2], this.options.loose) + } + } + + toString () { + return this.value + } + + test (version) { + debug('Comparator.test', version, this.options.loose) + + if (this.semver === ANY || version === ANY) { + return true + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + return cmp(version, this.operator, this.semver, this.options) + } + + intersects (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (this.operator === '') { + if (this.value === '') { + return true + } + return new Range(comp.value, options).test(this.value) + } else if (comp.operator === '') { + if (comp.value === '') { + return true + } + return new Range(this.value, options).test(comp.semver) + } + + const sameDirectionIncreasing = + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '>=' || comp.operator === '>') + const sameDirectionDecreasing = + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '<=' || comp.operator === '<') + const sameSemVer = this.semver.version === comp.semver.version + const differentDirectionsInclusive = + (this.operator === '>=' || this.operator === '<=') && + (comp.operator === '>=' || comp.operator === '<=') + const oppositeDirectionsLessThan = + cmp(this.semver, '<', comp.semver, options) && + (this.operator === '>=' || this.operator === '>') && + (comp.operator === '<=' || comp.operator === '<') + const oppositeDirectionsGreaterThan = + cmp(this.semver, '>', comp.semver, options) && + (this.operator === '<=' || this.operator === '<') && + (comp.operator === '>=' || comp.operator === '>') + + return ( + sameDirectionIncreasing || + sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || + oppositeDirectionsGreaterThan + ) + } +} + +module.exports = Comparator + +const {re, t} = __webpack_require__(331) +const cmp = __webpack_require__(308) +const debug = __webpack_require__(509) +const SemVer = __webpack_require__(243) +const Range = __webpack_require__(635) + + +/***/ }), /* 457 */ /***/ (function(__unusedmodule, exports) { @@ -73293,7 +75686,15 @@ function legacy (fs) { /***/ }), -/* 467 */, +/* 467 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(682) +const compareLoose = (a, b) => compare(a, b, true) +module.exports = compareLoose + + +/***/ }), /* 468 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -74792,7 +77193,15 @@ exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { /***/ }), /* 475 */, -/* 476 */, +/* 476 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const major = (a, loose) => new SemVer(a, loose).major +module.exports = major + + +/***/ }), /* 477 */, /* 478 */, /* 479 */, @@ -75520,7 +77929,16 @@ module.exports = setup; /* 487 */ /***/ (function(module) { -module.exports = {"name":"@typescript-eslint/typescript-estree","version":"2.31.0","description":"A parser that converts TypeScript source code into an ESTree compatible form","main":"dist/parser.js","types":"dist/parser.d.ts","files":["dist","README.md","LICENSE"],"engines":{"node":"^8.10.0 || ^10.13.0 || >=11.10.1"},"repository":{"type":"git","url":"https://github.com/typescript-eslint/typescript-eslint.git","directory":"packages/typescript-estree"},"bugs":{"url":"https://github.com/typescript-eslint/typescript-eslint/issues"},"license":"BSD-2-Clause","keywords":["ast","estree","ecmascript","javascript","typescript","parser","syntax"],"scripts":{"build":"tsc -b tsconfig.build.json","clean":"tsc -b tsconfig.build.json --clean","format":"prettier --write \"./**/*.{ts,js,json,md}\" --ignore-path ../../.prettierignore","lint":"eslint . --ext .js,.ts --ignore-path='../../.eslintignore'","test":"jest --coverage","typecheck":"tsc -p tsconfig.json --noEmit"},"dependencies":{"debug":"^4.1.1","eslint-visitor-keys":"^1.1.0","glob":"^7.1.6","is-glob":"^4.0.1","lodash":"^4.17.15","semver":"^6.3.0","tsutils":"^3.17.1"},"devDependencies":{"@babel/code-frame":"^7.8.3","@babel/parser":"^7.8.3","@babel/types":"^7.8.3","@types/babel__code-frame":"^7.0.1","@types/debug":"^4.1.5","@types/glob":"^7.1.1","@types/is-glob":"^4.0.1","@types/lodash":"^4.14.149","@types/semver":"^6.2.0","@types/tmp":"^0.1.0","@typescript-eslint/shared-fixtures":"2.31.0","tmp":"^0.1.0","typescript":"*"},"peerDependenciesMeta":{"typescript":{"optional":true}},"funding":{"type":"opencollective","url":"https://opencollective.com/typescript-eslint"},"gitHead":"176054c2171b682217d6855208e50b15e1712675","_resolved":"https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.31.0.tgz","_integrity":"sha512-vxW149bXFXXuBrAak0eKHOzbcu9cvi6iNcJDzEtOkRwGHxJG15chiAQAwhLOsk+86p9GTr/TziYvw+H9kMaIgA==","_from":"@typescript-eslint/typescript-estree@2.31.0"}; +const debug = ( + typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG) +) ? (...args) => console.error('SEMVER', ...args) + : () => {} + +module.exports = debug + /***/ }), /* 488 */ @@ -75592,7 +78010,69 @@ module.exports = resolveCommand; /***/ }), /* 490 */, -/* 491 */, +/* 491 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const Range = __webpack_require__(635) +const gt = __webpack_require__(738) + +const minVersion = (range, loose) => { + range = new Range(range, loose) + + let minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } + + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } + + minver = null + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] + + comparators.forEach((comparator) => { + // Clone to avoid manipulating the comparator's semver object. + const compver = new SemVer(comparator.semver.version) + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++ + } else { + compver.prerelease.push(0) + } + compver.raw = compver.format() + /* fallthrough */ + case '': + case '>=': + if (!minver || gt(minver, compver)) { + minver = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error(`Unexpected operation: ${comparator.operator}`) + } + }) + } + + if (minver && range.test(minver)) { + return minver + } + + return null +} +module.exports = minVersion + + +/***/ }), /* 492 */, /* 493 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -75615,7 +78095,15 @@ module.exports = global[ID]; /***/ }), /* 494 */, -/* 495 */, +/* 495 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(682) +const lte = (a, b, loose) => compare(a, b, loose) <= 0 +module.exports = lte + + +/***/ }), /* 496 */, /* 497 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -76238,7 +78726,21 @@ module.exports.default = module.exports; // For TypeScript /***/ }), /* 508 */, -/* 509 */, +/* 509 */ +/***/ (function(module) { + +const debug = ( + typeof process === 'object' && + process.env && + process.env.NODE_DEBUG && + /\bsemver\b/i.test(process.env.NODE_DEBUG) +) ? (...args) => console.error('SEMVER', ...args) + : () => {} + +module.exports = debug + + +/***/ }), /* 510 */ /***/ (function(module) { @@ -76398,280 +78900,31 @@ module.exports = (object, predicate) => { /***/ }), /* 513 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -var utils = __webpack_require__(658); -var formats = __webpack_require__(859); -var has = Object.prototype.hasOwnProperty; - -var arrayPrefixGenerators = { - brackets: function brackets(prefix) { - return prefix + '[]'; - }, - comma: 'comma', - indices: function indices(prefix, key) { - return prefix + '[' + key + ']'; - }, - repeat: function repeat(prefix) { - return prefix; - } -}; - -var isArray = Array.isArray; -var push = Array.prototype.push; -var pushToArray = function (arr, valueOrArray) { - push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]); -}; - -var toISO = Date.prototype.toISOString; - -var defaultFormat = formats['default']; -var defaults = { - addQueryPrefix: false, - allowDots: false, - charset: 'utf-8', - charsetSentinel: false, - delimiter: '&', - encode: true, - encoder: utils.encode, - encodeValuesOnly: false, - format: defaultFormat, - formatter: formats.formatters[defaultFormat], - // deprecated - indices: false, - serializeDate: function serializeDate(date) { - return toISO.call(date); - }, - skipNulls: false, - strictNullHandling: false -}; - -var isNonNullishPrimitive = function isNonNullishPrimitive(v) { - return typeof v === 'string' - || typeof v === 'number' - || typeof v === 'boolean' - || typeof v === 'symbol' - || typeof v === 'bigint'; -}; - -var stringify = function stringify( - object, - prefix, - generateArrayPrefix, - strictNullHandling, - skipNulls, - encoder, - filter, - sort, - allowDots, - serializeDate, - formatter, - encodeValuesOnly, - charset -) { - var obj = object; - if (typeof filter === 'function') { - obj = filter(prefix, obj); - } else if (obj instanceof Date) { - obj = serializeDate(obj); - } else if (generateArrayPrefix === 'comma' && isArray(obj)) { - obj = utils.maybeMap(obj, function (value) { - if (value instanceof Date) { - return serializeDate(value); - } - return value; - }).join(','); - } - - if (obj === null) { - if (strictNullHandling) { - return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key') : prefix; - } - - obj = ''; - } - - if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) { - if (encoder) { - var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key'); - return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value'))]; - } - return [formatter(prefix) + '=' + formatter(String(obj))]; - } - - var values = []; - - if (typeof obj === 'undefined') { - return values; - } - - var objKeys; - if (isArray(filter)) { - objKeys = filter; - } else { - var keys = Object.keys(obj); - objKeys = sort ? keys.sort(sort) : keys; - } - - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - var value = obj[key]; - - if (skipNulls && value === null) { - continue; - } - - var keyPrefix = isArray(obj) - ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix - : prefix + (allowDots ? '.' + key : '[' + key + ']'); - - pushToArray(values, stringify( - value, - keyPrefix, - generateArrayPrefix, - strictNullHandling, - skipNulls, - encoder, - filter, - sort, - allowDots, - serializeDate, - formatter, - encodeValuesOnly, - charset - )); - } - - return values; -}; - -var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { - if (!opts) { - return defaults; - } - - if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') { - throw new TypeError('Encoder has to be a function.'); - } - - var charset = opts.charset || defaults.charset; - if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { - throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); - } - - var format = formats['default']; - if (typeof opts.format !== 'undefined') { - if (!has.call(formats.formatters, opts.format)) { - throw new TypeError('Unknown format option provided.'); - } - format = opts.format; - } - var formatter = formats.formatters[format]; - - var filter = defaults.filter; - if (typeof opts.filter === 'function' || isArray(opts.filter)) { - filter = opts.filter; - } - - return { - addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix, - allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, - charset: charset, - charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, - delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter, - encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode, - encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder, - encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly, - filter: filter, - formatter: formatter, - serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate, - skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls, - sort: typeof opts.sort === 'function' ? opts.sort : null, - strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling - }; -}; - -module.exports = function (object, opts) { - var obj = object; - var options = normalizeStringifyOptions(opts); - - var objKeys; - var filter; - - if (typeof options.filter === 'function') { - filter = options.filter; - obj = filter('', obj); - } else if (isArray(options.filter)) { - filter = options.filter; - objKeys = filter; - } - - var keys = []; - - if (typeof obj !== 'object' || obj === null) { - return ''; - } - - var arrayFormat; - if (opts && opts.arrayFormat in arrayPrefixGenerators) { - arrayFormat = opts.arrayFormat; - } else if (opts && 'indices' in opts) { - arrayFormat = opts.indices ? 'indices' : 'repeat'; - } else { - arrayFormat = 'indices'; - } - - var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; - - if (!objKeys) { - objKeys = Object.keys(obj); - } - - if (options.sort) { - objKeys.sort(options.sort); - } +/***/ (function(module) { - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; +const numeric = /^[0-9]+$/ +const compareIdentifiers = (a, b) => { + const anum = numeric.test(a) + const bnum = numeric.test(b) - if (options.skipNulls && obj[key] === null) { - continue; - } - pushToArray(keys, stringify( - obj[key], - key, - generateArrayPrefix, - options.strictNullHandling, - options.skipNulls, - options.encode ? options.encoder : null, - options.filter, - options.sort, - options.allowDots, - options.serializeDate, - options.formatter, - options.encodeValuesOnly, - options.charset - )); - } + if (anum && bnum) { + a = +a + b = +b + } - var joined = keys.join(options.delimiter); - var prefix = options.addQueryPrefix === true ? '?' : ''; + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +} - if (options.charsetSentinel) { - if (options.charset === 'iso-8859-1') { - // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark - prefix += 'utf8=%26%2310003%3B&'; - } else { - // encodeURIComponent('✓') - prefix += 'utf8=%E2%9C%93&'; - } - } +const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) - return joined.length > 0 ? prefix + joined : ''; -}; +module.exports = { + compareIdentifiers, + rcompareIdentifiers +} /***/ }), @@ -76782,17 +79035,19 @@ class Converter { type: ts_estree_1.AST_NODE_TYPES.ExportDefaultDeclaration, declaration: result, range: [exportKeyword.getStart(this.ast), result.range[1]], + exportKind: 'value', }); } else { const isType = result.type === ts_estree_1.AST_NODE_TYPES.TSInterfaceDeclaration || result.type === ts_estree_1.AST_NODE_TYPES.TSTypeAliasDeclaration; + const isDeclare = result.declare === true; return this.createNode(node, { type: ts_estree_1.AST_NODE_TYPES.ExportNamedDeclaration, declaration: result, specifiers: [], source: null, - exportKind: isType ? 'type' : 'value', + exportKind: isType || isDeclare ? 'type' : 'value', range: [exportKeyword.getStart(this.ast), result.range[1]], }); } @@ -77120,10 +79375,7 @@ class Converter { return this.createNode(node, { type: ts_estree_1.AST_NODE_TYPES.Program, body: this.convertBodyExpressions(node.statements, node), - // externalModuleIndicator is internal field in TSC - sourceType: node.externalModuleIndicator - ? 'module' - : 'script', + sourceType: node.externalModuleIndicator ? 'module' : 'script', range: [node.getStart(this.ast), node.endOfFileToken.end], }); } @@ -77952,6 +80204,7 @@ class Converter { return this.createNode(node, { type: ts_estree_1.AST_NODE_TYPES.ExportDefaultDeclaration, declaration: this.convertChild(node.expression), + exportKind: 'value', }); } // Unary Operations @@ -80250,7 +82503,15 @@ exports.default = crc81wire; /***/ }), -/* 528 */, +/* 528 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(570) +const eq = (a, b, loose) => compare(a, b, loose) === 0 +module.exports = eq + + +/***/ }), /* 529 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -80260,7 +82521,16 @@ module.exports = factory(); /***/ }), -/* 530 */, +/* 530 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// Determine if version is greater than all the versions possible in the range. +const outside = __webpack_require__(750) +const gtr = (version, range, options) => outside(version, range, '>', options) +module.exports = gtr + + +/***/ }), /* 531 */ /***/ (function(module) { @@ -81523,7 +83793,7 @@ module.exports = class Value extends Container { var util = __webpack_require__(669); -var errors = module.exports = __webpack_require__(331); +var errors = module.exports = __webpack_require__(793); function failCheck(ExceptionConstructor, callee, messageFormat, formatArgs) { messageFormat = messageFormat || ''; @@ -81614,7 +83884,15 @@ module.exports.checkIsObject = typeCheck('object'); /***/ }), /* 545 */, -/* 546 */, +/* 546 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(570) +const lte = (a, b, loose) => compare(a, b, loose) <= 0 +module.exports = lte + + +/***/ }), /* 547 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -81633,7 +83911,7 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); const debug_1 = __importDefault(__webpack_require__(784)); const fs_1 = __importDefault(__webpack_require__(747)); -const semver_1 = __importDefault(__webpack_require__(701)); +const semver_1 = __importDefault(__webpack_require__(900)); const ts = __importStar(__webpack_require__(752)); const shared_1 = __webpack_require__(164); const log = debug_1.default('typescript-eslint:typescript-estree:createWatchProgram'); @@ -82145,9 +84423,22 @@ function () { return string.substr(0, start.length) === start; }; + _proto.getAnnotationURL = function getAnnotationURL(sourceMapString) { + return sourceMapString.match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//)[1].trim(); + }; + _proto.loadAnnotation = function loadAnnotation(css) { - var match = css.match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//); - if (match) this.annotation = match[1].trim(); + var annotations = css.match(/\/\*\s*# sourceMappingURL=(.*)\s*\*\//mg); + + if (annotations && annotations.length > 0) { + // Locate the last sourceMappingURL to avoid picking up + // sourceMappingURLs from comments, strings, etc. + var lastAnnotation = annotations[annotations.length - 1]; + + if (lastAnnotation) { + this.annotation = this.getAnnotationURL(lastAnnotation); + } + } }; _proto.decodeInline = function decodeInline(text) { @@ -82216,7 +84507,7 @@ function () { var _default = PreviousMap; exports.default = _default; module.exports = exports.default; -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXZpb3VzLW1hcC5lczYiXSwibmFtZXMiOlsiZnJvbUJhc2U2NCIsInN0ciIsIkJ1ZmZlciIsImZyb20iLCJ0b1N0cmluZyIsIndpbmRvdyIsImF0b2IiLCJQcmV2aW91c01hcCIsImNzcyIsIm9wdHMiLCJsb2FkQW5ub3RhdGlvbiIsImlubGluZSIsInN0YXJ0V2l0aCIsImFubm90YXRpb24iLCJwcmV2IiwibWFwIiwidW5kZWZpbmVkIiwidGV4dCIsImxvYWRNYXAiLCJjb25zdW1lciIsImNvbnN1bWVyQ2FjaGUiLCJtb3ppbGxhIiwiU291cmNlTWFwQ29uc3VtZXIiLCJ3aXRoQ29udGVudCIsInNvdXJjZXNDb250ZW50IiwibGVuZ3RoIiwic3RyaW5nIiwic3RhcnQiLCJzdWJzdHIiLCJtYXRjaCIsInRyaW0iLCJkZWNvZGVJbmxpbmUiLCJiYXNlQ2hhcnNldFVyaSIsImJhc2VVcmkiLCJ1cmkiLCJkZWNvZGVVUklDb21wb25lbnQiLCJ0ZXN0IiwiUmVnRXhwIiwibGFzdE1hdGNoIiwiZW5jb2RpbmciLCJFcnJvciIsImZpbGUiLCJwcmV2UGF0aCIsImZzIiwiZXhpc3RzU3luYyIsInJlYWRGaWxlU3luYyIsIlNvdXJjZU1hcEdlbmVyYXRvciIsImZyb21Tb3VyY2VNYXAiLCJpc01hcCIsIkpTT04iLCJzdHJpbmdpZnkiLCJwYXRoIiwiam9pbiIsImRpcm5hbWUiLCJyb290IiwibWFwcGluZ3MiLCJfbWFwcGluZ3MiXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUE7O0FBQ0E7O0FBQ0E7Ozs7QUFFQSxTQUFTQSxVQUFULENBQXFCQyxHQUFyQixFQUEwQjtBQUN4QixNQUFJQyxNQUFKLEVBQVk7QUFDVixXQUFPQSxNQUFNLENBQUNDLElBQVAsQ0FBWUYsR0FBWixFQUFpQixRQUFqQixFQUEyQkcsUUFBM0IsRUFBUDtBQUNELEdBRkQsTUFFTztBQUNMLFdBQU9DLE1BQU0sQ0FBQ0MsSUFBUCxDQUFZTCxHQUFaLENBQVA7QUFDRDtBQUNGO0FBRUQ7Ozs7Ozs7Ozs7Ozs7SUFXTU0sVzs7O0FBQ0o7Ozs7QUFJQSx1QkFBYUMsR0FBYixFQUFrQkMsSUFBbEIsRUFBd0I7QUFDdEIsU0FBS0MsY0FBTCxDQUFvQkYsR0FBcEI7QUFDQTs7Ozs7O0FBS0EsU0FBS0csTUFBTCxHQUFjLEtBQUtDLFNBQUwsQ0FBZSxLQUFLQyxVQUFwQixFQUFnQyxPQUFoQyxDQUFkO0FBRUEsUUFBSUMsSUFBSSxHQUFHTCxJQUFJLENBQUNNLEdBQUwsR0FBV04sSUFBSSxDQUFDTSxHQUFMLENBQVNELElBQXBCLEdBQTJCRSxTQUF0QztBQUNBLFFBQUlDLElBQUksR0FBRyxLQUFLQyxPQUFMLENBQWFULElBQUksQ0FBQ04sSUFBbEIsRUFBd0JXLElBQXhCLENBQVg7QUFDQSxRQUFJRyxJQUFKLEVBQVUsS0FBS0EsSUFBTCxHQUFZQSxJQUFaO0FBQ1g7QUFFRDs7Ozs7Ozs7Ozs7OztTQVNBRSxRLEdBQUEsb0JBQVk7QUFDVixRQUFJLENBQUMsS0FBS0MsYUFBVixFQUF5QjtBQUN2QixXQUFLQSxhQUFMLEdBQXFCLElBQUlDLG1CQUFRQyxpQkFBWixDQUE4QixLQUFLTCxJQUFuQyxDQUFyQjtBQUNEOztBQUNELFdBQU8sS0FBS0csYUFBWjtBQUNEO0FBRUQ7Ozs7Ozs7U0FLQUcsVyxHQUFBLHVCQUFlO0FBQ2IsV0FBTyxDQUFDLEVBQUUsS0FBS0osUUFBTCxHQUFnQkssY0FBaEIsSUFDQSxLQUFLTCxRQUFMLEdBQWdCSyxjQUFoQixDQUErQkMsTUFBL0IsR0FBd0MsQ0FEMUMsQ0FBUjtBQUVELEc7O1NBRURiLFMsR0FBQSxtQkFBV2MsTUFBWCxFQUFtQkMsS0FBbkIsRUFBMEI7QUFDeEIsUUFBSSxDQUFDRCxNQUFMLEVBQWEsT0FBTyxLQUFQO0FBQ2IsV0FBT0EsTUFBTSxDQUFDRSxNQUFQLENBQWMsQ0FBZCxFQUFpQkQsS0FBSyxDQUFDRixNQUF2QixNQUFtQ0UsS0FBMUM7QUFDRCxHOztTQUVEakIsYyxHQUFBLHdCQUFnQkYsR0FBaEIsRUFBcUI7QUFDbkIsUUFBSXFCLEtBQUssR0FBR3JCLEdBQUcsQ0FBQ3FCLEtBQUosQ0FBVSx1Q0FBVixDQUFaO0FBQ0EsUUFBSUEsS0FBSixFQUFXLEtBQUtoQixVQUFMLEdBQWtCZ0IsS0FBSyxDQUFDLENBQUQsQ0FBTCxDQUFTQyxJQUFULEVBQWxCO0FBQ1osRzs7U0FFREMsWSxHQUFBLHNCQUFjZCxJQUFkLEVBQW9CO0FBQ2xCLFFBQUllLGNBQWMsR0FBRyxnREFBckI7QUFDQSxRQUFJQyxPQUFPLEdBQUcsaUNBQWQ7QUFDQSxRQUFJQyxHQUFHLEdBQUcsd0JBQVY7O0FBRUEsUUFBSSxLQUFLdEIsU0FBTCxDQUFlSyxJQUFmLEVBQXFCaUIsR0FBckIsQ0FBSixFQUErQjtBQUM3QixhQUFPQyxrQkFBa0IsQ0FBQ2xCLElBQUksQ0FBQ1csTUFBTCxDQUFZTSxHQUFHLENBQUNULE1BQWhCLENBQUQsQ0FBekI7QUFDRDs7QUFFRCxRQUFJTyxjQUFjLENBQUNJLElBQWYsQ0FBb0JuQixJQUFwQixLQUE2QmdCLE9BQU8sQ0FBQ0csSUFBUixDQUFhbkIsSUFBYixDQUFqQyxFQUFxRDtBQUNuRCxhQUFPakIsVUFBVSxDQUFDaUIsSUFBSSxDQUFDVyxNQUFMLENBQVlTLE1BQU0sQ0FBQ0MsU0FBUCxDQUFpQmIsTUFBN0IsQ0FBRCxDQUFqQjtBQUNEOztBQUVELFFBQUljLFFBQVEsR0FBR3RCLElBQUksQ0FBQ1ksS0FBTCxDQUFXLGlDQUFYLEVBQThDLENBQTlDLENBQWY7QUFDQSxVQUFNLElBQUlXLEtBQUosQ0FBVSxxQ0FBcUNELFFBQS9DLENBQU47QUFDRCxHOztTQUVEckIsTyxHQUFBLGlCQUFTdUIsSUFBVCxFQUFlM0IsSUFBZixFQUFxQjtBQUNuQixRQUFJQSxJQUFJLEtBQUssS0FBYixFQUFvQixPQUFPLEtBQVA7O0FBRXBCLFFBQUlBLElBQUosRUFBVTtBQUNSLFVBQUksT0FBT0EsSUFBUCxLQUFnQixRQUFwQixFQUE4QjtBQUM1QixlQUFPQSxJQUFQO0FBQ0QsT0FGRCxNQUVPLElBQUksT0FBT0EsSUFBUCxLQUFnQixVQUFwQixFQUFnQztBQUNyQyxZQUFJNEIsUUFBUSxHQUFHNUIsSUFBSSxDQUFDMkIsSUFBRCxDQUFuQjs7QUFDQSxZQUFJQyxRQUFRLElBQUlDLFlBQUdDLFVBQWYsSUFBNkJELFlBQUdDLFVBQUgsQ0FBY0YsUUFBZCxDQUFqQyxFQUEwRDtBQUN4RCxpQkFBT0MsWUFBR0UsWUFBSCxDQUFnQkgsUUFBaEIsRUFBMEIsT0FBMUIsRUFBbUN0QyxRQUFuQyxHQUE4QzBCLElBQTlDLEVBQVA7QUFDRCxTQUZELE1BRU87QUFDTCxnQkFBTSxJQUFJVSxLQUFKLENBQ0oseUNBQXlDRSxRQUFRLENBQUN0QyxRQUFULEVBRHJDLENBQU47QUFFRDtBQUNGLE9BUk0sTUFRQSxJQUFJVSxJQUFJLFlBQVlPLG1CQUFRQyxpQkFBNUIsRUFBK0M7QUFDcEQsZUFBT0QsbUJBQVF5QixrQkFBUixDQUEyQkMsYUFBM0IsQ0FBeUNqQyxJQUF6QyxFQUErQ1YsUUFBL0MsRUFBUDtBQUNELE9BRk0sTUFFQSxJQUFJVSxJQUFJLFlBQVlPLG1CQUFReUIsa0JBQTVCLEVBQWdEO0FBQ3JELGVBQU9oQyxJQUFJLENBQUNWLFFBQUwsRUFBUDtBQUNELE9BRk0sTUFFQSxJQUFJLEtBQUs0QyxLQUFMLENBQVdsQyxJQUFYLENBQUosRUFBc0I7QUFDM0IsZUFBT21DLElBQUksQ0FBQ0MsU0FBTCxDQUFlcEMsSUFBZixDQUFQO0FBQ0QsT0FGTSxNQUVBO0FBQ0wsY0FBTSxJQUFJMEIsS0FBSixDQUNKLDZDQUE2QzFCLElBQUksQ0FBQ1YsUUFBTCxFQUR6QyxDQUFOO0FBRUQ7QUFDRixLQXJCRCxNQXFCTyxJQUFJLEtBQUtPLE1BQVQsRUFBaUI7QUFDdEIsYUFBTyxLQUFLb0IsWUFBTCxDQUFrQixLQUFLbEIsVUFBdkIsQ0FBUDtBQUNELEtBRk0sTUFFQSxJQUFJLEtBQUtBLFVBQVQsRUFBcUI7QUFDMUIsVUFBSUUsR0FBRyxHQUFHLEtBQUtGLFVBQWY7QUFDQSxVQUFJNEIsSUFBSixFQUFVMUIsR0FBRyxHQUFHb0MsY0FBS0MsSUFBTCxDQUFVRCxjQUFLRSxPQUFMLENBQWFaLElBQWIsQ0FBVixFQUE4QjFCLEdBQTlCLENBQU47QUFFVixXQUFLdUMsSUFBTCxHQUFZSCxjQUFLRSxPQUFMLENBQWF0QyxHQUFiLENBQVo7O0FBQ0EsVUFBSTRCLFlBQUdDLFVBQUgsSUFBaUJELFlBQUdDLFVBQUgsQ0FBYzdCLEdBQWQsQ0FBckIsRUFBeUM7QUFDdkMsZUFBTzRCLFlBQUdFLFlBQUgsQ0FBZ0I5QixHQUFoQixFQUFxQixPQUFyQixFQUE4QlgsUUFBOUIsR0FBeUMwQixJQUF6QyxFQUFQO0FBQ0QsT0FGRCxNQUVPO0FBQ0wsZUFBTyxLQUFQO0FBQ0Q7QUFDRjtBQUNGLEc7O1NBRURrQixLLEdBQUEsZUFBT2pDLEdBQVAsRUFBWTtBQUNWLFFBQUksT0FBT0EsR0FBUCxLQUFlLFFBQW5CLEVBQTZCLE9BQU8sS0FBUDtBQUM3QixXQUFPLE9BQU9BLEdBQUcsQ0FBQ3dDLFFBQVgsS0FBd0IsUUFBeEIsSUFBb0MsT0FBT3hDLEdBQUcsQ0FBQ3lDLFNBQVgsS0FBeUIsUUFBcEU7QUFDRCxHOzs7OztlQUdZakQsVyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBtb3ppbGxhIGZyb20gJ3NvdXJjZS1tYXAnXG5pbXBvcnQgcGF0aCBmcm9tICdwYXRoJ1xuaW1wb3J0IGZzIGZyb20gJ2ZzJ1xuXG5mdW5jdGlvbiBmcm9tQmFzZTY0IChzdHIpIHtcbiAgaWYgKEJ1ZmZlcikge1xuICAgIHJldHVybiBCdWZmZXIuZnJvbShzdHIsICdiYXNlNjQnKS50b1N0cmluZygpXG4gIH0gZWxzZSB7XG4gICAgcmV0dXJuIHdpbmRvdy5hdG9iKHN0cilcbiAgfVxufVxuXG4vKipcbiAqIFNvdXJjZSBtYXAgaW5mb3JtYXRpb24gZnJvbSBpbnB1dCBDU1MuXG4gKiBGb3IgZXhhbXBsZSwgc291cmNlIG1hcCBhZnRlciBTYXNzIGNvbXBpbGVyLlxuICpcbiAqIFRoaXMgY2xhc3Mgd2lsbCBhdXRvbWF0aWNhbGx5IGZpbmQgc291cmNlIG1hcCBpbiBpbnB1dCBDU1Mgb3IgaW4gZmlsZSBzeXN0ZW1cbiAqIG5lYXIgaW5wdXQgZmlsZSAoYWNjb3JkaW5nIGBmcm9tYCBvcHRpb24pLlxuICpcbiAqIEBleGFtcGxlXG4gKiBjb25zdCByb290ID0gcG9zdGNzcy5wYXJzZShjc3MsIHsgZnJvbTogJ2Euc2Fzcy5jc3MnIH0pXG4gKiByb290LmlucHV0Lm1hcCAvLz0+IFByZXZpb3VzTWFwXG4gKi9cbmNsYXNzIFByZXZpb3VzTWFwIHtcbiAgLyoqXG4gICAqIEBwYXJhbSB7c3RyaW5nfSAgICAgICAgIGNzcyAgICBJbnB1dCBDU1Mgc291cmNlLlxuICAgKiBAcGFyYW0ge3Byb2Nlc3NPcHRpb25zfSBbb3B0c10ge0BsaW5rIFByb2Nlc3NvciNwcm9jZXNzfSBvcHRpb25zLlxuICAgKi9cbiAgY29uc3RydWN0b3IgKGNzcywgb3B0cykge1xuICAgIHRoaXMubG9hZEFubm90YXRpb24oY3NzKVxuICAgIC8qKlxuICAgICAqIFdhcyBzb3VyY2UgbWFwIGlubGluZWQgYnkgZGF0YS11cmkgdG8gaW5wdXQgQ1NTLlxuICAgICAqXG4gICAgICogQHR5cGUge2Jvb2xlYW59XG4gICAgICovXG4gICAgdGhpcy5pbmxpbmUgPSB0aGlzLnN0YXJ0V2l0aCh0aGlzLmFubm90YXRpb24sICdkYXRhOicpXG5cbiAgICBsZXQgcHJldiA9IG9wdHMubWFwID8gb3B0cy5tYXAucHJldiA6IHVuZGVmaW5lZFxuICAgIGxldCB0ZXh0ID0gdGhpcy5sb2FkTWFwKG9wdHMuZnJvbSwgcHJldilcbiAgICBpZiAodGV4dCkgdGhpcy50ZXh0ID0gdGV4dFxuICB9XG5cbiAgLyoqXG4gICAqIENyZWF0ZSBhIGluc3RhbmNlIG9mIGBTb3VyY2VNYXBHZW5lcmF0b3JgIGNsYXNzXG4gICAqIGZyb20gdGhlIGBzb3VyY2UtbWFwYCBsaWJyYXJ5IHRvIHdvcmsgd2l0aCBzb3VyY2UgbWFwIGluZm9ybWF0aW9uLlxuICAgKlxuICAgKiBJdCBpcyBsYXp5IG1ldGhvZCwgc28gaXQgd2lsbCBjcmVhdGUgb2JqZWN0IG9ubHkgb24gZmlyc3QgY2FsbFxuICAgKiBhbmQgdGhlbiBpdCB3aWxsIHVzZSBjYWNoZS5cbiAgICpcbiAgICogQHJldHVybiB7U291cmNlTWFwR2VuZXJhdG9yfSBPYmplY3Qgd2l0aCBzb3VyY2UgbWFwIGluZm9ybWF0aW9uLlxuICAgKi9cbiAgY29uc3VtZXIgKCkge1xuICAgIGlmICghdGhpcy5jb25zdW1lckNhY2hlKSB7XG4gICAgICB0aGlzLmNvbnN1bWVyQ2FjaGUgPSBuZXcgbW96aWxsYS5Tb3VyY2VNYXBDb25zdW1lcih0aGlzLnRleHQpXG4gICAgfVxuICAgIHJldHVybiB0aGlzLmNvbnN1bWVyQ2FjaGVcbiAgfVxuXG4gIC8qKlxuICAgKiBEb2VzIHNvdXJjZSBtYXAgY29udGFpbnMgYHNvdXJjZXNDb250ZW50YCB3aXRoIGlucHV0IHNvdXJjZSB0ZXh0LlxuICAgKlxuICAgKiBAcmV0dXJuIHtib29sZWFufSBJcyBgc291cmNlc0NvbnRlbnRgIHByZXNlbnQuXG4gICAqL1xuICB3aXRoQ29udGVudCAoKSB7XG4gICAgcmV0dXJuICEhKHRoaXMuY29uc3VtZXIoKS5zb3VyY2VzQ29udGVudCAmJlxuICAgICAgICAgICAgICB0aGlzLmNvbnN1bWVyKCkuc291cmNlc0NvbnRlbnQubGVuZ3RoID4gMClcbiAgfVxuXG4gIHN0YXJ0V2l0aCAoc3RyaW5nLCBzdGFydCkge1xuICAgIGlmICghc3RyaW5nKSByZXR1cm4gZmFsc2VcbiAgICByZXR1cm4gc3RyaW5nLnN1YnN0cigwLCBzdGFydC5sZW5ndGgpID09PSBzdGFydFxuICB9XG5cbiAgbG9hZEFubm90YXRpb24gKGNzcykge1xuICAgIGxldCBtYXRjaCA9IGNzcy5tYXRjaCgvXFwvXFwqXFxzKiMgc291cmNlTWFwcGluZ1VSTD0oLiopXFxzKlxcKlxcLy8pXG4gICAgaWYgKG1hdGNoKSB0aGlzLmFubm90YXRpb24gPSBtYXRjaFsxXS50cmltKClcbiAgfVxuXG4gIGRlY29kZUlubGluZSAodGV4dCkge1xuICAgIGxldCBiYXNlQ2hhcnNldFVyaSA9IC9eZGF0YTphcHBsaWNhdGlvblxcL2pzb247Y2hhcnNldD11dGYtPzg7YmFzZTY0LC9cbiAgICBsZXQgYmFzZVVyaSA9IC9eZGF0YTphcHBsaWNhdGlvblxcL2pzb247YmFzZTY0LC9cbiAgICBsZXQgdXJpID0gJ2RhdGE6YXBwbGljYXRpb24vanNvbiwnXG5cbiAgICBpZiAodGhpcy5zdGFydFdpdGgodGV4dCwgdXJpKSkge1xuICAgICAgcmV0dXJuIGRlY29kZVVSSUNvbXBvbmVudCh0ZXh0LnN1YnN0cih1cmkubGVuZ3RoKSlcbiAgICB9XG5cbiAgICBpZiAoYmFzZUNoYXJzZXRVcmkudGVzdCh0ZXh0KSB8fCBiYXNlVXJpLnRlc3QodGV4dCkpIHtcbiAgICAgIHJldHVybiBmcm9tQmFzZTY0KHRleHQuc3Vic3RyKFJlZ0V4cC5sYXN0TWF0Y2gubGVuZ3RoKSlcbiAgICB9XG5cbiAgICBsZXQgZW5jb2RpbmcgPSB0ZXh0Lm1hdGNoKC9kYXRhOmFwcGxpY2F0aW9uXFwvanNvbjsoW14sXSspLC8pWzFdXG4gICAgdGhyb3cgbmV3IEVycm9yKCdVbnN1cHBvcnRlZCBzb3VyY2UgbWFwIGVuY29kaW5nICcgKyBlbmNvZGluZylcbiAgfVxuXG4gIGxvYWRNYXAgKGZpbGUsIHByZXYpIHtcbiAgICBpZiAocHJldiA9PT0gZmFsc2UpIHJldHVybiBmYWxzZVxuXG4gICAgaWYgKHByZXYpIHtcbiAgICAgIGlmICh0eXBlb2YgcHJldiA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgcmV0dXJuIHByZXZcbiAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHByZXYgPT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgbGV0IHByZXZQYXRoID0gcHJldihmaWxlKVxuICAgICAgICBpZiAocHJldlBhdGggJiYgZnMuZXhpc3RzU3luYyAmJiBmcy5leGlzdHNTeW5jKHByZXZQYXRoKSkge1xuICAgICAgICAgIHJldHVybiBmcy5yZWFkRmlsZVN5bmMocHJldlBhdGgsICd1dGYtOCcpLnRvU3RyaW5nKCkudHJpbSgpXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxuICAgICAgICAgICAgJ1VuYWJsZSB0byBsb2FkIHByZXZpb3VzIHNvdXJjZSBtYXA6ICcgKyBwcmV2UGF0aC50b1N0cmluZygpKVxuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKHByZXYgaW5zdGFuY2VvZiBtb3ppbGxhLlNvdXJjZU1hcENvbnN1bWVyKSB7XG4gICAgICAgIHJldHVybiBtb3ppbGxhLlNvdXJjZU1hcEdlbmVyYXRvci5mcm9tU291cmNlTWFwKHByZXYpLnRvU3RyaW5nKClcbiAgICAgIH0gZWxzZSBpZiAocHJldiBpbnN0YW5jZW9mIG1vemlsbGEuU291cmNlTWFwR2VuZXJhdG9yKSB7XG4gICAgICAgIHJldHVybiBwcmV2LnRvU3RyaW5nKClcbiAgICAgIH0gZWxzZSBpZiAodGhpcy5pc01hcChwcmV2KSkge1xuICAgICAgICByZXR1cm4gSlNPTi5zdHJpbmdpZnkocHJldilcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcihcbiAgICAgICAgICAnVW5zdXBwb3J0ZWQgcHJldmlvdXMgc291cmNlIG1hcCBmb3JtYXQ6ICcgKyBwcmV2LnRvU3RyaW5nKCkpXG4gICAgICB9XG4gICAgfSBlbHNlIGlmICh0aGlzLmlubGluZSkge1xuICAgICAgcmV0dXJuIHRoaXMuZGVjb2RlSW5saW5lKHRoaXMuYW5ub3RhdGlvbilcbiAgICB9IGVsc2UgaWYgKHRoaXMuYW5ub3RhdGlvbikge1xuICAgICAgbGV0IG1hcCA9IHRoaXMuYW5ub3RhdGlvblxuICAgICAgaWYgKGZpbGUpIG1hcCA9IHBhdGguam9pbihwYXRoLmRpcm5hbWUoZmlsZSksIG1hcClcblxuICAgICAgdGhpcy5yb290ID0gcGF0aC5kaXJuYW1lKG1hcClcbiAgICAgIGlmIChmcy5leGlzdHNTeW5jICYmIGZzLmV4aXN0c1N5bmMobWFwKSkge1xuICAgICAgICByZXR1cm4gZnMucmVhZEZpbGVTeW5jKG1hcCwgJ3V0Zi04JykudG9TdHJpbmcoKS50cmltKClcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHJldHVybiBmYWxzZVxuICAgICAgfVxuICAgIH1cbiAgfVxuXG4gIGlzTWFwIChtYXApIHtcbiAgICBpZiAodHlwZW9mIG1hcCAhPT0gJ29iamVjdCcpIHJldHVybiBmYWxzZVxuICAgIHJldHVybiB0eXBlb2YgbWFwLm1hcHBpbmdzID09PSAnc3RyaW5nJyB8fCB0eXBlb2YgbWFwLl9tYXBwaW5ncyA9PT0gJ3N0cmluZydcbiAgfVxufVxuXG5leHBvcnQgZGVmYXVsdCBQcmV2aW91c01hcFxuIl0sImZpbGUiOiJwcmV2aW91cy1tYXAuanMifQ== +//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByZXZpb3VzLW1hcC5lczYiXSwibmFtZXMiOlsiZnJvbUJhc2U2NCIsInN0ciIsIkJ1ZmZlciIsImZyb20iLCJ0b1N0cmluZyIsIndpbmRvdyIsImF0b2IiLCJQcmV2aW91c01hcCIsImNzcyIsIm9wdHMiLCJsb2FkQW5ub3RhdGlvbiIsImlubGluZSIsInN0YXJ0V2l0aCIsImFubm90YXRpb24iLCJwcmV2IiwibWFwIiwidW5kZWZpbmVkIiwidGV4dCIsImxvYWRNYXAiLCJjb25zdW1lciIsImNvbnN1bWVyQ2FjaGUiLCJtb3ppbGxhIiwiU291cmNlTWFwQ29uc3VtZXIiLCJ3aXRoQ29udGVudCIsInNvdXJjZXNDb250ZW50IiwibGVuZ3RoIiwic3RyaW5nIiwic3RhcnQiLCJzdWJzdHIiLCJnZXRBbm5vdGF0aW9uVVJMIiwic291cmNlTWFwU3RyaW5nIiwibWF0Y2giLCJ0cmltIiwiYW5ub3RhdGlvbnMiLCJsYXN0QW5ub3RhdGlvbiIsImRlY29kZUlubGluZSIsImJhc2VDaGFyc2V0VXJpIiwiYmFzZVVyaSIsInVyaSIsImRlY29kZVVSSUNvbXBvbmVudCIsInRlc3QiLCJSZWdFeHAiLCJsYXN0TWF0Y2giLCJlbmNvZGluZyIsIkVycm9yIiwiZmlsZSIsInByZXZQYXRoIiwiZnMiLCJleGlzdHNTeW5jIiwicmVhZEZpbGVTeW5jIiwiU291cmNlTWFwR2VuZXJhdG9yIiwiZnJvbVNvdXJjZU1hcCIsImlzTWFwIiwiSlNPTiIsInN0cmluZ2lmeSIsInBhdGgiLCJqb2luIiwiZGlybmFtZSIsInJvb3QiLCJtYXBwaW5ncyIsIl9tYXBwaW5ncyJdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQTs7QUFDQTs7QUFDQTs7OztBQUVBLFNBQVNBLFVBQVQsQ0FBcUJDLEdBQXJCLEVBQTBCO0FBQ3hCLE1BQUlDLE1BQUosRUFBWTtBQUNWLFdBQU9BLE1BQU0sQ0FBQ0MsSUFBUCxDQUFZRixHQUFaLEVBQWlCLFFBQWpCLEVBQTJCRyxRQUEzQixFQUFQO0FBQ0QsR0FGRCxNQUVPO0FBQ0wsV0FBT0MsTUFBTSxDQUFDQyxJQUFQLENBQVlMLEdBQVosQ0FBUDtBQUNEO0FBQ0Y7QUFFRDs7Ozs7Ozs7Ozs7OztJQVdNTSxXOzs7QUFDSjs7OztBQUlBLHVCQUFhQyxHQUFiLEVBQWtCQyxJQUFsQixFQUF3QjtBQUN0QixTQUFLQyxjQUFMLENBQW9CRixHQUFwQjtBQUNBOzs7Ozs7QUFLQSxTQUFLRyxNQUFMLEdBQWMsS0FBS0MsU0FBTCxDQUFlLEtBQUtDLFVBQXBCLEVBQWdDLE9BQWhDLENBQWQ7QUFFQSxRQUFJQyxJQUFJLEdBQUdMLElBQUksQ0FBQ00sR0FBTCxHQUFXTixJQUFJLENBQUNNLEdBQUwsQ0FBU0QsSUFBcEIsR0FBMkJFLFNBQXRDO0FBQ0EsUUFBSUMsSUFBSSxHQUFHLEtBQUtDLE9BQUwsQ0FBYVQsSUFBSSxDQUFDTixJQUFsQixFQUF3QlcsSUFBeEIsQ0FBWDtBQUNBLFFBQUlHLElBQUosRUFBVSxLQUFLQSxJQUFMLEdBQVlBLElBQVo7QUFDWDtBQUVEOzs7Ozs7Ozs7Ozs7O1NBU0FFLFEsR0FBQSxvQkFBWTtBQUNWLFFBQUksQ0FBQyxLQUFLQyxhQUFWLEVBQXlCO0FBQ3ZCLFdBQUtBLGFBQUwsR0FBcUIsSUFBSUMsbUJBQVFDLGlCQUFaLENBQThCLEtBQUtMLElBQW5DLENBQXJCO0FBQ0Q7O0FBQ0QsV0FBTyxLQUFLRyxhQUFaO0FBQ0Q7QUFFRDs7Ozs7OztTQUtBRyxXLEdBQUEsdUJBQWU7QUFDYixXQUFPLENBQUMsRUFBRSxLQUFLSixRQUFMLEdBQWdCSyxjQUFoQixJQUNBLEtBQUtMLFFBQUwsR0FBZ0JLLGNBQWhCLENBQStCQyxNQUEvQixHQUF3QyxDQUQxQyxDQUFSO0FBRUQsRzs7U0FFRGIsUyxHQUFBLG1CQUFXYyxNQUFYLEVBQW1CQyxLQUFuQixFQUEwQjtBQUN4QixRQUFJLENBQUNELE1BQUwsRUFBYSxPQUFPLEtBQVA7QUFDYixXQUFPQSxNQUFNLENBQUNFLE1BQVAsQ0FBYyxDQUFkLEVBQWlCRCxLQUFLLENBQUNGLE1BQXZCLE1BQW1DRSxLQUExQztBQUNELEc7O1NBRURFLGdCLEdBQUEsMEJBQWtCQyxlQUFsQixFQUFtQztBQUNqQyxXQUFPQSxlQUFlLENBQ25CQyxLQURJLENBQ0UsdUNBREYsRUFDMkMsQ0FEM0MsRUFFSkMsSUFGSSxFQUFQO0FBR0QsRzs7U0FFRHRCLGMsR0FBQSx3QkFBZ0JGLEdBQWhCLEVBQXFCO0FBQ25CLFFBQUl5QixXQUFXLEdBQUd6QixHQUFHLENBQUN1QixLQUFKLENBQVUseUNBQVYsQ0FBbEI7O0FBRUEsUUFBSUUsV0FBVyxJQUFJQSxXQUFXLENBQUNSLE1BQVosR0FBcUIsQ0FBeEMsRUFBMkM7QUFDekM7QUFDQTtBQUNBLFVBQUlTLGNBQWMsR0FBR0QsV0FBVyxDQUFDQSxXQUFXLENBQUNSLE1BQVosR0FBcUIsQ0FBdEIsQ0FBaEM7O0FBQ0EsVUFBSVMsY0FBSixFQUFvQjtBQUNsQixhQUFLckIsVUFBTCxHQUFrQixLQUFLZ0IsZ0JBQUwsQ0FBc0JLLGNBQXRCLENBQWxCO0FBQ0Q7QUFDRjtBQUNGLEc7O1NBRURDLFksR0FBQSxzQkFBY2xCLElBQWQsRUFBb0I7QUFDbEIsUUFBSW1CLGNBQWMsR0FBRyxnREFBckI7QUFDQSxRQUFJQyxPQUFPLEdBQUcsaUNBQWQ7QUFDQSxRQUFJQyxHQUFHLEdBQUcsd0JBQVY7O0FBRUEsUUFBSSxLQUFLMUIsU0FBTCxDQUFlSyxJQUFmLEVBQXFCcUIsR0FBckIsQ0FBSixFQUErQjtBQUM3QixhQUFPQyxrQkFBa0IsQ0FBQ3RCLElBQUksQ0FBQ1csTUFBTCxDQUFZVSxHQUFHLENBQUNiLE1BQWhCLENBQUQsQ0FBekI7QUFDRDs7QUFFRCxRQUFJVyxjQUFjLENBQUNJLElBQWYsQ0FBb0J2QixJQUFwQixLQUE2Qm9CLE9BQU8sQ0FBQ0csSUFBUixDQUFhdkIsSUFBYixDQUFqQyxFQUFxRDtBQUNuRCxhQUFPakIsVUFBVSxDQUFDaUIsSUFBSSxDQUFDVyxNQUFMLENBQVlhLE1BQU0sQ0FBQ0MsU0FBUCxDQUFpQmpCLE1BQTdCLENBQUQsQ0FBakI7QUFDRDs7QUFFRCxRQUFJa0IsUUFBUSxHQUFHMUIsSUFBSSxDQUFDYyxLQUFMLENBQVcsaUNBQVgsRUFBOEMsQ0FBOUMsQ0FBZjtBQUNBLFVBQU0sSUFBSWEsS0FBSixDQUFVLHFDQUFxQ0QsUUFBL0MsQ0FBTjtBQUNELEc7O1NBRUR6QixPLEdBQUEsaUJBQVMyQixJQUFULEVBQWUvQixJQUFmLEVBQXFCO0FBQ25CLFFBQUlBLElBQUksS0FBSyxLQUFiLEVBQW9CLE9BQU8sS0FBUDs7QUFFcEIsUUFBSUEsSUFBSixFQUFVO0FBQ1IsVUFBSSxPQUFPQSxJQUFQLEtBQWdCLFFBQXBCLEVBQThCO0FBQzVCLGVBQU9BLElBQVA7QUFDRCxPQUZELE1BRU8sSUFBSSxPQUFPQSxJQUFQLEtBQWdCLFVBQXBCLEVBQWdDO0FBQ3JDLFlBQUlnQyxRQUFRLEdBQUdoQyxJQUFJLENBQUMrQixJQUFELENBQW5COztBQUNBLFlBQUlDLFFBQVEsSUFBSUMsWUFBR0MsVUFBZixJQUE2QkQsWUFBR0MsVUFBSCxDQUFjRixRQUFkLENBQWpDLEVBQTBEO0FBQ3hELGlCQUFPQyxZQUFHRSxZQUFILENBQWdCSCxRQUFoQixFQUEwQixPQUExQixFQUFtQzFDLFFBQW5DLEdBQThDNEIsSUFBOUMsRUFBUDtBQUNELFNBRkQsTUFFTztBQUNMLGdCQUFNLElBQUlZLEtBQUosQ0FDSix5Q0FBeUNFLFFBQVEsQ0FBQzFDLFFBQVQsRUFEckMsQ0FBTjtBQUVEO0FBQ0YsT0FSTSxNQVFBLElBQUlVLElBQUksWUFBWU8sbUJBQVFDLGlCQUE1QixFQUErQztBQUNwRCxlQUFPRCxtQkFBUTZCLGtCQUFSLENBQTJCQyxhQUEzQixDQUF5Q3JDLElBQXpDLEVBQStDVixRQUEvQyxFQUFQO0FBQ0QsT0FGTSxNQUVBLElBQUlVLElBQUksWUFBWU8sbUJBQVE2QixrQkFBNUIsRUFBZ0Q7QUFDckQsZUFBT3BDLElBQUksQ0FBQ1YsUUFBTCxFQUFQO0FBQ0QsT0FGTSxNQUVBLElBQUksS0FBS2dELEtBQUwsQ0FBV3RDLElBQVgsQ0FBSixFQUFzQjtBQUMzQixlQUFPdUMsSUFBSSxDQUFDQyxTQUFMLENBQWV4QyxJQUFmLENBQVA7QUFDRCxPQUZNLE1BRUE7QUFDTCxjQUFNLElBQUk4QixLQUFKLENBQ0osNkNBQTZDOUIsSUFBSSxDQUFDVixRQUFMLEVBRHpDLENBQU47QUFFRDtBQUNGLEtBckJELE1BcUJPLElBQUksS0FBS08sTUFBVCxFQUFpQjtBQUN0QixhQUFPLEtBQUt3QixZQUFMLENBQWtCLEtBQUt0QixVQUF2QixDQUFQO0FBQ0QsS0FGTSxNQUVBLElBQUksS0FBS0EsVUFBVCxFQUFxQjtBQUMxQixVQUFJRSxHQUFHLEdBQUcsS0FBS0YsVUFBZjtBQUNBLFVBQUlnQyxJQUFKLEVBQVU5QixHQUFHLEdBQUd3QyxjQUFLQyxJQUFMLENBQVVELGNBQUtFLE9BQUwsQ0FBYVosSUFBYixDQUFWLEVBQThCOUIsR0FBOUIsQ0FBTjtBQUVWLFdBQUsyQyxJQUFMLEdBQVlILGNBQUtFLE9BQUwsQ0FBYTFDLEdBQWIsQ0FBWjs7QUFDQSxVQUFJZ0MsWUFBR0MsVUFBSCxJQUFpQkQsWUFBR0MsVUFBSCxDQUFjakMsR0FBZCxDQUFyQixFQUF5QztBQUN2QyxlQUFPZ0MsWUFBR0UsWUFBSCxDQUFnQmxDLEdBQWhCLEVBQXFCLE9BQXJCLEVBQThCWCxRQUE5QixHQUF5QzRCLElBQXpDLEVBQVA7QUFDRCxPQUZELE1BRU87QUFDTCxlQUFPLEtBQVA7QUFDRDtBQUNGO0FBQ0YsRzs7U0FFRG9CLEssR0FBQSxlQUFPckMsR0FBUCxFQUFZO0FBQ1YsUUFBSSxPQUFPQSxHQUFQLEtBQWUsUUFBbkIsRUFBNkIsT0FBTyxLQUFQO0FBQzdCLFdBQU8sT0FBT0EsR0FBRyxDQUFDNEMsUUFBWCxLQUF3QixRQUF4QixJQUFvQyxPQUFPNUMsR0FBRyxDQUFDNkMsU0FBWCxLQUF5QixRQUFwRTtBQUNELEc7Ozs7O2VBR1lyRCxXIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IG1vemlsbGEgZnJvbSAnc291cmNlLW1hcCdcbmltcG9ydCBwYXRoIGZyb20gJ3BhdGgnXG5pbXBvcnQgZnMgZnJvbSAnZnMnXG5cbmZ1bmN0aW9uIGZyb21CYXNlNjQgKHN0cikge1xuICBpZiAoQnVmZmVyKSB7XG4gICAgcmV0dXJuIEJ1ZmZlci5mcm9tKHN0ciwgJ2Jhc2U2NCcpLnRvU3RyaW5nKClcbiAgfSBlbHNlIHtcbiAgICByZXR1cm4gd2luZG93LmF0b2Ioc3RyKVxuICB9XG59XG5cbi8qKlxuICogU291cmNlIG1hcCBpbmZvcm1hdGlvbiBmcm9tIGlucHV0IENTUy5cbiAqIEZvciBleGFtcGxlLCBzb3VyY2UgbWFwIGFmdGVyIFNhc3MgY29tcGlsZXIuXG4gKlxuICogVGhpcyBjbGFzcyB3aWxsIGF1dG9tYXRpY2FsbHkgZmluZCBzb3VyY2UgbWFwIGluIGlucHV0IENTUyBvciBpbiBmaWxlIHN5c3RlbVxuICogbmVhciBpbnB1dCBmaWxlIChhY2NvcmRpbmcgYGZyb21gIG9wdGlvbikuXG4gKlxuICogQGV4YW1wbGVcbiAqIGNvbnN0IHJvb3QgPSBwb3N0Y3NzLnBhcnNlKGNzcywgeyBmcm9tOiAnYS5zYXNzLmNzcycgfSlcbiAqIHJvb3QuaW5wdXQubWFwIC8vPT4gUHJldmlvdXNNYXBcbiAqL1xuY2xhc3MgUHJldmlvdXNNYXAge1xuICAvKipcbiAgICogQHBhcmFtIHtzdHJpbmd9ICAgICAgICAgY3NzICAgIElucHV0IENTUyBzb3VyY2UuXG4gICAqIEBwYXJhbSB7cHJvY2Vzc09wdGlvbnN9IFtvcHRzXSB7QGxpbmsgUHJvY2Vzc29yI3Byb2Nlc3N9IG9wdGlvbnMuXG4gICAqL1xuICBjb25zdHJ1Y3RvciAoY3NzLCBvcHRzKSB7XG4gICAgdGhpcy5sb2FkQW5ub3RhdGlvbihjc3MpXG4gICAgLyoqXG4gICAgICogV2FzIHNvdXJjZSBtYXAgaW5saW5lZCBieSBkYXRhLXVyaSB0byBpbnB1dCBDU1MuXG4gICAgICpcbiAgICAgKiBAdHlwZSB7Ym9vbGVhbn1cbiAgICAgKi9cbiAgICB0aGlzLmlubGluZSA9IHRoaXMuc3RhcnRXaXRoKHRoaXMuYW5ub3RhdGlvbiwgJ2RhdGE6JylcblxuICAgIGxldCBwcmV2ID0gb3B0cy5tYXAgPyBvcHRzLm1hcC5wcmV2IDogdW5kZWZpbmVkXG4gICAgbGV0IHRleHQgPSB0aGlzLmxvYWRNYXAob3B0cy5mcm9tLCBwcmV2KVxuICAgIGlmICh0ZXh0KSB0aGlzLnRleHQgPSB0ZXh0XG4gIH1cblxuICAvKipcbiAgICogQ3JlYXRlIGEgaW5zdGFuY2Ugb2YgYFNvdXJjZU1hcEdlbmVyYXRvcmAgY2xhc3NcbiAgICogZnJvbSB0aGUgYHNvdXJjZS1tYXBgIGxpYnJhcnkgdG8gd29yayB3aXRoIHNvdXJjZSBtYXAgaW5mb3JtYXRpb24uXG4gICAqXG4gICAqIEl0IGlzIGxhenkgbWV0aG9kLCBzbyBpdCB3aWxsIGNyZWF0ZSBvYmplY3Qgb25seSBvbiBmaXJzdCBjYWxsXG4gICAqIGFuZCB0aGVuIGl0IHdpbGwgdXNlIGNhY2hlLlxuICAgKlxuICAgKiBAcmV0dXJuIHtTb3VyY2VNYXBHZW5lcmF0b3J9IE9iamVjdCB3aXRoIHNvdXJjZSBtYXAgaW5mb3JtYXRpb24uXG4gICAqL1xuICBjb25zdW1lciAoKSB7XG4gICAgaWYgKCF0aGlzLmNvbnN1bWVyQ2FjaGUpIHtcbiAgICAgIHRoaXMuY29uc3VtZXJDYWNoZSA9IG5ldyBtb3ppbGxhLlNvdXJjZU1hcENvbnN1bWVyKHRoaXMudGV4dClcbiAgICB9XG4gICAgcmV0dXJuIHRoaXMuY29uc3VtZXJDYWNoZVxuICB9XG5cbiAgLyoqXG4gICAqIERvZXMgc291cmNlIG1hcCBjb250YWlucyBgc291cmNlc0NvbnRlbnRgIHdpdGggaW5wdXQgc291cmNlIHRleHQuXG4gICAqXG4gICAqIEByZXR1cm4ge2Jvb2xlYW59IElzIGBzb3VyY2VzQ29udGVudGAgcHJlc2VudC5cbiAgICovXG4gIHdpdGhDb250ZW50ICgpIHtcbiAgICByZXR1cm4gISEodGhpcy5jb25zdW1lcigpLnNvdXJjZXNDb250ZW50ICYmXG4gICAgICAgICAgICAgIHRoaXMuY29uc3VtZXIoKS5zb3VyY2VzQ29udGVudC5sZW5ndGggPiAwKVxuICB9XG5cbiAgc3RhcnRXaXRoIChzdHJpbmcsIHN0YXJ0KSB7XG4gICAgaWYgKCFzdHJpbmcpIHJldHVybiBmYWxzZVxuICAgIHJldHVybiBzdHJpbmcuc3Vic3RyKDAsIHN0YXJ0Lmxlbmd0aCkgPT09IHN0YXJ0XG4gIH1cblxuICBnZXRBbm5vdGF0aW9uVVJMIChzb3VyY2VNYXBTdHJpbmcpIHtcbiAgICByZXR1cm4gc291cmNlTWFwU3RyaW5nXG4gICAgICAubWF0Y2goL1xcL1xcKlxccyojIHNvdXJjZU1hcHBpbmdVUkw9KC4qKVxccypcXCpcXC8vKVsxXVxuICAgICAgLnRyaW0oKVxuICB9XG5cbiAgbG9hZEFubm90YXRpb24gKGNzcykge1xuICAgIGxldCBhbm5vdGF0aW9ucyA9IGNzcy5tYXRjaCgvXFwvXFwqXFxzKiMgc291cmNlTWFwcGluZ1VSTD0oLiopXFxzKlxcKlxcLy9tZylcblxuICAgIGlmIChhbm5vdGF0aW9ucyAmJiBhbm5vdGF0aW9ucy5sZW5ndGggPiAwKSB7XG4gICAgICAvLyBMb2NhdGUgdGhlIGxhc3Qgc291cmNlTWFwcGluZ1VSTCB0byBhdm9pZCBwaWNraW5nIHVwXG4gICAgICAvLyBzb3VyY2VNYXBwaW5nVVJMcyBmcm9tIGNvbW1lbnRzLCBzdHJpbmdzLCBldGMuXG4gICAgICBsZXQgbGFzdEFubm90YXRpb24gPSBhbm5vdGF0aW9uc1thbm5vdGF0aW9ucy5sZW5ndGggLSAxXVxuICAgICAgaWYgKGxhc3RBbm5vdGF0aW9uKSB7XG4gICAgICAgIHRoaXMuYW5ub3RhdGlvbiA9IHRoaXMuZ2V0QW5ub3RhdGlvblVSTChsYXN0QW5ub3RhdGlvbilcbiAgICAgIH1cbiAgICB9XG4gIH1cblxuICBkZWNvZGVJbmxpbmUgKHRleHQpIHtcbiAgICBsZXQgYmFzZUNoYXJzZXRVcmkgPSAvXmRhdGE6YXBwbGljYXRpb25cXC9qc29uO2NoYXJzZXQ9dXRmLT84O2Jhc2U2NCwvXG4gICAgbGV0IGJhc2VVcmkgPSAvXmRhdGE6YXBwbGljYXRpb25cXC9qc29uO2Jhc2U2NCwvXG4gICAgbGV0IHVyaSA9ICdkYXRhOmFwcGxpY2F0aW9uL2pzb24sJ1xuXG4gICAgaWYgKHRoaXMuc3RhcnRXaXRoKHRleHQsIHVyaSkpIHtcbiAgICAgIHJldHVybiBkZWNvZGVVUklDb21wb25lbnQodGV4dC5zdWJzdHIodXJpLmxlbmd0aCkpXG4gICAgfVxuXG4gICAgaWYgKGJhc2VDaGFyc2V0VXJpLnRlc3QodGV4dCkgfHwgYmFzZVVyaS50ZXN0KHRleHQpKSB7XG4gICAgICByZXR1cm4gZnJvbUJhc2U2NCh0ZXh0LnN1YnN0cihSZWdFeHAubGFzdE1hdGNoLmxlbmd0aCkpXG4gICAgfVxuXG4gICAgbGV0IGVuY29kaW5nID0gdGV4dC5tYXRjaCgvZGF0YTphcHBsaWNhdGlvblxcL2pzb247KFteLF0rKSwvKVsxXVxuICAgIHRocm93IG5ldyBFcnJvcignVW5zdXBwb3J0ZWQgc291cmNlIG1hcCBlbmNvZGluZyAnICsgZW5jb2RpbmcpXG4gIH1cblxuICBsb2FkTWFwIChmaWxlLCBwcmV2KSB7XG4gICAgaWYgKHByZXYgPT09IGZhbHNlKSByZXR1cm4gZmFsc2VcblxuICAgIGlmIChwcmV2KSB7XG4gICAgICBpZiAodHlwZW9mIHByZXYgPT09ICdzdHJpbmcnKSB7XG4gICAgICAgIHJldHVybiBwcmV2XG4gICAgICB9IGVsc2UgaWYgKHR5cGVvZiBwcmV2ID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIGxldCBwcmV2UGF0aCA9IHByZXYoZmlsZSlcbiAgICAgICAgaWYgKHByZXZQYXRoICYmIGZzLmV4aXN0c1N5bmMgJiYgZnMuZXhpc3RzU3luYyhwcmV2UGF0aCkpIHtcbiAgICAgICAgICByZXR1cm4gZnMucmVhZEZpbGVTeW5jKHByZXZQYXRoLCAndXRmLTgnKS50b1N0cmluZygpLnRyaW0oKVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHRocm93IG5ldyBFcnJvcihcbiAgICAgICAgICAgICdVbmFibGUgdG8gbG9hZCBwcmV2aW91cyBzb3VyY2UgbWFwOiAnICsgcHJldlBhdGgudG9TdHJpbmcoKSlcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIGlmIChwcmV2IGluc3RhbmNlb2YgbW96aWxsYS5Tb3VyY2VNYXBDb25zdW1lcikge1xuICAgICAgICByZXR1cm4gbW96aWxsYS5Tb3VyY2VNYXBHZW5lcmF0b3IuZnJvbVNvdXJjZU1hcChwcmV2KS50b1N0cmluZygpXG4gICAgICB9IGVsc2UgaWYgKHByZXYgaW5zdGFuY2VvZiBtb3ppbGxhLlNvdXJjZU1hcEdlbmVyYXRvcikge1xuICAgICAgICByZXR1cm4gcHJldi50b1N0cmluZygpXG4gICAgICB9IGVsc2UgaWYgKHRoaXMuaXNNYXAocHJldikpIHtcbiAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KHByZXYpXG4gICAgICB9IGVsc2Uge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXG4gICAgICAgICAgJ1Vuc3VwcG9ydGVkIHByZXZpb3VzIHNvdXJjZSBtYXAgZm9ybWF0OiAnICsgcHJldi50b1N0cmluZygpKVxuICAgICAgfVxuICAgIH0gZWxzZSBpZiAodGhpcy5pbmxpbmUpIHtcbiAgICAgIHJldHVybiB0aGlzLmRlY29kZUlubGluZSh0aGlzLmFubm90YXRpb24pXG4gICAgfSBlbHNlIGlmICh0aGlzLmFubm90YXRpb24pIHtcbiAgICAgIGxldCBtYXAgPSB0aGlzLmFubm90YXRpb25cbiAgICAgIGlmIChmaWxlKSBtYXAgPSBwYXRoLmpvaW4ocGF0aC5kaXJuYW1lKGZpbGUpLCBtYXApXG5cbiAgICAgIHRoaXMucm9vdCA9IHBhdGguZGlybmFtZShtYXApXG4gICAgICBpZiAoZnMuZXhpc3RzU3luYyAmJiBmcy5leGlzdHNTeW5jKG1hcCkpIHtcbiAgICAgICAgcmV0dXJuIGZzLnJlYWRGaWxlU3luYyhtYXAsICd1dGYtOCcpLnRvU3RyaW5nKCkudHJpbSgpXG4gICAgICB9IGVsc2Uge1xuICAgICAgICByZXR1cm4gZmFsc2VcbiAgICAgIH1cbiAgICB9XG4gIH1cblxuICBpc01hcCAobWFwKSB7XG4gICAgaWYgKHR5cGVvZiBtYXAgIT09ICdvYmplY3QnKSByZXR1cm4gZmFsc2VcbiAgICByZXR1cm4gdHlwZW9mIG1hcC5tYXBwaW5ncyA9PT0gJ3N0cmluZycgfHwgdHlwZW9mIG1hcC5fbWFwcGluZ3MgPT09ICdzdHJpbmcnXG4gIH1cbn1cblxuZXhwb3J0IGRlZmF1bHQgUHJldmlvdXNNYXBcbiJdLCJmaWxlIjoicHJldmlvdXMtbWFwLmpzIn0= /***/ }), @@ -82708,7 +84999,17 @@ exports.quickSort = function (ary, comparator) { /***/ }), -/* 570 */, +/* 570 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const compare = (a, b, loose) => + new SemVer(a, loose).compare(new SemVer(b, loose)) + +module.exports = compare + + +/***/ }), /* 571 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -83300,7 +85601,167 @@ function getPageLinks (link) { /***/ }), -/* 578 */, +/* 578 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(635) +const { ANY } = __webpack_require__(456) +const satisfies = __webpack_require__(171) +const compare = __webpack_require__(570) + +// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff: +// - Every simple range `r1, r2, ...` is a subset of some `R1, R2, ...` +// +// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff: +// - If c is only the ANY comparator +// - If C is only the ANY comparator, return true +// - Else return false +// - Let EQ be the set of = comparators in c +// - If EQ is more than one, return true (null set) +// - Let GT be the highest > or >= comparator in c +// - Let LT be the lowest < or <= comparator in c +// - If GT and LT, and GT.semver > LT.semver, return true (null set) +// - If EQ +// - If GT, and EQ does not satisfy GT, return true (null set) +// - If LT, and EQ does not satisfy LT, return true (null set) +// - If EQ satisfies every C, return true +// - Else return false +// - If GT +// - If GT is lower than any > or >= comp in C, return false +// - If GT is >=, and GT.semver does not satisfy every C, return false +// - If LT +// - If LT.semver is greater than that of any > comp in C, return false +// - If LT is <=, and LT.semver does not satisfy every C, return false +// - If any C is a = range, and GT or LT are set, return false +// - Else return true + +const subset = (sub, dom, options) => { + sub = new Range(sub, options) + dom = new Range(dom, options) + let sawNonNull = false + + OUTER: for (const simpleSub of sub.set) { + for (const simpleDom of dom.set) { + const isSub = simpleSubset(simpleSub, simpleDom, options) + sawNonNull = sawNonNull || isSub !== null + if (isSub) + continue OUTER + } + // the null set is a subset of everything, but null simple ranges in + // a complex range should be ignored. so if we saw a non-null range, + // then we know this isn't a subset, but if EVERY simple range was null, + // then it is a subset. + if (sawNonNull) + return false + } + return true +} + +const simpleSubset = (sub, dom, options) => { + if (sub.length === 1 && sub[0].semver === ANY) + return dom.length === 1 && dom[0].semver === ANY + + const eqSet = new Set() + let gt, lt + for (const c of sub) { + if (c.operator === '>' || c.operator === '>=') + gt = higherGT(gt, c, options) + else if (c.operator === '<' || c.operator === '<=') + lt = lowerLT(lt, c, options) + else + eqSet.add(c.semver) + } + + if (eqSet.size > 1) + return null + + let gtltComp + if (gt && lt) { + gtltComp = compare(gt.semver, lt.semver, options) + if (gtltComp > 0) + return null + else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) + return null + } + + // will iterate one or zero times + for (const eq of eqSet) { + if (gt && !satisfies(eq, String(gt), options)) + return null + + if (lt && !satisfies(eq, String(lt), options)) + return null + + for (const c of dom) { + if (!satisfies(eq, String(c), options)) + return false + } + return true + } + + let higher, lower + let hasDomLT, hasDomGT + for (const c of dom) { + hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>=' + hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<=' + if (gt) { + if (c.operator === '>' || c.operator === '>=') { + higher = higherGT(gt, c, options) + if (higher === c) + return false + } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) + return false + } + if (lt) { + if (c.operator === '<' || c.operator === '<=') { + lower = lowerLT(lt, c, options) + if (lower === c) + return false + } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) + return false + } + if (!c.operator && (lt || gt) && gtltComp !== 0) + return false + } + + // if there was a < or >, and nothing in the dom, then must be false + // UNLESS it was limited by another range in the other direction. + // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0 + if (gt && hasDomLT && !lt && gtltComp !== 0) + return false + + if (lt && hasDomGT && !gt && gtltComp !== 0) + return false + + return true +} + +// >=1.2.3 is lower than >1.2.3 +const higherGT = (a, b, options) => { + if (!a) + return b + const comp = compare(a.semver, b.semver, options) + return comp > 0 ? a + : comp < 0 ? b + : b.operator === '>' && a.operator === '>=' ? b + : a +} + +// <=1.2.3 is higher than <1.2.3 +const lowerLT = (a, b, options) => { + if (!a) + return b + const comp = compare(a.semver, b.semver, options) + return comp < 0 ? a + : comp > 0 ? b + : b.operator === '<' && a.operator === '<=' ? b + : a +} + +module.exports = subset + + +/***/ }), /* 579 */, /* 580 */ /***/ (function(module) { @@ -84300,7 +86761,15 @@ module.exports = exports.default; /***/ }), -/* 586 */, +/* 586 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(570) +const rcompare = (a, b, loose) => compare(b, a, loose) +module.exports = rcompare + + +/***/ }), /* 587 */ /***/ (function(module, exports, __webpack_require__) { @@ -85012,20 +87481,201 @@ exports.SourceNode = SourceNode; /***/ }), -/* 589 */, +/* 589 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const outside = __webpack_require__(750) +// Determine if version is less than all the versions possible in the range +const ltr = (version, range, options) => outside(version, range, '<', options) +module.exports = ltr + + +/***/ }), /* 590 */ -/***/ (function(module) { +/***/ (function(module, exports, __webpack_require__) { -module.exports = function (x, opts) { - /** - * This file is purposefully a passthrough. It's expected that third-party - * environments will override it at runtime in order to inject special logic - * into `resolve` (by manipulating the options). One such example is the PnP - * code path in Yarn. - */ +const { MAX_SAFE_COMPONENT_LENGTH } = __webpack_require__(627) +const debug = __webpack_require__(487) +exports = module.exports = {} - return opts || {}; -}; +// The actual regexps go on exports.re +const re = exports.re = [] +const src = exports.src = [] +const t = exports.t = {} +let R = 0 + +const createToken = (name, value, isGlobal) => { + const index = R++ + debug(index, value) + t[name] = index + src[index] = value + re[index] = new RegExp(value, isGlobal ? 'g' : undefined) +} + +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. + +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. + +createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*') +createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+') + +// ## Non-numeric Identifier +// Zero or more digits, followed by a letter or hyphen, and then zero or +// more letters, digits, or hyphens. + +createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*') + +// ## Main Version +// Three dot-separated numeric identifiers. + +createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})\\.` + + `(${src[t.NUMERICIDENTIFIER]})`) + +createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + + `(${src[t.NUMERICIDENTIFIERLOOSE]})`) + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER] +}|${src[t.NONNUMERICIDENTIFIER]})`) + +createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE] +}|${src[t.NONNUMERICIDENTIFIER]})`) + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER] +}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`) + +createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] +}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`) + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+') + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER] +}(?:\\.${src[t.BUILDIDENTIFIER]})*))`) + +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. + +// Note that the only major, minor, patch, and pre-release sections of +// the version string are capturing groups. The build metadata is not a +// capturing group, because it should not ever be used in version +// comparison. + +createToken('FULLPLAIN', `v?${src[t.MAINVERSION] +}${src[t.PRERELEASE]}?${ + src[t.BUILD]}?`) + +createToken('FULL', `^${src[t.FULLPLAIN]}$`) + +// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. +// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty +// common in the npm registry. +createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE] +}${src[t.PRERELEASELOOSE]}?${ + src[t.BUILD]}?`) + +createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`) + +createToken('GTLT', '((?:<|>)?=?)') + +// Something like "2.*" or "1.2.x". +// Note that "x.x" is a valid xRange identifer, meaning "any version" +// Only the first item is strictly required. +createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`) +createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`) + +createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + + `(?:${src[t.PRERELEASE]})?${ + src[t.BUILD]}?` + + `)?)?`) + +createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + + `(?:${src[t.PRERELEASELOOSE]})?${ + src[t.BUILD]}?` + + `)?)?`) + +createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`) +createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) + +// Coercion. +// Extract anything that could conceivably be a part of a valid semver +createToken('COERCE', `${'(^|[^\\d])' + + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:$|[^\\d])`) +createToken('COERCERTL', src[t.COERCE], true) + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +createToken('LONETILDE', '(?:~>?)') + +createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true) +exports.tildeTrimReplace = '$1~' + +createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`) +createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`) + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +createToken('LONECARET', '(?:\\^)') + +createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true) +exports.caretTrimReplace = '$1^' + +createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`) +createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`) + +// A simple gt/lt/eq thing, or just "" to indicate "any version" +createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`) +createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`) + +// An expression to strip any whitespace between the gtlt and the thing +// it modifies, so that `> 1.2.3` ==> `>1.2.3` +createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT] +}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true) +exports.comparatorTrimReplace = '$1$2$3' + +// Something like `1.2.3 - 1.2.4` +// Note that these all use the loose form, because they'll be +// checked against either the strict or loose comparator form +// later. +createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAIN]})` + + `\\s*$`) + +createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + + `\\s+-\\s+` + + `(${src[t.XRANGEPLAINLOOSE]})` + + `\\s*$`) + +// Star ranges basically just allow anything at all. +createToken('STAR', '(<|>)?=?\\s*\\*') +// >=0.0.0 is like a star +createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$') /***/ }), @@ -85250,7 +87900,284 @@ function done(stream, er, data) { } /***/ }), -/* 593 */, +/* 593 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + + +var utils = __webpack_require__(733); +var formats = __webpack_require__(859); +var has = Object.prototype.hasOwnProperty; + +var arrayPrefixGenerators = { + brackets: function brackets(prefix) { + return prefix + '[]'; + }, + comma: 'comma', + indices: function indices(prefix, key) { + return prefix + '[' + key + ']'; + }, + repeat: function repeat(prefix) { + return prefix; + } +}; + +var isArray = Array.isArray; +var push = Array.prototype.push; +var pushToArray = function (arr, valueOrArray) { + push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]); +}; + +var toISO = Date.prototype.toISOString; + +var defaultFormat = formats['default']; +var defaults = { + addQueryPrefix: false, + allowDots: false, + charset: 'utf-8', + charsetSentinel: false, + delimiter: '&', + encode: true, + encoder: utils.encode, + encodeValuesOnly: false, + format: defaultFormat, + formatter: formats.formatters[defaultFormat], + // deprecated + indices: false, + serializeDate: function serializeDate(date) { + return toISO.call(date); + }, + skipNulls: false, + strictNullHandling: false +}; + +var isNonNullishPrimitive = function isNonNullishPrimitive(v) { + return typeof v === 'string' + || typeof v === 'number' + || typeof v === 'boolean' + || typeof v === 'symbol' + || typeof v === 'bigint'; +}; + +var stringify = function stringify( + object, + prefix, + generateArrayPrefix, + strictNullHandling, + skipNulls, + encoder, + filter, + sort, + allowDots, + serializeDate, + formatter, + encodeValuesOnly, + charset +) { + var obj = object; + if (typeof filter === 'function') { + obj = filter(prefix, obj); + } else if (obj instanceof Date) { + obj = serializeDate(obj); + } else if (generateArrayPrefix === 'comma' && isArray(obj)) { + obj = utils.maybeMap(obj, function (value) { + if (value instanceof Date) { + return serializeDate(value); + } + return value; + }).join(','); + } + + if (obj === null) { + if (strictNullHandling) { + return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key') : prefix; + } + + obj = ''; + } + + if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) { + if (encoder) { + var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key'); + return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value'))]; + } + return [formatter(prefix) + '=' + formatter(String(obj))]; + } + + var values = []; + + if (typeof obj === 'undefined') { + return values; + } + + var objKeys; + if (isArray(filter)) { + objKeys = filter; + } else { + var keys = Object.keys(obj); + objKeys = sort ? keys.sort(sort) : keys; + } + + for (var i = 0; i < objKeys.length; ++i) { + var key = objKeys[i]; + var value = obj[key]; + + if (skipNulls && value === null) { + continue; + } + + var keyPrefix = isArray(obj) + ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(prefix, key) : prefix + : prefix + (allowDots ? '.' + key : '[' + key + ']'); + + pushToArray(values, stringify( + value, + keyPrefix, + generateArrayPrefix, + strictNullHandling, + skipNulls, + encoder, + filter, + sort, + allowDots, + serializeDate, + formatter, + encodeValuesOnly, + charset + )); + } + + return values; +}; + +var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { + if (!opts) { + return defaults; + } + + if (opts.encoder !== null && opts.encoder !== undefined && typeof opts.encoder !== 'function') { + throw new TypeError('Encoder has to be a function.'); + } + + var charset = opts.charset || defaults.charset; + if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { + throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); + } + + var format = formats['default']; + if (typeof opts.format !== 'undefined') { + if (!has.call(formats.formatters, opts.format)) { + throw new TypeError('Unknown format option provided.'); + } + format = opts.format; + } + var formatter = formats.formatters[format]; + + var filter = defaults.filter; + if (typeof opts.filter === 'function' || isArray(opts.filter)) { + filter = opts.filter; + } + + return { + addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix, + allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, + charset: charset, + charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, + delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter, + encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode, + encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder, + encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly, + filter: filter, + formatter: formatter, + serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate, + skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls, + sort: typeof opts.sort === 'function' ? opts.sort : null, + strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling + }; +}; + +module.exports = function (object, opts) { + var obj = object; + var options = normalizeStringifyOptions(opts); + + var objKeys; + var filter; + + if (typeof options.filter === 'function') { + filter = options.filter; + obj = filter('', obj); + } else if (isArray(options.filter)) { + filter = options.filter; + objKeys = filter; + } + + var keys = []; + + if (typeof obj !== 'object' || obj === null) { + return ''; + } + + var arrayFormat; + if (opts && opts.arrayFormat in arrayPrefixGenerators) { + arrayFormat = opts.arrayFormat; + } else if (opts && 'indices' in opts) { + arrayFormat = opts.indices ? 'indices' : 'repeat'; + } else { + arrayFormat = 'indices'; + } + + var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; + + if (!objKeys) { + objKeys = Object.keys(obj); + } + + if (options.sort) { + objKeys.sort(options.sort); + } + + for (var i = 0; i < objKeys.length; ++i) { + var key = objKeys[i]; + + if (options.skipNulls && obj[key] === null) { + continue; + } + pushToArray(keys, stringify( + obj[key], + key, + generateArrayPrefix, + options.strictNullHandling, + options.skipNulls, + options.encode ? options.encoder : null, + options.filter, + options.sort, + options.allowDots, + options.serializeDate, + options.formatter, + options.encodeValuesOnly, + options.charset + )); + } + + var joined = keys.join(options.delimiter); + var prefix = options.addQueryPrefix === true ? '?' : ''; + + if (options.charsetSentinel) { + if (options.charset === 'iso-8859-1') { + // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark + prefix += 'utf8=%26%2310003%3B&'; + } else { + // encodeURIComponent('✓') + prefix += 'utf8=%E2%9C%93&'; + } + } + + return joined.length > 0 ? prefix + joined : ''; +}; + + +/***/ }), /* 594 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -85266,7 +88193,7 @@ module.exports = __webpack_require__(807).PassThrough "use strict"; -var stringify = __webpack_require__(513); +var stringify = __webpack_require__(593); var parse = __webpack_require__(997); var formats = __webpack_require__(859); @@ -86083,8 +89010,27 @@ function clone (obj) { /***/ }), -/* 609 */, -/* 610 */, +/* 609 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(658) +const prerelease = (version, options) => { + const parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} +module.exports = prerelease + + +/***/ }), +/* 610 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const minor = (a, loose) => new SemVer(a, loose).minor +module.exports = minor + + +/***/ }), /* 611 */, /* 612 */, /* 613 */ @@ -86237,7 +89183,15 @@ module.exports = require("events"); /* 615 */, /* 616 */, /* 617 */, -/* 618 */, +/* 618 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(682) +const gte = (a, b, loose) => compare(a, b, loose) >= 0 +module.exports = gte + + +/***/ }), /* 619 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -86330,7 +89284,29 @@ module.exports = __webpack_require__(413); /***/ }), -/* 627 */, +/* 627 */ +/***/ (function(module) { + +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +const SEMVER_SPEC_VERSION = '2.0.0' + +const MAX_LENGTH = 256 +const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 + +// Max safe segment length for coercion. +const MAX_SAFE_COMPONENT_LENGTH = 16 + +module.exports = { + SEMVER_SPEC_VERSION, + MAX_LENGTH, + MAX_SAFE_INTEGER, + MAX_SAFE_COMPONENT_LENGTH +} + + +/***/ }), /* 628 */, /* 629 */, /* 630 */ @@ -86424,7 +89400,56 @@ exports.MappingList = MappingList; module.exports = require("net"); /***/ }), -/* 632 */, +/* 632 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// given a set of versions and a range, create a "simplified" range +// that includes the same versions that the original range does +// If the original range is shorter than the simplified one, return that. +const satisfies = __webpack_require__(171) +const compare = __webpack_require__(570) +module.exports = (versions, range, options) => { + const set = [] + let min = null + let prev = null + const v = versions.sort((a, b) => compare(a, b, options)) + for (const version of v) { + const included = satisfies(version, range, options) + if (included) { + prev = version + if (!min) + min = version + } else { + if (prev) { + set.push([min, prev]) + } + prev = null + min = null + } + } + if (min) + set.push([min, null]) + + const ranges = [] + for (const [min, max] of set) { + if (min === max) + ranges.push(min) + else if (!max && min === v[0]) + ranges.push('*') + else if (!max) + ranges.push(`>=${min}`) + else if (min === v[0]) + ranges.push(`<=${max}`) + else + ranges.push(`${min} - ${max}`) + } + const simplified = ranges.join(' || ') + const original = typeof range.raw === 'string' ? range.raw : String(range) + return simplified.length < original.length ? simplified : range +} + + +/***/ }), /* 633 */, /* 634 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -86486,7 +89511,475 @@ function slice (args) { /***/ }), -/* 635 */, +/* 635 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// hoisted class for cyclic dependency +class Range { + constructor (range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (range instanceof Range) { + if ( + range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease + ) { + return range + } else { + return new Range(range.raw, options) + } + } + + if (range instanceof Comparator) { + // just put it in the set and return + this.raw = range.value + this.set = [[range]] + this.format() + return this + } + + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease + + // First, split based on boolean or || + this.raw = range + this.set = range + .split(/\s*\|\|\s*/) + // map the range to a 2d array of comparators + .map(range => this.parseRange(range.trim())) + // throw out any comparator lists that are empty + // this generally means that it was not a valid range, which is allowed + // in loose mode, but will still throw if the WHOLE range is invalid. + .filter(c => c.length) + + if (!this.set.length) { + throw new TypeError(`Invalid SemVer Range: ${range}`) + } + + this.format() + } + + format () { + this.range = this.set + .map((comps) => { + return comps.join(' ').trim() + }) + .join('||') + .trim() + return this.range + } + + toString () { + return this.range + } + + parseRange (range) { + const loose = this.options.loose + range = range.trim() + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] + range = range.replace(hr, hyphenReplace(this.options.includePrerelease)) + debug('hyphen replace', range) + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range, re[t.COMPARATORTRIM]) + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[t.TILDETRIM], tildeTrimReplace) + + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[t.CARETTRIM], caretTrimReplace) + + // normalize spaces + range = range.split(/\s+/).join(' ') + + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + return range + .split(' ') + .map(comp => parseComparator(comp, this.options)) + .join(' ') + .split(/\s+/) + .map(comp => replaceGTE0(comp, this.options)) + // in loose mode, throw out any that are not valid comparators + .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) + .map(comp => new Comparator(comp, this.options)) + } + + intersects (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + return this.set.some((thisComparators) => { + return ( + isSatisfiable(thisComparators, options) && + range.set.some((rangeComparators) => { + return ( + isSatisfiable(rangeComparators, options) && + thisComparators.every((thisComparator) => { + return rangeComparators.every((rangeComparator) => { + return thisComparator.intersects(rangeComparator, options) + }) + }) + ) + }) + ) + }) + } + + // if ANY of the sets match ALL of its comparators, then pass + test (version) { + if (!version) { + return false + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + for (let i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } + } + return false + } +} +module.exports = Range + +const Comparator = __webpack_require__(456) +const debug = __webpack_require__(509) +const SemVer = __webpack_require__(243) +const { + re, + t, + comparatorTrimReplace, + tildeTrimReplace, + caretTrimReplace +} = __webpack_require__(331) + +// take a set of comparators and determine whether there +// exists a version which can satisfy it +const isSatisfiable = (comparators, options) => { + let result = true + const remainingComparators = comparators.slice() + let testComparator = remainingComparators.pop() + + while (result && remainingComparators.length) { + result = remainingComparators.every((otherComparator) => { + return testComparator.intersects(otherComparator, options) + }) + + testComparator = remainingComparators.pop() + } + + return result +} + +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +const parseComparator = (comp, options) => { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp +} + +const isX = id => !id || id.toLowerCase() === 'x' || id === '*' + +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0 +const replaceTildes = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { + return replaceTilde(comp, options) + }).join(' ') + +const replaceTilde = (comp, options) => { + const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] + return comp.replace(r, (_, M, m, p, pr) => { + debug('tilde', comp, _, M, m, p, pr) + let ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${M}.0.0 <${+M + 1}.0.0-0` + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0-0 + ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0` + } else if (pr) { + debug('replaceTilde pr', pr) + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0` + } else { + // ~1.2.3 == >=1.2.3 <1.3.0-0 + ret = `>=${M}.${m}.${p + } <${M}.${+m + 1}.0-0` + } + + debug('tilde return', ret) + return ret + }) +} + +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 +// ^1.2.3 --> >=1.2.3 <2.0.0-0 +// ^1.2.0 --> >=1.2.0 <2.0.0-0 +const replaceCarets = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { + return replaceCaret(comp, options) + }).join(' ') + +const replaceCaret = (comp, options) => { + debug('caret', comp, options) + const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] + const z = options.includePrerelease ? '-0' : '' + return comp.replace(r, (_, M, m, p, pr) => { + debug('caret', comp, _, M, m, p, pr) + let ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` + } else if (isX(p)) { + if (M === '0') { + ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` + } else { + ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0` + } + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${m}.${+p + 1}-0` + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0` + } + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${+M + 1}.0.0-0` + } + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p + }${z} <${M}.${m}.${+p + 1}-0` + } else { + ret = `>=${M}.${m}.${p + }${z} <${M}.${+m + 1}.0-0` + } + } else { + ret = `>=${M}.${m}.${p + } <${+M + 1}.0.0-0` + } + } + + debug('caret return', ret) + return ret + }) +} + +const replaceXRanges = (comp, options) => { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map((comp) => { + return replaceXRange(comp, options) + }).join(' ') +} + +const replaceXRange = (comp, options) => { + comp = comp.trim() + const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] + return comp.replace(r, (ret, gtlt, M, m, p, pr) => { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + const xM = isX(M) + const xm = xM || isX(m) + const xp = xm || isX(p) + const anyX = xp + + if (gtlt === '=' && anyX) { + gtlt = '' + } + + // if we're including prereleases in the match, then we need + // to fix this to -0, the lowest possible prerelease value + pr = options.includePrerelease ? '-0' : '' + + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0-0' + } else { + // nothing is forbidden + ret = '*' + } + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0 + } + p = 0 + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + gtlt = '>=' + if (xm) { + M = +M + 1 + m = 0 + p = 0 + } else { + m = +m + 1 + p = 0 + } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) { + M = +M + 1 + } else { + m = +m + 1 + } + } + + if (gtlt === '<') + pr = '-0' + + ret = `${gtlt + M}.${m}.${p}${pr}` + } else if (xm) { + ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` + } else if (xp) { + ret = `>=${M}.${m}.0${pr + } <${M}.${+m + 1}.0-0` + } + + debug('xRange return', ret) + + return ret + }) +} + +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +const replaceStars = (comp, options) => { + debug('replaceStars', comp, options) + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[t.STAR], '') +} + +const replaceGTE0 = (comp, options) => { + debug('replaceGTE0', comp, options) + return comp.trim() + .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') +} + +// This function is passed to string.replace(re[t.HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0-0 +const hyphenReplace = incPr => ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) => { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = `>=${fM}.0.0${incPr ? '-0' : ''}` + } else if (isX(fp)) { + from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}` + } else if (fpr) { + from = `>=${from}` + } else { + from = `>=${from}${incPr ? '-0' : ''}` + } + + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = `<${+tM + 1}.0.0-0` + } else if (isX(tp)) { + to = `<${tM}.${+tm + 1}.0-0` + } else if (tpr) { + to = `<=${tM}.${tm}.${tp}-${tpr}` + } else if (incPr) { + to = `<${tM}.${tm}.${+tp + 1}-0` + } else { + to = `<=${to}` + } + + return (`${from} ${to}`).trim() +} + +const testSet = (set, version, options) => { + for (let i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } + + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (let i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === Comparator.ANY) { + continue + } + + if (set[i].semver.prerelease.length > 0) { + const allowed = set[i].semver + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true + } + } + } + + // Version has a -pre, but it's not one of the ones we like. + return false + } + + return true +} + + +/***/ }), /* 636 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -86500,7 +89993,15 @@ module.exports = __webpack_require__(665); /***/ }), /* 637 */, -/* 638 */, +/* 638 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compareBuild = __webpack_require__(805) +const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) +module.exports = sort + + +/***/ }), /* 639 */, /* 640 */, /* 641 */ @@ -86582,7 +90083,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const debug_1 = __importDefault(__webpack_require__(784)); const glob_1 = __webpack_require__(120); const is_glob_1 = __importDefault(__webpack_require__(846)); -const semver_1 = __importDefault(__webpack_require__(701)); +const semver_1 = __importDefault(__webpack_require__(900)); const ts = __importStar(__webpack_require__(752)); const ast_converter_1 = __webpack_require__(204); const convert_1 = __webpack_require__(514); @@ -86856,7 +90357,7 @@ function warnAboutTSVersion() { //------------------------------------------------------------------------------ // Public //------------------------------------------------------------------------------ -const version = __webpack_require__(487).version; +const version = __webpack_require__(156).version; exports.version = version; function parse(code, options) { /** @@ -87740,257 +91241,45 @@ function Writable(fn, options) { /***/ }), /* 657 */, /* 658 */ -/***/ (function(module) { - -"use strict"; - - -var has = Object.prototype.hasOwnProperty; -var isArray = Array.isArray; - -var hexTable = (function () { - var array = []; - for (var i = 0; i < 256; ++i) { - array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); - } - - return array; -}()); - -var compactQueue = function compactQueue(queue) { - while (queue.length > 1) { - var item = queue.pop(); - var obj = item.obj[item.prop]; - - if (isArray(obj)) { - var compacted = []; - - for (var j = 0; j < obj.length; ++j) { - if (typeof obj[j] !== 'undefined') { - compacted.push(obj[j]); - } - } - - item.obj[item.prop] = compacted; - } - } -}; - -var arrayToObject = function arrayToObject(source, options) { - var obj = options && options.plainObjects ? Object.create(null) : {}; - for (var i = 0; i < source.length; ++i) { - if (typeof source[i] !== 'undefined') { - obj[i] = source[i]; - } - } - - return obj; -}; - -var merge = function merge(target, source, options) { - /* eslint no-param-reassign: 0 */ - if (!source) { - return target; - } - - if (typeof source !== 'object') { - if (isArray(target)) { - target.push(source); - } else if (target && typeof target === 'object') { - if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) { - target[source] = true; - } - } else { - return [target, source]; - } - - return target; - } - - if (!target || typeof target !== 'object') { - return [target].concat(source); - } - - var mergeTarget = target; - if (isArray(target) && !isArray(source)) { - mergeTarget = arrayToObject(target, options); - } - - if (isArray(target) && isArray(source)) { - source.forEach(function (item, i) { - if (has.call(target, i)) { - var targetItem = target[i]; - if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { - target[i] = merge(targetItem, item, options); - } else { - target.push(item); - } - } else { - target[i] = item; - } - }); - return target; - } - - return Object.keys(source).reduce(function (acc, key) { - var value = source[key]; - - if (has.call(acc, key)) { - acc[key] = merge(acc[key], value, options); - } else { - acc[key] = value; - } - return acc; - }, mergeTarget); -}; - -var assign = function assignSingleSource(target, source) { - return Object.keys(source).reduce(function (acc, key) { - acc[key] = source[key]; - return acc; - }, target); -}; - -var decode = function (str, decoder, charset) { - var strWithoutPlus = str.replace(/\+/g, ' '); - if (charset === 'iso-8859-1') { - // unescape never throws, no try...catch needed: - return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); - } - // utf-8 - try { - return decodeURIComponent(strWithoutPlus); - } catch (e) { - return strWithoutPlus; - } -}; - -var encode = function encode(str, defaultEncoder, charset) { - // This code was originally written by Brian White (mscdex) for the io.js core querystring library. - // It has been adapted here for stricter adherence to RFC 3986 - if (str.length === 0) { - return str; - } - - var string = str; - if (typeof str === 'symbol') { - string = Symbol.prototype.toString.call(str); - } else if (typeof str !== 'string') { - string = String(str); - } - - if (charset === 'iso-8859-1') { - return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { - return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; - }); - } - - var out = ''; - for (var i = 0; i < string.length; ++i) { - var c = string.charCodeAt(i); - - if ( - c === 0x2D // - - || c === 0x2E // . - || c === 0x5F // _ - || c === 0x7E // ~ - || (c >= 0x30 && c <= 0x39) // 0-9 - || (c >= 0x41 && c <= 0x5A) // a-z - || (c >= 0x61 && c <= 0x7A) // A-Z - ) { - out += string.charAt(i); - continue; - } - - if (c < 0x80) { - out = out + hexTable[c]; - continue; - } - - if (c < 0x800) { - out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - if (c < 0xD800 || c >= 0xE000) { - out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); - continue; - } - - i += 1; - c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); - out += hexTable[0xF0 | (c >> 18)] - + hexTable[0x80 | ((c >> 12) & 0x3F)] - + hexTable[0x80 | ((c >> 6) & 0x3F)] - + hexTable[0x80 | (c & 0x3F)]; - } - - return out; -}; - -var compact = function compact(value) { - var queue = [{ obj: { o: value }, prop: 'o' }]; - var refs = []; +/***/ (function(module, __unusedexports, __webpack_require__) { - for (var i = 0; i < queue.length; ++i) { - var item = queue[i]; - var obj = item.obj[item.prop]; +const {MAX_LENGTH} = __webpack_require__(627) +const { re, t } = __webpack_require__(590) +const SemVer = __webpack_require__(369) - var keys = Object.keys(obj); - for (var j = 0; j < keys.length; ++j) { - var key = keys[j]; - var val = obj[key]; - if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { - queue.push({ obj: obj, prop: key }); - refs.push(val); - } - } +const parse = (version, options) => { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } + } - compactQueue(queue); - - return value; -}; - -var isRegExp = function isRegExp(obj) { - return Object.prototype.toString.call(obj) === '[object RegExp]'; -}; + if (version instanceof SemVer) { + return version + } -var isBuffer = function isBuffer(obj) { - if (!obj || typeof obj !== 'object') { - return false; - } + if (typeof version !== 'string') { + return null + } - return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); -}; + if (version.length > MAX_LENGTH) { + return null + } -var combine = function combine(a, b) { - return [].concat(a, b); -}; + const r = options.loose ? re[t.LOOSE] : re[t.FULL] + if (!r.test(version)) { + return null + } -var maybeMap = function maybeMap(val, fn) { - if (isArray(val)) { - var mapped = []; - for (var i = 0; i < val.length; i += 1) { - mapped.push(fn(val[i])); - } - return mapped; - } - return fn(val); -}; + try { + return new SemVer(version, options) + } catch (er) { + return null + } +} -module.exports = { - arrayToObject: arrayToObject, - assign: assign, - combine: combine, - compact: compact, - decode: decode, - encode: encode, - isBuffer: isBuffer, - isRegExp: isRegExp, - maybeMap: maybeMap, - merge: merge -}; +module.exports = parse /***/ }), @@ -89679,7 +92968,17 @@ module.exports.win32 = win32; /***/ }), -/* 682 */, +/* 682 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const compare = (a, b, loose) => + new SemVer(a, loose).compare(new SemVer(b, loose)) + +module.exports = compare + + +/***/ }), /* 683 */ /***/ (function(module, exports) { @@ -92086,7 +95385,36 @@ exports.Deprecation = Deprecation; /***/ }), -/* 693 */, +/* 693 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const Range = __webpack_require__(635) +const minSatisfying = (versions, range, options) => { + let min = null + let minSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!min || minSV.compare(v) === 1) { + // compare(min, v, true) + min = v + minSV = new SemVer(min, options) + } + } + }) + return min +} +module.exports = minSatisfying + + +/***/ }), /* 694 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -92776,4927 +96104,4847 @@ module.exports = exports.default; /***/ }), /* 699 */, /* 700 */, -/* 701 */ -/***/ (function(module, exports) { - -exports = module.exports = SemVer +/* 701 */, +/* 702 */, +/* 703 */, +/* 704 */ +/***/ (function(module, exports, __webpack_require__) { -var debug -/* istanbul ignore next */ -if (typeof process === 'object' && - process.env && - process.env.NODE_DEBUG && - /\bsemver\b/i.test(process.env.NODE_DEBUG)) { - debug = function () { - var args = Array.prototype.slice.call(arguments, 0) - args.unshift('SEMVER') - console.log.apply(console, args) - } -} else { - debug = function () {} -} +/* module decorator */ module = __webpack_require__.nmd(module); +/** + * lodash (Custom Build) + * Build: `lodash modularize exports="npm" -o ./` + * Copyright jQuery Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ -// Note: this is the semver.org version of the spec that it implements -// Not necessarily the package version of this code. -exports.SEMVER_SPEC_VERSION = '2.0.0' +/** Used as the size to enable large array optimizations. */ +var LARGE_ARRAY_SIZE = 200; -var MAX_LENGTH = 256 -var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +/** Used as the `TypeError` message for "Functions" methods. */ +var FUNC_ERROR_TEXT = 'Expected a function'; -// Max safe segment length for coercion. -var MAX_SAFE_COMPONENT_LENGTH = 16 +/** Used to stand-in for `undefined` hash values. */ +var HASH_UNDEFINED = '__lodash_hash_undefined__'; -// The actual regexps go on exports.re -var re = exports.re = [] -var src = exports.src = [] -var t = exports.tokens = {} -var R = 0 +/** Used to compose bitmasks for comparison styles. */ +var UNORDERED_COMPARE_FLAG = 1, + PARTIAL_COMPARE_FLAG = 2; -function tok (n) { - t[n] = R++ -} +/** Used as references for various `Number` constants. */ +var INFINITY = 1 / 0, + MAX_SAFE_INTEGER = 9007199254740991; -// The following Regular Expressions can be used for tokenizing, -// validating, and parsing SemVer version strings. +/** `Object#toString` result references. */ +var argsTag = '[object Arguments]', + arrayTag = '[object Array]', + boolTag = '[object Boolean]', + dateTag = '[object Date]', + errorTag = '[object Error]', + funcTag = '[object Function]', + genTag = '[object GeneratorFunction]', + mapTag = '[object Map]', + numberTag = '[object Number]', + objectTag = '[object Object]', + promiseTag = '[object Promise]', + regexpTag = '[object RegExp]', + setTag = '[object Set]', + stringTag = '[object String]', + symbolTag = '[object Symbol]', + weakMapTag = '[object WeakMap]'; -// ## Numeric Identifier -// A single `0`, or a non-zero digit followed by zero or more digits. +var arrayBufferTag = '[object ArrayBuffer]', + dataViewTag = '[object DataView]', + float32Tag = '[object Float32Array]', + float64Tag = '[object Float64Array]', + int8Tag = '[object Int8Array]', + int16Tag = '[object Int16Array]', + int32Tag = '[object Int32Array]', + uint8Tag = '[object Uint8Array]', + uint8ClampedTag = '[object Uint8ClampedArray]', + uint16Tag = '[object Uint16Array]', + uint32Tag = '[object Uint32Array]'; -tok('NUMERICIDENTIFIER') -src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' -tok('NUMERICIDENTIFIERLOOSE') -src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+' +/** Used to match property names within property paths. */ +var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, + reIsPlainProp = /^\w*$/, + reLeadingDot = /^\./, + rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; -// ## Non-numeric Identifier -// Zero or more digits, followed by a letter or hyphen, and then zero or -// more letters, digits, or hyphens. +/** + * Used to match `RegExp` + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + */ +var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; -tok('NONNUMERICIDENTIFIER') -src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' +/** Used to match backslashes in property paths. */ +var reEscapeChar = /\\(\\)?/g; -// ## Main Version -// Three dot-separated numeric identifiers. +/** Used to detect host constructors (Safari). */ +var reIsHostCtor = /^\[object .+?Constructor\]$/; -tok('MAINVERSION') -src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')' +/** Used to detect unsigned integer values. */ +var reIsUint = /^(?:0|[1-9]\d*)$/; -tok('MAINVERSIONLOOSE') -src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' +/** Used to identify `toStringTag` values of typed arrays. */ +var typedArrayTags = {}; +typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = +typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = +typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = +typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = +typedArrayTags[uint32Tag] = true; +typedArrayTags[argsTag] = typedArrayTags[arrayTag] = +typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = +typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = +typedArrayTags[errorTag] = typedArrayTags[funcTag] = +typedArrayTags[mapTag] = typedArrayTags[numberTag] = +typedArrayTags[objectTag] = typedArrayTags[regexpTag] = +typedArrayTags[setTag] = typedArrayTags[stringTag] = +typedArrayTags[weakMapTag] = false; -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. +/** Detect free variable `global` from Node.js. */ +var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; -tok('PRERELEASEIDENTIFIER') -src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; -tok('PRERELEASEIDENTIFIERLOOSE') -src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. +/** Detect free variable `exports`. */ +var freeExports = true && exports && !exports.nodeType && exports; -tok('PRERELEASE') -src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' +/** Detect free variable `module`. */ +var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module; -tok('PRERELEASELOOSE') -src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' +/** Detect the popular CommonJS extension `module.exports`. */ +var moduleExports = freeModule && freeModule.exports === freeExports; -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. +/** Detect free variable `process` from Node.js. */ +var freeProcess = moduleExports && freeGlobal.process; -tok('BUILDIDENTIFIER') -src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' +/** Used to access faster Node.js helpers. */ +var nodeUtil = (function() { + try { + return freeProcess && freeProcess.binding('util'); + } catch (e) {} +}()); -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. +/* Node.js helper references. */ +var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; -tok('BUILD') -src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + - '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))' +/** + * A specialized version of `_.forEach` for arrays without support for + * iteratee shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns `array`. + */ +function arrayEach(array, iteratee) { + var index = -1, + length = array ? array.length : 0; -// ## Full Version String -// A main version, followed optionally by a pre-release version and -// build metadata. + while (++index < length) { + if (iteratee(array[index], index, array) === false) { + break; + } + } + return array; +} -// Note that the only major, minor, patch, and pre-release sections of -// the version string are capturing groups. The build metadata is not a -// capturing group, because it should not ever be used in version -// comparison. +/** + * A specialized version of `_.some` for arrays without support for iteratee + * shorthands. + * + * @private + * @param {Array} [array] The array to iterate over. + * @param {Function} predicate The function invoked per iteration. + * @returns {boolean} Returns `true` if any element passes the predicate check, + * else `false`. + */ +function arraySome(array, predicate) { + var index = -1, + length = array ? array.length : 0; -tok('FULL') -tok('FULLPLAIN') -src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + - src[t.PRERELEASE] + '?' + - src[t.BUILD] + '?' + while (++index < length) { + if (predicate(array[index], index, array)) { + return true; + } + } + return false; +} -src[t.FULL] = '^' + src[t.FULLPLAIN] + '$' +/** + * The base implementation of `_.property` without support for deep paths. + * + * @private + * @param {string} key The key of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function baseProperty(key) { + return function(object) { + return object == null ? undefined : object[key]; + }; +} -// like full, but allows v1.2.3 and =1.2.3, which people do sometimes. -// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty -// common in the npm registry. -tok('LOOSEPLAIN') -src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + - src[t.PRERELEASELOOSE] + '?' + - src[t.BUILD] + '?' +/** + * The base implementation of `_.times` without support for iteratee shorthands + * or max array length checks. + * + * @private + * @param {number} n The number of times to invoke `iteratee`. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Array} Returns the array of results. + */ +function baseTimes(n, iteratee) { + var index = -1, + result = Array(n); -tok('LOOSE') -src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' + while (++index < n) { + result[index] = iteratee(index); + } + return result; +} -tok('GTLT') -src[t.GTLT] = '((?:<|>)?=?)' +/** + * The base implementation of `_.unary` without support for storing metadata. + * + * @private + * @param {Function} func The function to cap arguments for. + * @returns {Function} Returns the new capped function. + */ +function baseUnary(func) { + return function(value) { + return func(value); + }; +} -// Something like "2.*" or "1.2.x". -// Note that "x.x" is a valid xRange identifer, meaning "any version" -// Only the first item is strictly required. -tok('XRANGEIDENTIFIERLOOSE') -src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' -tok('XRANGEIDENTIFIER') -src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' +/** + * Gets the value at `key` of `object`. + * + * @private + * @param {Object} [object] The object to query. + * @param {string} key The key of the property to get. + * @returns {*} Returns the property value. + */ +function getValue(object, key) { + return object == null ? undefined : object[key]; +} -tok('XRANGEPLAIN') -src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:' + src[t.PRERELEASE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' +/** + * Checks if `value` is a host object in IE < 9. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + */ +function isHostObject(value) { + // Many host objects are `Object` objects that can coerce to strings + // despite having improperly defined `toString` methods. + var result = false; + if (value != null && typeof value.toString != 'function') { + try { + result = !!(value + ''); + } catch (e) {} + } + return result; +} -tok('XRANGEPLAINLOOSE') -src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:' + src[t.PRERELEASELOOSE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' +/** + * Converts `map` to its key-value pairs. + * + * @private + * @param {Object} map The map to convert. + * @returns {Array} Returns the key-value pairs. + */ +function mapToArray(map) { + var index = -1, + result = Array(map.size); -tok('XRANGE') -src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' -tok('XRANGELOOSE') -src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' + map.forEach(function(value, key) { + result[++index] = [key, value]; + }); + return result; +} -// Coercion. -// Extract anything that could conceivably be a part of a valid semver -tok('COERCE') -src[t.COERCE] = '(^|[^\\d])' + - '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + - '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + - '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + - '(?:$|[^\\d])' -tok('COERCERTL') -re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g') +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} -// Tilde ranges. -// Meaning is "reasonably at or greater than" -tok('LONETILDE') -src[t.LONETILDE] = '(?:~>?)' +/** + * Converts `set` to an array of its values. + * + * @private + * @param {Object} set The set to convert. + * @returns {Array} Returns the values. + */ +function setToArray(set) { + var index = -1, + result = Array(set.size); -tok('TILDETRIM') -src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' -re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') -var tildeTrimReplace = '$1~' + set.forEach(function(value) { + result[++index] = value; + }); + return result; +} -tok('TILDE') -src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' -tok('TILDELOOSE') -src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' +/** Used for built-in method references. */ +var arrayProto = Array.prototype, + funcProto = Function.prototype, + objectProto = Object.prototype; -// Caret ranges. -// Meaning is "at least and backwards compatible with" -tok('LONECARET') -src[t.LONECARET] = '(?:\\^)' +/** Used to detect overreaching core-js shims. */ +var coreJsData = root['__core-js_shared__']; -tok('CARETTRIM') -src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' -re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') -var caretTrimReplace = '$1^' +/** Used to detect methods masquerading as native. */ +var maskSrcKey = (function() { + var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); + return uid ? ('Symbol(src)_1.' + uid) : ''; +}()); -tok('CARET') -src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' -tok('CARETLOOSE') -src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; -// A simple gt/lt/eq thing, or just "" to indicate "any version" -tok('COMPARATORLOOSE') -src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$' -tok('COMPARATOR') -src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$' +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; -// An expression to strip any whitespace between the gtlt and the thing -// it modifies, so that `> 1.2.3` ==> `>1.2.3` -tok('COMPARATORTRIM') -src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] + - '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')' +/** + * Used to resolve the + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) + * of values. + */ +var objectToString = objectProto.toString; -// this one has to use the /g flag -re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') -var comparatorTrimReplace = '$1$2$3' +/** Used to detect if a method is native. */ +var reIsNative = RegExp('^' + + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') + .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' +); -// Something like `1.2.3 - 1.2.4` -// Note that these all use the loose form, because they'll be -// checked against either the strict or loose comparator form -// later. -tok('HYPHENRANGE') -src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAIN] + ')' + - '\\s*$' +/** Built-in value references. */ +var Symbol = root.Symbol, + Uint8Array = root.Uint8Array, + getPrototype = overArg(Object.getPrototypeOf, Object), + objectCreate = Object.create, + propertyIsEnumerable = objectProto.propertyIsEnumerable, + splice = arrayProto.splice; -tok('HYPHENRANGELOOSE') -src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s*$' +/* Built-in method references for those with the same name as other `lodash` methods. */ +var nativeKeys = overArg(Object.keys, Object); -// Star ranges basically just allow anything at all. -tok('STAR') -src[t.STAR] = '(<|>)?=?\\s*\\*' +/* Built-in method references that are verified to be native. */ +var DataView = getNative(root, 'DataView'), + Map = getNative(root, 'Map'), + Promise = getNative(root, 'Promise'), + Set = getNative(root, 'Set'), + WeakMap = getNative(root, 'WeakMap'), + nativeCreate = getNative(Object, 'create'); -// Compile to actual regexp objects. -// All are flag-free, unless they were created above with a flag. -for (var i = 0; i < R; i++) { - debug(i, src[i]) - if (!re[i]) { - re[i] = new RegExp(src[i]) - } -} +/** Used to detect maps, sets, and weakmaps. */ +var dataViewCtorString = toSource(DataView), + mapCtorString = toSource(Map), + promiseCtorString = toSource(Promise), + setCtorString = toSource(Set), + weakMapCtorString = toSource(WeakMap); -exports.parse = parse -function parse (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } +/** Used to convert symbols to primitives and strings. */ +var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, + symbolToString = symbolProto ? symbolProto.toString : undefined; - if (version instanceof SemVer) { - return version - } +/** + * Creates a hash object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Hash(entries) { + var index = -1, + length = entries ? entries.length : 0; - if (typeof version !== 'string') { - return null + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); } +} - if (version.length > MAX_LENGTH) { - return null - } +/** + * Removes all key-value entries from the hash. + * + * @private + * @name clear + * @memberOf Hash + */ +function hashClear() { + this.__data__ = nativeCreate ? nativeCreate(null) : {}; +} - var r = options.loose ? re[t.LOOSE] : re[t.FULL] - if (!r.test(version)) { - return null - } +/** + * Removes `key` and its value from the hash. + * + * @private + * @name delete + * @memberOf Hash + * @param {Object} hash The hash to modify. + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function hashDelete(key) { + return this.has(key) && delete this.__data__[key]; +} - try { - return new SemVer(version, options) - } catch (er) { - return null +/** + * Gets the hash value for `key`. + * + * @private + * @name get + * @memberOf Hash + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function hashGet(key) { + var data = this.__data__; + if (nativeCreate) { + var result = data[key]; + return result === HASH_UNDEFINED ? undefined : result; } + return hasOwnProperty.call(data, key) ? data[key] : undefined; } -exports.valid = valid -function valid (version, options) { - var v = parse(version, options) - return v ? v.version : null +/** + * Checks if a hash value for `key` exists. + * + * @private + * @name has + * @memberOf Hash + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function hashHas(key) { + var data = this.__data__; + return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); } -exports.clean = clean -function clean (version, options) { - var s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null +/** + * Sets the hash `key` to `value`. + * + * @private + * @name set + * @memberOf Hash + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the hash instance. + */ +function hashSet(key, value) { + var data = this.__data__; + data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; + return this; } -exports.SemVer = SemVer - -function SemVer (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - if (version instanceof SemVer) { - if (version.loose === options.loose) { - return version - } else { - version = version.version - } - } else if (typeof version !== 'string') { - throw new TypeError('Invalid Version: ' + version) - } +// Add methods to `Hash`. +Hash.prototype.clear = hashClear; +Hash.prototype['delete'] = hashDelete; +Hash.prototype.get = hashGet; +Hash.prototype.has = hashHas; +Hash.prototype.set = hashSet; - if (version.length > MAX_LENGTH) { - throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') - } +/** + * Creates an list cache object. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function ListCache(entries) { + var index = -1, + length = entries ? entries.length : 0; - if (!(this instanceof SemVer)) { - return new SemVer(version, options) + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); } +} - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose +/** + * Removes all key-value entries from the list cache. + * + * @private + * @name clear + * @memberOf ListCache + */ +function listCacheClear() { + this.__data__ = []; +} - var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) +/** + * Removes `key` and its value from the list cache. + * + * @private + * @name delete + * @memberOf ListCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function listCacheDelete(key) { + var data = this.__data__, + index = assocIndexOf(data, key); - if (!m) { - throw new TypeError('Invalid Version: ' + version) + if (index < 0) { + return false; } + var lastIndex = data.length - 1; + if (index == lastIndex) { + data.pop(); + } else { + splice.call(data, index, 1); + } + return true; +} - this.raw = version - - // these are actually numbers - this.major = +m[1] - this.minor = +m[2] - this.patch = +m[3] +/** + * Gets the list cache value for `key`. + * + * @private + * @name get + * @memberOf ListCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function listCacheGet(key) { + var data = this.__data__, + index = assocIndexOf(data, key); - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError('Invalid major version') - } + return index < 0 ? undefined : data[index][1]; +} - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError('Invalid minor version') - } +/** + * Checks if a list cache value for `key` exists. + * + * @private + * @name has + * @memberOf ListCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function listCacheHas(key) { + return assocIndexOf(this.__data__, key) > -1; +} - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError('Invalid patch version') - } +/** + * Sets the list cache `key` to `value`. + * + * @private + * @name set + * @memberOf ListCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the list cache instance. + */ +function listCacheSet(key, value) { + var data = this.__data__, + index = assocIndexOf(data, key); - // numberify any prerelease numeric ids - if (!m[4]) { - this.prerelease = [] + if (index < 0) { + data.push([key, value]); } else { - this.prerelease = m[4].split('.').map(function (id) { - if (/^[0-9]+$/.test(id)) { - var num = +id - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num - } - } - return id - }) + data[index][1] = value; } - - this.build = m[5] ? m[5].split('.') : [] - this.format() + return this; } -SemVer.prototype.format = function () { - this.version = this.major + '.' + this.minor + '.' + this.patch - if (this.prerelease.length) { - this.version += '-' + this.prerelease.join('.') +// Add methods to `ListCache`. +ListCache.prototype.clear = listCacheClear; +ListCache.prototype['delete'] = listCacheDelete; +ListCache.prototype.get = listCacheGet; +ListCache.prototype.has = listCacheHas; +ListCache.prototype.set = listCacheSet; + +/** + * Creates a map cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function MapCache(entries) { + var index = -1, + length = entries ? entries.length : 0; + + this.clear(); + while (++index < length) { + var entry = entries[index]; + this.set(entry[0], entry[1]); } - return this.version } -SemVer.prototype.toString = function () { - return this.version +/** + * Removes all key-value entries from the map. + * + * @private + * @name clear + * @memberOf MapCache + */ +function mapCacheClear() { + this.__data__ = { + 'hash': new Hash, + 'map': new (Map || ListCache), + 'string': new Hash + }; } -SemVer.prototype.compare = function (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +/** + * Removes `key` and its value from the map. + * + * @private + * @name delete + * @memberOf MapCache + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function mapCacheDelete(key) { + return getMapData(this, key)['delete'](key); +} - return this.compareMain(other) || this.comparePre(other) +/** + * Gets the map value for `key`. + * + * @private + * @name get + * @memberOf MapCache + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function mapCacheGet(key) { + return getMapData(this, key).get(key); } -SemVer.prototype.compareMain = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +/** + * Checks if a map value for `key` exists. + * + * @private + * @name has + * @memberOf MapCache + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function mapCacheHas(key) { + return getMapData(this, key).has(key); +} - return compareIdentifiers(this.major, other.major) || - compareIdentifiers(this.minor, other.minor) || - compareIdentifiers(this.patch, other.patch) +/** + * Sets the map `key` to `value`. + * + * @private + * @name set + * @memberOf MapCache + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the map cache instance. + */ +function mapCacheSet(key, value) { + getMapData(this, key).set(key, value); + return this; } -SemVer.prototype.comparePre = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +// Add methods to `MapCache`. +MapCache.prototype.clear = mapCacheClear; +MapCache.prototype['delete'] = mapCacheDelete; +MapCache.prototype.get = mapCacheGet; +MapCache.prototype.has = mapCacheHas; +MapCache.prototype.set = mapCacheSet; - // NOT having a prerelease is > having one - if (this.prerelease.length && !other.prerelease.length) { - return -1 - } else if (!this.prerelease.length && other.prerelease.length) { - return 1 - } else if (!this.prerelease.length && !other.prerelease.length) { - return 0 +/** + * + * Creates an array cache object to store unique values. + * + * @private + * @constructor + * @param {Array} [values] The values to cache. + */ +function SetCache(values) { + var index = -1, + length = values ? values.length : 0; + + this.__data__ = new MapCache; + while (++index < length) { + this.add(values[index]); } +} - var i = 0 - do { - var a = this.prerelease[i] - var b = other.prerelease[i] - debug('prerelease compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) +/** + * Adds `value` to the array cache. + * + * @private + * @name add + * @memberOf SetCache + * @alias push + * @param {*} value The value to cache. + * @returns {Object} Returns the cache instance. + */ +function setCacheAdd(value) { + this.__data__.set(value, HASH_UNDEFINED); + return this; } -SemVer.prototype.compareBuild = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +/** + * Checks if `value` is in the array cache. + * + * @private + * @name has + * @memberOf SetCache + * @param {*} value The value to search for. + * @returns {number} Returns `true` if `value` is found, else `false`. + */ +function setCacheHas(value) { + return this.__data__.has(value); +} - var i = 0 - do { - var a = this.build[i] - var b = other.build[i] - debug('prerelease compare', i, a, b) - if (a === undefined && b === undefined) { - return 0 - } else if (b === undefined) { - return 1 - } else if (a === undefined) { - return -1 - } else if (a === b) { - continue - } else { - return compareIdentifiers(a, b) - } - } while (++i) +// Add methods to `SetCache`. +SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; +SetCache.prototype.has = setCacheHas; + +/** + * Creates a stack cache object to store key-value pairs. + * + * @private + * @constructor + * @param {Array} [entries] The key-value pairs to cache. + */ +function Stack(entries) { + this.__data__ = new ListCache(entries); } -// preminor will bump the version up to the next minor release, and immediately -// down to pre-release. premajor and prepatch work the same way. -SemVer.prototype.inc = function (release, identifier) { - switch (release) { - case 'premajor': - this.prerelease.length = 0 - this.patch = 0 - this.minor = 0 - this.major++ - this.inc('pre', identifier) - break - case 'preminor': - this.prerelease.length = 0 - this.patch = 0 - this.minor++ - this.inc('pre', identifier) - break - case 'prepatch': - // If this is already a prerelease, it will bump to the next version - // drop any prereleases that might already exist, since they are not - // relevant at this point. - this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) - break - // If the input is a non-prerelease version, this acts the same as - // prepatch. - case 'prerelease': - if (this.prerelease.length === 0) { - this.inc('patch', identifier) - } - this.inc('pre', identifier) - break - - case 'major': - // If this is a pre-major version, bump up to the same major version. - // Otherwise increment major. - // 1.0.0-5 bumps to 1.0.0 - // 1.1.0 bumps to 2.0.0 - if (this.minor !== 0 || - this.patch !== 0 || - this.prerelease.length === 0) { - this.major++ - } - this.minor = 0 - this.patch = 0 - this.prerelease = [] - break - case 'minor': - // If this is a pre-minor version, bump up to the same minor version. - // Otherwise increment minor. - // 1.2.0-5 bumps to 1.2.0 - // 1.2.1 bumps to 1.3.0 - if (this.patch !== 0 || this.prerelease.length === 0) { - this.minor++ - } - this.patch = 0 - this.prerelease = [] - break - case 'patch': - // If this is not a pre-release version, it will increment the patch. - // If it is a pre-release it will bump up to the same patch version. - // 1.2.0-5 patches to 1.2.0 - // 1.2.0 patches to 1.2.1 - if (this.prerelease.length === 0) { - this.patch++ - } - this.prerelease = [] - break - // This probably shouldn't be used publicly. - // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction. - case 'pre': - if (this.prerelease.length === 0) { - this.prerelease = [0] - } else { - var i = this.prerelease.length - while (--i >= 0) { - if (typeof this.prerelease[i] === 'number') { - this.prerelease[i]++ - i = -2 - } - } - if (i === -1) { - // didn't increment anything - this.prerelease.push(0) - } - } - if (identifier) { - // 1.2.0-beta.1 bumps to 1.2.0-beta.2, - // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 - if (this.prerelease[0] === identifier) { - if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] - } - } else { - this.prerelease = [identifier, 0] - } - } - break +/** + * Removes all key-value entries from the stack. + * + * @private + * @name clear + * @memberOf Stack + */ +function stackClear() { + this.__data__ = new ListCache; +} - default: - throw new Error('invalid increment argument: ' + release) - } - this.format() - this.raw = this.version - return this +/** + * Removes `key` and its value from the stack. + * + * @private + * @name delete + * @memberOf Stack + * @param {string} key The key of the value to remove. + * @returns {boolean} Returns `true` if the entry was removed, else `false`. + */ +function stackDelete(key) { + return this.__data__['delete'](key); } -exports.inc = inc -function inc (version, release, loose, identifier) { - if (typeof (loose) === 'string') { - identifier = loose - loose = undefined - } +/** + * Gets the stack value for `key`. + * + * @private + * @name get + * @memberOf Stack + * @param {string} key The key of the value to get. + * @returns {*} Returns the entry value. + */ +function stackGet(key) { + return this.__data__.get(key); +} - try { - return new SemVer(version, loose).inc(release, identifier).version - } catch (er) { - return null - } +/** + * Checks if a stack value for `key` exists. + * + * @private + * @name has + * @memberOf Stack + * @param {string} key The key of the entry to check. + * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + */ +function stackHas(key) { + return this.__data__.has(key); } -exports.diff = diff -function diff (version1, version2) { - if (eq(version1, version2)) { - return null - } else { - var v1 = parse(version1) - var v2 = parse(version2) - var prefix = '' - if (v1.prerelease.length || v2.prerelease.length) { - prefix = 'pre' - var defaultResult = 'prerelease' - } - for (var key in v1) { - if (key === 'major' || key === 'minor' || key === 'patch') { - if (v1[key] !== v2[key]) { - return prefix + key - } - } +/** + * Sets the stack `key` to `value`. + * + * @private + * @name set + * @memberOf Stack + * @param {string} key The key of the value to set. + * @param {*} value The value to set. + * @returns {Object} Returns the stack cache instance. + */ +function stackSet(key, value) { + var cache = this.__data__; + if (cache instanceof ListCache) { + var pairs = cache.__data__; + if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { + pairs.push([key, value]); + return this; } - return defaultResult // may be undefined + cache = this.__data__ = new MapCache(pairs); } + cache.set(key, value); + return this; } -exports.compareIdentifiers = compareIdentifiers - -var numeric = /^[0-9]+$/ -function compareIdentifiers (a, b) { - var anum = numeric.test(a) - var bnum = numeric.test(b) +// Add methods to `Stack`. +Stack.prototype.clear = stackClear; +Stack.prototype['delete'] = stackDelete; +Stack.prototype.get = stackGet; +Stack.prototype.has = stackHas; +Stack.prototype.set = stackSet; - if (anum && bnum) { - a = +a - b = +b - } +/** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ +function arrayLikeKeys(value, inherited) { + // Safari 8.1 makes `arguments.callee` enumerable in strict mode. + // Safari 9 makes `arguments.length` enumerable in strict mode. + var result = (isArray(value) || isArguments(value)) + ? baseTimes(value.length, String) + : []; - return a === b ? 0 - : (anum && !bnum) ? -1 - : (bnum && !anum) ? 1 - : a < b ? -1 - : 1 -} + var length = result.length, + skipIndexes = !!length; -exports.rcompareIdentifiers = rcompareIdentifiers -function rcompareIdentifiers (a, b) { - return compareIdentifiers(b, a) + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && (key == 'length' || isIndex(key, length)))) { + result.push(key); + } + } + return result; } -exports.major = major -function major (a, loose) { - return new SemVer(a, loose).major +/** + * Gets the index at which the `key` is found in `array` of key-value pairs. + * + * @private + * @param {Array} array The array to inspect. + * @param {*} key The key to search for. + * @returns {number} Returns the index of the matched value, else `-1`. + */ +function assocIndexOf(array, key) { + var length = array.length; + while (length--) { + if (eq(array[length][0], key)) { + return length; + } + } + return -1; } -exports.minor = minor -function minor (a, loose) { - return new SemVer(a, loose).minor +/** + * The base implementation of `_.create` without support for assigning + * properties to the created object. + * + * @private + * @param {Object} prototype The object to inherit from. + * @returns {Object} Returns the new object. + */ +function baseCreate(proto) { + return isObject(proto) ? objectCreate(proto) : {}; } -exports.patch = patch -function patch (a, loose) { - return new SemVer(a, loose).patch -} +/** + * The base implementation of `baseForOwn` which iterates over `object` + * properties returned by `keysFunc` and invokes `iteratee` for each property. + * Iteratee functions may exit iteration early by explicitly returning `false`. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @param {Function} keysFunc The function to get the keys of `object`. + * @returns {Object} Returns `object`. + */ +var baseFor = createBaseFor(); -exports.compare = compare -function compare (a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)) +/** + * The base implementation of `_.forOwn` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {Object} Returns `object`. + */ +function baseForOwn(object, iteratee) { + return object && baseFor(object, iteratee, keys); } -exports.compareLoose = compareLoose -function compareLoose (a, b) { - return compare(a, b, true) -} +/** + * The base implementation of `_.get` without support for default values. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @returns {*} Returns the resolved value. + */ +function baseGet(object, path) { + path = isKey(path, object) ? [path] : castPath(path); -exports.compareBuild = compareBuild -function compareBuild (a, b, loose) { - var versionA = new SemVer(a, loose) - var versionB = new SemVer(b, loose) - return versionA.compare(versionB) || versionA.compareBuild(versionB) -} + var index = 0, + length = path.length; -exports.rcompare = rcompare -function rcompare (a, b, loose) { - return compare(b, a, loose) + while (object != null && index < length) { + object = object[toKey(path[index++])]; + } + return (index && index == length) ? object : undefined; } -exports.sort = sort -function sort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(a, b, loose) - }) +/** + * The base implementation of `getTag`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +function baseGetTag(value) { + return objectToString.call(value); } -exports.rsort = rsort -function rsort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(b, a, loose) - }) +/** + * The base implementation of `_.hasIn` without support for deep paths. + * + * @private + * @param {Object} [object] The object to query. + * @param {Array|string} key The key to check. + * @returns {boolean} Returns `true` if `key` exists, else `false`. + */ +function baseHasIn(object, key) { + return object != null && key in Object(object); } -exports.gt = gt -function gt (a, b, loose) { - return compare(a, b, loose) > 0 +/** + * The base implementation of `_.isEqual` which supports partial comparisons + * and tracks traversed objects. + * + * @private + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @param {Function} [customizer] The function to customize comparisons. + * @param {boolean} [bitmask] The bitmask of comparison flags. + * The bitmask may be composed of the following flags: + * 1 - Unordered comparison + * 2 - Partial comparison + * @param {Object} [stack] Tracks traversed `value` and `other` objects. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + */ +function baseIsEqual(value, other, customizer, bitmask, stack) { + if (value === other) { + return true; + } + if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { + return value !== value && other !== other; + } + return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack); } -exports.lt = lt -function lt (a, b, loose) { - return compare(a, b, loose) < 0 -} +/** + * A specialized version of `baseIsEqual` for arrays and objects which performs + * deep comparisons and tracks traversed objects enabling objects with circular + * references to be compared. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} [customizer] The function to customize comparisons. + * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` + * for more details. + * @param {Object} [stack] Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) { + var objIsArr = isArray(object), + othIsArr = isArray(other), + objTag = arrayTag, + othTag = arrayTag; -exports.eq = eq -function eq (a, b, loose) { - return compare(a, b, loose) === 0 -} + if (!objIsArr) { + objTag = getTag(object); + objTag = objTag == argsTag ? objectTag : objTag; + } + if (!othIsArr) { + othTag = getTag(other); + othTag = othTag == argsTag ? objectTag : othTag; + } + var objIsObj = objTag == objectTag && !isHostObject(object), + othIsObj = othTag == objectTag && !isHostObject(other), + isSameTag = objTag == othTag; -exports.neq = neq -function neq (a, b, loose) { - return compare(a, b, loose) !== 0 -} + if (isSameTag && !objIsObj) { + stack || (stack = new Stack); + return (objIsArr || isTypedArray(object)) + ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) + : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack); + } + if (!(bitmask & PARTIAL_COMPARE_FLAG)) { + var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), + othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); -exports.gte = gte -function gte (a, b, loose) { - return compare(a, b, loose) >= 0 -} + if (objIsWrapped || othIsWrapped) { + var objUnwrapped = objIsWrapped ? object.value() : object, + othUnwrapped = othIsWrapped ? other.value() : other; -exports.lte = lte -function lte (a, b, loose) { - return compare(a, b, loose) <= 0 + stack || (stack = new Stack); + return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack); + } + } + if (!isSameTag) { + return false; + } + stack || (stack = new Stack); + return equalObjects(object, other, equalFunc, customizer, bitmask, stack); } -exports.cmp = cmp -function cmp (a, op, b, loose) { - switch (op) { - case '===': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a === b - - case '!==': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a !== b - - case '': - case '=': - case '==': - return eq(a, b, loose) - - case '!=': - return neq(a, b, loose) - - case '>': - return gt(a, b, loose) - - case '>=': - return gte(a, b, loose) - - case '<': - return lt(a, b, loose) - - case '<=': - return lte(a, b, loose) +/** + * The base implementation of `_.isMatch` without support for iteratee shorthands. + * + * @private + * @param {Object} object The object to inspect. + * @param {Object} source The object of property values to match. + * @param {Array} matchData The property names, values, and compare flags to match. + * @param {Function} [customizer] The function to customize comparisons. + * @returns {boolean} Returns `true` if `object` is a match, else `false`. + */ +function baseIsMatch(object, source, matchData, customizer) { + var index = matchData.length, + length = index, + noCustomizer = !customizer; - default: - throw new TypeError('Invalid operator: ' + op) + if (object == null) { + return !length; } -} - -exports.Comparator = Comparator -function Comparator (comp, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false + object = Object(object); + while (index--) { + var data = matchData[index]; + if ((noCustomizer && data[2]) + ? data[1] !== object[data[0]] + : !(data[0] in object) + ) { + return false; } } + while (++index < length) { + data = matchData[index]; + var key = data[0], + objValue = object[key], + srcValue = data[1]; - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp + if (noCustomizer && data[2]) { + if (objValue === undefined && !(key in object)) { + return false; + } } else { - comp = comp.value + var stack = new Stack; + if (customizer) { + var result = customizer(objValue, srcValue, key, object, source, stack); + } + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) + : result + )) { + return false; + } } } + return true; +} - if (!(this instanceof Comparator)) { - return new Comparator(comp, options) - } - - debug('comparator', comp, options) - this.options = options - this.loose = !!options.loose - this.parse(comp) - - if (this.semver === ANY) { - this.value = '' - } else { - this.value = this.operator + this.semver.version +/** + * The base implementation of `_.isNative` without bad shim checks. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a native function, + * else `false`. + */ +function baseIsNative(value) { + if (!isObject(value) || isMasked(value)) { + return false; } - - debug('comp', this) + var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; + return pattern.test(toSource(value)); } -var ANY = {} -Comparator.prototype.parse = function (comp) { - var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var m = comp.match(r) +/** + * The base implementation of `_.isTypedArray` without Node.js optimizations. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + */ +function baseIsTypedArray(value) { + return isObjectLike(value) && + isLength(value.length) && !!typedArrayTags[objectToString.call(value)]; +} - if (!m) { - throw new TypeError('Invalid comparator: ' + comp) +/** + * The base implementation of `_.iteratee`. + * + * @private + * @param {*} [value=_.identity] The value to convert to an iteratee. + * @returns {Function} Returns the iteratee. + */ +function baseIteratee(value) { + // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. + // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. + if (typeof value == 'function') { + return value; } - - this.operator = m[1] !== undefined ? m[1] : '' - if (this.operator === '=') { - this.operator = '' + if (value == null) { + return identity; } - - // if it literally is just '>' or '' then allow anything. - if (!m[2]) { - this.semver = ANY - } else { - this.semver = new SemVer(m[2], this.options.loose) + if (typeof value == 'object') { + return isArray(value) + ? baseMatchesProperty(value[0], value[1]) + : baseMatches(value); } + return property(value); } -Comparator.prototype.toString = function () { - return this.value -} - -Comparator.prototype.test = function (version) { - debug('Comparator.test', version, this.options.loose) - - if (this.semver === ANY || version === ANY) { - return true +/** + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ +function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); } } - - return cmp(version, this.operator, this.semver, this.options) + return result; } -Comparator.prototype.intersects = function (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') +/** + * The base implementation of `_.matches` which doesn't clone `source`. + * + * @private + * @param {Object} source The object of property values to match. + * @returns {Function} Returns the new spec function. + */ +function baseMatches(source) { + var matchData = getMatchData(source); + if (matchData.length == 1 && matchData[0][2]) { + return matchesStrictComparable(matchData[0][0], matchData[0][1]); } + return function(object) { + return object === source || baseIsMatch(object, source, matchData); + }; +} - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } +/** + * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. + * + * @private + * @param {string} path The path of the property to get. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. + */ +function baseMatchesProperty(path, srcValue) { + if (isKey(path) && isStrictComparable(srcValue)) { + return matchesStrictComparable(toKey(path), srcValue); } + return function(object) { + var objValue = get(object, path); + return (objValue === undefined && objValue === srcValue) + ? hasIn(object, path) + : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG); + }; +} - var rangeTmp +/** + * A specialized version of `baseProperty` which supports deep paths. + * + * @private + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + */ +function basePropertyDeep(path) { + return function(object) { + return baseGet(object, path); + }; +} - if (this.operator === '') { - if (this.value === '') { - return true - } - rangeTmp = new Range(comp.value, options) - return satisfies(this.value, rangeTmp, options) - } else if (comp.operator === '') { - if (comp.value === '') { - return true - } - rangeTmp = new Range(this.value, options) - return satisfies(comp.semver, rangeTmp, options) +/** + * The base implementation of `_.toString` which doesn't convert nullish + * values to empty strings. + * + * @private + * @param {*} value The value to process. + * @returns {string} Returns the string. + */ +function baseToString(value) { + // Exit early for strings to avoid a performance hit in some environments. + if (typeof value == 'string') { + return value; } + if (isSymbol(value)) { + return symbolToString ? symbolToString.call(value) : ''; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; +} - var sameDirectionIncreasing = - (this.operator === '>=' || this.operator === '>') && - (comp.operator === '>=' || comp.operator === '>') - var sameDirectionDecreasing = - (this.operator === '<=' || this.operator === '<') && - (comp.operator === '<=' || comp.operator === '<') - var sameSemVer = this.semver.version === comp.semver.version - var differentDirectionsInclusive = - (this.operator === '>=' || this.operator === '<=') && - (comp.operator === '>=' || comp.operator === '<=') - var oppositeDirectionsLessThan = - cmp(this.semver, '<', comp.semver, options) && - ((this.operator === '>=' || this.operator === '>') && - (comp.operator === '<=' || comp.operator === '<')) - var oppositeDirectionsGreaterThan = - cmp(this.semver, '>', comp.semver, options) && - ((this.operator === '<=' || this.operator === '<') && - (comp.operator === '>=' || comp.operator === '>')) - - return sameDirectionIncreasing || sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || oppositeDirectionsGreaterThan +/** + * Casts `value` to a path array if it's not one. + * + * @private + * @param {*} value The value to inspect. + * @returns {Array} Returns the cast property path array. + */ +function castPath(value) { + return isArray(value) ? value : stringToPath(value); } -exports.Range = Range -function Range (range, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } +/** + * Creates a base function for methods like `_.forIn` and `_.forOwn`. + * + * @private + * @param {boolean} [fromRight] Specify iterating from right to left. + * @returns {Function} Returns the new base function. + */ +function createBaseFor(fromRight) { + return function(object, iteratee, keysFunc) { + var index = -1, + iterable = Object(object), + props = keysFunc(object), + length = props.length; - if (range instanceof Range) { - if (range.loose === !!options.loose && - range.includePrerelease === !!options.includePrerelease) { - return range - } else { - return new Range(range.raw, options) + while (length--) { + var key = props[fromRight ? length : ++index]; + if (iteratee(iterable[key], key, iterable) === false) { + break; + } } - } + return object; + }; +} - if (range instanceof Comparator) { - return new Range(range.value, options) - } +/** + * A specialized version of `baseIsEqualDeep` for arrays with support for + * partial deep comparisons. + * + * @private + * @param {Array} array The array to compare. + * @param {Array} other The other array to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} customizer The function to customize comparisons. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. + * @param {Object} stack Tracks traversed `array` and `other` objects. + * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. + */ +function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { + var isPartial = bitmask & PARTIAL_COMPARE_FLAG, + arrLength = array.length, + othLength = other.length; - if (!(this instanceof Range)) { - return new Range(range, options) + if (arrLength != othLength && !(isPartial && othLength > arrLength)) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(array); + if (stacked && stack.get(other)) { + return stacked == other; } + var index = -1, + result = true, + seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined; - this.options = options - this.loose = !!options.loose - this.includePrerelease = !!options.includePrerelease + stack.set(array, other); + stack.set(other, array); - // First, split based on boolean or || - this.raw = range - this.set = range.split(/\s*\|\|\s*/).map(function (range) { - return this.parseRange(range.trim()) - }, this).filter(function (c) { - // throw out any that are not relevant for whatever reason - return c.length - }) + // Ignore non-index properties. + while (++index < arrLength) { + var arrValue = array[index], + othValue = other[index]; - if (!this.set.length) { - throw new TypeError('Invalid SemVer Range: ' + range) + if (customizer) { + var compared = isPartial + ? customizer(othValue, arrValue, index, other, array, stack) + : customizer(arrValue, othValue, index, array, other, stack); + } + if (compared !== undefined) { + if (compared) { + continue; + } + result = false; + break; + } + // Recursively compare arrays (susceptible to call stack limits). + if (seen) { + if (!arraySome(other, function(othValue, othIndex) { + if (!seen.has(othIndex) && + (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { + return seen.add(othIndex); + } + })) { + result = false; + break; + } + } else if (!( + arrValue === othValue || + equalFunc(arrValue, othValue, customizer, bitmask, stack) + )) { + result = false; + break; + } } - - this.format() + stack['delete'](array); + stack['delete'](other); + return result; } -Range.prototype.format = function () { - this.range = this.set.map(function (comps) { - return comps.join(' ').trim() - }).join('||').trim() - return this.range -} +/** + * A specialized version of `baseIsEqualDeep` for comparing objects of + * the same `toStringTag`. + * + * **Note:** This function only supports comparing values with tags of + * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {string} tag The `toStringTag` of the objects to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} customizer The function to customize comparisons. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) { + switch (tag) { + case dataViewTag: + if ((object.byteLength != other.byteLength) || + (object.byteOffset != other.byteOffset)) { + return false; + } + object = object.buffer; + other = other.buffer; -Range.prototype.toString = function () { - return this.range -} + case arrayBufferTag: + if ((object.byteLength != other.byteLength) || + !equalFunc(new Uint8Array(object), new Uint8Array(other))) { + return false; + } + return true; -Range.prototype.parseRange = function (range) { - var loose = this.options.loose - range = range.trim() - // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` - var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] - range = range.replace(hr, hyphenReplace) - debug('hyphen replace', range) - // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` - range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) - debug('comparator trim', range, re[t.COMPARATORTRIM]) + case boolTag: + case dateTag: + case numberTag: + // Coerce booleans to `1` or `0` and dates to milliseconds. + // Invalid dates are coerced to `NaN`. + return eq(+object, +other); - // `~ 1.2.3` => `~1.2.3` - range = range.replace(re[t.TILDETRIM], tildeTrimReplace) + case errorTag: + return object.name == other.name && object.message == other.message; - // `^ 1.2.3` => `^1.2.3` - range = range.replace(re[t.CARETTRIM], caretTrimReplace) + case regexpTag: + case stringTag: + // Coerce regexes to strings and treat strings, primitives and objects, + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring + // for more details. + return object == (other + ''); - // normalize spaces - range = range.split(/\s+/).join(' ') + case mapTag: + var convert = mapToArray; - // At this point, the range is completely trimmed and - // ready to be split into comparators. + case setTag: + var isPartial = bitmask & PARTIAL_COMPARE_FLAG; + convert || (convert = setToArray); - var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var set = range.split(' ').map(function (comp) { - return parseComparator(comp, this.options) - }, this).join(' ').split(/\s+/) - if (this.options.loose) { - // in loose mode, throw out any that are not valid comparators - set = set.filter(function (comp) { - return !!comp.match(compRe) - }) - } - set = set.map(function (comp) { - return new Comparator(comp, this.options) - }, this) + if (object.size != other.size && !isPartial) { + return false; + } + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked) { + return stacked == other; + } + bitmask |= UNORDERED_COMPARE_FLAG; - return set -} + // Recursively compare objects (susceptible to call stack limits). + stack.set(object, other); + var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack); + stack['delete'](object); + return result; -Range.prototype.intersects = function (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') + case symbolTag: + if (symbolValueOf) { + return symbolValueOf.call(object) == symbolValueOf.call(other); + } } + return false; +} - return this.set.some(function (thisComparators) { - return ( - isSatisfiable(thisComparators, options) && - range.set.some(function (rangeComparators) { - return ( - isSatisfiable(rangeComparators, options) && - thisComparators.every(function (thisComparator) { - return rangeComparators.every(function (rangeComparator) { - return thisComparator.intersects(rangeComparator, options) - }) - }) - ) - }) - ) - }) -} - -// take a set of comparators and determine whether there -// exists a version which can satisfy it -function isSatisfiable (comparators, options) { - var result = true - var remainingComparators = comparators.slice() - var testComparator = remainingComparators.pop() - - while (result && remainingComparators.length) { - result = remainingComparators.every(function (otherComparator) { - return testComparator.intersects(otherComparator, options) - }) +/** + * A specialized version of `baseIsEqualDeep` for objects with support for + * partial deep comparisons. + * + * @private + * @param {Object} object The object to compare. + * @param {Object} other The other object to compare. + * @param {Function} equalFunc The function to determine equivalents of values. + * @param {Function} customizer The function to customize comparisons. + * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` + * for more details. + * @param {Object} stack Tracks traversed `object` and `other` objects. + * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. + */ +function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { + var isPartial = bitmask & PARTIAL_COMPARE_FLAG, + objProps = keys(object), + objLength = objProps.length, + othProps = keys(other), + othLength = othProps.length; - testComparator = remainingComparators.pop() + if (objLength != othLength && !isPartial) { + return false; } - - return result -} - -// Mostly just for testing and legacy API reasons -exports.toComparators = toComparators -function toComparators (range, options) { - return new Range(range, options).set.map(function (comp) { - return comp.map(function (c) { - return c.value - }).join(' ').trim().split(' ') - }) -} - -// comprised of xranges, tildes, stars, and gtlt's at this point. -// already replaced the hyphen ranges -// turn into a set of JUST comparators. -function parseComparator (comp, options) { - debug('comp', comp, options) - comp = replaceCarets(comp, options) - debug('caret', comp) - comp = replaceTildes(comp, options) - debug('tildes', comp) - comp = replaceXRanges(comp, options) - debug('xrange', comp) - comp = replaceStars(comp, options) - debug('stars', comp) - return comp -} - -function isX (id) { - return !id || id.toLowerCase() === 'x' || id === '*' -} - -// ~, ~> --> * (any, kinda silly) -// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0 -// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0 -// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0 -// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0 -// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0 -function replaceTildes (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceTilde(comp, options) - }).join(' ') -} - -function replaceTilde (comp, options) { - var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] - return comp.replace(r, function (_, M, m, p, pr) { - debug('tilde', comp, _, M, m, p, pr) - var ret - - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - // ~1.2 == >=1.2.0 <1.3.0 - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else if (pr) { - debug('replaceTilde pr', pr) - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } else { - // ~1.2.3 == >=1.2.3 <1.3.0 - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } - - debug('tilde return', ret) - return ret - }) -} - -// ^ --> * (any, kinda silly) -// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0 -// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0 -// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0 -// ^1.2.3 --> >=1.2.3 <2.0.0 -// ^1.2.0 --> >=1.2.0 <2.0.0 -function replaceCarets (comp, options) { - return comp.trim().split(/\s+/).map(function (comp) { - return replaceCaret(comp, options) - }).join(' ') -} - -function replaceCaret (comp, options) { - debug('caret', comp, options) - var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] - return comp.replace(r, function (_, M, m, p, pr) { - debug('caret', comp, _, M, m, p, pr) - var ret - - if (isX(M)) { - ret = '' - } else if (isX(m)) { - ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0' - } else if (isX(p)) { - if (M === '0') { - ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0' - } else { - ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0' - } - } else if (pr) { - debug('replaceCaret pr', pr) - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + '-' + pr + - ' <' + (+M + 1) + '.0.0' - } - } else { - debug('no pr') - if (M === '0') { - if (m === '0') { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + m + '.' + (+p + 1) - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + M + '.' + (+m + 1) + '.0' - } - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + (+M + 1) + '.0.0' - } - } - - debug('caret return', ret) - return ret - }) -} - -function replaceXRanges (comp, options) { - debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map(function (comp) { - return replaceXRange(comp, options) - }).join(' ') -} - -function replaceXRange (comp, options) { - comp = comp.trim() - var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] - return comp.replace(r, function (ret, gtlt, M, m, p, pr) { - debug('xRange', comp, ret, gtlt, M, m, p, pr) - var xM = isX(M) - var xm = xM || isX(m) - var xp = xm || isX(p) - var anyX = xp - - if (gtlt === '=' && anyX) { - gtlt = '' - } - - // if we're including prereleases in the match, then we need - // to fix this to -0, the lowest possible prerelease value - pr = options.includePrerelease ? '-0' : '' - - if (xM) { - if (gtlt === '>' || gtlt === '<') { - // nothing is allowed - ret = '<0.0.0-0' - } else { - // nothing is forbidden - ret = '*' - } - } else if (gtlt && anyX) { - // we know patch is an x, because we have any x at all. - // replace X with 0 - if (xm) { - m = 0 - } - p = 0 - - if (gtlt === '>') { - // >1 => >=2.0.0 - // >1.2 => >=1.3.0 - // >1.2.3 => >= 1.2.4 - gtlt = '>=' - if (xm) { - M = +M + 1 - m = 0 - p = 0 - } else { - m = +m + 1 - p = 0 - } - } else if (gtlt === '<=') { - // <=0.7.x is actually <0.8.0, since any 0.7.x should - // pass. Similarly, <=7.x is actually <8.0.0, etc. - gtlt = '<' - if (xm) { - M = +M + 1 - } else { - m = +m + 1 - } - } - - ret = gtlt + M + '.' + m + '.' + p + pr - } else if (xm) { - ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr - } else if (xp) { - ret = '>=' + M + '.' + m + '.0' + pr + - ' <' + M + '.' + (+m + 1) + '.0' + pr + var index = objLength; + while (index--) { + var key = objProps[index]; + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { + return false; } - - debug('xRange return', ret) - - return ret - }) -} - -// Because * is AND-ed with everything else in the comparator, -// and '' means "any version", just remove the *s entirely. -function replaceStars (comp, options) { - debug('replaceStars', comp, options) - // Looseness is ignored here. star is always as loose as it gets! - return comp.trim().replace(re[t.STAR], '') -} - -// This function is passed to string.replace(re[t.HYPHENRANGE]) -// M, m, patch, prerelease, build -// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 -// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do -// 1.2 - 3.4 => >=1.2.0 <3.5.0 -function hyphenReplace ($0, - from, fM, fm, fp, fpr, fb, - to, tM, tm, tp, tpr, tb) { - if (isX(fM)) { - from = '' - } else if (isX(fm)) { - from = '>=' + fM + '.0.0' - } else if (isX(fp)) { - from = '>=' + fM + '.' + fm + '.0' - } else { - from = '>=' + from - } - - if (isX(tM)) { - to = '' - } else if (isX(tm)) { - to = '<' + (+tM + 1) + '.0.0' - } else if (isX(tp)) { - to = '<' + tM + '.' + (+tm + 1) + '.0' - } else if (tpr) { - to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr - } else { - to = '<=' + to } - - return (from + ' ' + to).trim() -} - -// if ANY of the sets match ALL of its comparators, then pass -Range.prototype.test = function (version) { - if (!version) { - return false + // Assume cyclic values are equal. + var stacked = stack.get(object); + if (stacked && stack.get(other)) { + return stacked == other; } + var result = true; + stack.set(object, other); + stack.set(other, object); - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } + var skipCtor = isPartial; + while (++index < objLength) { + key = objProps[index]; + var objValue = object[key], + othValue = other[key]; - for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true + if (customizer) { + var compared = isPartial + ? customizer(othValue, objValue, key, other, object, stack) + : customizer(objValue, othValue, key, object, other, stack); } - } - return false -} - -function testSet (set, version, options) { - for (var i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false + // Recursively compare objects (susceptible to call stack limits). + if (!(compared === undefined + ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack)) + : compared + )) { + result = false; + break; } + skipCtor || (skipCtor = key == 'constructor'); } + if (result && !skipCtor) { + var objCtor = object.constructor, + othCtor = other.constructor; - if (version.prerelease.length && !options.includePrerelease) { - // Find the set of versions that are allowed to have prereleases - // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 - // That should allow `1.2.3-pr.2` to pass. - // However, `1.2.4-alpha.notready` should NOT be allowed, - // even though it's within the range set by the comparators. - for (i = 0; i < set.length; i++) { - debug(set[i].semver) - if (set[i].semver === ANY) { - continue - } - - if (set[i].semver.prerelease.length > 0) { - var allowed = set[i].semver - if (allowed.major === version.major && - allowed.minor === version.minor && - allowed.patch === version.patch) { - return true - } - } + // Non `Object` object instances with different constructors are not equal. + if (objCtor != othCtor && + ('constructor' in object && 'constructor' in other) && + !(typeof objCtor == 'function' && objCtor instanceof objCtor && + typeof othCtor == 'function' && othCtor instanceof othCtor)) { + result = false; } - - // Version has a -pre, but it's not one of the ones we like. - return false - } - - return true -} - -exports.satisfies = satisfies -function satisfies (version, range, options) { - try { - range = new Range(range, options) - } catch (er) { - return false - } - return range.test(version) -} - -exports.maxSatisfying = maxSatisfying -function maxSatisfying (versions, range, options) { - var max = null - var maxSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null } - versions.forEach(function (v) { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!max || maxSV.compare(v) === -1) { - // compare(max, v, true) - max = v - maxSV = new SemVer(max, options) - } - } - }) - return max + stack['delete'](object); + stack['delete'](other); + return result; } -exports.minSatisfying = minSatisfying -function minSatisfying (versions, range, options) { - var min = null - var minSV = null - try { - var rangeObj = new Range(range, options) - } catch (er) { - return null - } - versions.forEach(function (v) { - if (rangeObj.test(v)) { - // satisfies(v, range, options) - if (!min || minSV.compare(v) === 1) { - // compare(min, v, true) - min = v - minSV = new SemVer(min, options) - } - } - }) - return min +/** + * Gets the data for `map`. + * + * @private + * @param {Object} map The map to query. + * @param {string} key The reference key. + * @returns {*} Returns the map data. + */ +function getMapData(map, key) { + var data = map.__data__; + return isKeyable(key) + ? data[typeof key == 'string' ? 'string' : 'hash'] + : data.map; } -exports.minVersion = minVersion -function minVersion (range, loose) { - range = new Range(range, loose) - - var minver = new SemVer('0.0.0') - if (range.test(minver)) { - return minver - } - - minver = new SemVer('0.0.0-0') - if (range.test(minver)) { - return minver - } - - minver = null - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] - - comparators.forEach(function (comparator) { - // Clone to avoid manipulating the comparator's semver object. - var compver = new SemVer(comparator.semver.version) - switch (comparator.operator) { - case '>': - if (compver.prerelease.length === 0) { - compver.patch++ - } else { - compver.prerelease.push(0) - } - compver.raw = compver.format() - /* fallthrough */ - case '': - case '>=': - if (!minver || gt(minver, compver)) { - minver = compver - } - break - case '<': - case '<=': - /* Ignore maximum versions */ - break - /* istanbul ignore next */ - default: - throw new Error('Unexpected operation: ' + comparator.operator) - } - }) - } - - if (minver && range.test(minver)) { - return minver - } +/** + * Gets the property names, values, and compare flags of `object`. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the match data of `object`. + */ +function getMatchData(object) { + var result = keys(object), + length = result.length; - return null -} + while (length--) { + var key = result[length], + value = object[key]; -exports.validRange = validRange -function validRange (range, options) { - try { - // Return '*' instead of '' so that truthiness works. - // This will throw if it's invalid anyway - return new Range(range, options).range || '*' - } catch (er) { - return null + result[length] = [key, value, isStrictComparable(value)]; } + return result; } -// Determine if version is less than all the versions possible in the range -exports.ltr = ltr -function ltr (version, range, options) { - return outside(version, range, '<', options) -} - -// Determine if version is greater than all the versions possible in the range. -exports.gtr = gtr -function gtr (version, range, options) { - return outside(version, range, '>', options) +/** + * Gets the native function at `key` of `object`. + * + * @private + * @param {Object} object The object to query. + * @param {string} key The key of the method to get. + * @returns {*} Returns the function if it's native, else `undefined`. + */ +function getNative(object, key) { + var value = getValue(object, key); + return baseIsNative(value) ? value : undefined; } -exports.outside = outside -function outside (version, range, hilo, options) { - version = new SemVer(version, options) - range = new Range(range, options) - - var gtfn, ltefn, ltfn, comp, ecomp - switch (hilo) { - case '>': - gtfn = gt - ltefn = lte - ltfn = lt - comp = '>' - ecomp = '>=' - break - case '<': - gtfn = lt - ltefn = gte - ltfn = gt - comp = '<' - ecomp = '<=' - break - default: - throw new TypeError('Must provide a hilo val of "<" or ">"') - } - - // If it satisifes the range it is not outside - if (satisfies(version, range, options)) { - return false - } - - // From now on, variable terms are as if we're in "gtr" mode. - // but note that everything is flipped for the "ltr" function. - - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] +/** + * Gets the `toStringTag` of `value`. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ +var getTag = baseGetTag; - var high = null - var low = null +// Fallback for data views, maps, sets, and weak maps in IE 11, +// for data views in Edge < 14, and promises in Node.js. +if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || + (Map && getTag(new Map) != mapTag) || + (Promise && getTag(Promise.resolve()) != promiseTag) || + (Set && getTag(new Set) != setTag) || + (WeakMap && getTag(new WeakMap) != weakMapTag)) { + getTag = function(value) { + var result = objectToString.call(value), + Ctor = result == objectTag ? value.constructor : undefined, + ctorString = Ctor ? toSource(Ctor) : undefined; - comparators.forEach(function (comparator) { - if (comparator.semver === ANY) { - comparator = new Comparator('>=0.0.0') - } - high = high || comparator - low = low || comparator - if (gtfn(comparator.semver, high.semver, options)) { - high = comparator - } else if (ltfn(comparator.semver, low.semver, options)) { - low = comparator + if (ctorString) { + switch (ctorString) { + case dataViewCtorString: return dataViewTag; + case mapCtorString: return mapTag; + case promiseCtorString: return promiseTag; + case setCtorString: return setTag; + case weakMapCtorString: return weakMapTag; } - }) - - // If the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false } - - // If the lowest version comparator has an operator and our version - // is less than it then it isn't higher than the range - if ((!low.operator || low.operator === comp) && - ltefn(version, low.semver)) { - return false - } else if (low.operator === ecomp && ltfn(version, low.semver)) { - return false - } - } - return true -} - -exports.prerelease = prerelease -function prerelease (version, options) { - var parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} - -exports.intersects = intersects -function intersects (r1, r2, options) { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) + return result; + }; } -exports.coerce = coerce -function coerce (version, options) { - if (version instanceof SemVer) { - return version - } - - if (typeof version === 'number') { - version = String(version) - } - - if (typeof version !== 'string') { - return null - } +/** + * Checks if `path` exists on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @param {Function} hasFunc The function to check properties. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + */ +function hasPath(object, path, hasFunc) { + path = isKey(path, object) ? [path] : castPath(path); - options = options || {} + var result, + index = -1, + length = path.length; - var match = null - if (!options.rtl) { - match = version.match(re[t.COERCE]) - } else { - // Find the right-most coercible string that does not share - // a terminus with a more left-ward coercible string. - // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' - // - // Walk through the string checking with a /g regexp - // Manually set the index so as to pick up overlapping matches. - // Stop when we get a match that ends at the string end, since no - // coercible string can be more right-ward without the same terminus. - var next - while ((next = re[t.COERCERTL].exec(version)) && - (!match || match.index + match[0].length !== version.length) - ) { - if (!match || - next.index + next[0].length !== match.index + match[0].length) { - match = next - } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + while (++index < length) { + var key = toKey(path[index]); + if (!(result = object != null && hasFunc(object, key))) { + break; } - // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 + object = object[key]; } - - if (match === null) { - return null + if (result) { + return result; } - - return parse(match[2] + - '.' + (match[3] || '0') + - '.' + (match[4] || '0'), options) + var length = object ? object.length : 0; + return !!length && isLength(length) && isIndex(key, length) && + (isArray(object) || isArguments(object)); } - -/***/ }), -/* 702 */, -/* 703 */, -/* 704 */ -/***/ (function(module, exports, __webpack_require__) { - -/* module decorator */ module = __webpack_require__.nmd(module); -/** - * lodash (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ - -/** Used as the size to enable large array optimizations. */ -var LARGE_ARRAY_SIZE = 200; - -/** Used as the `TypeError` message for "Functions" methods. */ -var FUNC_ERROR_TEXT = 'Expected a function'; - -/** Used to stand-in for `undefined` hash values. */ -var HASH_UNDEFINED = '__lodash_hash_undefined__'; - -/** Used to compose bitmasks for comparison styles. */ -var UNORDERED_COMPARE_FLAG = 1, - PARTIAL_COMPARE_FLAG = 2; - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0, - MAX_SAFE_INTEGER = 9007199254740991; - -/** `Object#toString` result references. */ -var argsTag = '[object Arguments]', - arrayTag = '[object Array]', - boolTag = '[object Boolean]', - dateTag = '[object Date]', - errorTag = '[object Error]', - funcTag = '[object Function]', - genTag = '[object GeneratorFunction]', - mapTag = '[object Map]', - numberTag = '[object Number]', - objectTag = '[object Object]', - promiseTag = '[object Promise]', - regexpTag = '[object RegExp]', - setTag = '[object Set]', - stringTag = '[object String]', - symbolTag = '[object Symbol]', - weakMapTag = '[object WeakMap]'; - -var arrayBufferTag = '[object ArrayBuffer]', - dataViewTag = '[object DataView]', - float32Tag = '[object Float32Array]', - float64Tag = '[object Float64Array]', - int8Tag = '[object Int8Array]', - int16Tag = '[object Int16Array]', - int32Tag = '[object Int32Array]', - uint8Tag = '[object Uint8Array]', - uint8ClampedTag = '[object Uint8ClampedArray]', - uint16Tag = '[object Uint16Array]', - uint32Tag = '[object Uint32Array]'; - -/** Used to match property names within property paths. */ -var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, - reIsPlainProp = /^\w*$/, - reLeadingDot = /^\./, - rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; - /** - * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). + * Checks if `value` is a valid array-like index. + * + * @private + * @param {*} value The value to check. + * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. + * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. */ -var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; - -/** Used to match backslashes in property paths. */ -var reEscapeChar = /\\(\\)?/g; - -/** Used to detect host constructors (Safari). */ -var reIsHostCtor = /^\[object .+?Constructor\]$/; - -/** Used to detect unsigned integer values. */ -var reIsUint = /^(?:0|[1-9]\d*)$/; - -/** Used to identify `toStringTag` values of typed arrays. */ -var typedArrayTags = {}; -typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = -typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = -typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = -typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = -typedArrayTags[uint32Tag] = true; -typedArrayTags[argsTag] = typedArrayTags[arrayTag] = -typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = -typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = -typedArrayTags[errorTag] = typedArrayTags[funcTag] = -typedArrayTags[mapTag] = typedArrayTags[numberTag] = -typedArrayTags[objectTag] = typedArrayTags[regexpTag] = -typedArrayTags[setTag] = typedArrayTags[stringTag] = -typedArrayTags[weakMapTag] = false; - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -/** Detect free variable `exports`. */ -var freeExports = true && exports && !exports.nodeType && exports; - -/** Detect free variable `module`. */ -var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module; - -/** Detect the popular CommonJS extension `module.exports`. */ -var moduleExports = freeModule && freeModule.exports === freeExports; - -/** Detect free variable `process` from Node.js. */ -var freeProcess = moduleExports && freeGlobal.process; - -/** Used to access faster Node.js helpers. */ -var nodeUtil = (function() { - try { - return freeProcess && freeProcess.binding('util'); - } catch (e) {} -}()); - -/* Node.js helper references. */ -var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; +function isIndex(value, length) { + length = length == null ? MAX_SAFE_INTEGER : length; + return !!length && + (typeof value == 'number' || reIsUint.test(value)) && + (value > -1 && value % 1 == 0 && value < length); +} /** - * A specialized version of `_.forEach` for arrays without support for - * iteratee shorthands. + * Checks if `value` is a property name and not a property path. * * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns `array`. + * @param {*} value The value to check. + * @param {Object} [object] The object to query keys on. + * @returns {boolean} Returns `true` if `value` is a property name, else `false`. */ -function arrayEach(array, iteratee) { - var index = -1, - length = array ? array.length : 0; - - while (++index < length) { - if (iteratee(array[index], index, array) === false) { - break; - } +function isKey(value, object) { + if (isArray(value)) { + return false; } - return array; + var type = typeof value; + if (type == 'number' || type == 'symbol' || type == 'boolean' || + value == null || isSymbol(value)) { + return true; + } + return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || + (object != null && value in Object(object)); } /** - * A specialized version of `_.some` for arrays without support for iteratee - * shorthands. + * Checks if `value` is suitable for use as unique object key. * * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} predicate The function invoked per iteration. - * @returns {boolean} Returns `true` if any element passes the predicate check, - * else `false`. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is suitable, else `false`. */ -function arraySome(array, predicate) { - var index = -1, - length = array ? array.length : 0; - - while (++index < length) { - if (predicate(array[index], index, array)) { - return true; - } - } - return false; +function isKeyable(value) { + var type = typeof value; + return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') + ? (value !== '__proto__') + : (value === null); } /** - * The base implementation of `_.property` without support for deep paths. + * Checks if `func` has its source masked. * * @private - * @param {string} key The key of the property to get. - * @returns {Function} Returns the new accessor function. + * @param {Function} func The function to check. + * @returns {boolean} Returns `true` if `func` is masked, else `false`. */ -function baseProperty(key) { - return function(object) { - return object == null ? undefined : object[key]; - }; +function isMasked(func) { + return !!maskSrcKey && (maskSrcKey in func); } /** - * The base implementation of `_.times` without support for iteratee shorthands - * or max array length checks. + * Checks if `value` is likely a prototype object. * * @private - * @param {number} n The number of times to invoke `iteratee`. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Array} Returns the array of results. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. */ -function baseTimes(n, iteratee) { - var index = -1, - result = Array(n); +function isPrototype(value) { + var Ctor = value && value.constructor, + proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; - while (++index < n) { - result[index] = iteratee(index); - } - return result; + return value === proto; } /** - * The base implementation of `_.unary` without support for storing metadata. + * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. * * @private - * @param {Function} func The function to cap arguments for. - * @returns {Function} Returns the new capped function. + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` if suitable for strict + * equality comparisons, else `false`. */ -function baseUnary(func) { - return function(value) { - return func(value); - }; +function isStrictComparable(value) { + return value === value && !isObject(value); } /** - * Gets the value at `key` of `object`. + * A specialized version of `matchesProperty` for source values suitable + * for strict equality comparisons, i.e. `===`. * * @private - * @param {Object} [object] The object to query. * @param {string} key The key of the property to get. - * @returns {*} Returns the property value. + * @param {*} srcValue The value to match. + * @returns {Function} Returns the new spec function. */ -function getValue(object, key) { - return object == null ? undefined : object[key]; +function matchesStrictComparable(key, srcValue) { + return function(object) { + if (object == null) { + return false; + } + return object[key] === srcValue && + (srcValue !== undefined || (key in Object(object))); + }; } /** - * Checks if `value` is a host object in IE < 9. + * Converts `string` to a property path array. * * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + * @param {string} string The string to convert. + * @returns {Array} Returns the property path array. */ -function isHostObject(value) { - // Many host objects are `Object` objects that can coerce to strings - // despite having improperly defined `toString` methods. - var result = false; - if (value != null && typeof value.toString != 'function') { - try { - result = !!(value + ''); - } catch (e) {} +var stringToPath = memoize(function(string) { + string = toString(string); + + var result = []; + if (reLeadingDot.test(string)) { + result.push(''); } + string.replace(rePropName, function(match, number, quote, string) { + result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); + }); return result; -} +}); /** - * Converts `map` to its key-value pairs. + * Converts `value` to a string key if it's not a string or symbol. * * @private - * @param {Object} map The map to convert. - * @returns {Array} Returns the key-value pairs. + * @param {*} value The value to inspect. + * @returns {string|symbol} Returns the key. */ -function mapToArray(map) { - var index = -1, - result = Array(map.size); - - map.forEach(function(value, key) { - result[++index] = [key, value]; - }); - return result; +function toKey(value) { + if (typeof value == 'string' || isSymbol(value)) { + return value; + } + var result = (value + ''); + return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; } /** - * Creates a unary function that invokes `func` with its argument transformed. + * Converts `func` to its source code. * * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. + * @param {Function} func The function to process. + * @returns {string} Returns the source code. */ -function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; +function toSource(func) { + if (func != null) { + try { + return funcToString.call(func); + } catch (e) {} + try { + return (func + ''); + } catch (e) {} + } + return ''; } /** - * Converts `set` to an array of its values. + * Creates a function that memoizes the result of `func`. If `resolver` is + * provided, it determines the cache key for storing the result based on the + * arguments provided to the memoized function. By default, the first argument + * provided to the memoized function is used as the map cache key. The `func` + * is invoked with the `this` binding of the memoized function. * - * @private - * @param {Object} set The set to convert. - * @returns {Array} Returns the values. + * **Note:** The cache is exposed as the `cache` property on the memoized + * function. Its creation may be customized by replacing the `_.memoize.Cache` + * constructor with one whose instances implement the + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) + * method interface of `delete`, `get`, `has`, and `set`. + * + * @static + * @memberOf _ + * @since 0.1.0 + * @category Function + * @param {Function} func The function to have its output memoized. + * @param {Function} [resolver] The function to resolve the cache key. + * @returns {Function} Returns the new memoized function. + * @example + * + * var object = { 'a': 1, 'b': 2 }; + * var other = { 'c': 3, 'd': 4 }; + * + * var values = _.memoize(_.values); + * values(object); + * // => [1, 2] + * + * values(other); + * // => [3, 4] + * + * object.a = 2; + * values(object); + * // => [1, 2] + * + * // Modify the result cache. + * values.cache.set(object, ['a', 'b']); + * values(object); + * // => ['a', 'b'] + * + * // Replace `_.memoize.Cache`. + * _.memoize.Cache = WeakMap; */ -function setToArray(set) { - var index = -1, - result = Array(set.size); +function memoize(func, resolver) { + if (typeof func != 'function' || (resolver && typeof resolver != 'function')) { + throw new TypeError(FUNC_ERROR_TEXT); + } + var memoized = function() { + var args = arguments, + key = resolver ? resolver.apply(this, args) : args[0], + cache = memoized.cache; - set.forEach(function(value) { - result[++index] = value; - }); - return result; + if (cache.has(key)) { + return cache.get(key); + } + var result = func.apply(this, args); + memoized.cache = cache.set(key, result); + return result; + }; + memoized.cache = new (memoize.Cache || MapCache); + return memoized; } -/** Used for built-in method references. */ -var arrayProto = Array.prototype, - funcProto = Function.prototype, - objectProto = Object.prototype; - -/** Used to detect overreaching core-js shims. */ -var coreJsData = root['__core-js_shared__']; - -/** Used to detect methods masquerading as native. */ -var maskSrcKey = (function() { - var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); - return uid ? ('Symbol(src)_1.' + uid) : ''; -}()); - -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; - -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/** Used to detect if a method is native. */ -var reIsNative = RegExp('^' + - funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') - .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' -); - -/** Built-in value references. */ -var Symbol = root.Symbol, - Uint8Array = root.Uint8Array, - getPrototype = overArg(Object.getPrototypeOf, Object), - objectCreate = Object.create, - propertyIsEnumerable = objectProto.propertyIsEnumerable, - splice = arrayProto.splice; - -/* Built-in method references for those with the same name as other `lodash` methods. */ -var nativeKeys = overArg(Object.keys, Object); - -/* Built-in method references that are verified to be native. */ -var DataView = getNative(root, 'DataView'), - Map = getNative(root, 'Map'), - Promise = getNative(root, 'Promise'), - Set = getNative(root, 'Set'), - WeakMap = getNative(root, 'WeakMap'), - nativeCreate = getNative(Object, 'create'); - -/** Used to detect maps, sets, and weakmaps. */ -var dataViewCtorString = toSource(DataView), - mapCtorString = toSource(Map), - promiseCtorString = toSource(Promise), - setCtorString = toSource(Set), - weakMapCtorString = toSource(WeakMap); - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; +// Assign cache to `_.memoize`. +memoize.Cache = MapCache; /** - * Creates a hash object. + * Performs a + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) + * comparison between two values to determine if they are equivalent. * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. - */ -function Hash(entries) { - var index = -1, - length = entries ? entries.length : 0; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } -} - -/** - * Removes all key-value entries from the hash. + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to compare. + * @param {*} other The other value to compare. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. + * @example * - * @private - * @name clear - * @memberOf Hash - */ -function hashClear() { - this.__data__ = nativeCreate ? nativeCreate(null) : {}; -} - -/** - * Removes `key` and its value from the hash. + * var object = { 'a': 1 }; + * var other = { 'a': 1 }; * - * @private - * @name delete - * @memberOf Hash - * @param {Object} hash The hash to modify. - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function hashDelete(key) { - return this.has(key) && delete this.__data__[key]; -} - -/** - * Gets the hash value for `key`. + * _.eq(object, object); + * // => true * - * @private - * @name get - * @memberOf Hash - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. + * _.eq(object, other); + * // => false + * + * _.eq('a', 'a'); + * // => true + * + * _.eq('a', Object('a')); + * // => false + * + * _.eq(NaN, NaN); + * // => true */ -function hashGet(key) { - var data = this.__data__; - if (nativeCreate) { - var result = data[key]; - return result === HASH_UNDEFINED ? undefined : result; - } - return hasOwnProperty.call(data, key) ? data[key] : undefined; +function eq(value, other) { + return value === other || (value !== value && other !== other); } /** - * Checks if a hash value for `key` exists. + * Checks if `value` is likely an `arguments` object. * - * @private - * @name has - * @memberOf Hash - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an `arguments` object, + * else `false`. + * @example + * + * _.isArguments(function() { return arguments; }()); + * // => true + * + * _.isArguments([1, 2, 3]); + * // => false */ -function hashHas(key) { - var data = this.__data__; - return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key); +function isArguments(value) { + // Safari 8.1 makes `arguments.callee` enumerable in strict mode. + return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && + (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); } /** - * Sets the hash `key` to `value`. + * Checks if `value` is classified as an `Array` object. * - * @private - * @name set - * @memberOf Hash - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the hash instance. + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array, else `false`. + * @example + * + * _.isArray([1, 2, 3]); + * // => true + * + * _.isArray(document.body.children); + * // => false + * + * _.isArray('abc'); + * // => false + * + * _.isArray(_.noop); + * // => false */ -function hashSet(key, value) { - var data = this.__data__; - data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; - return this; -} - -// Add methods to `Hash`. -Hash.prototype.clear = hashClear; -Hash.prototype['delete'] = hashDelete; -Hash.prototype.get = hashGet; -Hash.prototype.has = hashHas; -Hash.prototype.set = hashSet; +var isArray = Array.isArray; /** - * Creates an list cache object. + * Checks if `value` is array-like. A value is considered array-like if it's + * not a function and has a `value.length` that's an integer greater than or + * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is array-like, else `false`. + * @example + * + * _.isArrayLike([1, 2, 3]); + * // => true + * + * _.isArrayLike(document.body.children); + * // => true + * + * _.isArrayLike('abc'); + * // => true + * + * _.isArrayLike(_.noop); + * // => false */ -function ListCache(entries) { - var index = -1, - length = entries ? entries.length : 0; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } +function isArrayLike(value) { + return value != null && isLength(value.length) && !isFunction(value); } /** - * Removes all key-value entries from the list cache. + * This method is like `_.isArrayLike` except that it also checks if `value` + * is an object. * - * @private - * @name clear - * @memberOf ListCache + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an array-like object, + * else `false`. + * @example + * + * _.isArrayLikeObject([1, 2, 3]); + * // => true + * + * _.isArrayLikeObject(document.body.children); + * // => true + * + * _.isArrayLikeObject('abc'); + * // => false + * + * _.isArrayLikeObject(_.noop); + * // => false */ -function listCacheClear() { - this.__data__ = []; +function isArrayLikeObject(value) { + return isObjectLike(value) && isArrayLike(value); } /** - * Removes `key` and its value from the list cache. + * Checks if `value` is classified as a `Function` object. * - * @private - * @name delete - * @memberOf ListCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a function, else `false`. + * @example + * + * _.isFunction(_); + * // => true + * + * _.isFunction(/abc/); + * // => false */ -function listCacheDelete(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - return false; - } - var lastIndex = data.length - 1; - if (index == lastIndex) { - data.pop(); - } else { - splice.call(data, index, 1); - } - return true; +function isFunction(value) { + // The use of `Object#toString` avoids issues with the `typeof` operator + // in Safari 8-9 which returns 'object' for typed array and other constructors. + var tag = isObject(value) ? objectToString.call(value) : ''; + return tag == funcTag || tag == genTag; } /** - * Gets the list cache value for `key`. + * Checks if `value` is a valid array-like length. * - * @private - * @name get - * @memberOf ListCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. + * @example + * + * _.isLength(3); + * // => true + * + * _.isLength(Number.MIN_VALUE); + * // => false + * + * _.isLength(Infinity); + * // => false + * + * _.isLength('3'); + * // => false */ -function listCacheGet(key) { - var data = this.__data__, - index = assocIndexOf(data, key); - - return index < 0 ? undefined : data[index][1]; +function isLength(value) { + return typeof value == 'number' && + value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } /** - * Checks if a list cache value for `key` exists. + * Checks if `value` is the + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) + * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * - * @private - * @name has - * @memberOf ListCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * @static + * @memberOf _ + * @since 0.1.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is an object, else `false`. + * @example + * + * _.isObject({}); + * // => true + * + * _.isObject([1, 2, 3]); + * // => true + * + * _.isObject(_.noop); + * // => true + * + * _.isObject(null); + * // => false */ -function listCacheHas(key) { - return assocIndexOf(this.__data__, key) > -1; +function isObject(value) { + var type = typeof value; + return !!value && (type == 'object' || type == 'function'); } /** - * Sets the list cache `key` to `value`. + * Checks if `value` is object-like. A value is object-like if it's not `null` + * and has a `typeof` result of "object". * - * @private - * @name set - * @memberOf ListCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the list cache instance. + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is object-like, else `false`. + * @example + * + * _.isObjectLike({}); + * // => true + * + * _.isObjectLike([1, 2, 3]); + * // => true + * + * _.isObjectLike(_.noop); + * // => false + * + * _.isObjectLike(null); + * // => false */ -function listCacheSet(key, value) { - var data = this.__data__, - index = assocIndexOf(data, key); - - if (index < 0) { - data.push([key, value]); - } else { - data[index][1] = value; - } - return this; +function isObjectLike(value) { + return !!value && typeof value == 'object'; } -// Add methods to `ListCache`. -ListCache.prototype.clear = listCacheClear; -ListCache.prototype['delete'] = listCacheDelete; -ListCache.prototype.get = listCacheGet; -ListCache.prototype.has = listCacheHas; -ListCache.prototype.set = listCacheSet; - /** - * Creates a map cache object to store key-value pairs. + * Checks if `value` is classified as a `Symbol` primitive or object. * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @example + * + * _.isSymbol(Symbol.iterator); + * // => true + * + * _.isSymbol('abc'); + * // => false */ -function MapCache(entries) { - var index = -1, - length = entries ? entries.length : 0; - - this.clear(); - while (++index < length) { - var entry = entries[index]; - this.set(entry[0], entry[1]); - } +function isSymbol(value) { + return typeof value == 'symbol' || + (isObjectLike(value) && objectToString.call(value) == symbolTag); } /** - * Removes all key-value entries from the map. + * Checks if `value` is classified as a typed array. * - * @private - * @name clear - * @memberOf MapCache + * @static + * @memberOf _ + * @since 3.0.0 + * @category Lang + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. + * @example + * + * _.isTypedArray(new Uint8Array); + * // => true + * + * _.isTypedArray([]); + * // => false */ -function mapCacheClear() { - this.__data__ = { - 'hash': new Hash, - 'map': new (Map || ListCache), - 'string': new Hash - }; -} +var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; /** - * Removes `key` and its value from the map. + * Converts `value` to a string. An empty string is returned for `null` + * and `undefined` values. The sign of `-0` is preserved. * - * @private - * @name delete - * @memberOf MapCache - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. + * @static + * @memberOf _ + * @since 4.0.0 + * @category Lang + * @param {*} value The value to process. + * @returns {string} Returns the string. + * @example + * + * _.toString(null); + * // => '' + * + * _.toString(-0); + * // => '-0' + * + * _.toString([1, 2, 3]); + * // => '1,2,3' */ -function mapCacheDelete(key) { - return getMapData(this, key)['delete'](key); +function toString(value) { + return value == null ? '' : baseToString(value); } /** - * Gets the map value for `key`. + * Gets the value at `path` of `object`. If the resolved value is + * `undefined`, the `defaultValue` is returned in its place. * - * @private - * @name get - * @memberOf MapCache - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. + * @static + * @memberOf _ + * @since 3.7.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path of the property to get. + * @param {*} [defaultValue] The value returned for `undefined` resolved values. + * @returns {*} Returns the resolved value. + * @example + * + * var object = { 'a': [{ 'b': { 'c': 3 } }] }; + * + * _.get(object, 'a[0].b.c'); + * // => 3 + * + * _.get(object, ['a', '0', 'b', 'c']); + * // => 3 + * + * _.get(object, 'a.b.c', 'default'); + * // => 'default' */ -function mapCacheGet(key) { - return getMapData(this, key).get(key); +function get(object, path, defaultValue) { + var result = object == null ? undefined : baseGet(object, path); + return result === undefined ? defaultValue : result; } /** - * Checks if a map value for `key` exists. + * Checks if `path` is a direct or inherited property of `object`. * - * @private - * @name has - * @memberOf MapCache - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * @static + * @memberOf _ + * @since 4.0.0 + * @category Object + * @param {Object} object The object to query. + * @param {Array|string} path The path to check. + * @returns {boolean} Returns `true` if `path` exists, else `false`. + * @example + * + * var object = _.create({ 'a': _.create({ 'b': 2 }) }); + * + * _.hasIn(object, 'a'); + * // => true + * + * _.hasIn(object, 'a.b'); + * // => true + * + * _.hasIn(object, ['a', 'b']); + * // => true + * + * _.hasIn(object, 'b'); + * // => false */ -function mapCacheHas(key) { - return getMapData(this, key).has(key); +function hasIn(object, path) { + return object != null && hasPath(object, path, baseHasIn); } /** - * Sets the map `key` to `value`. + * Creates an array of the own enumerable property names of `object`. * - * @private - * @name set - * @memberOf MapCache - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the map cache instance. + * **Note:** Non-object values are coerced to objects. See the + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * for more details. + * + * @static + * @since 0.1.0 + * @memberOf _ + * @category Object + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + * @example + * + * function Foo() { + * this.a = 1; + * this.b = 2; + * } + * + * Foo.prototype.c = 3; + * + * _.keys(new Foo); + * // => ['a', 'b'] (iteration order is not guaranteed) + * + * _.keys('hi'); + * // => ['0', '1'] */ -function mapCacheSet(key, value) { - getMapData(this, key).set(key, value); - return this; +function keys(object) { + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } -// Add methods to `MapCache`. -MapCache.prototype.clear = mapCacheClear; -MapCache.prototype['delete'] = mapCacheDelete; -MapCache.prototype.get = mapCacheGet; -MapCache.prototype.has = mapCacheHas; -MapCache.prototype.set = mapCacheSet; - /** + * An alternative to `_.reduce`; this method transforms `object` to a new + * `accumulator` object which is the result of running each of its own + * enumerable string keyed properties thru `iteratee`, with each invocation + * potentially mutating the `accumulator` object. If `accumulator` is not + * provided, a new object with the same `[[Prototype]]` will be used. The + * iteratee is invoked with four arguments: (accumulator, value, key, object). + * Iteratee functions may exit iteration early by explicitly returning `false`. * - * Creates an array cache object to store unique values. + * @static + * @memberOf _ + * @since 1.3.0 + * @category Object + * @param {Object} object The object to iterate over. + * @param {Function} [iteratee=_.identity] The function invoked per iteration. + * @param {*} [accumulator] The custom accumulator value. + * @returns {*} Returns the accumulated value. + * @example * - * @private - * @constructor - * @param {Array} [values] The values to cache. + * _.transform([2, 3, 4], function(result, n) { + * result.push(n *= n); + * return n % 2 == 0; + * }, []); + * // => [4, 9] + * + * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { + * (result[value] || (result[value] = [])).push(key); + * }, {}); + * // => { '1': ['a', 'c'], '2': ['b'] } */ -function SetCache(values) { - var index = -1, - length = values ? values.length : 0; +function transform(object, iteratee, accumulator) { + var isArr = isArray(object) || isTypedArray(object); + iteratee = baseIteratee(iteratee, 4); - this.__data__ = new MapCache; - while (++index < length) { - this.add(values[index]); + if (accumulator == null) { + if (isArr || isObject(object)) { + var Ctor = object.constructor; + if (isArr) { + accumulator = isArray(object) ? new Ctor : []; + } else { + accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; + } + } else { + accumulator = {}; + } } + (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { + return iteratee(accumulator, value, index, object); + }); + return accumulator; } /** - * Adds `value` to the array cache. + * This method returns the first argument it receives. * - * @private - * @name add - * @memberOf SetCache - * @alias push - * @param {*} value The value to cache. - * @returns {Object} Returns the cache instance. - */ -function setCacheAdd(value) { - this.__data__.set(value, HASH_UNDEFINED); - return this; -} - -/** - * Checks if `value` is in the array cache. + * @static + * @since 0.1.0 + * @memberOf _ + * @category Util + * @param {*} value Any value. + * @returns {*} Returns `value`. + * @example * - * @private - * @name has - * @memberOf SetCache - * @param {*} value The value to search for. - * @returns {number} Returns `true` if `value` is found, else `false`. - */ -function setCacheHas(value) { - return this.__data__.has(value); -} - -// Add methods to `SetCache`. -SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; -SetCache.prototype.has = setCacheHas; - -/** - * Creates a stack cache object to store key-value pairs. + * var object = { 'a': 1 }; * - * @private - * @constructor - * @param {Array} [entries] The key-value pairs to cache. + * console.log(_.identity(object) === object); + * // => true */ -function Stack(entries) { - this.__data__ = new ListCache(entries); +function identity(value) { + return value; } /** - * Removes all key-value entries from the stack. + * Creates a function that returns the value at `path` of a given object. * - * @private - * @name clear - * @memberOf Stack - */ -function stackClear() { - this.__data__ = new ListCache; -} - -/** - * Removes `key` and its value from the stack. + * @static + * @memberOf _ + * @since 2.4.0 + * @category Util + * @param {Array|string} path The path of the property to get. + * @returns {Function} Returns the new accessor function. + * @example * - * @private - * @name delete - * @memberOf Stack - * @param {string} key The key of the value to remove. - * @returns {boolean} Returns `true` if the entry was removed, else `false`. - */ -function stackDelete(key) { - return this.__data__['delete'](key); -} - -/** - * Gets the stack value for `key`. + * var objects = [ + * { 'a': { 'b': 2 } }, + * { 'a': { 'b': 1 } } + * ]; * - * @private - * @name get - * @memberOf Stack - * @param {string} key The key of the value to get. - * @returns {*} Returns the entry value. - */ -function stackGet(key) { - return this.__data__.get(key); -} - -/** - * Checks if a stack value for `key` exists. + * _.map(objects, _.property('a.b')); + * // => [2, 1] * - * @private - * @name has - * @memberOf Stack - * @param {string} key The key of the entry to check. - * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. + * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); + * // => [1, 2] */ -function stackHas(key) { - return this.__data__.has(key); +function property(path) { + return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); } +module.exports = transform; + + +/***/ }), +/* 705 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SectionHeader = __webpack_require__(392); + /** - * Sets the stack `key` to `value`. - * - * @private - * @name set - * @memberOf Stack - * @param {string} key The key of the value to set. - * @param {*} value The value to set. - * @returns {Object} Returns the stack cache instance. + * The string table is used to store section and symbol names. In the ELF image, it consists + * of a sequence of null-terminated ASCII strings. */ -function stackSet(key, value) { - var cache = this.__data__; - if (cache instanceof ListCache) { - var pairs = cache.__data__; - if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { - pairs.push([key, value]); - return this; +class StringTable { + constructor(arg) { + if (typeof arg === 'object') { + // from StringTable.parse() + Object.assign(this, arg); + return; } - cache = this.__data__ = new MapCache(pairs); - } - cache.set(key, value); - return this; -} -// Add methods to `Stack`. -Stack.prototype.clear = stackClear; -Stack.prototype['delete'] = stackDelete; -Stack.prototype.get = stackGet; -Stack.prototype.has = stackHas; -Stack.prototype.set = stackSet; + this.strings = ''; + this.section_header = new SectionHeader({ + name: arg, + type: 'strtab', + flags: '', + addr: 0, + offset: null, + size: null, + link: 0, + info: 0, + addralign: 1, + entsize: 0, + }); + } -/** - * Creates an array of the enumerable property names of the array-like `value`. - * - * @private - * @param {*} value The value to query. - * @param {boolean} inherited Specify returning inherited property names. - * @returns {Array} Returns the array of property names. - */ -function arrayLikeKeys(value, inherited) { - // Safari 8.1 makes `arguments.callee` enumerable in strict mode. - // Safari 9 makes `arguments.length` enumerable in strict mode. - var result = (isArray(value) || isArguments(value)) - ? baseTimes(value.length, String) - : []; + static parse({ header, data }) { + return new StringTable({ + section_header: header, + strings: data.toString(StringTable.ENCODING), + }); + } - var length = result.length, - skipIndexes = !!length; + add_string(str) { + return this.getStringOffset(str, true); + } - for (var key in value) { - if ((inherited || hasOwnProperty.call(value, key)) && - !(skipIndexes && (key == 'length' || isIndex(key, length)))) { - result.push(key); + /** + * Returns the offset into the table of the specified string + * @param {string} str string to locate + * @param {boolean} [add] optional - automatically add the string if it's not in the table + */ + getStringOffset(str, add = false) { + // strings are a concatenated list of null-terminated values + const str0 = str + '\0'; + let offset = this.strings.indexOf(str0); + if (offset < 0) { + if (!add) { + throw new Error(`String '${str}' not found in string table`); + } + offset = this.strings.length; + this.strings += str0; } + return offset; } - return result; -} -/** - * Gets the index at which the `key` is found in `array` of key-value pairs. - * - * @private - * @param {Array} array The array to inspect. - * @param {*} key The key to search for. - * @returns {number} Returns the index of the matched value, else `-1`. - */ -function assocIndexOf(array, key) { - var length = array.length; - while (length--) { - if (eq(array[length][0], key)) { - return length; - } + // retrieve the string from the table at the given offset + getString(offset) { + if (offset < 0 || offset >= this.strings.length) + throw new RangeError(`Offset out of range of string table. Offset=${offset}, Table length=${this.strings.length}`); + const s = this.strings.slice(offset, this.strings.indexOf('\0', offset)); + return s; } - return -1; -} -/** - * The base implementation of `_.create` without support for assigning - * properties to the created object. - * - * @private - * @param {Object} prototype The object to inherit from. - * @returns {Object} Returns the new object. - */ -function baseCreate(proto) { - return isObject(proto) ? objectCreate(proto) : {}; + calculate_size(elf_offset) { + this.elf_offset = this.section_header.offset = elf_offset; + // ELF only allows ascii chars, so bytes = length + this.elf_size = this.section_header.size = this.strings.length; + return this.elf_size; + } + + write(stream) { + stream.writeBuf(Buffer.from(this.strings, StringTable.ENCODING)); + } } -/** - * The base implementation of `baseForOwn` which iterates over `object` - * properties returned by `keysFunc` and invokes `iteratee` for each property. - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {Function} keysFunc The function to get the keys of `object`. - * @returns {Object} Returns `object`. - */ -var baseFor = createBaseFor(); +StringTable.ENCODING = 'ascii'; -/** - * The base implementation of `_.forOwn` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {Object} Returns `object`. - */ -function baseForOwn(object, iteratee) { - return object && baseFor(object, iteratee, keys); -} +module.exports = StringTable; -/** - * The base implementation of `_.get` without support for default values. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @returns {*} Returns the resolved value. - */ -function baseGet(object, path) { - path = isKey(path, object) ? [path] : castPath(path); - var index = 0, - length = path.length; +/***/ }), +/* 706 */ +/***/ (function(module, __unusedexports, __webpack_require__) { - while (object != null && index < length) { - object = object[toKey(path[index++])]; - } - return (index && index == length) ? object : undefined; -} +/** + * JSON Format Plugin + * + * @module plugins/json + * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE} + * @copyright (c) 2012-2014 Chris Talkington, contributors. + */ +var inherits = __webpack_require__(669).inherits; +var Transform = __webpack_require__(574).Transform; + +var crc32 = __webpack_require__(538); +var util = __webpack_require__(108); + +/** + * @constructor + * @param {(JsonOptions|TransformOptions)} options + */ +var Json = function(options) { + if (!(this instanceof Json)) { + return new Json(options); + } + + options = this.options = util.defaults(options, {}); + + Transform.call(this, options); + + this.supports = { + directory: true, + symlink: true + }; + + this.files = []; +}; + +inherits(Json, Transform); + +/** + * [_transform description] + * + * @private + * @param {Buffer} chunk + * @param {String} encoding + * @param {Function} callback + * @return void + */ +Json.prototype._transform = function(chunk, encoding, callback) { + callback(null, chunk); +}; + +/** + * [_writeStringified description] + * + * @private + * @return void + */ +Json.prototype._writeStringified = function() { + var fileString = JSON.stringify(this.files); + this.write(fileString); +}; + +/** + * [append description] + * + * @param {(Buffer|Stream)} source + * @param {EntryData} data + * @param {Function} callback + * @return void + */ +Json.prototype.append = function(source, data, callback) { + var self = this; + + data.crc32 = 0; + + function onend(err, sourceBuffer) { + if (err) { + callback(err); + return; + } + + data.size = sourceBuffer.length || 0; + data.crc32 = crc32.unsigned(sourceBuffer); + + self.files.push(data); + + callback(null, data); + } + + if (data.sourceType === 'buffer') { + onend(null, source); + } else if (data.sourceType === 'stream') { + util.collectStream(source, onend); + } +}; + +/** + * [finalize description] + * + * @return void + */ +Json.prototype.finalize = function() { + this._writeStringified(); + this.end(); +}; + +module.exports = Json; + +/** + * @typedef {Object} JsonOptions + * @global + */ -/** - * The base implementation of `getTag`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -function baseGetTag(value) { - return objectToString.call(value); -} -/** - * The base implementation of `_.hasIn` without support for deep paths. - * - * @private - * @param {Object} [object] The object to query. - * @param {Array|string} key The key to check. - * @returns {boolean} Returns `true` if `key` exists, else `false`. - */ -function baseHasIn(object, key) { - return object != null && key in Object(object); -} +/***/ }), +/* 707 */ +/***/ (function(module, __unusedexports, __webpack_require__) { -/** - * The base implementation of `_.isEqual` which supports partial comparisons - * and tracks traversed objects. - * - * @private - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @param {Function} [customizer] The function to customize comparisons. - * @param {boolean} [bitmask] The bitmask of comparison flags. - * The bitmask may be composed of the following flags: - * 1 - Unordered comparison - * 2 - Partial comparison - * @param {Object} [stack] Tracks traversed `value` and `other` objects. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - */ -function baseIsEqual(value, other, customizer, bitmask, stack) { - if (value === other) { - return true; - } - if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) { - return value !== value && other !== other; - } - return baseIsEqualDeep(value, other, baseIsEqual, customizer, bitmask, stack); -} +"use strict"; -/** - * A specialized version of `baseIsEqual` for arrays and objects which performs - * deep comparisons and tracks traversed objects enabling objects with circular - * references to be compared. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} [customizer] The function to customize comparisons. - * @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} [stack] Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function baseIsEqualDeep(object, other, equalFunc, customizer, bitmask, stack) { - var objIsArr = isArray(object), - othIsArr = isArray(other), - objTag = arrayTag, - othTag = arrayTag; - if (!objIsArr) { - objTag = getTag(object); - objTag = objTag == argsTag ? objectTag : objTag; - } - if (!othIsArr) { - othTag = getTag(other); - othTag = othTag == argsTag ? objectTag : othTag; - } - var objIsObj = objTag == objectTag && !isHostObject(object), - othIsObj = othTag == objectTag && !isHostObject(other), - isSameTag = objTag == othTag; +module.exports = __webpack_require__(651).default; - if (isSameTag && !objIsObj) { - stack || (stack = new Stack); - return (objIsArr || isTypedArray(object)) - ? equalArrays(object, other, equalFunc, customizer, bitmask, stack) - : equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack); - } - if (!(bitmask & PARTIAL_COMPARE_FLAG)) { - var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), - othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); - if (objIsWrapped || othIsWrapped) { - var objUnwrapped = objIsWrapped ? object.value() : object, - othUnwrapped = othIsWrapped ? other.value() : other; +/***/ }), +/* 708 */ +/***/ (function(module) { - stack || (stack = new Stack); - return equalFunc(objUnwrapped, othUnwrapped, customizer, bitmask, stack); - } - } - if (!isSameTag) { - return false; - } - stack || (stack = new Stack); - return equalObjects(object, other, equalFunc, customizer, bitmask, stack); +// When the API is rate limiting, the request is retried later +const shouldRetry = function(response, index) { + return response.status === RATE_LIMIT_STATUS && index !== MAX_RETRY } -/** - * The base implementation of `_.isMatch` without support for iteratee shorthands. - * - * @private - * @param {Object} object The object to inspect. - * @param {Object} source The object of property values to match. - * @param {Array} matchData The property names, values, and compare flags to match. - * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if `object` is a match, else `false`. - */ -function baseIsMatch(object, source, matchData, customizer) { - var index = matchData.length, - length = index, - noCustomizer = !customizer; +const waitForRetry = async function(response) { + const delay = getDelay(response) + await sleep(delay) +} - if (object == null) { - return !length; - } - object = Object(object); - while (index--) { - var data = matchData[index]; - if ((noCustomizer && data[2]) - ? data[1] !== object[data[0]] - : !(data[0] in object) - ) { - return false; - } - } - while (++index < length) { - data = matchData[index]; - var key = data[0], - objValue = object[key], - srcValue = data[1]; +const getDelay = function({ headers }) { + const rateLimitReset = headers.get(RATE_LIMIT_HEADER) - if (noCustomizer && data[2]) { - if (objValue === undefined && !(key in object)) { - return false; - } - } else { - var stack = new Stack; - if (customizer) { - var result = customizer(objValue, srcValue, key, object, source, stack); - } - if (!(result === undefined - ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) - : result - )) { - return false; - } - } + if (!rateLimitReset) { + return DEFAULT_RETRY_DELAY } - return true; -} -/** - * The base implementation of `_.isNative` without bad shim checks. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a native function, - * else `false`. - */ -function baseIsNative(value) { - if (!isObject(value) || isMasked(value)) { - return false; - } - var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor; - return pattern.test(toSource(value)); + return Math.max(Number(rateLimitReset) * SECS_TO_MSECS - Date.now(), MIN_RETRY_DELAY) } -/** - * The base implementation of `_.isTypedArray` without Node.js optimizations. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - */ -function baseIsTypedArray(value) { - return isObjectLike(value) && - isLength(value.length) && !!typedArrayTags[objectToString.call(value)]; +const sleep = function(ms) { + return new Promise(resolve => setTimeout(resolve, ms)) } -/** - * The base implementation of `_.iteratee`. - * - * @private - * @param {*} [value=_.identity] The value to convert to an iteratee. - * @returns {Function} Returns the iteratee. - */ -function baseIteratee(value) { - // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. - // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. - if (typeof value == 'function') { - return value; - } - if (value == null) { - return identity; - } - if (typeof value == 'object') { - return isArray(value) - ? baseMatchesProperty(value[0], value[1]) - : baseMatches(value); - } - return property(value); -} +const DEFAULT_RETRY_DELAY = 5e3 +const MIN_RETRY_DELAY = 1e3 +const SECS_TO_MSECS = 1e3 +const MAX_RETRY = 10 +const RATE_LIMIT_STATUS = 429 +const RATE_LIMIT_HEADER = 'X-RateLimit-Reset' -/** - * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - */ -function baseKeys(object) { - if (!isPrototype(object)) { - return nativeKeys(object); - } - var result = []; - for (var key in Object(object)) { - if (hasOwnProperty.call(object, key) && key != 'constructor') { - result.push(key); - } - } - return result; -} +module.exports = { shouldRetry, waitForRetry, MAX_RETRY } -/** - * The base implementation of `_.matches` which doesn't clone `source`. - * - * @private - * @param {Object} source The object of property values to match. - * @returns {Function} Returns the new spec function. - */ -function baseMatches(source) { - var matchData = getMatchData(source); - if (matchData.length == 1 && matchData[0][2]) { - return matchesStrictComparable(matchData[0][0], matchData[0][1]); - } - return function(object) { - return object === source || baseIsMatch(object, source, matchData); - }; -} -/** - * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. - * - * @private - * @param {string} path The path of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ -function baseMatchesProperty(path, srcValue) { - if (isKey(path) && isStrictComparable(srcValue)) { - return matchesStrictComparable(toKey(path), srcValue); - } - return function(object) { - var objValue = get(object, path); - return (objValue === undefined && objValue === srcValue) - ? hasIn(object, path) - : baseIsEqual(srcValue, objValue, undefined, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG); - }; -} +/***/ }), +/* 709 */, +/* 710 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { -/** - * A specialized version of `baseProperty` which supports deep paths. - * - * @private - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. - */ -function basePropertyDeep(path) { - return function(object) { - return baseGet(object, path); - }; -} +"use strict"; -/** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ -function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} -/** - * Casts `value` to a path array if it's not one. - * - * @private - * @param {*} value The value to inspect. - * @returns {Array} Returns the cast property path array. - */ -function castPath(value) { - return isArray(value) ? value : stringToPath(value); -} +Object.defineProperty(exports, "__esModule", { + value: true +}); -/** - * Creates a base function for methods like `_.forIn` and `_.forOwn`. - * - * @private - * @param {boolean} [fromRight] Specify iterating from right to left. - * @returns {Function} Returns the new base function. - */ -function createBaseFor(fromRight) { - return function(object, iteratee, keysFunc) { - var index = -1, - iterable = Object(object), - props = keysFunc(object), - length = props.length; +var _buffer = __webpack_require__(407); - while (length--) { - var key = props[fromRight ? length : ++index]; - if (iteratee(iterable[key], key, iterable) === false) { - break; - } - } - return object; - }; -} +var _create_buffer = __webpack_require__(346); -/** - * A specialized version of `baseIsEqualDeep` for arrays with support for - * partial deep comparisons. - * - * @private - * @param {Array} array The array to compare. - * @param {Array} other The other array to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} stack Tracks traversed `array` and `other` objects. - * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. - */ -function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { - var isPartial = bitmask & PARTIAL_COMPARE_FLAG, - arrLength = array.length, - othLength = other.length; +var _create_buffer2 = _interopRequireDefault(_create_buffer); - if (arrLength != othLength && !(isPartial && othLength > arrLength)) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(array); - if (stacked && stack.get(other)) { - return stacked == other; - } - var index = -1, - result = true, - seen = (bitmask & UNORDERED_COMPARE_FLAG) ? new SetCache : undefined; +var _define_crc = __webpack_require__(200); - stack.set(array, other); - stack.set(other, array); +var _define_crc2 = _interopRequireDefault(_define_crc); - // Ignore non-index properties. - while (++index < arrLength) { - var arrValue = array[index], - othValue = other[index]; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - if (customizer) { - var compared = isPartial - ? customizer(othValue, arrValue, index, other, array, stack) - : customizer(arrValue, othValue, index, array, other, stack); - } - if (compared !== undefined) { - if (compared) { - continue; - } - result = false; - break; - } - // Recursively compare arrays (susceptible to call stack limits). - if (seen) { - if (!arraySome(other, function(othValue, othIndex) { - if (!seen.has(othIndex) && - (arrValue === othValue || equalFunc(arrValue, othValue, customizer, bitmask, stack))) { - return seen.add(othIndex); - } - })) { - result = false; - break; - } - } else if (!( - arrValue === othValue || - equalFunc(arrValue, othValue, customizer, bitmask, stack) - )) { - result = false; - break; - } +// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c` +// prettier-ignore +var TABLE = [0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78]; + +if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); + +var crc16kermit = (0, _define_crc2.default)('kermit', function (buf, previous) { + if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); + + var crc = typeof previous !== 'undefined' ? ~~previous : 0x0000; + + for (var index = 0; index < buf.length; index++) { + var byte = buf[index]; + crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; } - stack['delete'](array); - stack['delete'](other); - return result; -} -/** - * A specialized version of `baseIsEqualDeep` for comparing objects of - * the same `toStringTag`. - * - * **Note:** This function only supports comparing values with tags of - * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {string} tag The `toStringTag` of the objects to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) { - switch (tag) { - case dataViewTag: - if ((object.byteLength != other.byteLength) || - (object.byteOffset != other.byteOffset)) { - return false; - } - object = object.buffer; - other = other.buffer; + return crc; +}); - case arrayBufferTag: - if ((object.byteLength != other.byteLength) || - !equalFunc(new Uint8Array(object), new Uint8Array(other))) { - return false; - } - return true; +exports.default = crc16kermit; - case boolTag: - case dateTag: - case numberTag: - // Coerce booleans to `1` or `0` and dates to milliseconds. - // Invalid dates are coerced to `NaN`. - return eq(+object, +other); - case errorTag: - return object.name == other.name && object.message == other.message; +/***/ }), +/* 711 */, +/* 712 */ +/***/ (function(module, __unusedexports, __webpack_require__) { - case regexpTag: - case stringTag: - // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring - // for more details. - return object == (other + ''); +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. - case mapTag: - var convert = mapToArray; +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. - case setTag: - var isPartial = bitmask & PARTIAL_COMPARE_FLAG; - convert || (convert = setToArray); - if (object.size != other.size && !isPartial) { - return false; - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked) { - return stacked == other; - } - bitmask |= UNORDERED_COMPARE_FLAG; - // Recursively compare objects (susceptible to call stack limits). - stack.set(object, other); - var result = equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask, stack); - stack['delete'](object); - return result; +module.exports = Transform; - case symbolTag: - if (symbolValueOf) { - return symbolValueOf.call(object) == symbolValueOf.call(other); - } - } - return false; -} +var Duplex = __webpack_require__(361); -/** - * A specialized version of `baseIsEqualDeep` for objects with support for - * partial deep comparisons. - * - * @private - * @param {Object} object The object to compare. - * @param {Object} other The other object to compare. - * @param {Function} equalFunc The function to determine equivalents of values. - * @param {Function} customizer The function to customize comparisons. - * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` - * for more details. - * @param {Object} stack Tracks traversed `object` and `other` objects. - * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. - */ -function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { - var isPartial = bitmask & PARTIAL_COMPARE_FLAG, - objProps = keys(object), - objLength = objProps.length, - othProps = keys(other), - othLength = othProps.length; +/**/ +var util = Object.create(__webpack_require__(286)); +util.inherits = __webpack_require__(689); +/**/ - if (objLength != othLength && !isPartial) { - return false; - } - var index = objLength; - while (index--) { - var key = objProps[index]; - if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { - return false; - } - } - // Assume cyclic values are equal. - var stacked = stack.get(object); - if (stacked && stack.get(other)) { - return stacked == other; - } - var result = true; - stack.set(object, other); - stack.set(other, object); +util.inherits(Transform, Duplex); - var skipCtor = isPartial; - while (++index < objLength) { - key = objProps[index]; - var objValue = object[key], - othValue = other[key]; +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; - if (customizer) { - var compared = isPartial - ? customizer(othValue, objValue, key, other, object, stack) - : customizer(objValue, othValue, key, object, other, stack); - } - // Recursively compare objects (susceptible to call stack limits). - if (!(compared === undefined - ? (objValue === othValue || equalFunc(objValue, othValue, customizer, bitmask, stack)) - : compared - )) { - result = false; - break; - } - skipCtor || (skipCtor = key == 'constructor'); - } - if (result && !skipCtor) { - var objCtor = object.constructor, - othCtor = other.constructor; + var cb = ts.writecb; - // Non `Object` object instances with different constructors are not equal. - if (objCtor != othCtor && - ('constructor' in object && 'constructor' in other) && - !(typeof objCtor == 'function' && objCtor instanceof objCtor && - typeof othCtor == 'function' && othCtor instanceof othCtor)) { - result = false; - } + if (!cb) { + return this.emit('error', new Error('write callback called multiple times')); } - stack['delete'](object); - stack['delete'](other); - return result; -} -/** - * Gets the data for `map`. - * - * @private - * @param {Object} map The map to query. - * @param {string} key The reference key. - * @returns {*} Returns the map data. - */ -function getMapData(map, key) { - var data = map.__data__; - return isKeyable(key) - ? data[typeof key == 'string' ? 'string' : 'hash'] - : data.map; -} + ts.writechunk = null; + ts.writecb = null; -/** - * Gets the property names, values, and compare flags of `object`. - * - * @private - * @param {Object} object The object to query. - * @returns {Array} Returns the match data of `object`. - */ -function getMatchData(object) { - var result = keys(object), - length = result.length; + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); - while (length--) { - var key = result[length], - value = object[key]; + cb(er); - result[length] = [key, value, isStrictComparable(value)]; + var rs = this._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); } - return result; -} - -/** - * Gets the native function at `key` of `object`. - * - * @private - * @param {Object} object The object to query. - * @param {string} key The key of the method to get. - * @returns {*} Returns the function if it's native, else `undefined`. - */ -function getNative(object, key) { - var value = getValue(object, key); - return baseIsNative(value) ? value : undefined; } -/** - * Gets the `toStringTag` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {string} Returns the `toStringTag`. - */ -var getTag = baseGetTag; +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); -// Fallback for data views, maps, sets, and weak maps in IE 11, -// for data views in Edge < 14, and promises in Node.js. -if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || - (Map && getTag(new Map) != mapTag) || - (Promise && getTag(Promise.resolve()) != promiseTag) || - (Set && getTag(new Set) != setTag) || - (WeakMap && getTag(new WeakMap) != weakMapTag)) { - getTag = function(value) { - var result = objectToString.call(value), - Ctor = result == objectTag ? value.constructor : undefined, - ctorString = Ctor ? toSource(Ctor) : undefined; + Duplex.call(this, options); - if (ctorString) { - switch (ctorString) { - case dataViewCtorString: return dataViewTag; - case mapCtorString: return mapTag; - case promiseCtorString: return promiseTag; - case setCtorString: return setTag; - case weakMapCtorString: return weakMapTag; - } - } - return result; + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null }; -} - -/** - * Checks if `path` exists on `object`. - * - * @private - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @param {Function} hasFunc The function to check properties. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - */ -function hasPath(object, path, hasFunc) { - path = isKey(path, object) ? [path] : castPath(path); - var result, - index = -1, - length = path.length; + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; - while (++index < length) { - var key = toKey(path[index]); - if (!(result = object != null && hasFunc(object, key))) { - break; - } - object = object[key]; - } - if (result) { - return result; - } - var length = object ? object.length : 0; - return !!length && isLength(length) && isIndex(key, length) && - (isArray(object) || isArguments(object)); -} + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; -/** - * Checks if `value` is a valid array-like index. - * - * @private - * @param {*} value The value to check. - * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. - * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. - */ -function isIndex(value, length) { - length = length == null ? MAX_SAFE_INTEGER : length; - return !!length && - (typeof value == 'number' || reIsUint.test(value)) && - (value > -1 && value % 1 == 0 && value < length); -} + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; -/** - * Checks if `value` is a property name and not a property path. - * - * @private - * @param {*} value The value to check. - * @param {Object} [object] The object to query keys on. - * @returns {boolean} Returns `true` if `value` is a property name, else `false`. - */ -function isKey(value, object) { - if (isArray(value)) { - return false; - } - var type = typeof value; - if (type == 'number' || type == 'symbol' || type == 'boolean' || - value == null || isSymbol(value)) { - return true; + if (typeof options.flush === 'function') this._flush = options.flush; } - return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || - (object != null && value in Object(object)); -} - -/** - * Checks if `value` is suitable for use as unique object key. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is suitable, else `false`. - */ -function isKeyable(value) { - var type = typeof value; - return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') - ? (value !== '__proto__') - : (value === null); -} -/** - * Checks if `func` has its source masked. - * - * @private - * @param {Function} func The function to check. - * @returns {boolean} Returns `true` if `func` is masked, else `false`. - */ -function isMasked(func) { - return !!maskSrcKey && (maskSrcKey in func); + // When the writable side finishes, then flush out anything remaining. + this.on('prefinish', prefinish); } -/** - * Checks if `value` is likely a prototype object. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. - */ -function isPrototype(value) { - var Ctor = value && value.constructor, - proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; +function prefinish() { + var _this = this; - return value === proto; + if (typeof this._flush === 'function') { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } } -/** - * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. - * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` if suitable for strict - * equality comparisons, else `false`. - */ -function isStrictComparable(value) { - return value === value && !isObject(value); -} - -/** - * A specialized version of `matchesProperty` for source values suitable - * for strict equality comparisons, i.e. `===`. - * - * @private - * @param {string} key The key of the property to get. - * @param {*} srcValue The value to match. - * @returns {Function} Returns the new spec function. - */ -function matchesStrictComparable(key, srcValue) { - return function(object) { - if (object == null) { - return false; - } - return object[key] === srcValue && - (srcValue !== undefined || (key in Object(object))); - }; -} +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; -/** - * Converts `string` to a property path array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the property path array. - */ -var stringToPath = memoize(function(string) { - string = toString(string); +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('_transform() is not implemented'); +}; - var result = []; - if (reLeadingDot.test(string)) { - result.push(''); +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); } - string.replace(rePropName, function(match, number, quote, string) { - result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); - }); - return result; -}); +}; -/** - * Converts `value` to a string key if it's not a string or symbol. - * - * @private - * @param {*} value The value to inspect. - * @returns {string|symbol} Returns the key. - */ -function toKey(value) { - if (typeof value == 'string' || isSymbol(value)) { - return value; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; -/** - * Converts `func` to its source code. - * - * @private - * @param {Function} func The function to process. - * @returns {string} Returns the source code. - */ -function toSource(func) { - if (func != null) { - try { - return funcToString.call(func); - } catch (e) {} - try { - return (func + ''); - } catch (e) {} + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; } - return ''; -} +}; -/** - * Creates a function that memoizes the result of `func`. If `resolver` is - * provided, it determines the cache key for storing the result based on the - * arguments provided to the memoized function. By default, the first argument - * provided to the memoized function is used as the map cache key. The `func` - * is invoked with the `this` binding of the memoized function. - * - * **Note:** The cache is exposed as the `cache` property on the memoized - * function. Its creation may be customized by replacing the `_.memoize.Cache` - * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) - * method interface of `delete`, `get`, `has`, and `set`. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Function - * @param {Function} func The function to have its output memoized. - * @param {Function} [resolver] The function to resolve the cache key. - * @returns {Function} Returns the new memoized function. - * @example - * - * var object = { 'a': 1, 'b': 2 }; - * var other = { 'c': 3, 'd': 4 }; - * - * var values = _.memoize(_.values); - * values(object); - * // => [1, 2] - * - * values(other); - * // => [3, 4] - * - * object.a = 2; - * values(object); - * // => [1, 2] - * - * // Modify the result cache. - * values.cache.set(object, ['a', 'b']); - * values(object); - * // => ['a', 'b'] - * - * // Replace `_.memoize.Cache`. - * _.memoize.Cache = WeakMap; - */ -function memoize(func, resolver) { - if (typeof func != 'function' || (resolver && typeof resolver != 'function')) { - throw new TypeError(FUNC_ERROR_TEXT); - } - var memoized = function() { - var args = arguments, - key = resolver ? resolver.apply(this, args) : args[0], - cache = memoized.cache; +Transform.prototype._destroy = function (err, cb) { + var _this2 = this; - if (cache.has(key)) { - return cache.get(key); - } - var result = func.apply(this, args); - memoized.cache = cache.set(key, result); - return result; - }; - memoized.cache = new (memoize.Cache || MapCache); - return memoized; -} + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + _this2.emit('close'); + }); +}; -// Assign cache to `_.memoize`. -memoize.Cache = MapCache; +function done(stream, er, data) { + if (er) return stream.emit('error', er); -/** - * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) - * comparison between two values to determine if they are equivalent. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to compare. - * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, else `false`. - * @example - * - * var object = { 'a': 1 }; - * var other = { 'a': 1 }; - * - * _.eq(object, object); - * // => true - * - * _.eq(object, other); - * // => false - * - * _.eq('a', 'a'); - * // => true - * - * _.eq('a', Object('a')); - * // => false - * - * _.eq(NaN, NaN); - * // => true - */ -function eq(value, other) { - return value === other || (value !== value && other !== other); -} + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); -/** - * Checks if `value` is likely an `arguments` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an `arguments` object, - * else `false`. - * @example - * - * _.isArguments(function() { return arguments; }()); - * // => true - * - * _.isArguments([1, 2, 3]); - * // => false - */ -function isArguments(value) { - // Safari 8.1 makes `arguments.callee` enumerable in strict mode. - return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') && - (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag); -} + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); -/** - * Checks if `value` is classified as an `Array` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array, else `false`. - * @example - * - * _.isArray([1, 2, 3]); - * // => true - * - * _.isArray(document.body.children); - * // => false - * - * _.isArray('abc'); - * // => false - * - * _.isArray(_.noop); - * // => false - */ -var isArray = Array.isArray; + if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); -/** - * Checks if `value` is array-like. A value is considered array-like if it's - * not a function and has a `value.length` that's an integer greater than or - * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is array-like, else `false`. - * @example - * - * _.isArrayLike([1, 2, 3]); - * // => true - * - * _.isArrayLike(document.body.children); - * // => true - * - * _.isArrayLike('abc'); - * // => true - * - * _.isArrayLike(_.noop); - * // => false - */ -function isArrayLike(value) { - return value != null && isLength(value.length) && !isFunction(value); + return stream.push(null); } -/** - * This method is like `_.isArrayLike` except that it also checks if `value` - * is an object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an array-like object, - * else `false`. - * @example - * - * _.isArrayLikeObject([1, 2, 3]); - * // => true - * - * _.isArrayLikeObject(document.body.children); - * // => true - * - * _.isArrayLikeObject('abc'); - * // => false - * - * _.isArrayLikeObject(_.noop); - * // => false - */ -function isArrayLikeObject(value) { - return isObjectLike(value) && isArrayLike(value); -} +/***/ }), +/* 713 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { -/** - * Checks if `value` is classified as a `Function` object. - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a function, else `false`. - * @example - * - * _.isFunction(_); - * // => true - * - * _.isFunction(/abc/); - * // => false - */ -function isFunction(value) { - // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 8-9 which returns 'object' for typed array and other constructors. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag; -} +"use strict"; -/** - * Checks if `value` is a valid array-like length. - * - * **Note:** This method is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. - * @example - * - * _.isLength(3); - * // => true - * - * _.isLength(Number.MIN_VALUE); - * // => false - * - * _.isLength(Infinity); - * // => false - * - * _.isLength('3'); - * // => false - */ -function isLength(value) { - return typeof value == 'number' && - value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; +Object.defineProperty(exports, "__esModule", { value: true }); +const ts = __webpack_require__(752); +const node_1 = __webpack_require__(10); +const _3_2_1 = __webpack_require__(584); +const type_1 = __webpack_require__(90); +function getChildOfKind(node, kind, sourceFile) { + for (const child of node.getChildren(sourceFile)) + if (child.kind === kind) + return child; } - -/** - * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) - * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) - * - * @static - * @memberOf _ - * @since 0.1.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an object, else `false`. - * @example - * - * _.isObject({}); - * // => true - * - * _.isObject([1, 2, 3]); - * // => true - * - * _.isObject(_.noop); - * // => true - * - * _.isObject(null); - * // => false - */ -function isObject(value) { - var type = typeof value; - return !!value && (type == 'object' || type == 'function'); +exports.getChildOfKind = getChildOfKind; +function isTokenKind(kind) { + return kind >= ts.SyntaxKind.FirstToken && kind <= ts.SyntaxKind.LastToken; } - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; +exports.isTokenKind = isTokenKind; +function isNodeKind(kind) { + return kind >= ts.SyntaxKind.FirstNode; } - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. - * @example - * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false - */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && objectToString.call(value) == symbolTag); +exports.isNodeKind = isNodeKind; +function isAssignmentKind(kind) { + return kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment; } - -/** - * Checks if `value` is classified as a typed array. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. - * @example - * - * _.isTypedArray(new Uint8Array); - * // => true - * - * _.isTypedArray([]); - * // => false - */ -var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; - -/** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {string} Returns the string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ -function toString(value) { - return value == null ? '' : baseToString(value); +exports.isAssignmentKind = isAssignmentKind; +function isTypeNodeKind(kind) { + return kind >= ts.SyntaxKind.FirstTypeNode && kind <= ts.SyntaxKind.LastTypeNode; } - -/** - * Gets the value at `path` of `object`. If the resolved value is - * `undefined`, the `defaultValue` is returned in its place. - * - * @static - * @memberOf _ - * @since 3.7.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path of the property to get. - * @param {*} [defaultValue] The value returned for `undefined` resolved values. - * @returns {*} Returns the resolved value. - * @example - * - * var object = { 'a': [{ 'b': { 'c': 3 } }] }; - * - * _.get(object, 'a[0].b.c'); - * // => 3 - * - * _.get(object, ['a', '0', 'b', 'c']); - * // => 3 - * - * _.get(object, 'a.b.c', 'default'); - * // => 'default' - */ -function get(object, path, defaultValue) { - var result = object == null ? undefined : baseGet(object, path); - return result === undefined ? defaultValue : result; +exports.isTypeNodeKind = isTypeNodeKind; +function isJsDocKind(kind) { + return kind >= ts.SyntaxKind.FirstJSDocNode && kind <= ts.SyntaxKind.LastJSDocNode; } - -/** - * Checks if `path` is a direct or inherited property of `object`. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Object - * @param {Object} object The object to query. - * @param {Array|string} path The path to check. - * @returns {boolean} Returns `true` if `path` exists, else `false`. - * @example - * - * var object = _.create({ 'a': _.create({ 'b': 2 }) }); - * - * _.hasIn(object, 'a'); - * // => true - * - * _.hasIn(object, 'a.b'); - * // => true - * - * _.hasIn(object, ['a', 'b']); - * // => true - * - * _.hasIn(object, 'b'); - * // => false - */ -function hasIn(object, path) { - return object != null && hasPath(object, path, baseHasIn); +exports.isJsDocKind = isJsDocKind; +function isKeywordKind(kind) { + return kind >= ts.SyntaxKind.FirstKeyword && kind <= ts.SyntaxKind.LastKeyword; } - -/** - * Creates an array of the own enumerable property names of `object`. - * - * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) - * for more details. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Object - * @param {Object} object The object to query. - * @returns {Array} Returns the array of property names. - * @example - * - * function Foo() { - * this.a = 1; - * this.b = 2; - * } - * - * Foo.prototype.c = 3; - * - * _.keys(new Foo); - * // => ['a', 'b'] (iteration order is not guaranteed) - * - * _.keys('hi'); - * // => ['0', '1'] - */ -function keys(object) { - return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); +exports.isKeywordKind = isKeywordKind; +function isThisParameter(parameter) { + return parameter.name.kind === ts.SyntaxKind.Identifier && parameter.name.originalKeywordKind === ts.SyntaxKind.ThisKeyword; } - -/** - * An alternative to `_.reduce`; this method transforms `object` to a new - * `accumulator` object which is the result of running each of its own - * enumerable string keyed properties thru `iteratee`, with each invocation - * potentially mutating the `accumulator` object. If `accumulator` is not - * provided, a new object with the same `[[Prototype]]` will be used. The - * iteratee is invoked with four arguments: (accumulator, value, key, object). - * Iteratee functions may exit iteration early by explicitly returning `false`. - * - * @static - * @memberOf _ - * @since 1.3.0 - * @category Object - * @param {Object} object The object to iterate over. - * @param {Function} [iteratee=_.identity] The function invoked per iteration. - * @param {*} [accumulator] The custom accumulator value. - * @returns {*} Returns the accumulated value. - * @example - * - * _.transform([2, 3, 4], function(result, n) { - * result.push(n *= n); - * return n % 2 == 0; - * }, []); - * // => [4, 9] - * - * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { - * (result[value] || (result[value] = [])).push(key); - * }, {}); - * // => { '1': ['a', 'c'], '2': ['b'] } - */ -function transform(object, iteratee, accumulator) { - var isArr = isArray(object) || isTypedArray(object); - iteratee = baseIteratee(iteratee, 4); - - if (accumulator == null) { - if (isArr || isObject(object)) { - var Ctor = object.constructor; - if (isArr) { - accumulator = isArray(object) ? new Ctor : []; - } else { - accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; - } - } else { - accumulator = {}; +exports.isThisParameter = isThisParameter; +function getModifier(node, kind) { + if (node.modifiers !== undefined) + for (const modifier of node.modifiers) + if (modifier.kind === kind) + return modifier; +} +exports.getModifier = getModifier; +function hasModifier(modifiers, ...kinds) { + if (modifiers === undefined) + return false; + for (const modifier of modifiers) + if (kinds.includes(modifier.kind)) + return true; + return false; +} +exports.hasModifier = hasModifier; +function isParameterProperty(node) { + return hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ReadonlyKeyword); +} +exports.isParameterProperty = isParameterProperty; +function hasAccessModifier(node) { + return hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword); +} +exports.hasAccessModifier = hasAccessModifier; +function isFlagSet(obj, flag) { + return (obj.flags & flag) !== 0; +} +exports.isNodeFlagSet = isFlagSet; +exports.isTypeFlagSet = isFlagSet; +exports.isSymbolFlagSet = isFlagSet; +function isObjectFlagSet(objectType, flag) { + return (objectType.objectFlags & flag) !== 0; +} +exports.isObjectFlagSet = isObjectFlagSet; +function isModifierFlagSet(node, flag) { + return (ts.getCombinedModifierFlags(node) & flag) !== 0; +} +exports.isModifierFlagSet = isModifierFlagSet; +function getPreviousStatement(statement) { + const parent = statement.parent; + if (node_1.isBlockLike(parent)) { + const index = parent.statements.indexOf(statement); + if (index > 0) + return parent.statements[index - 1]; } - } - (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) { - return iteratee(accumulator, value, index, object); - }); - return accumulator; } - -/** - * This method returns the first argument it receives. - * - * @static - * @since 0.1.0 - * @memberOf _ - * @category Util - * @param {*} value Any value. - * @returns {*} Returns `value`. - * @example - * - * var object = { 'a': 1 }; - * - * console.log(_.identity(object) === object); - * // => true - */ -function identity(value) { - return value; +exports.getPreviousStatement = getPreviousStatement; +function getNextStatement(statement) { + const parent = statement.parent; + if (node_1.isBlockLike(parent)) { + const index = parent.statements.indexOf(statement); + if (index < parent.statements.length) + return parent.statements[index + 1]; + } } - -/** - * Creates a function that returns the value at `path` of a given object. - * - * @static - * @memberOf _ - * @since 2.4.0 - * @category Util - * @param {Array|string} path The path of the property to get. - * @returns {Function} Returns the new accessor function. - * @example - * - * var objects = [ - * { 'a': { 'b': 2 } }, - * { 'a': { 'b': 1 } } - * ]; - * - * _.map(objects, _.property('a.b')); - * // => [2, 1] - * - * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); - * // => [1, 2] - */ -function property(path) { - return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); +exports.getNextStatement = getNextStatement; +function getPreviousToken(node, sourceFile) { + let parent = node.parent; + while (parent !== undefined && parent.pos === node.pos) + parent = parent.parent; + if (parent === undefined) + return; + outer: while (true) { + const children = parent.getChildren(sourceFile); + for (let i = children.length - 1; i >= 0; --i) { + const child = children[i]; + if (child.pos < node.pos && child.kind !== ts.SyntaxKind.JSDocComment) { + if (isTokenKind(child.kind)) + return child; + parent = child; + continue outer; + } + } + return; + } } - -module.exports = transform; - - -/***/ }), -/* 705 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SectionHeader = __webpack_require__(392); - -/** - * The string table is used to store section and symbol names. In the ELF image, it consists - * of a sequence of null-terminated ASCII strings. - */ -class StringTable { - constructor(arg) { - if (typeof arg === 'object') { - // from StringTable.parse() - Object.assign(this, arg); - return; +exports.getPreviousToken = getPreviousToken; +function getNextToken(node, sourceFile = node.getSourceFile()) { + if (node.kind === ts.SyntaxKind.SourceFile || node.kind === ts.SyntaxKind.EndOfFileToken) + return; + const end = node.end; + node = node.parent; + while (node.end === end) { + if (node.parent === undefined) + return node.endOfFileToken; + node = node.parent; } - - this.strings = ''; - this.section_header = new SectionHeader({ - name: arg, - type: 'strtab', - flags: '', - addr: 0, - offset: null, - size: null, - link: 0, - info: 0, - addralign: 1, - entsize: 0, - }); - } - - static parse({ header, data }) { - return new StringTable({ - section_header: header, - strings: data.toString(StringTable.ENCODING), - }); - } - - add_string(str) { - return this.getStringOffset(str, true); - } - - /** - * Returns the offset into the table of the specified string - * @param {string} str string to locate - * @param {boolean} [add] optional - automatically add the string if it's not in the table - */ - getStringOffset(str, add = false) { - // strings are a concatenated list of null-terminated values - const str0 = str + '\0'; - let offset = this.strings.indexOf(str0); - if (offset < 0) { - if (!add) { - throw new Error(`String '${str}' not found in string table`); - } - offset = this.strings.length; - this.strings += str0; + return getTokenAtPositionWorker(node, end, sourceFile, false); +} +exports.getNextToken = getNextToken; +function getTokenAtPosition(parent, pos, sourceFile, allowJsDoc) { + if (pos < parent.pos || pos >= parent.end) + return; + if (isTokenKind(parent.kind)) + return parent; + if (sourceFile === undefined) + sourceFile = parent.getSourceFile(); + return getTokenAtPositionWorker(parent, pos, sourceFile, allowJsDoc === true); +} +exports.getTokenAtPosition = getTokenAtPosition; +function getTokenAtPositionWorker(node, pos, sourceFile, allowJsDoc) { + outer: while (true) { + for (const child of node.getChildren(sourceFile)) { + if (child.end > pos && (allowJsDoc || child.kind !== ts.SyntaxKind.JSDocComment)) { + if (isTokenKind(child.kind)) + return child; + node = child; + continue outer; + } + } + return; } - return offset; - } - - // retrieve the string from the table at the given offset - getString(offset) { - if (offset < 0 || offset >= this.strings.length) - throw new RangeError(`Offset out of range of string table. Offset=${offset}, Table length=${this.strings.length}`); - const s = this.strings.slice(offset, this.strings.indexOf('\0', offset)); - return s; - } - - calculate_size(elf_offset) { - this.elf_offset = this.section_header.offset = elf_offset; - // ELF only allows ascii chars, so bytes = length - this.elf_size = this.section_header.size = this.strings.length; - return this.elf_size; - } - - write(stream) { - stream.writeBuf(Buffer.from(this.strings, StringTable.ENCODING)); - } } - -StringTable.ENCODING = 'ascii'; - -module.exports = StringTable; - - -/***/ }), -/* 706 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -/** - * JSON Format Plugin - * - * @module plugins/json - * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE} - * @copyright (c) 2012-2014 Chris Talkington, contributors. - */ -var inherits = __webpack_require__(669).inherits; -var Transform = __webpack_require__(574).Transform; - -var crc32 = __webpack_require__(538); -var util = __webpack_require__(108); - -/** - * @constructor - * @param {(JsonOptions|TransformOptions)} options - */ -var Json = function(options) { - if (!(this instanceof Json)) { - return new Json(options); - } - - options = this.options = util.defaults(options, {}); - - Transform.call(this, options); - - this.supports = { - directory: true, - symlink: true - }; - - this.files = []; -}; - -inherits(Json, Transform); - -/** - * [_transform description] - * - * @private - * @param {Buffer} chunk - * @param {String} encoding - * @param {Function} callback - * @return void - */ -Json.prototype._transform = function(chunk, encoding, callback) { - callback(null, chunk); -}; - -/** - * [_writeStringified description] - * - * @private - * @return void - */ -Json.prototype._writeStringified = function() { - var fileString = JSON.stringify(this.files); - this.write(fileString); -}; - -/** - * [append description] - * - * @param {(Buffer|Stream)} source - * @param {EntryData} data - * @param {Function} callback - * @return void - */ -Json.prototype.append = function(source, data, callback) { - var self = this; - - data.crc32 = 0; - - function onend(err, sourceBuffer) { - if (err) { - callback(err); - return; - } - - data.size = sourceBuffer.length || 0; - data.crc32 = crc32.unsigned(sourceBuffer); - - self.files.push(data); - - callback(null, data); - } - - if (data.sourceType === 'buffer') { - onend(null, source); - } else if (data.sourceType === 'stream') { - util.collectStream(source, onend); - } -}; - -/** - * [finalize description] - * - * @return void - */ -Json.prototype.finalize = function() { - this._writeStringified(); - this.end(); -}; - -module.exports = Json; - -/** - * @typedef {Object} JsonOptions - * @global - */ - - -/***/ }), -/* 707 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -module.exports = __webpack_require__(651).default; - - -/***/ }), -/* 708 */, -/* 709 */, -/* 710 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _buffer = __webpack_require__(407); - -var _create_buffer = __webpack_require__(346); - -var _create_buffer2 = _interopRequireDefault(_create_buffer); - -var _define_crc = __webpack_require__(200); - -var _define_crc2 = _interopRequireDefault(_define_crc); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// Generated by `./pycrc.py --algorithm=table-driven --model=kermit --generate=c` -// prettier-ignore -var TABLE = [0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78]; - -if (typeof Int32Array !== 'undefined') TABLE = new Int32Array(TABLE); - -var crc16kermit = (0, _define_crc2.default)('kermit', function (buf, previous) { - if (!_buffer.Buffer.isBuffer(buf)) buf = (0, _create_buffer2.default)(buf); - - var crc = typeof previous !== 'undefined' ? ~~previous : 0x0000; - - for (var index = 0; index < buf.length; index++) { - var byte = buf[index]; - crc = (TABLE[(crc ^ byte) & 0xff] ^ crc >> 8) & 0xffff; - } - - return crc; -}); - -exports.default = crc16kermit; - - -/***/ }), -/* 711 */, -/* 712 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// a transform stream is a readable/writable stream where you do -// something with the data. Sometimes it's called a "filter", -// but that's not a great name for it, since that implies a thing where -// some bits pass through, and others are simply ignored. (That would -// be a valid example of a transform, of course.) -// -// While the output is causally related to the input, it's not a -// necessarily symmetric or synchronous transformation. For example, -// a zlib stream might take multiple plain-text writes(), and then -// emit a single compressed chunk some time in the future. -// -// Here's how this works: -// -// The Transform stream has all the aspects of the readable and writable -// stream classes. When you write(chunk), that calls _write(chunk,cb) -// internally, and returns false if there's a lot of pending writes -// buffered up. When you call read(), that calls _read(n) until -// there's enough pending readable data buffered up. -// -// In a transform stream, the written data is placed in a buffer. When -// _read(n) is called, it transforms the queued up data, calling the -// buffered _write cb's as it consumes chunks. If consuming a single -// written chunk would result in multiple output chunks, then the first -// outputted bit calls the readcb, and subsequent chunks just go into -// the read buffer, and will cause it to emit 'readable' if necessary. -// -// This way, back-pressure is actually determined by the reading side, -// since _read has to be called to start processing a new chunk. However, -// a pathological inflate type of transform can cause excessive buffering -// here. For example, imagine a stream where every byte of input is -// interpreted as an integer from 0-255, and then results in that many -// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in -// 1kb of data being output. In this case, you could write a very small -// amount of input, and end up with a very large amount of output. In -// such a pathological inflating mechanism, there'd be no way to tell -// the system to stop doing the transform. A single 4MB write could -// cause the system to run out of memory. -// -// However, even in such a pathological case, only a single written chunk -// would be consumed, and then the rest would wait (un-transformed) until -// the results of the previous transformed chunk were consumed. - - - -module.exports = Transform; - -var Duplex = __webpack_require__(361); - -/**/ -var util = Object.create(__webpack_require__(286)); -util.inherits = __webpack_require__(689); -/**/ - -util.inherits(Transform, Duplex); - -function afterTransform(er, data) { - var ts = this._transformState; - ts.transforming = false; - - var cb = ts.writecb; - - if (!cb) { - return this.emit('error', new Error('write callback called multiple times')); - } - - ts.writechunk = null; - ts.writecb = null; - - if (data != null) // single equals check for both `null` and `undefined` - this.push(data); - - cb(er); - - var rs = this._readableState; - rs.reading = false; - if (rs.needReadable || rs.length < rs.highWaterMark) { - this._read(rs.highWaterMark); - } -} - -function Transform(options) { - if (!(this instanceof Transform)) return new Transform(options); - - Duplex.call(this, options); - - this._transformState = { - afterTransform: afterTransform.bind(this), - needTransform: false, - transforming: false, - writecb: null, - writechunk: null, - writeencoding: null - }; - - // start out asking for a readable event once data is transformed. - this._readableState.needReadable = true; - - // we have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - this._readableState.sync = false; - - if (options) { - if (typeof options.transform === 'function') this._transform = options.transform; - - if (typeof options.flush === 'function') this._flush = options.flush; - } - - // When the writable side finishes, then flush out anything remaining. - this.on('prefinish', prefinish); +function getCommentAtPosition(sourceFile, pos, parent = sourceFile) { + const token = getTokenAtPosition(parent, pos, sourceFile); + if (token === undefined || token.kind === ts.SyntaxKind.JsxText || pos >= token.end - (ts.tokenToString(token.kind) || '').length) + return; + const startPos = token.pos === 0 + ? (ts.getShebang(sourceFile.text) || '').length + : token.pos; + return startPos !== 0 && ts.forEachTrailingCommentRange(sourceFile.text, startPos, commentAtPositionCallback, pos) || + ts.forEachLeadingCommentRange(sourceFile.text, startPos, commentAtPositionCallback, pos); } - -function prefinish() { - var _this = this; - - if (typeof this._flush === 'function') { - this._flush(function (er, data) { - done(_this, er, data); - }); - } else { - done(this, null, null); - } +exports.getCommentAtPosition = getCommentAtPosition; +function commentAtPositionCallback(pos, end, kind, _nl, at) { + return at >= pos && at < end ? { pos, end, kind } : undefined; } - -Transform.prototype.push = function (chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); -}; - -// This is the part where you do stuff! -// override this function in implementation classes. -// 'chunk' is an input chunk. -// -// Call `push(newChunk)` to pass along transformed output -// to the readable side. You may call 'push' zero or more times. -// -// Call `cb(err)` when you are done with this chunk. If you pass -// an error, then that'll put the hurt on the whole operation. If you -// never call cb(), then you'll never get another chunk. -Transform.prototype._transform = function (chunk, encoding, cb) { - throw new Error('_transform() is not implemented'); -}; - -Transform.prototype._write = function (chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); - } -}; - -// Doesn't matter what the args are here. -// _transform does all the work. -// That we got here means that the readable side wants more data. -Transform.prototype._read = function (n) { - var ts = this._transformState; - - if (ts.writechunk !== null && ts.writecb && !ts.transforming) { - ts.transforming = true; - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; - } -}; - -Transform.prototype._destroy = function (err, cb) { - var _this2 = this; - - Duplex.prototype._destroy.call(this, err, function (err2) { - cb(err2); - _this2.emit('close'); - }); -}; - -function done(stream, er, data) { - if (er) return stream.emit('error', er); - - if (data != null) // single equals check for both `null` and `undefined` - stream.push(data); - - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0'); - - if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming'); - - return stream.push(null); +function isPositionInComment(sourceFile, pos, parent) { + return getCommentAtPosition(sourceFile, pos, parent) !== undefined; } - -/***/ }), -/* 713 */, -/* 714 */, -/* 715 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ - -var base64VLQ = __webpack_require__(474); -var util = __webpack_require__(737); -var ArraySet = __webpack_require__(998).ArraySet; -var MappingList = __webpack_require__(468).MappingList; - -/** - * An instance of the SourceMapGenerator represents a source map which is - * being built incrementally. You may pass an object with the following - * properties: - * - * - file: The filename of the generated source. - * - sourceRoot: A root for all relative URLs in this source map. - */ -function SourceMapGenerator(aArgs) { - if (!aArgs) { - aArgs = {}; - } - this._file = util.getArg(aArgs, 'file', null); - this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); - this._skipValidation = util.getArg(aArgs, 'skipValidation', false); - this._sources = new ArraySet(); - this._names = new ArraySet(); - this._mappings = new MappingList(); - this._sourcesContents = null; +exports.isPositionInComment = isPositionInComment; +function commentText(sourceText, comment) { + return sourceText.substring(comment.pos + 2, comment.kind === ts.SyntaxKind.SingleLineCommentTrivia ? comment.end : comment.end - 2); } - -SourceMapGenerator.prototype._version = 3; - -/** - * Creates a new SourceMapGenerator based on a SourceMapConsumer - * - * @param aSourceMapConsumer The SourceMap. - */ -SourceMapGenerator.fromSourceMap = - function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { - var sourceRoot = aSourceMapConsumer.sourceRoot; - var generator = new SourceMapGenerator({ - file: aSourceMapConsumer.file, - sourceRoot: sourceRoot - }); - aSourceMapConsumer.eachMapping(function (mapping) { - var newMapping = { - generated: { - line: mapping.generatedLine, - column: mapping.generatedColumn +exports.commentText = commentText; +function getWrappedNodeAtPosition(wrap, pos) { + if (wrap.node.pos > pos || wrap.node.end <= pos) + return; + outer: while (true) { + for (const child of wrap.children) { + if (child.node.pos > pos) + return wrap; + if (child.node.end > pos) { + wrap = child; + continue outer; + } } - }; - - if (mapping.source != null) { - newMapping.source = mapping.source; - if (sourceRoot != null) { - newMapping.source = util.relative(sourceRoot, newMapping.source); + return wrap; + } +} +exports.getWrappedNodeAtPosition = getWrappedNodeAtPosition; +function getPropertyName(propertyName) { + if (propertyName.kind === ts.SyntaxKind.ComputedPropertyName) { + if (!node_1.isLiteralExpression(propertyName.expression)) + return; + if (_3_2_1.isBigIntLiteral(propertyName.expression)) + return propertyName.expression.text.slice(0, -1); + return propertyName.expression.text; + } + return propertyName.text; +} +exports.getPropertyName = getPropertyName; +function forEachDestructuringIdentifier(pattern, fn) { + for (const element of pattern.elements) { + if (element.kind !== ts.SyntaxKind.BindingElement) + continue; + let result; + if (element.name.kind === ts.SyntaxKind.Identifier) { + result = fn(element); } - - newMapping.original = { - line: mapping.originalLine, - column: mapping.originalColumn - }; - - if (mapping.name != null) { - newMapping.name = mapping.name; + else { + result = forEachDestructuringIdentifier(element.name, fn); } - } - - generator.addMapping(newMapping); - }); - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var sourceRelative = sourceFile; - if (sourceRoot !== null) { - sourceRelative = util.relative(sourceRoot, sourceFile); - } - - if (!generator._sources.has(sourceRelative)) { - generator._sources.add(sourceRelative); - } - - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content != null) { - generator.setSourceContent(sourceFile, content); - } - }); - return generator; - }; - -/** - * Add a single mapping from original source line and column to the generated - * source's line and column for this source map being created. The mapping - * object should have the following properties: - * - * - generated: An object with the generated line and column positions. - * - original: An object with the original line and column positions. - * - source: The original source file (relative to the sourceRoot). - * - name: An optional original token name for this mapping. - */ -SourceMapGenerator.prototype.addMapping = - function SourceMapGenerator_addMapping(aArgs) { - var generated = util.getArg(aArgs, 'generated'); - var original = util.getArg(aArgs, 'original', null); - var source = util.getArg(aArgs, 'source', null); - var name = util.getArg(aArgs, 'name', null); - - if (!this._skipValidation) { - this._validateMapping(generated, original, source, name); + if (result) + return result; } - - if (source != null) { - source = String(source); - if (!this._sources.has(source)) { - this._sources.add(source); - } +} +exports.forEachDestructuringIdentifier = forEachDestructuringIdentifier; +function forEachDeclaredVariable(declarationList, cb) { + for (const declaration of declarationList.declarations) { + let result; + if (declaration.name.kind === ts.SyntaxKind.Identifier) { + result = cb(declaration); + } + else { + result = forEachDestructuringIdentifier(declaration.name, cb); + } + if (result) + return result; } - - if (name != null) { - name = String(name); - if (!this._names.has(name)) { - this._names.add(name); - } +} +exports.forEachDeclaredVariable = forEachDeclaredVariable; +var VariableDeclarationKind; +(function (VariableDeclarationKind) { + VariableDeclarationKind[VariableDeclarationKind["Var"] = 0] = "Var"; + VariableDeclarationKind[VariableDeclarationKind["Let"] = 1] = "Let"; + VariableDeclarationKind[VariableDeclarationKind["Const"] = 2] = "Const"; +})(VariableDeclarationKind = exports.VariableDeclarationKind || (exports.VariableDeclarationKind = {})); +function getVariableDeclarationKind(declarationList) { + if (declarationList.flags & ts.NodeFlags.Let) + return 1; + if (declarationList.flags & ts.NodeFlags.Const) + return 2; + return 0; +} +exports.getVariableDeclarationKind = getVariableDeclarationKind; +function isBlockScopedVariableDeclarationList(declarationList) { + return (declarationList.flags & ts.NodeFlags.BlockScoped) !== 0; +} +exports.isBlockScopedVariableDeclarationList = isBlockScopedVariableDeclarationList; +function isBlockScopedVariableDeclaration(declaration) { + const parent = declaration.parent; + return parent.kind === ts.SyntaxKind.CatchClause || + isBlockScopedVariableDeclarationList(parent); +} +exports.isBlockScopedVariableDeclaration = isBlockScopedVariableDeclaration; +function isBlockScopedDeclarationStatement(statement) { + switch (statement.kind) { + case ts.SyntaxKind.VariableStatement: + return isBlockScopedVariableDeclarationList(statement.declarationList); + case ts.SyntaxKind.ClassDeclaration: + case ts.SyntaxKind.EnumDeclaration: + case ts.SyntaxKind.InterfaceDeclaration: + case ts.SyntaxKind.TypeAliasDeclaration: + return true; + default: + return false; } - - this._mappings.add({ - generatedLine: generated.line, - generatedColumn: generated.column, - originalLine: original != null && original.line, - originalColumn: original != null && original.column, - source: source, - name: name - }); - }; - -/** - * Set the source content for a source file. - */ -SourceMapGenerator.prototype.setSourceContent = - function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { - var source = aSourceFile; - if (this._sourceRoot != null) { - source = util.relative(this._sourceRoot, source); +} +exports.isBlockScopedDeclarationStatement = isBlockScopedDeclarationStatement; +function isInSingleStatementContext(statement) { + switch (statement.parent.kind) { + case ts.SyntaxKind.ForStatement: + case ts.SyntaxKind.ForInStatement: + case ts.SyntaxKind.ForOfStatement: + case ts.SyntaxKind.WhileStatement: + case ts.SyntaxKind.DoStatement: + case ts.SyntaxKind.IfStatement: + case ts.SyntaxKind.WithStatement: + case ts.SyntaxKind.LabeledStatement: + return true; + default: + return false; } - - if (aSourceContent != null) { - // Add the source content to the _sourcesContents map. - // Create a new _sourcesContents map if the property is null. - if (!this._sourcesContents) { - this._sourcesContents = Object.create(null); - } - this._sourcesContents[util.toSetString(source)] = aSourceContent; - } else if (this._sourcesContents) { - // Remove the source file from the _sourcesContents map. - // If the _sourcesContents map is empty, set the property to null. - delete this._sourcesContents[util.toSetString(source)]; - if (Object.keys(this._sourcesContents).length === 0) { - this._sourcesContents = null; - } +} +exports.isInSingleStatementContext = isInSingleStatementContext; +var ScopeBoundary; +(function (ScopeBoundary) { + ScopeBoundary[ScopeBoundary["None"] = 0] = "None"; + ScopeBoundary[ScopeBoundary["Function"] = 1] = "Function"; + ScopeBoundary[ScopeBoundary["Block"] = 2] = "Block"; + ScopeBoundary[ScopeBoundary["Type"] = 4] = "Type"; + ScopeBoundary[ScopeBoundary["ConditionalType"] = 8] = "ConditionalType"; +})(ScopeBoundary = exports.ScopeBoundary || (exports.ScopeBoundary = {})); +var ScopeBoundarySelector; +(function (ScopeBoundarySelector) { + ScopeBoundarySelector[ScopeBoundarySelector["Function"] = 1] = "Function"; + ScopeBoundarySelector[ScopeBoundarySelector["Block"] = 3] = "Block"; + ScopeBoundarySelector[ScopeBoundarySelector["Type"] = 7] = "Type"; + ScopeBoundarySelector[ScopeBoundarySelector["InferType"] = 8] = "InferType"; +})(ScopeBoundarySelector = exports.ScopeBoundarySelector || (exports.ScopeBoundarySelector = {})); +function isScopeBoundary(node) { + return isFunctionScopeBoundary(node) || isBlockScopeBoundary(node) || isTypeScopeBoundary(node); +} +exports.isScopeBoundary = isScopeBoundary; +function isTypeScopeBoundary(node) { + switch (node.kind) { + case ts.SyntaxKind.InterfaceDeclaration: + case ts.SyntaxKind.TypeAliasDeclaration: + case ts.SyntaxKind.MappedType: + return 4; + case ts.SyntaxKind.ConditionalType: + return 8; + default: + return 0; } - }; - -/** - * Applies the mappings of a sub-source-map for a specific source file to the - * source map being generated. Each mapping to the supplied source file is - * rewritten using the supplied source map. Note: The resolution for the - * resulting mappings is the minimium of this map and the supplied map. - * - * @param aSourceMapConsumer The source map to be applied. - * @param aSourceFile Optional. The filename of the source file. - * If omitted, SourceMapConsumer's file property will be used. - * @param aSourceMapPath Optional. The dirname of the path to the source map - * to be applied. If relative, it is relative to the SourceMapConsumer. - * This parameter is needed when the two source maps aren't in the same - * directory, and the source map to be applied contains relative source - * paths. If so, those relative source paths need to be rewritten - * relative to the SourceMapGenerator. - */ -SourceMapGenerator.prototype.applySourceMap = - function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { - var sourceFile = aSourceFile; - // If aSourceFile is omitted, we will use the file property of the SourceMap - if (aSourceFile == null) { - if (aSourceMapConsumer.file == null) { - throw new Error( - 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + - 'or the source map\'s "file" property. Both were omitted.' - ); - } - sourceFile = aSourceMapConsumer.file; +} +exports.isTypeScopeBoundary = isTypeScopeBoundary; +function isFunctionScopeBoundary(node) { + switch (node.kind) { + case ts.SyntaxKind.FunctionExpression: + case ts.SyntaxKind.ArrowFunction: + case ts.SyntaxKind.Constructor: + case ts.SyntaxKind.ModuleDeclaration: + case ts.SyntaxKind.ClassDeclaration: + case ts.SyntaxKind.ClassExpression: + case ts.SyntaxKind.EnumDeclaration: + case ts.SyntaxKind.MethodDeclaration: + case ts.SyntaxKind.FunctionDeclaration: + case ts.SyntaxKind.GetAccessor: + case ts.SyntaxKind.SetAccessor: + case ts.SyntaxKind.MethodSignature: + case ts.SyntaxKind.CallSignature: + case ts.SyntaxKind.ConstructSignature: + case ts.SyntaxKind.ConstructorType: + case ts.SyntaxKind.FunctionType: + return 1; + case ts.SyntaxKind.SourceFile: + return ts.isExternalModule(node) ? 1 : 0; + default: + return 0; } - var sourceRoot = this._sourceRoot; - // Make "sourceFile" relative if an absolute Url is passed. - if (sourceRoot != null) { - sourceFile = util.relative(sourceRoot, sourceFile); +} +exports.isFunctionScopeBoundary = isFunctionScopeBoundary; +function isBlockScopeBoundary(node) { + switch (node.kind) { + case ts.SyntaxKind.Block: + const parent = node.parent; + return parent.kind !== ts.SyntaxKind.CatchClause && + (parent.kind === ts.SyntaxKind.SourceFile || + !isFunctionScopeBoundary(parent)) + ? 2 + : 0; + case ts.SyntaxKind.ForStatement: + case ts.SyntaxKind.ForInStatement: + case ts.SyntaxKind.ForOfStatement: + case ts.SyntaxKind.CaseBlock: + case ts.SyntaxKind.CatchClause: + case ts.SyntaxKind.WithStatement: + return 2; + default: + return 0; } - // Applying the SourceMap can add and remove items from the sources and - // the names array. - var newSources = new ArraySet(); - var newNames = new ArraySet(); - - // Find mappings for the "sourceFile" - this._mappings.unsortedForEach(function (mapping) { - if (mapping.source === sourceFile && mapping.originalLine != null) { - // Check if it can be mapped by the source map, then update the mapping. - var original = aSourceMapConsumer.originalPositionFor({ - line: mapping.originalLine, - column: mapping.originalColumn - }); - if (original.source != null) { - // Copy mapping - mapping.source = original.source; - if (aSourceMapPath != null) { - mapping.source = util.join(aSourceMapPath, mapping.source) - } - if (sourceRoot != null) { - mapping.source = util.relative(sourceRoot, mapping.source); - } - mapping.originalLine = original.line; - mapping.originalColumn = original.column; - if (original.name != null) { - mapping.name = original.name; - } - } - } - - var source = mapping.source; - if (source != null && !newSources.has(source)) { - newSources.add(source); - } - - var name = mapping.name; - if (name != null && !newNames.has(name)) { - newNames.add(name); - } - - }, this); - this._sources = newSources; - this._names = newNames; - - // Copy sourcesContents of applied map. - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content != null) { - if (aSourceMapPath != null) { - sourceFile = util.join(aSourceMapPath, sourceFile); - } - if (sourceRoot != null) { - sourceFile = util.relative(sourceRoot, sourceFile); - } - this.setSourceContent(sourceFile, content); - } - }, this); - }; - -/** - * A mapping can have one of the three levels of data: - * - * 1. Just the generated position. - * 2. The Generated position, original position, and original source. - * 3. Generated and original position, original source, as well as a name - * token. - * - * To maintain consistency, we validate that any new mapping being added falls - * in to one of these categories. - */ -SourceMapGenerator.prototype._validateMapping = - function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, - aName) { - // When aOriginal is truthy but has empty values for .line and .column, - // it is most likely a programmer error. In this case we throw a very - // specific error message to try to guide them the right way. - // For example: https://github.com/Polymer/polymer-bundler/pull/519 - if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { - throw new Error( - 'original.line and original.column are not numbers -- you probably meant to omit ' + - 'the original mapping entirely and only map the generated position. If so, pass ' + - 'null for the original mapping instead of an object with empty or null values.' - ); +} +exports.isBlockScopeBoundary = isBlockScopeBoundary; +function hasOwnThisReference(node) { + switch (node.kind) { + case ts.SyntaxKind.ClassDeclaration: + case ts.SyntaxKind.ClassExpression: + case ts.SyntaxKind.FunctionExpression: + return true; + case ts.SyntaxKind.FunctionDeclaration: + return node.body !== undefined; + case ts.SyntaxKind.MethodDeclaration: + case ts.SyntaxKind.GetAccessor: + case ts.SyntaxKind.SetAccessor: + return node.parent.kind === ts.SyntaxKind.ObjectLiteralExpression; + default: + return false; } - - if (aGenerated && 'line' in aGenerated && 'column' in aGenerated - && aGenerated.line > 0 && aGenerated.column >= 0 - && !aOriginal && !aSource && !aName) { - // Case 1. - return; +} +exports.hasOwnThisReference = hasOwnThisReference; +function isFunctionWithBody(node) { + switch (node.kind) { + case ts.SyntaxKind.GetAccessor: + case ts.SyntaxKind.SetAccessor: + case ts.SyntaxKind.FunctionDeclaration: + case ts.SyntaxKind.MethodDeclaration: + case ts.SyntaxKind.Constructor: + return node.body !== undefined; + case ts.SyntaxKind.FunctionExpression: + case ts.SyntaxKind.ArrowFunction: + return true; + default: + return false; } - else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated - && aOriginal && 'line' in aOriginal && 'column' in aOriginal - && aGenerated.line > 0 && aGenerated.column >= 0 - && aOriginal.line > 0 && aOriginal.column >= 0 - && aSource) { - // Cases 2 and 3. - return; +} +exports.isFunctionWithBody = isFunctionWithBody; +function forEachToken(node, cb, sourceFile = node.getSourceFile()) { + return (function iterate(child) { + if (isTokenKind(child.kind)) + return cb(child); + if (child.kind !== ts.SyntaxKind.JSDocComment) + return child.getChildren(sourceFile).forEach(iterate); + })(node); +} +exports.forEachToken = forEachToken; +function forEachTokenWithTrivia(node, cb, sourceFile = node.getSourceFile()) { + const fullText = sourceFile.text; + const scanner = ts.createScanner(sourceFile.languageVersion, false, sourceFile.languageVariant, fullText); + return forEachToken(node, (token) => { + const tokenStart = token.kind === ts.SyntaxKind.JsxText || token.pos === token.end ? token.pos : token.getStart(sourceFile); + if (tokenStart !== token.pos) { + scanner.setTextPos(token.pos); + let kind = scanner.scan(); + let pos = scanner.getTokenPos(); + while (pos < tokenStart) { + const textPos = scanner.getTextPos(); + cb(fullText, kind, { pos, end: textPos }, token.parent); + if (textPos === tokenStart) + break; + kind = scanner.scan(); + pos = scanner.getTokenPos(); + } + } + return cb(fullText, token.kind, { end: token.end, pos: tokenStart }, token.parent); + }, sourceFile); +} +exports.forEachTokenWithTrivia = forEachTokenWithTrivia; +function forEachComment(node, cb, sourceFile = node.getSourceFile()) { + const fullText = sourceFile.text; + const notJsx = sourceFile.languageVariant !== ts.LanguageVariant.JSX; + return forEachToken(node, (token) => { + if (token.pos === token.end) + return; + if (token.kind !== ts.SyntaxKind.JsxText) + ts.forEachLeadingCommentRange(fullText, token.pos === 0 ? (ts.getShebang(fullText) || '').length : token.pos, commentCallback); + if (notJsx || canHaveTrailingTrivia(token)) + return ts.forEachTrailingCommentRange(fullText, token.end, commentCallback); + }, sourceFile); + function commentCallback(pos, end, kind) { + cb(fullText, { pos, end, kind }); } - else { - throw new Error('Invalid mapping: ' + JSON.stringify({ - generated: aGenerated, - source: aSource, - original: aOriginal, - name: aName - })); +} +exports.forEachComment = forEachComment; +function canHaveTrailingTrivia(token) { + switch (token.kind) { + case ts.SyntaxKind.CloseBraceToken: + return token.parent.kind !== ts.SyntaxKind.JsxExpression || !isJsxElementOrFragment(token.parent.parent); + case ts.SyntaxKind.GreaterThanToken: + switch (token.parent.kind) { + case ts.SyntaxKind.JsxOpeningElement: + return token.end !== token.parent.end; + case ts.SyntaxKind.JsxOpeningFragment: + return false; + case ts.SyntaxKind.JsxSelfClosingElement: + return token.end !== token.parent.end || + !isJsxElementOrFragment(token.parent.parent); + case ts.SyntaxKind.JsxClosingElement: + case ts.SyntaxKind.JsxClosingFragment: + return !isJsxElementOrFragment(token.parent.parent.parent); + } } - }; - -/** - * Serialize the accumulated mappings in to the stream of base 64 VLQs - * specified by the source map format. - */ -SourceMapGenerator.prototype._serializeMappings = - function SourceMapGenerator_serializeMappings() { - var previousGeneratedColumn = 0; - var previousGeneratedLine = 1; - var previousOriginalColumn = 0; - var previousOriginalLine = 0; - var previousName = 0; - var previousSource = 0; - var result = ''; - var next; - var mapping; - var nameIdx; - var sourceIdx; - - var mappings = this._mappings.toArray(); - for (var i = 0, len = mappings.length; i < len; i++) { - mapping = mappings[i]; - next = '' - - if (mapping.generatedLine !== previousGeneratedLine) { - previousGeneratedColumn = 0; - while (mapping.generatedLine !== previousGeneratedLine) { - next += ';'; - previousGeneratedLine++; - } - } - else { - if (i > 0) { - if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { - continue; - } - next += ','; - } - } - - next += base64VLQ.encode(mapping.generatedColumn - - previousGeneratedColumn); - previousGeneratedColumn = mapping.generatedColumn; - - if (mapping.source != null) { - sourceIdx = this._sources.indexOf(mapping.source); - next += base64VLQ.encode(sourceIdx - previousSource); - previousSource = sourceIdx; - - // lines are stored 0-based in SourceMap spec version 3 - next += base64VLQ.encode(mapping.originalLine - 1 - - previousOriginalLine); - previousOriginalLine = mapping.originalLine - 1; - - next += base64VLQ.encode(mapping.originalColumn - - previousOriginalColumn); - previousOriginalColumn = mapping.originalColumn; - - if (mapping.name != null) { - nameIdx = this._names.indexOf(mapping.name); - next += base64VLQ.encode(nameIdx - previousName); - previousName = nameIdx; - } - } - - result += next; + return true; +} +function isJsxElementOrFragment(node) { + return node.kind === ts.SyntaxKind.JsxElement || node.kind === ts.SyntaxKind.JsxFragment; +} +function getLineRanges(sourceFile) { + const lineStarts = sourceFile.getLineStarts(); + const result = []; + const length = lineStarts.length; + const sourceText = sourceFile.text; + let pos = 0; + for (let i = 1; i < length; ++i) { + const end = lineStarts[i]; + let lineEnd = end; + for (; lineEnd > pos; --lineEnd) + if (!ts.isLineBreak(sourceText.charCodeAt(lineEnd - 1))) + break; + result.push({ + pos, + end, + contentLength: lineEnd - pos, + }); + pos = end; } - + result.push({ + pos, + end: sourceFile.end, + contentLength: sourceFile.end - pos, + }); return result; - }; - -SourceMapGenerator.prototype._generateSourcesContent = - function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { - return aSources.map(function (source) { - if (!this._sourcesContents) { - return null; - } - if (aSourceRoot != null) { - source = util.relative(aSourceRoot, source); - } - var key = util.toSetString(source); - return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) - ? this._sourcesContents[key] - : null; - }, this); - }; - -/** - * Externalize the source map. - */ -SourceMapGenerator.prototype.toJSON = - function SourceMapGenerator_toJSON() { - var map = { - version: this._version, - sources: this._sources.toArray(), - names: this._names.toArray(), - mappings: this._serializeMappings() - }; - if (this._file != null) { - map.file = this._file; - } - if (this._sourceRoot != null) { - map.sourceRoot = this._sourceRoot; +} +exports.getLineRanges = getLineRanges; +function getLineBreakStyle(sourceFile) { + const lineStarts = sourceFile.getLineStarts(); + return lineStarts.length === 1 || lineStarts[1] < 2 || sourceFile.text[lineStarts[1] - 2] !== '\r' + ? '\n' + : '\r\n'; +} +exports.getLineBreakStyle = getLineBreakStyle; +let cachedScanner; +function scanToken(text, languageVersion) { + if (cachedScanner === undefined) { + cachedScanner = ts.createScanner(languageVersion, false, undefined, text); } - if (this._sourcesContents) { - map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); + else { + cachedScanner.setScriptTarget(languageVersion); + cachedScanner.setText(text); } - - return map; - }; - -/** - * Render the source map being generated to a string. - */ -SourceMapGenerator.prototype.toString = - function SourceMapGenerator_toString() { - return JSON.stringify(this.toJSON()); - }; - -exports.SourceMapGenerator = SourceMapGenerator; + cachedScanner.scan(); + return cachedScanner; +} +function isValidIdentifier(text, languageVersion = ts.ScriptTarget.Latest) { + const scan = scanToken(text, languageVersion); + return scan.isIdentifier() && scan.getTextPos() === text.length && scan.getTokenPos() === 0; +} +exports.isValidIdentifier = isValidIdentifier; +function charSize(ch) { + return ch >= 0x10000 ? 2 : 1; +} +function isValidPropertyAccess(text, languageVersion = ts.ScriptTarget.Latest) { + if (text.length === 0) + return false; + let ch = text.codePointAt(0); + if (!ts.isIdentifierStart(ch, languageVersion)) + return false; + for (let i = charSize(ch); i < text.length; i += charSize(ch)) { + ch = text.codePointAt(i); + if (!ts.isIdentifierPart(ch, languageVersion)) + return false; + } + return true; +} +exports.isValidPropertyAccess = isValidPropertyAccess; +function isValidPropertyName(text, languageVersion = ts.ScriptTarget.Latest) { + if (isValidPropertyAccess(text, languageVersion)) + return true; + const scan = scanToken(text, languageVersion); + return scan.getTextPos() === text.length && + scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTokenValue() === text; +} +exports.isValidPropertyName = isValidPropertyName; +function isValidNumericLiteral(text, languageVersion = ts.ScriptTarget.Latest) { + const scan = scanToken(text, languageVersion); + return scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTextPos() === text.length && scan.getTokenPos() === 0; +} +exports.isValidNumericLiteral = isValidNumericLiteral; +function isValidJsxIdentifier(text, languageVersion = ts.ScriptTarget.Latest) { + if (text.length === 0) + return false; + let ch = text.codePointAt(0); + if (!ts.isIdentifierStart(ch, languageVersion)) + return false; + for (let i = charSize(ch); i < text.length; i += charSize(ch)) { + ch = text.codePointAt(i); + if (!ts.isIdentifierPart(ch, languageVersion) && ch !== 45) + return false; + } + return true; +} +exports.isValidJsxIdentifier = isValidJsxIdentifier; +function isNumericPropertyName(name) { + return String(+name) === name; +} +exports.isNumericPropertyName = isNumericPropertyName; +function isSameLine(sourceFile, pos1, pos2) { + return ts.getLineAndCharacterOfPosition(sourceFile, pos1).line === ts.getLineAndCharacterOfPosition(sourceFile, pos2).line; +} +exports.isSameLine = isSameLine; +var SideEffectOptions; +(function (SideEffectOptions) { + SideEffectOptions[SideEffectOptions["None"] = 0] = "None"; + SideEffectOptions[SideEffectOptions["TaggedTemplate"] = 1] = "TaggedTemplate"; + SideEffectOptions[SideEffectOptions["Constructor"] = 2] = "Constructor"; + SideEffectOptions[SideEffectOptions["JsxElement"] = 4] = "JsxElement"; +})(SideEffectOptions = exports.SideEffectOptions || (exports.SideEffectOptions = {})); +function hasSideEffects(node, options) { + switch (node.kind) { + case ts.SyntaxKind.CallExpression: + case ts.SyntaxKind.PostfixUnaryExpression: + case ts.SyntaxKind.AwaitExpression: + case ts.SyntaxKind.YieldExpression: + case ts.SyntaxKind.DeleteExpression: + return true; + case ts.SyntaxKind.TypeAssertionExpression: + case ts.SyntaxKind.AsExpression: + case ts.SyntaxKind.ParenthesizedExpression: + case ts.SyntaxKind.NonNullExpression: + case ts.SyntaxKind.VoidExpression: + case ts.SyntaxKind.TypeOfExpression: + case ts.SyntaxKind.PropertyAccessExpression: + case ts.SyntaxKind.SpreadElement: + case ts.SyntaxKind.PartiallyEmittedExpression: + return hasSideEffects(node.expression, options); + case ts.SyntaxKind.BinaryExpression: + return isAssignmentKind(node.operatorToken.kind) || + hasSideEffects(node.left, options) || + hasSideEffects(node.right, options); + case ts.SyntaxKind.PrefixUnaryExpression: + switch (node.operator) { + case ts.SyntaxKind.PlusPlusToken: + case ts.SyntaxKind.MinusMinusToken: + return true; + default: + return hasSideEffects(node.operand, options); + } + case ts.SyntaxKind.ElementAccessExpression: + return hasSideEffects(node.expression, options) || + node.argumentExpression !== undefined && + hasSideEffects(node.argumentExpression, options); + case ts.SyntaxKind.ConditionalExpression: + return hasSideEffects(node.condition, options) || + hasSideEffects(node.whenTrue, options) || + hasSideEffects(node.whenFalse, options); + case ts.SyntaxKind.NewExpression: + if (options & 2 || hasSideEffects(node.expression, options)) + return true; + if (node.arguments !== undefined) + for (const child of node.arguments) + if (hasSideEffects(child, options)) + return true; + return false; + case ts.SyntaxKind.TaggedTemplateExpression: + if (options & 1 || hasSideEffects(node.tag, options)) + return true; + if (node.template.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral) + return false; + node = node.template; + case ts.SyntaxKind.TemplateExpression: + for (const child of node.templateSpans) + if (hasSideEffects(child.expression, options)) + return true; + return false; + case ts.SyntaxKind.ClassExpression: + return classExpressionHasSideEffects(node, options); + case ts.SyntaxKind.ArrayLiteralExpression: + for (const child of node.elements) + if (hasSideEffects(child, options)) + return true; + return false; + case ts.SyntaxKind.ObjectLiteralExpression: + for (const child of node.properties) { + if (child.name !== undefined && child.name.kind === ts.SyntaxKind.ComputedPropertyName && + hasSideEffects(child.name.expression, options)) + return true; + switch (child.kind) { + case ts.SyntaxKind.PropertyAssignment: + if (hasSideEffects(child.initializer, options)) + return true; + break; + case ts.SyntaxKind.SpreadAssignment: + if (hasSideEffects(child.expression, options)) + return true; + } + } + return false; + case ts.SyntaxKind.JsxExpression: + return node.expression !== undefined && hasSideEffects(node.expression, options); + case ts.SyntaxKind.JsxElement: + case ts.SyntaxKind.JsxFragment: + for (const child of node.children) + if (child.kind !== ts.SyntaxKind.JsxText && hasSideEffects(child, options)) + return true; + if (node.kind === ts.SyntaxKind.JsxFragment) + return false; + node = node.openingElement; + case ts.SyntaxKind.JsxSelfClosingElement: + case ts.SyntaxKind.JsxOpeningElement: + if (options & 4) + return true; + for (const child of node.attributes.properties) { + if (child.kind === ts.SyntaxKind.JsxSpreadAttribute) { + if (hasSideEffects(child.expression, options)) + return true; + } + else if (child.initializer !== undefined && hasSideEffects(child.initializer, options)) { + return true; + } + } + return false; + case ts.SyntaxKind.CommaListExpression: + for (const child of node.elements) + if (hasSideEffects(child, options)) + return true; + return false; + default: + return false; + } +} +exports.hasSideEffects = hasSideEffects; +function classExpressionHasSideEffects(node, options) { + if (node.heritageClauses !== undefined && node.heritageClauses[0].token === ts.SyntaxKind.ExtendsKeyword) + for (const base of node.heritageClauses[0].types) + if (hasSideEffects(base.expression, options)) + return true; + for (const child of node.members) + if (child.name !== undefined && child.name.kind === ts.SyntaxKind.ComputedPropertyName && + hasSideEffects(child.name.expression, options) || + node_1.isPropertyDeclaration(child) && child.initializer !== undefined && + hasSideEffects(child.initializer, options)) + return true; + return false; +} +function getDeclarationOfBindingElement(node) { + let parent = node.parent.parent; + while (parent.kind === ts.SyntaxKind.BindingElement) + parent = parent.parent.parent; + return parent; +} +exports.getDeclarationOfBindingElement = getDeclarationOfBindingElement; +function isExpressionValueUsed(node) { + while (true) { + const parent = node.parent; + switch (parent.kind) { + case ts.SyntaxKind.CallExpression: + case ts.SyntaxKind.NewExpression: + case ts.SyntaxKind.ElementAccessExpression: + case ts.SyntaxKind.WhileStatement: + case ts.SyntaxKind.DoStatement: + case ts.SyntaxKind.WithStatement: + case ts.SyntaxKind.ThrowStatement: + case ts.SyntaxKind.ReturnStatement: + case ts.SyntaxKind.JsxExpression: + case ts.SyntaxKind.JsxSpreadAttribute: + case ts.SyntaxKind.JsxElement: + case ts.SyntaxKind.JsxFragment: + case ts.SyntaxKind.JsxSelfClosingElement: + case ts.SyntaxKind.ComputedPropertyName: + case ts.SyntaxKind.ArrowFunction: + case ts.SyntaxKind.ExportSpecifier: + case ts.SyntaxKind.ExportAssignment: + case ts.SyntaxKind.ImportDeclaration: + case ts.SyntaxKind.ExternalModuleReference: + case ts.SyntaxKind.Decorator: + case ts.SyntaxKind.TaggedTemplateExpression: + case ts.SyntaxKind.TemplateSpan: + case ts.SyntaxKind.ExpressionWithTypeArguments: + case ts.SyntaxKind.TypeOfExpression: + case ts.SyntaxKind.AwaitExpression: + case ts.SyntaxKind.YieldExpression: + case ts.SyntaxKind.LiteralType: + case ts.SyntaxKind.JsxAttributes: + case ts.SyntaxKind.JsxOpeningElement: + case ts.SyntaxKind.JsxClosingElement: + case ts.SyntaxKind.IfStatement: + case ts.SyntaxKind.CaseClause: + case ts.SyntaxKind.SwitchStatement: + return true; + case ts.SyntaxKind.PropertyAccessExpression: + return parent.expression === node; + case ts.SyntaxKind.QualifiedName: + return parent.left === node; + case ts.SyntaxKind.ShorthandPropertyAssignment: + return parent.objectAssignmentInitializer === node || + !isInDestructuringAssignment(parent); + case ts.SyntaxKind.PropertyAssignment: + return parent.initializer === node && !isInDestructuringAssignment(parent); + case ts.SyntaxKind.SpreadAssignment: + case ts.SyntaxKind.SpreadElement: + case ts.SyntaxKind.ArrayLiteralExpression: + return !isInDestructuringAssignment(parent); + case ts.SyntaxKind.ParenthesizedExpression: + case ts.SyntaxKind.AsExpression: + case ts.SyntaxKind.TypeAssertionExpression: + case ts.SyntaxKind.PostfixUnaryExpression: + case ts.SyntaxKind.PrefixUnaryExpression: + case ts.SyntaxKind.NonNullExpression: + node = parent; + break; + case ts.SyntaxKind.ForStatement: + return parent.condition === node; + case ts.SyntaxKind.ForInStatement: + case ts.SyntaxKind.ForOfStatement: + return parent.expression === node; + case ts.SyntaxKind.ConditionalExpression: + if (parent.condition === node) + return true; + node = parent; + break; + case ts.SyntaxKind.PropertyDeclaration: + case ts.SyntaxKind.BindingElement: + case ts.SyntaxKind.VariableDeclaration: + case ts.SyntaxKind.Parameter: + case ts.SyntaxKind.EnumMember: + return parent.initializer === node; + case ts.SyntaxKind.ImportEqualsDeclaration: + return parent.moduleReference === node; + case ts.SyntaxKind.CommaListExpression: + if (parent.elements[parent.elements.length - 1] !== node) + return false; + node = parent; + break; + case ts.SyntaxKind.BinaryExpression: + if (parent.right === node) { + if (parent.operatorToken.kind === ts.SyntaxKind.CommaToken) { + node = parent; + break; + } + return true; + } + switch (parent.operatorToken.kind) { + case ts.SyntaxKind.CommaToken: + case ts.SyntaxKind.EqualsToken: + return false; + case ts.SyntaxKind.EqualsEqualsEqualsToken: + case ts.SyntaxKind.EqualsEqualsToken: + case ts.SyntaxKind.ExclamationEqualsEqualsToken: + case ts.SyntaxKind.ExclamationEqualsToken: + case ts.SyntaxKind.InstanceOfKeyword: + case ts.SyntaxKind.PlusToken: + case ts.SyntaxKind.MinusToken: + case ts.SyntaxKind.AsteriskToken: + case ts.SyntaxKind.SlashToken: + case ts.SyntaxKind.PercentToken: + case ts.SyntaxKind.AsteriskAsteriskToken: + case ts.SyntaxKind.GreaterThanToken: + case ts.SyntaxKind.GreaterThanGreaterThanToken: + case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken: + case ts.SyntaxKind.GreaterThanEqualsToken: + case ts.SyntaxKind.LessThanToken: + case ts.SyntaxKind.LessThanLessThanToken: + case ts.SyntaxKind.LessThanEqualsToken: + case ts.SyntaxKind.AmpersandToken: + case ts.SyntaxKind.BarToken: + case ts.SyntaxKind.CaretToken: + case ts.SyntaxKind.BarBarToken: + case ts.SyntaxKind.AmpersandAmpersandToken: + case ts.SyntaxKind.InKeyword: + return true; + default: + node = parent; + } + break; + default: + return false; + } + } +} +exports.isExpressionValueUsed = isExpressionValueUsed; +function isInDestructuringAssignment(node) { + switch (node.kind) { + case ts.SyntaxKind.ShorthandPropertyAssignment: + if (node.objectAssignmentInitializer !== undefined) + return true; + case ts.SyntaxKind.PropertyAssignment: + case ts.SyntaxKind.SpreadAssignment: + node = node.parent; + break; + case ts.SyntaxKind.SpreadElement: + if (node.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression) + return false; + node = node.parent; + } + while (true) { + switch (node.parent.kind) { + case ts.SyntaxKind.BinaryExpression: + return node.parent.left === node && + node.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken; + case ts.SyntaxKind.ForOfStatement: + return node.parent.initializer === node; + case ts.SyntaxKind.ArrayLiteralExpression: + case ts.SyntaxKind.ObjectLiteralExpression: + node = node.parent; + break; + case ts.SyntaxKind.SpreadAssignment: + case ts.SyntaxKind.PropertyAssignment: + node = node.parent.parent; + break; + case ts.SyntaxKind.SpreadElement: + if (node.parent.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression) + return false; + node = node.parent.parent; + break; + default: + return false; + } + } +} +var AccessKind; +(function (AccessKind) { + AccessKind[AccessKind["None"] = 0] = "None"; + AccessKind[AccessKind["Read"] = 1] = "Read"; + AccessKind[AccessKind["Write"] = 2] = "Write"; + AccessKind[AccessKind["Delete"] = 4] = "Delete"; + AccessKind[AccessKind["ReadWrite"] = 3] = "ReadWrite"; + AccessKind[AccessKind["Modification"] = 6] = "Modification"; +})(AccessKind = exports.AccessKind || (exports.AccessKind = {})); +function getAccessKind(node) { + const parent = node.parent; + switch (parent.kind) { + case ts.SyntaxKind.DeleteExpression: + return 4; + case ts.SyntaxKind.PostfixUnaryExpression: + return 3; + case ts.SyntaxKind.PrefixUnaryExpression: + return parent.operator === ts.SyntaxKind.PlusPlusToken || + parent.operator === ts.SyntaxKind.MinusMinusToken + ? 3 + : 1; + case ts.SyntaxKind.BinaryExpression: + return parent.right === node + ? 1 + : !isAssignmentKind(parent.operatorToken.kind) + ? 1 + : parent.operatorToken.kind === ts.SyntaxKind.EqualsToken + ? 2 + : 3; + case ts.SyntaxKind.ShorthandPropertyAssignment: + return parent.objectAssignmentInitializer === node + ? 1 + : isInDestructuringAssignment(parent) + ? 2 + : 1; + case ts.SyntaxKind.PropertyAssignment: + return parent.name === node + ? 0 + : isInDestructuringAssignment(parent) + ? 2 + : 1; + case ts.SyntaxKind.ArrayLiteralExpression: + case ts.SyntaxKind.SpreadElement: + case ts.SyntaxKind.SpreadAssignment: + return isInDestructuringAssignment(parent) + ? 2 + : 1; + case ts.SyntaxKind.ParenthesizedExpression: + case ts.SyntaxKind.NonNullExpression: + case ts.SyntaxKind.TypeAssertionExpression: + case ts.SyntaxKind.AsExpression: + return getAccessKind(parent); + case ts.SyntaxKind.ForOfStatement: + case ts.SyntaxKind.ForInStatement: + return parent.initializer === node + ? 2 + : 1; + case ts.SyntaxKind.ExpressionWithTypeArguments: + return parent.parent.token === ts.SyntaxKind.ExtendsKeyword && + parent.parent.parent.kind !== ts.SyntaxKind.InterfaceDeclaration + ? 1 + : 0; + case ts.SyntaxKind.ComputedPropertyName: + case ts.SyntaxKind.ExpressionStatement: + case ts.SyntaxKind.TypeOfExpression: + case ts.SyntaxKind.ElementAccessExpression: + case ts.SyntaxKind.ForStatement: + case ts.SyntaxKind.IfStatement: + case ts.SyntaxKind.DoStatement: + case ts.SyntaxKind.WhileStatement: + case ts.SyntaxKind.SwitchStatement: + case ts.SyntaxKind.WithStatement: + case ts.SyntaxKind.ThrowStatement: + case ts.SyntaxKind.CallExpression: + case ts.SyntaxKind.NewExpression: + case ts.SyntaxKind.TaggedTemplateExpression: + case ts.SyntaxKind.JsxExpression: + case ts.SyntaxKind.Decorator: + case ts.SyntaxKind.TemplateSpan: + case ts.SyntaxKind.JsxOpeningElement: + case ts.SyntaxKind.JsxSelfClosingElement: + case ts.SyntaxKind.JsxSpreadAttribute: + case ts.SyntaxKind.VoidExpression: + case ts.SyntaxKind.ReturnStatement: + case ts.SyntaxKind.AwaitExpression: + case ts.SyntaxKind.YieldExpression: + case ts.SyntaxKind.ConditionalExpression: + case ts.SyntaxKind.CaseClause: + case ts.SyntaxKind.JsxElement: + return 1; + case ts.SyntaxKind.ArrowFunction: + return parent.body === node + ? 1 + : 2; + case ts.SyntaxKind.PropertyDeclaration: + case ts.SyntaxKind.VariableDeclaration: + case ts.SyntaxKind.Parameter: + case ts.SyntaxKind.EnumMember: + case ts.SyntaxKind.BindingElement: + case ts.SyntaxKind.JsxAttribute: + return parent.initializer === node + ? 1 + : 0; + case ts.SyntaxKind.PropertyAccessExpression: + return parent.expression === node + ? 1 + : 0; + case ts.SyntaxKind.ExportAssignment: + return parent.isExportEquals + ? 1 + : 0; + } + return 0; +} +exports.getAccessKind = getAccessKind; +function isReassignmentTarget(node) { + return (getAccessKind(node) & 2) !== 0; +} +exports.isReassignmentTarget = isReassignmentTarget; +function canHaveJsDoc(node) { + const kind = node.kind; + switch (kind) { + case ts.SyntaxKind.Parameter: + case ts.SyntaxKind.CallSignature: + case ts.SyntaxKind.ConstructSignature: + case ts.SyntaxKind.MethodSignature: + case ts.SyntaxKind.PropertySignature: + case ts.SyntaxKind.ArrowFunction: + case ts.SyntaxKind.ParenthesizedExpression: + case ts.SyntaxKind.SpreadAssignment: + case ts.SyntaxKind.ShorthandPropertyAssignment: + case ts.SyntaxKind.PropertyAssignment: + case ts.SyntaxKind.FunctionExpression: + case ts.SyntaxKind.FunctionDeclaration: + case ts.SyntaxKind.LabeledStatement: + case ts.SyntaxKind.ExpressionStatement: + case ts.SyntaxKind.VariableStatement: + case ts.SyntaxKind.Constructor: + case ts.SyntaxKind.MethodDeclaration: + case ts.SyntaxKind.PropertyDeclaration: + case ts.SyntaxKind.GetAccessor: + case ts.SyntaxKind.SetAccessor: + case ts.SyntaxKind.ClassDeclaration: + case ts.SyntaxKind.ClassExpression: + case ts.SyntaxKind.InterfaceDeclaration: + case ts.SyntaxKind.TypeAliasDeclaration: + case ts.SyntaxKind.EnumMember: + case ts.SyntaxKind.EnumDeclaration: + case ts.SyntaxKind.ModuleDeclaration: + case ts.SyntaxKind.ImportEqualsDeclaration: + case ts.SyntaxKind.IndexSignature: + case ts.SyntaxKind.FunctionType: + case ts.SyntaxKind.ConstructorType: + case ts.SyntaxKind.JSDocFunctionType: + case ts.SyntaxKind.EndOfFileToken: + case ts.SyntaxKind.ExportDeclaration: + return true; + default: + return false; + } +} +exports.canHaveJsDoc = canHaveJsDoc; +function getJsDoc(node, sourceFile) { + if (node.kind === ts.SyntaxKind.EndOfFileToken) + return parseJsDocWorker(node, sourceFile || node.parent); + const result = []; + for (const child of node.getChildren(sourceFile)) { + if (!node_1.isJsDoc(child)) + break; + result.push(child); + } + return result; +} +exports.getJsDoc = getJsDoc; +function parseJsDocOfNode(node, considerTrailingComments, sourceFile = node.getSourceFile()) { + if (canHaveJsDoc(node) && node.kind !== ts.SyntaxKind.EndOfFileToken) { + const result = getJsDoc(node, sourceFile); + if (result.length !== 0 || !considerTrailingComments) + return result; + } + return parseJsDocWorker(node, sourceFile, considerTrailingComments); +} +exports.parseJsDocOfNode = parseJsDocOfNode; +function parseJsDocWorker(node, sourceFile, considerTrailingComments) { + const nodeStart = node.getStart(sourceFile); + const start = ts[considerTrailingComments && isSameLine(sourceFile, node.pos, nodeStart) + ? 'forEachTrailingCommentRange' + : 'forEachLeadingCommentRange'](sourceFile.text, node.pos, (pos, _end, kind) => kind === ts.SyntaxKind.MultiLineCommentTrivia && sourceFile.text[pos + 2] === '*' ? { pos } : undefined); + if (start === undefined) + return []; + const startPos = start.pos; + const text = sourceFile.text.slice(startPos, nodeStart); + const newSourceFile = ts.createSourceFile('jsdoc.ts', `${text}var a;`, sourceFile.languageVersion); + const result = getJsDoc(newSourceFile.statements[0], newSourceFile); + for (const doc of result) + updateNode(doc, node); + return result; + function updateNode(n, parent) { + n.pos += startPos; + n.end += startPos; + n.parent = parent; + return ts.forEachChild(n, (child) => updateNode(child, n), (children) => { + children.pos += startPos; + children.end += startPos; + for (const child of children) + updateNode(child, n); + }); + } +} +var ImportKind; +(function (ImportKind) { + ImportKind[ImportKind["ImportDeclaration"] = 1] = "ImportDeclaration"; + ImportKind[ImportKind["ImportEquals"] = 2] = "ImportEquals"; + ImportKind[ImportKind["ExportFrom"] = 4] = "ExportFrom"; + ImportKind[ImportKind["DynamicImport"] = 8] = "DynamicImport"; + ImportKind[ImportKind["Require"] = 16] = "Require"; + ImportKind[ImportKind["ImportType"] = 32] = "ImportType"; + ImportKind[ImportKind["All"] = 63] = "All"; + ImportKind[ImportKind["AllImports"] = 59] = "AllImports"; + ImportKind[ImportKind["AllStaticImports"] = 3] = "AllStaticImports"; + ImportKind[ImportKind["AllImportExpressions"] = 24] = "AllImportExpressions"; + ImportKind[ImportKind["AllRequireLike"] = 18] = "AllRequireLike"; + ImportKind[ImportKind["AllNestedImports"] = 56] = "AllNestedImports"; + ImportKind[ImportKind["AllTopLevelImports"] = 7] = "AllTopLevelImports"; +})(ImportKind = exports.ImportKind || (exports.ImportKind = {})); +function findImports(sourceFile, kinds) { + const result = []; + for (const node of findImportLikeNodes(sourceFile, kinds)) { + switch (node.kind) { + case ts.SyntaxKind.ImportDeclaration: + addIfTextualLiteral(node.moduleSpecifier); + break; + case ts.SyntaxKind.ImportEqualsDeclaration: + addIfTextualLiteral(node.moduleReference.expression); + break; + case ts.SyntaxKind.ExportDeclaration: + addIfTextualLiteral(node.moduleSpecifier); + break; + case ts.SyntaxKind.CallExpression: + addIfTextualLiteral(node.arguments[0]); + break; + case ts.SyntaxKind.ImportType: + if (node_1.isLiteralTypeNode(node.argument)) + addIfTextualLiteral(node.argument.literal); + break; + default: + throw new Error('unexpected node'); + } + } + return result; + function addIfTextualLiteral(node) { + if (node_1.isTextualLiteral(node)) + result.push(node); + } +} +exports.findImports = findImports; +function findImportLikeNodes(sourceFile, kinds) { + return new ImportFinder(sourceFile, kinds).find(); +} +exports.findImportLikeNodes = findImportLikeNodes; +class ImportFinder { + constructor(_sourceFile, _options) { + this._sourceFile = _sourceFile; + this._options = _options; + this._result = []; + } + find() { + if (this._sourceFile.isDeclarationFile) + this._options &= ~24; + if (this._options & 7) + this._findImports(this._sourceFile.statements); + if (this._options & 56) + this._findNestedImports(); + return this._result; + } + _findImports(statements) { + for (const statement of statements) { + if (node_1.isImportDeclaration(statement)) { + if (this._options & 1) + this._result.push(statement); + } + else if (node_1.isImportEqualsDeclaration(statement)) { + if (this._options & 2 && + statement.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference) + this._result.push(statement); + } + else if (node_1.isExportDeclaration(statement)) { + if (statement.moduleSpecifier !== undefined && this._options & 4) + this._result.push(statement); + } + else if (node_1.isModuleDeclaration(statement)) { + this._findImportsInModule(statement); + } + } + } + _findImportsInModule(declaration) { + if (declaration.body === undefined) + return; + if (declaration.body.kind === ts.SyntaxKind.ModuleDeclaration) + return this._findImportsInModule(declaration.body); + this._findImports(declaration.body.statements); + } + _findNestedImports() { + let re; + if ((this._options & 56) === 16) { + re = /\brequire\s*[ { + if (kind === ts.SyntaxKind.SingleLineCommentTrivia) { + const text = source.slice(pos, end); + const match = /^\/{2,3}\s*@ts-(no)?check(?:\s|$)/i.exec(text); + if (match !== null) + directive = { pos, end, enabled: match[1] === undefined }; + } + }); + return directive; +} +exports.getCheckJsDirective = getCheckJsDirective; +function isConstAssertion(node) { + return node_1.isTypeReferenceNode(node.type) && + node.type.typeName.kind === ts.SyntaxKind.Identifier && + node.type.typeName.escapedText === 'const'; +} +exports.isConstAssertion = isConstAssertion; +function isInConstContext(node) { + let current = node; + while (true) { + const parent = current.parent; + outer: switch (parent.kind) { + case ts.SyntaxKind.TypeAssertionExpression: + case ts.SyntaxKind.AsExpression: + return isConstAssertion(parent); + case ts.SyntaxKind.PrefixUnaryExpression: + if (current.kind !== ts.SyntaxKind.NumericLiteral) + return false; + switch (parent.operator) { + case ts.SyntaxKind.PlusToken: + case ts.SyntaxKind.MinusToken: + current = parent; + break outer; + default: + return false; + } + case ts.SyntaxKind.PropertyAssignment: + if (parent.initializer !== current) + return false; + current = parent.parent; + break; + case ts.SyntaxKind.ShorthandPropertyAssignment: + current = parent.parent; + break; + case ts.SyntaxKind.ParenthesizedExpression: + case ts.SyntaxKind.ArrayLiteralExpression: + case ts.SyntaxKind.ObjectLiteralExpression: + current = parent; + break; + default: + return false; + } + } +} +exports.isInConstContext = isInConstContext; +function isReadonlyAssignmentDeclaration(node, checker) { + if (!isBindableObjectDefinePropertyCall(node)) + return false; + const descriptorType = checker.getTypeAtLocation(node.arguments[2]); + if (descriptorType.getProperty('value') === undefined) + return descriptorType.getProperty('set') === undefined; + const writableProp = descriptorType.getProperty('writable'); + if (writableProp === undefined) + return false; + const writableType = writableProp.valueDeclaration !== undefined && node_1.isPropertyAssignment(writableProp.valueDeclaration) + ? checker.getTypeAtLocation(writableProp.valueDeclaration.initializer) + : checker.getTypeOfSymbolAtLocation(writableProp, node.arguments[2]); + return type_1.isBooleanLiteralType(writableType, false); +} +exports.isReadonlyAssignmentDeclaration = isReadonlyAssignmentDeclaration; +function isBindableObjectDefinePropertyCall(node) { + return node.arguments.length === 3 && + node_1.isEntityNameExpression(node.arguments[0]) && + node_1.isNumericOrStringLikeLiteral(node.arguments[1]) && + node_1.isPropertyAccessExpression(node.expression) && + node.expression.name.escapedText === 'defineProperty' && + node_1.isIdentifier(node.expression.expression) && + node.expression.expression.escapedText === 'Object'; +} +exports.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; +function isWellKnownSymbolLiterally(node) { + return ts.isPropertyAccessExpression(node) && + ts.isIdentifier(node.expression) && + node.expression.escapedText === 'Symbol'; +} +exports.isWellKnownSymbolLiterally = isWellKnownSymbolLiterally; +function getPropertyNameOfWellKnownSymbol(node) { + return { + displayName: `[Symbol.${node.name.text}]`, + symbolName: ('__@' + node.name.text), + }; +} +exports.getPropertyNameOfWellKnownSymbol = getPropertyNameOfWellKnownSymbol; +function getLateBoundPropertyNames(node, checker) { + const result = { + known: true, + names: [], + }; + node = unwrapParentheses(node); + if (isWellKnownSymbolLiterally(node)) { + result.names.push(getPropertyNameOfWellKnownSymbol(node)); + } + else { + const type = checker.getTypeAtLocation(node); + for (const key of type_1.unionTypeParts(checker.getBaseConstraintOfType(type) || type)) { + const propertyName = type_1.getPropertyNameFromType(key); + if (propertyName) { + result.names.push(propertyName); + } + else { + result.known = false; + } + } + } + return result; +} +exports.getLateBoundPropertyNames = getLateBoundPropertyNames; +function getLateBoundPropertyNamesOfPropertyName(node, checker) { + const staticName = getPropertyName(node); + return staticName !== undefined + ? { known: true, names: [{ displayName: staticName, symbolName: ts.escapeLeadingUnderscores(staticName) }] } + : getLateBoundPropertyNames(node.expression, checker); +} +exports.getLateBoundPropertyNamesOfPropertyName = getLateBoundPropertyNamesOfPropertyName; +function getSingleLateBoundPropertyNameOfPropertyName(node, checker) { + const staticName = getPropertyName(node); + if (staticName !== undefined) + return { displayName: staticName, symbolName: ts.escapeLeadingUnderscores(staticName) }; + const { expression } = node; + return isWellKnownSymbolLiterally(expression) + ? getPropertyNameOfWellKnownSymbol(expression) + : type_1.getPropertyNameFromType(checker.getTypeAtLocation(expression)); +} +exports.getSingleLateBoundPropertyNameOfPropertyName = getSingleLateBoundPropertyNameOfPropertyName; +function unwrapParentheses(node) { + while (node.kind === ts.SyntaxKind.ParenthesizedExpression) + node = node.expression; + return node; +} +exports.unwrapParentheses = unwrapParentheses; /***/ }), -/* 716 */, -/* 717 */, -/* 718 */, -/* 719 */, -/* 720 */ -/***/ (function(module) { +/* 714 */, +/* 715 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { -/** - * lodash (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause */ -/** `Object#toString` result references. */ -var objectTag = '[object Object]'; +var base64VLQ = __webpack_require__(474); +var util = __webpack_require__(737); +var ArraySet = __webpack_require__(998).ArraySet; +var MappingList = __webpack_require__(468).MappingList; /** - * Checks if `value` is a host object in IE < 9. + * An instance of the SourceMapGenerator represents a source map which is + * being built incrementally. You may pass an object with the following + * properties: * - * @private - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + * - file: The filename of the generated source. + * - sourceRoot: A root for all relative URLs in this source map. */ -function isHostObject(value) { - // Many host objects are `Object` objects that can coerce to strings - // despite having improperly defined `toString` methods. - var result = false; - if (value != null && typeof value.toString != 'function') { - try { - result = !!(value + ''); - } catch (e) {} +function SourceMapGenerator(aArgs) { + if (!aArgs) { + aArgs = {}; } - return result; + this._file = util.getArg(aArgs, 'file', null); + this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); + this._skipValidation = util.getArg(aArgs, 'skipValidation', false); + this._sources = new ArraySet(); + this._names = new ArraySet(); + this._mappings = new MappingList(); + this._sourcesContents = null; } +SourceMapGenerator.prototype._version = 3; + /** - * Creates a unary function that invokes `func` with its argument transformed. + * Creates a new SourceMapGenerator based on a SourceMapConsumer * - * @private - * @param {Function} func The function to wrap. - * @param {Function} transform The argument transform. - * @returns {Function} Returns the new function. + * @param aSourceMapConsumer The SourceMap. */ -function overArg(func, transform) { - return function(arg) { - return func(transform(arg)); - }; -} - -/** Used for built-in method references. */ -var funcProto = Function.prototype, - objectProto = Object.prototype; +SourceMapGenerator.fromSourceMap = + function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { + var sourceRoot = aSourceMapConsumer.sourceRoot; + var generator = new SourceMapGenerator({ + file: aSourceMapConsumer.file, + sourceRoot: sourceRoot + }); + aSourceMapConsumer.eachMapping(function (mapping) { + var newMapping = { + generated: { + line: mapping.generatedLine, + column: mapping.generatedColumn + } + }; -/** Used to resolve the decompiled source of functions. */ -var funcToString = funcProto.toString; + if (mapping.source != null) { + newMapping.source = mapping.source; + if (sourceRoot != null) { + newMapping.source = util.relative(sourceRoot, newMapping.source); + } -/** Used to check objects for own properties. */ -var hasOwnProperty = objectProto.hasOwnProperty; + newMapping.original = { + line: mapping.originalLine, + column: mapping.originalColumn + }; -/** Used to infer the `Object` constructor. */ -var objectCtorString = funcToString.call(Object); + if (mapping.name != null) { + newMapping.name = mapping.name; + } + } -/** + generator.addMapping(newMapping); + }); + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var sourceRelative = sourceFile; + if (sourceRoot !== null) { + sourceRelative = util.relative(sourceRoot, sourceFile); + } + + if (!generator._sources.has(sourceRelative)) { + generator._sources.add(sourceRelative); + } + + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + generator.setSourceContent(sourceFile, content); + } + }); + return generator; + }; + +/** + * Add a single mapping from original source line and column to the generated + * source's line and column for this source map being created. The mapping + * object should have the following properties: + * + * - generated: An object with the generated line and column positions. + * - original: An object with the original line and column positions. + * - source: The original source file (relative to the sourceRoot). + * - name: An optional original token name for this mapping. + */ +SourceMapGenerator.prototype.addMapping = + function SourceMapGenerator_addMapping(aArgs) { + var generated = util.getArg(aArgs, 'generated'); + var original = util.getArg(aArgs, 'original', null); + var source = util.getArg(aArgs, 'source', null); + var name = util.getArg(aArgs, 'name', null); + + if (!this._skipValidation) { + this._validateMapping(generated, original, source, name); + } + + if (source != null) { + source = String(source); + if (!this._sources.has(source)) { + this._sources.add(source); + } + } + + if (name != null) { + name = String(name); + if (!this._names.has(name)) { + this._names.add(name); + } + } + + this._mappings.add({ + generatedLine: generated.line, + generatedColumn: generated.column, + originalLine: original != null && original.line, + originalColumn: original != null && original.column, + source: source, + name: name + }); + }; + +/** + * Set the source content for a source file. + */ +SourceMapGenerator.prototype.setSourceContent = + function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { + var source = aSourceFile; + if (this._sourceRoot != null) { + source = util.relative(this._sourceRoot, source); + } + + if (aSourceContent != null) { + // Add the source content to the _sourcesContents map. + // Create a new _sourcesContents map if the property is null. + if (!this._sourcesContents) { + this._sourcesContents = Object.create(null); + } + this._sourcesContents[util.toSetString(source)] = aSourceContent; + } else if (this._sourcesContents) { + // Remove the source file from the _sourcesContents map. + // If the _sourcesContents map is empty, set the property to null. + delete this._sourcesContents[util.toSetString(source)]; + if (Object.keys(this._sourcesContents).length === 0) { + this._sourcesContents = null; + } + } + }; + +/** + * Applies the mappings of a sub-source-map for a specific source file to the + * source map being generated. Each mapping to the supplied source file is + * rewritten using the supplied source map. Note: The resolution for the + * resulting mappings is the minimium of this map and the supplied map. + * + * @param aSourceMapConsumer The source map to be applied. + * @param aSourceFile Optional. The filename of the source file. + * If omitted, SourceMapConsumer's file property will be used. + * @param aSourceMapPath Optional. The dirname of the path to the source map + * to be applied. If relative, it is relative to the SourceMapConsumer. + * This parameter is needed when the two source maps aren't in the same + * directory, and the source map to be applied contains relative source + * paths. If so, those relative source paths need to be rewritten + * relative to the SourceMapGenerator. + */ +SourceMapGenerator.prototype.applySourceMap = + function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { + var sourceFile = aSourceFile; + // If aSourceFile is omitted, we will use the file property of the SourceMap + if (aSourceFile == null) { + if (aSourceMapConsumer.file == null) { + throw new Error( + 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + + 'or the source map\'s "file" property. Both were omitted.' + ); + } + sourceFile = aSourceMapConsumer.file; + } + var sourceRoot = this._sourceRoot; + // Make "sourceFile" relative if an absolute Url is passed. + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + // Applying the SourceMap can add and remove items from the sources and + // the names array. + var newSources = new ArraySet(); + var newNames = new ArraySet(); + + // Find mappings for the "sourceFile" + this._mappings.unsortedForEach(function (mapping) { + if (mapping.source === sourceFile && mapping.originalLine != null) { + // Check if it can be mapped by the source map, then update the mapping. + var original = aSourceMapConsumer.originalPositionFor({ + line: mapping.originalLine, + column: mapping.originalColumn + }); + if (original.source != null) { + // Copy mapping + mapping.source = original.source; + if (aSourceMapPath != null) { + mapping.source = util.join(aSourceMapPath, mapping.source) + } + if (sourceRoot != null) { + mapping.source = util.relative(sourceRoot, mapping.source); + } + mapping.originalLine = original.line; + mapping.originalColumn = original.column; + if (original.name != null) { + mapping.name = original.name; + } + } + } + + var source = mapping.source; + if (source != null && !newSources.has(source)) { + newSources.add(source); + } + + var name = mapping.name; + if (name != null && !newNames.has(name)) { + newNames.add(name); + } + + }, this); + this._sources = newSources; + this._names = newNames; + + // Copy sourcesContents of applied map. + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + if (aSourceMapPath != null) { + sourceFile = util.join(aSourceMapPath, sourceFile); + } + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + this.setSourceContent(sourceFile, content); + } + }, this); + }; + +/** + * A mapping can have one of the three levels of data: + * + * 1. Just the generated position. + * 2. The Generated position, original position, and original source. + * 3. Generated and original position, original source, as well as a name + * token. + * + * To maintain consistency, we validate that any new mapping being added falls + * in to one of these categories. + */ +SourceMapGenerator.prototype._validateMapping = + function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, + aName) { + // When aOriginal is truthy but has empty values for .line and .column, + // it is most likely a programmer error. In this case we throw a very + // specific error message to try to guide them the right way. + // For example: https://github.com/Polymer/polymer-bundler/pull/519 + if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { + throw new Error( + 'original.line and original.column are not numbers -- you probably meant to omit ' + + 'the original mapping entirely and only map the generated position. If so, pass ' + + 'null for the original mapping instead of an object with empty or null values.' + ); + } + + if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aGenerated.line > 0 && aGenerated.column >= 0 + && !aOriginal && !aSource && !aName) { + // Case 1. + return; + } + else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aOriginal && 'line' in aOriginal && 'column' in aOriginal + && aGenerated.line > 0 && aGenerated.column >= 0 + && aOriginal.line > 0 && aOriginal.column >= 0 + && aSource) { + // Cases 2 and 3. + return; + } + else { + throw new Error('Invalid mapping: ' + JSON.stringify({ + generated: aGenerated, + source: aSource, + original: aOriginal, + name: aName + })); + } + }; + +/** + * Serialize the accumulated mappings in to the stream of base 64 VLQs + * specified by the source map format. + */ +SourceMapGenerator.prototype._serializeMappings = + function SourceMapGenerator_serializeMappings() { + var previousGeneratedColumn = 0; + var previousGeneratedLine = 1; + var previousOriginalColumn = 0; + var previousOriginalLine = 0; + var previousName = 0; + var previousSource = 0; + var result = ''; + var next; + var mapping; + var nameIdx; + var sourceIdx; + + var mappings = this._mappings.toArray(); + for (var i = 0, len = mappings.length; i < len; i++) { + mapping = mappings[i]; + next = '' + + if (mapping.generatedLine !== previousGeneratedLine) { + previousGeneratedColumn = 0; + while (mapping.generatedLine !== previousGeneratedLine) { + next += ';'; + previousGeneratedLine++; + } + } + else { + if (i > 0) { + if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { + continue; + } + next += ','; + } + } + + next += base64VLQ.encode(mapping.generatedColumn + - previousGeneratedColumn); + previousGeneratedColumn = mapping.generatedColumn; + + if (mapping.source != null) { + sourceIdx = this._sources.indexOf(mapping.source); + next += base64VLQ.encode(sourceIdx - previousSource); + previousSource = sourceIdx; + + // lines are stored 0-based in SourceMap spec version 3 + next += base64VLQ.encode(mapping.originalLine - 1 + - previousOriginalLine); + previousOriginalLine = mapping.originalLine - 1; + + next += base64VLQ.encode(mapping.originalColumn + - previousOriginalColumn); + previousOriginalColumn = mapping.originalColumn; + + if (mapping.name != null) { + nameIdx = this._names.indexOf(mapping.name); + next += base64VLQ.encode(nameIdx - previousName); + previousName = nameIdx; + } + } + + result += next; + } + + return result; + }; + +SourceMapGenerator.prototype._generateSourcesContent = + function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { + return aSources.map(function (source) { + if (!this._sourcesContents) { + return null; + } + if (aSourceRoot != null) { + source = util.relative(aSourceRoot, source); + } + var key = util.toSetString(source); + return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) + ? this._sourcesContents[key] + : null; + }, this); + }; + +/** + * Externalize the source map. + */ +SourceMapGenerator.prototype.toJSON = + function SourceMapGenerator_toJSON() { + var map = { + version: this._version, + sources: this._sources.toArray(), + names: this._names.toArray(), + mappings: this._serializeMappings() + }; + if (this._file != null) { + map.file = this._file; + } + if (this._sourceRoot != null) { + map.sourceRoot = this._sourceRoot; + } + if (this._sourcesContents) { + map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); + } + + return map; + }; + +/** + * Render the source map being generated to a string. + */ +SourceMapGenerator.prototype.toString = + function SourceMapGenerator_toString() { + return JSON.stringify(this.toJSON()); + }; + +exports.SourceMapGenerator = SourceMapGenerator; + + +/***/ }), +/* 716 */, +/* 717 */, +/* 718 */, +/* 719 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const parse = __webpack_require__(658) +const {re, t} = __webpack_require__(590) + +const coerce = (version, options) => { + if (version instanceof SemVer) { + return version + } + + if (typeof version === 'number') { + version = String(version) + } + + if (typeof version !== 'string') { + return null + } + + options = options || {} + + let match = null + if (!options.rtl) { + match = version.match(re[t.COERCE]) + } else { + // Find the right-most coercible string that does not share + // a terminus with a more left-ward coercible string. + // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // + // Walk through the string checking with a /g regexp + // Manually set the index so as to pick up overlapping matches. + // Stop when we get a match that ends at the string end, since no + // coercible string can be more right-ward without the same terminus. + let next + while ((next = re[t.COERCERTL].exec(version)) && + (!match || match.index + match[0].length !== version.length) + ) { + if (!match || + next.index + next[0].length !== match.index + match[0].length) { + match = next + } + re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + } + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 + } + + if (match === null) + return null + + return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) +} +module.exports = coerce + + +/***/ }), +/* 720 */ +/***/ (function(module) { + +/** + * lodash (Custom Build) + * Build: `lodash modularize exports="npm" -o ./` + * Copyright jQuery Foundation and other contributors + * Released under MIT license + * Based on Underscore.js 1.8.3 + * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + */ + +/** `Object#toString` result references. */ +var objectTag = '[object Object]'; + +/** + * Checks if `value` is a host object in IE < 9. + * + * @private + * @param {*} value The value to check. + * @returns {boolean} Returns `true` if `value` is a host object, else `false`. + */ +function isHostObject(value) { + // Many host objects are `Object` objects that can coerce to strings + // despite having improperly defined `toString` methods. + var result = false; + if (value != null && typeof value.toString != 'function') { + try { + result = !!(value + ''); + } catch (e) {} + } + return result; +} + +/** + * Creates a unary function that invokes `func` with its argument transformed. + * + * @private + * @param {Function} func The function to wrap. + * @param {Function} transform The argument transform. + * @returns {Function} Returns the new function. + */ +function overArg(func, transform) { + return function(arg) { + return func(transform(arg)); + }; +} + +/** Used for built-in method references. */ +var funcProto = Function.prototype, + objectProto = Object.prototype; + +/** Used to resolve the decompiled source of functions. */ +var funcToString = funcProto.toString; + +/** Used to check objects for own properties. */ +var hasOwnProperty = objectProto.hasOwnProperty; + +/** Used to infer the `Object` constructor. */ +var objectCtorString = funcToString.call(Object); + +/** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. @@ -98075,7 +101323,261 @@ module.exports = TokenizeError; /***/ }), -/* 733 */, +/* 733 */ +/***/ (function(module) { + +"use strict"; + + +var has = Object.prototype.hasOwnProperty; +var isArray = Array.isArray; + +var hexTable = (function () { + var array = []; + for (var i = 0; i < 256; ++i) { + array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); + } + + return array; +}()); + +var compactQueue = function compactQueue(queue) { + while (queue.length > 1) { + var item = queue.pop(); + var obj = item.obj[item.prop]; + + if (isArray(obj)) { + var compacted = []; + + for (var j = 0; j < obj.length; ++j) { + if (typeof obj[j] !== 'undefined') { + compacted.push(obj[j]); + } + } + + item.obj[item.prop] = compacted; + } + } +}; + +var arrayToObject = function arrayToObject(source, options) { + var obj = options && options.plainObjects ? Object.create(null) : {}; + for (var i = 0; i < source.length; ++i) { + if (typeof source[i] !== 'undefined') { + obj[i] = source[i]; + } + } + + return obj; +}; + +var merge = function merge(target, source, options) { + /* eslint no-param-reassign: 0 */ + if (!source) { + return target; + } + + if (typeof source !== 'object') { + if (isArray(target)) { + target.push(source); + } else if (target && typeof target === 'object') { + if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) { + target[source] = true; + } + } else { + return [target, source]; + } + + return target; + } + + if (!target || typeof target !== 'object') { + return [target].concat(source); + } + + var mergeTarget = target; + if (isArray(target) && !isArray(source)) { + mergeTarget = arrayToObject(target, options); + } + + if (isArray(target) && isArray(source)) { + source.forEach(function (item, i) { + if (has.call(target, i)) { + var targetItem = target[i]; + if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { + target[i] = merge(targetItem, item, options); + } else { + target.push(item); + } + } else { + target[i] = item; + } + }); + return target; + } + + return Object.keys(source).reduce(function (acc, key) { + var value = source[key]; + + if (has.call(acc, key)) { + acc[key] = merge(acc[key], value, options); + } else { + acc[key] = value; + } + return acc; + }, mergeTarget); +}; + +var assign = function assignSingleSource(target, source) { + return Object.keys(source).reduce(function (acc, key) { + acc[key] = source[key]; + return acc; + }, target); +}; + +var decode = function (str, decoder, charset) { + var strWithoutPlus = str.replace(/\+/g, ' '); + if (charset === 'iso-8859-1') { + // unescape never throws, no try...catch needed: + return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); + } + // utf-8 + try { + return decodeURIComponent(strWithoutPlus); + } catch (e) { + return strWithoutPlus; + } +}; + +var encode = function encode(str, defaultEncoder, charset) { + // This code was originally written by Brian White (mscdex) for the io.js core querystring library. + // It has been adapted here for stricter adherence to RFC 3986 + if (str.length === 0) { + return str; + } + + var string = str; + if (typeof str === 'symbol') { + string = Symbol.prototype.toString.call(str); + } else if (typeof str !== 'string') { + string = String(str); + } + + if (charset === 'iso-8859-1') { + return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { + return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; + }); + } + + var out = ''; + for (var i = 0; i < string.length; ++i) { + var c = string.charCodeAt(i); + + if ( + c === 0x2D // - + || c === 0x2E // . + || c === 0x5F // _ + || c === 0x7E // ~ + || (c >= 0x30 && c <= 0x39) // 0-9 + || (c >= 0x41 && c <= 0x5A) // a-z + || (c >= 0x61 && c <= 0x7A) // A-Z + ) { + out += string.charAt(i); + continue; + } + + if (c < 0x80) { + out = out + hexTable[c]; + continue; + } + + if (c < 0x800) { + out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + if (c < 0xD800 || c >= 0xE000) { + out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); + continue; + } + + i += 1; + c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); + out += hexTable[0xF0 | (c >> 18)] + + hexTable[0x80 | ((c >> 12) & 0x3F)] + + hexTable[0x80 | ((c >> 6) & 0x3F)] + + hexTable[0x80 | (c & 0x3F)]; + } + + return out; +}; + +var compact = function compact(value) { + var queue = [{ obj: { o: value }, prop: 'o' }]; + var refs = []; + + for (var i = 0; i < queue.length; ++i) { + var item = queue[i]; + var obj = item.obj[item.prop]; + + var keys = Object.keys(obj); + for (var j = 0; j < keys.length; ++j) { + var key = keys[j]; + var val = obj[key]; + if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { + queue.push({ obj: obj, prop: key }); + refs.push(val); + } + } + } + + compactQueue(queue); + + return value; +}; + +var isRegExp = function isRegExp(obj) { + return Object.prototype.toString.call(obj) === '[object RegExp]'; +}; + +var isBuffer = function isBuffer(obj) { + if (!obj || typeof obj !== 'object') { + return false; + } + + return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); +}; + +var combine = function combine(a, b) { + return [].concat(a, b); +}; + +var maybeMap = function maybeMap(val, fn) { + if (isArray(val)) { + var mapped = []; + for (var i = 0; i < val.length; i += 1) { + mapped.push(fn(val[i])); + } + return mapped; + } + return fn(val); +}; + +module.exports = { + arrayToObject: arrayToObject, + assign: assign, + combine: combine, + compact: compact, + decode: decode, + encode: encode, + isBuffer: isBuffer, + isRegExp: isRegExp, + maybeMap: maybeMap, + merge: merge +}; + + +/***/ }), /* 734 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -98791,7 +102293,15 @@ exports.computeSourceURL = computeSourceURL; /***/ }), -/* 738 */, +/* 738 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(570) +const gt = (a, b, loose) => compare(a, b, loose) > 0 +module.exports = gt + + +/***/ }), /* 739 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -99134,24 +102644,131 @@ module.exports = require("fs"); /***/ }), /* 748 */, -/* 749 */, -/* 750 */, +/* 749 */ +/***/ (function(module) { + +// Note: this is the semver.org version of the spec that it implements +// Not necessarily the package version of this code. +const SEMVER_SPEC_VERSION = '2.0.0' + +const MAX_LENGTH = 256 +const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 + +// Max safe segment length for coercion. +const MAX_SAFE_COMPONENT_LENGTH = 16 + +module.exports = { + SEMVER_SPEC_VERSION, + MAX_LENGTH, + MAX_SAFE_INTEGER, + MAX_SAFE_COMPONENT_LENGTH +} + + +/***/ }), +/* 750 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const Comparator = __webpack_require__(123) +const {ANY} = Comparator +const Range = __webpack_require__(986) +const satisfies = __webpack_require__(121) +const gt = __webpack_require__(136) +const lt = __webpack_require__(342) +const lte = __webpack_require__(495) +const gte = __webpack_require__(618) + +const outside = (version, range, hilo, options) => { + version = new SemVer(version, options) + range = new Range(range, options) + + let gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } + + // If it satisifes the range it is not outside + if (satisfies(version, range, options)) { + return false + } + + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. + + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] + + let high = null + let low = null + + comparators.forEach((comparator) => { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.0') + } + high = high || comparator + low = low || comparator + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator + } + }) + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false + } + } + return true +} + +module.exports = outside + + +/***/ }), /* 751 */, /* 752 */ /***/ (function(module, __unusedexports, __webpack_require__) { "use strict"; /*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. +Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - +License at http://www.apache.org/licenses/LICENSE-2.0 + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ @@ -99385,9 +103002,9 @@ var ts; (function (ts) { // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configurePrerelease` too. - ts.versionMajorMinor = "3.8"; + ts.versionMajorMinor = "3.9"; /** The version of the TypeScript compiler release */ - ts.version = "3.8.3"; + ts.version = "3.9.3"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -100173,6 +103790,18 @@ var ts; return to; } ts.append = append; + function combine(xs, ys) { + if (xs === undefined) + return ys; + if (ys === undefined) + return xs; + if (isArray(xs)) + return isArray(ys) ? concatenate(xs, ys) : append(xs, ys); + if (isArray(ys)) + return append(ys, xs); + return [xs, ys]; + } + ts.combine = combine; /** * Gets the actual offset into an array for a relative offset. Negative offsets indicate a * position offset from the end of the array. @@ -100632,6 +104261,10 @@ var ts; } } } + function createUnderscoreEscapedMultiMap() { + return createMultiMap(); + } + ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap; /** * Tests whether a value is an array. */ @@ -101307,84 +104940,192 @@ var ts; } } } + function padLeft(s, length) { + while (s.length < length) { + s = " " + s; + } + return s; + } + ts.padLeft = padLeft; + function padRight(s, length) { + while (s.length < length) { + s = s + " "; + } + return s; + } + ts.padRight = padRight; })(ts || (ts = {})); /* @internal */ var ts; (function (ts) { var Debug; (function (Debug) { - /* eslint-disable prefer-const */ - Debug.currentAssertionLevel = 0 /* None */; + var currentAssertionLevel = 0 /* None */; + // eslint-disable-next-line prefer-const Debug.isDebugging = false; - /* eslint-enable prefer-const */ + var assertionCache = {}; + function getAssertionLevel() { + return currentAssertionLevel; + } + Debug.getAssertionLevel = getAssertionLevel; + function setAssertionLevel(level) { + var prevAssertionLevel = currentAssertionLevel; + currentAssertionLevel = level; + if (level > prevAssertionLevel) { + // restore assertion functions for the current assertion level (see `shouldAssertFunction`). + for (var _i = 0, _a = ts.getOwnKeys(assertionCache); _i < _a.length; _i++) { + var key = _a[_i]; + var cachedFunc = assertionCache[key]; + if (cachedFunc !== undefined && Debug[key] !== cachedFunc.assertion && level >= cachedFunc.level) { + Debug[key] = cachedFunc; + assertionCache[key] = undefined; + } + } + } + } + Debug.setAssertionLevel = setAssertionLevel; function shouldAssert(level) { - return Debug.currentAssertionLevel >= level; + return currentAssertionLevel >= level; } Debug.shouldAssert = shouldAssert; + /** + * Tests whether an assertion function should be executed. If it shouldn't, it is cached and replaced with `ts.noop`. + * Replaced assertion functions are restored when `Debug.setAssertionLevel` is set to a high enough level. + * @param level The minimum assertion level required. + * @param name The name of the current assertion function. + */ + function shouldAssertFunction(level, name) { + if (!shouldAssert(level)) { + assertionCache[name] = { level: level, assertion: Debug[name] }; + Debug[name] = ts.noop; + return false; + } + return true; + } + function fail(message, stackCrawlMark) { + debugger; + var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); + if (Error.captureStackTrace) { + Error.captureStackTrace(e, stackCrawlMark || fail); + } + throw e; + } + Debug.fail = fail; + function failBadSyntaxKind(node, message, stackCrawlMark) { + return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind); + } + Debug.failBadSyntaxKind = failBadSyntaxKind; function assert(expression, message, verboseDebugInfo, stackCrawlMark) { if (!expression) { + message = message ? "False expression: " + message : "False expression."; if (verboseDebugInfo) { message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); } - fail(message ? "False expression: " + message : "False expression.", stackCrawlMark || assert); + fail(message, stackCrawlMark || assert); } } Debug.assert = assert; - function assertEqual(a, b, msg, msg2) { + function assertEqual(a, b, msg, msg2, stackCrawlMark) { if (a !== b) { var message = msg ? msg2 ? msg + " " + msg2 : msg : ""; - fail("Expected " + a + " === " + b + ". " + message); + fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual); } } Debug.assertEqual = assertEqual; - function assertLessThan(a, b, msg) { + function assertLessThan(a, b, msg, stackCrawlMark) { if (a >= b) { - fail("Expected " + a + " < " + b + ". " + (msg || "")); + fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan); } } Debug.assertLessThan = assertLessThan; - function assertLessThanOrEqual(a, b) { + function assertLessThanOrEqual(a, b, stackCrawlMark) { if (a > b) { - fail("Expected " + a + " <= " + b); + fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual); } } Debug.assertLessThanOrEqual = assertLessThanOrEqual; - function assertGreaterThanOrEqual(a, b) { + function assertGreaterThanOrEqual(a, b, stackCrawlMark) { if (a < b) { - fail("Expected " + a + " >= " + b); + fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual); } } Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; - function fail(message, stackCrawlMark) { - debugger; - var e = new Error(message ? "Debug Failure. " + message : "Debug Failure."); - if (Error.captureStackTrace) { - Error.captureStackTrace(e, stackCrawlMark || fail); + function assertIsDefined(value, message, stackCrawlMark) { + // eslint-disable-next-line no-null/no-null + if (value === undefined || value === null) { + fail(message, stackCrawlMark || assertIsDefined); } - throw e; } - Debug.fail = fail; - function assertDefined(value, message) { - // eslint-disable-next-line no-null/no-null - if (value === undefined || value === null) - return fail(message); + Debug.assertIsDefined = assertIsDefined; + function checkDefined(value, message, stackCrawlMark) { + assertIsDefined(value, message, stackCrawlMark || checkDefined); return value; } - Debug.assertDefined = assertDefined; - function assertEachDefined(value, message) { + Debug.checkDefined = checkDefined; + /** + * @deprecated Use `checkDefined` to check whether a value is defined inline. Use `assertIsDefined` to check whether + * a value is defined at the statement level. + */ + Debug.assertDefined = checkDefined; + function assertEachIsDefined(value, message, stackCrawlMark) { for (var _i = 0, value_1 = value; _i < value_1.length; _i++) { var v = value_1[_i]; - assertDefined(v, message); + assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined); } + } + Debug.assertEachIsDefined = assertEachIsDefined; + function checkEachDefined(value, message, stackCrawlMark) { + assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined); return value; } - Debug.assertEachDefined = assertEachDefined; + Debug.checkEachDefined = checkEachDefined; + /** + * @deprecated Use `checkEachDefined` to check whether the elements of an array are defined inline. Use `assertEachIsDefined` to check whether + * the elements of an array are defined at the statement level. + */ + Debug.assertEachDefined = checkEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; + function assertEachNode(nodes, test, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode); + } + } + Debug.assertEachNode = assertEachNode; + function assertNode(node, test, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode); + } + } + Debug.assertNode = assertNode; + function assertNotNode(node, test, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNotNode); + } + } + Debug.assertNotNode = assertNotNode; + function assertOptionalNode(node, test, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode); + } + } + Debug.assertOptionalNode = assertOptionalNode; + function assertOptionalToken(node, kind, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, stackCrawlMark || assertOptionalToken); + } + } + Debug.assertOptionalToken = assertOptionalToken; + function assertMissingNode(node, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode); + } + } + Debug.assertMissingNode = assertMissingNode; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -101482,28 +105223,6 @@ var ts; return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true); } Debug.formatObjectFlags = formatObjectFlags; - function failBadSyntaxKind(node, message) { - return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", failBadSyntaxKind); - } - Debug.failBadSyntaxKind = failBadSyntaxKind; - Debug.assertEachNode = shouldAssert(1 /* Normal */) - ? function (nodes, test, message) { return assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertEachNode); } - : ts.noop; - Debug.assertNode = shouldAssert(1 /* Normal */) - ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } - : ts.noop; - Debug.assertNotNode = shouldAssert(1 /* Normal */) - ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } - : ts.noop; - Debug.assertOptionalNode = shouldAssert(1 /* Normal */) - ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } - : ts.noop; - Debug.assertOptionalToken = shouldAssert(1 /* Normal */) - ? function (node, kind, message) { return assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was not a '" + formatSyntaxKind(kind) + "' token."; }, Debug.assertOptionalToken); } - : ts.noop; - Debug.assertMissingNode = shouldAssert(1 /* Normal */) - ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); } - : ts.noop; var isDebugInfoEnabled = false; var extendedDebugModule; function extendedDebug() { @@ -101789,7 +105508,7 @@ var ts; if (prerelease === void 0) { prerelease = ""; } if (build === void 0) { build = ""; } if (typeof major === "string") { - var result = ts.Debug.assertDefined(tryParseComponents(major), "Invalid version"); + var result = ts.Debug.checkDefined(tryParseComponents(major), "Invalid version"); (major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build); } ts.Debug.assert(major >= 0, "Invalid argument: major"); @@ -101920,7 +105639,7 @@ var ts; */ var VersionRange = /** @class */ (function () { function VersionRange(spec) { - this._alternatives = spec ? ts.Debug.assertDefined(parseRange(spec), "Invalid range spec.") : ts.emptyArray; + this._alternatives = spec ? ts.Debug.checkDefined(parseRange(spec), "Invalid range spec.") : ts.emptyArray; } VersionRange.tryParse = function (text) { var sets = parseRange(text); @@ -102460,32 +106179,33 @@ var ts; SyntaxKind[SyntaxKind["JSDocSignature"] = 305] = "JSDocSignature"; SyntaxKind[SyntaxKind["JSDocTag"] = 306] = "JSDocTag"; SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 307] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 308] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 309] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocPublicTag"] = 310] = "JSDocPublicTag"; - SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 311] = "JSDocPrivateTag"; - SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 312] = "JSDocProtectedTag"; - SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 313] = "JSDocReadonlyTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 314] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 315] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 316] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 317] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 318] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 319] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 320] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 321] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 322] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 308] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 309] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 310] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 311] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 312] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 313] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 314] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 315] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 316] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 317] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 318] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 319] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 320] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 321] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 322] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 323] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 323] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 324] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 324] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 325] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 326] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 327] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 328] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 329] = "SyntheticReferenceExpression"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 325] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 326] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 327] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 328] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 329] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 330] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 330] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 331] = "Count"; // Markers SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; @@ -102515,9 +106235,9 @@ var ts; SyntaxKind[SyntaxKind["LastStatement"] = 241] = "LastStatement"; SyntaxKind[SyntaxKind["FirstNode"] = 153] = "FirstNode"; SyntaxKind[SyntaxKind["FirstJSDocNode"] = 294] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 322] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 323] = "LastJSDocNode"; SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 306] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 322] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 323] = "LastJSDocTagNode"; /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 122] = "FirstContextualKeyword"; /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 152] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); @@ -102650,6 +106370,8 @@ var ts; /* @internal */ TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; /* @internal */ + TokenFlags[TokenFlags["ContainsInvalidEscape"] = 2048] = "ContainsInvalidEscape"; + /* @internal */ TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; @@ -102667,13 +106389,18 @@ var ts; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; FlowFlags[FlowFlags["Call"] = 512] = "Call"; - FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; + FlowFlags[FlowFlags["ReduceLabel"] = 1024] = "ReduceLabel"; + FlowFlags[FlowFlags["Referenced"] = 2048] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 4096] = "Shared"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); + /* @internal */ + var CommentDirectiveType; + (function (CommentDirectiveType) { + CommentDirectiveType[CommentDirectiveType["ExpectError"] = 0] = "ExpectError"; + CommentDirectiveType[CommentDirectiveType["Ignore"] = 1] = "Ignore"; + })(CommentDirectiveType = ts.CommentDirectiveType || (ts.CommentDirectiveType = {})); var OperationCanceledException = /** @class */ (function () { function OperationCanceledException() { } @@ -102748,6 +106475,7 @@ var ts; NodeBuilderFlags[NodeBuilderFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; + NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; // Error handling NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; NodeBuilderFlags[NodeBuilderFlags["AllowQualifedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifedNameInPlaceOfIdentifier"; @@ -102786,6 +106514,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; + TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -102797,7 +106526,7 @@ var ts; TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument"; TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; /** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 277904747] = "NodeBuilderFlagsMask"; + TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 814775659] = "NodeBuilderFlagsMask"; })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); var SymbolFormatFlags; (function (SymbolFormatFlags) { @@ -102975,6 +106704,9 @@ var ts; CheckFlags[CheckFlags["OptionalParameter"] = 16384] = "OptionalParameter"; CheckFlags[CheckFlags["RestParameter"] = 32768] = "RestParameter"; CheckFlags[CheckFlags["DeferredType"] = 65536] = "DeferredType"; + CheckFlags[CheckFlags["HasNeverType"] = 131072] = "HasNeverType"; + CheckFlags[CheckFlags["Mapped"] = 262144] = "Mapped"; + CheckFlags[CheckFlags["StripOptional"] = 524288] = "StripOptional"; CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; CheckFlags[CheckFlags["Discriminant"] = 192] = "Discriminant"; CheckFlags[CheckFlags["Partial"] = 48] = "Partial"; @@ -103091,6 +106823,8 @@ var ts; TypeFlags[TypeFlags["ObjectFlagsType"] = 3899393] = "ObjectFlagsType"; /* @internal */ TypeFlags[TypeFlags["Simplifiable"] = 25165824] = "Simplifiable"; + /* @internal */ + TypeFlags[TypeFlags["Substructure"] = 66584576] = "Substructure"; // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never TypeFlags[TypeFlags["Narrowable"] = 133970943] = "Narrowable"; @@ -103099,19 +106833,16 @@ var ts; TypeFlags[TypeFlags["NotPrimitiveUnion"] = 66994211] = "NotPrimitiveUnion"; // The following flags are aggregated during union and intersection type construction /* @internal */ - TypeFlags[TypeFlags["IncludesMask"] = 68943871] = "IncludesMask"; + TypeFlags[TypeFlags["IncludesMask"] = 71041023] = "IncludesMask"; // The following flags are used for different purposes during union and intersection type construction /* @internal */ TypeFlags[TypeFlags["IncludesStructuredOrInstantiable"] = 262144] = "IncludesStructuredOrInstantiable"; /* @internal */ - TypeFlags[TypeFlags["IncludesNonWideningType"] = 2097152] = "IncludesNonWideningType"; - /* @internal */ - TypeFlags[TypeFlags["IncludesWildcard"] = 4194304] = "IncludesWildcard"; + TypeFlags[TypeFlags["IncludesNonWideningType"] = 4194304] = "IncludesNonWideningType"; /* @internal */ - TypeFlags[TypeFlags["IncludesEmptyObject"] = 8388608] = "IncludesEmptyObject"; - // The following flag is used for different purposes by maybeTypeOfKind + TypeFlags[TypeFlags["IncludesWildcard"] = 8388608] = "IncludesWildcard"; /* @internal */ - TypeFlags[TypeFlags["GenericMappedType"] = 131072] = "GenericMappedType"; + TypeFlags[TypeFlags["IncludesEmptyObject"] = 16777216] = "IncludesEmptyObject"; })(TypeFlags = ts.TypeFlags || (ts.TypeFlags = {})); var ObjectFlags; (function (ObjectFlags) { @@ -103141,6 +106872,24 @@ var ts; ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 1048576] = "ContainsObjectOrArrayLiteral"; /* @internal */ ObjectFlags[ObjectFlags["NonInferrableType"] = 2097152] = "NonInferrableType"; + /* @internal */ + ObjectFlags[ObjectFlags["IsGenericObjectTypeComputed"] = 4194304] = "IsGenericObjectTypeComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType"; + /* @internal */ + ObjectFlags[ObjectFlags["IsGenericIndexTypeComputed"] = 16777216] = "IsGenericIndexTypeComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["IsGenericIndexType"] = 33554432] = "IsGenericIndexType"; + /* @internal */ + ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 67108864] = "CouldContainTypeVariablesComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 134217728] = "CouldContainTypeVariables"; + /* @internal */ + ObjectFlags[ObjectFlags["ContainsIntersections"] = 268435456] = "ContainsIntersections"; + /* @internal */ + ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 268435456] = "IsNeverIntersectionComputed"; + /* @internal */ + ObjectFlags[ObjectFlags["IsNeverIntersection"] = 536870912] = "IsNeverIntersection"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; /* @internal */ ObjectFlags[ObjectFlags["RequiresWidening"] = 1572864] = "RequiresWidening"; @@ -103180,6 +106929,7 @@ var ts; SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes"; SignatureFlags[SignatureFlags["IsInnerCallChain"] = 4] = "IsInnerCallChain"; SignatureFlags[SignatureFlags["IsOuterCallChain"] = 8] = "IsOuterCallChain"; + SignatureFlags[SignatureFlags["IsUntypedSignatureInJSFile"] = 16] = "IsUntypedSignatureInJSFile"; // We do not propagate `IsInnerCallChain` to instantiated signatures, as that would result in us // attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when // instantiating the return type. @@ -103191,6 +106941,15 @@ var ts; IndexKind[IndexKind["String"] = 0] = "String"; IndexKind[IndexKind["Number"] = 1] = "Number"; })(IndexKind = ts.IndexKind || (ts.IndexKind = {})); + /* @internal */ + var TypeMapKind; + (function (TypeMapKind) { + TypeMapKind[TypeMapKind["Simple"] = 0] = "Simple"; + TypeMapKind[TypeMapKind["Array"] = 1] = "Array"; + TypeMapKind[TypeMapKind["Function"] = 2] = "Function"; + TypeMapKind[TypeMapKind["Composite"] = 3] = "Composite"; + TypeMapKind[TypeMapKind["Merged"] = 4] = "Merged"; + })(TypeMapKind = ts.TypeMapKind || (ts.TypeMapKind = {})); var InferencePriority; (function (InferencePriority) { InferencePriority[InferencePriority["NakedTypeVariable"] = 1] = "NakedTypeVariable"; @@ -103612,6 +107371,7 @@ var ts; EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping"; /*@internal*/ EmitFlags[EmitFlags["TypeScriptClassWrapper"] = 33554432] = "TypeScriptClassWrapper"; /*@internal*/ EmitFlags[EmitFlags["NeverApplyImportHelper"] = 67108864] = "NeverApplyImportHelper"; + /*@internal*/ EmitFlags[EmitFlags["IgnoreSourceNewlines"] = 134217728] = "IgnoreSourceNewlines"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); /** * Used by the checker, this enum keeps track of external emit helpers that should be type @@ -103640,8 +107400,9 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["MakeTemplateObject"] = 131072] = "MakeTemplateObject"; ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldGet"] = 262144] = "ClassPrivateFieldGet"; ExternalEmitHelpers[ExternalEmitHelpers["ClassPrivateFieldSet"] = 524288] = "ClassPrivateFieldSet"; + ExternalEmitHelpers[ExternalEmitHelpers["CreateBinding"] = 1048576] = "CreateBinding"; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; - ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 524288] = "LastEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 1048576] = "LastEmitHelper"; // Helpers included by ES2015 for..of ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes"; // Helpers included by ES2017 for..await..of @@ -103663,6 +107424,13 @@ var ts; EmitHint[EmitHint["EmbeddedStatement"] = 5] = "EmbeddedStatement"; EmitHint[EmitHint["JsxAttributeValue"] = 6] = "JsxAttributeValue"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); + /* @internal */ + var LexicalEnvironmentFlags; + (function (LexicalEnvironmentFlags) { + LexicalEnvironmentFlags[LexicalEnvironmentFlags["None"] = 0] = "None"; + LexicalEnvironmentFlags[LexicalEnvironmentFlags["InParameters"] = 1] = "InParameters"; + LexicalEnvironmentFlags[LexicalEnvironmentFlags["VariablesHoistedInParameters"] = 2] = "VariablesHoistedInParameters"; // a temp variable was hoisted while visiting a parameter list + })(LexicalEnvironmentFlags = ts.LexicalEnvironmentFlags || (ts.LexicalEnvironmentFlags = {})); /*@internal*/ var BundleFileSectionKind; (function (BundleFileSectionKind) { @@ -103712,6 +107480,7 @@ var ts; ListFormat[ListFormat["NoInterveningComments"] = 262144] = "NoInterveningComments"; ListFormat[ListFormat["NoSpaceIfEmpty"] = 524288] = "NoSpaceIfEmpty"; ListFormat[ListFormat["SingleElement"] = 1048576] = "SingleElement"; + ListFormat[ListFormat["SpaceAfterList"] = 2097152] = "SpaceAfterList"; // Precomputed Formats ListFormat[ListFormat["Modifiers"] = 262656] = "Modifiers"; ListFormat[ListFormat["HeritageClauses"] = 512] = "HeritageClauses"; @@ -103744,7 +107513,7 @@ var ts; ListFormat[ListFormat["CaseOrDefaultClauseStatements"] = 163969] = "CaseOrDefaultClauseStatements"; ListFormat[ListFormat["HeritageClauseTypes"] = 528] = "HeritageClauseTypes"; ListFormat[ListFormat["SourceFileStatements"] = 131073] = "SourceFileStatements"; - ListFormat[ListFormat["Decorators"] = 49153] = "Decorators"; + ListFormat[ListFormat["Decorators"] = 2146305] = "Decorators"; ListFormat[ListFormat["TypeArguments"] = 53776] = "TypeArguments"; ListFormat[ListFormat["TypeParameters"] = 53776] = "TypeParameters"; ListFormat[ListFormat["Parameters"] = 2576] = "Parameters"; @@ -104124,7 +107893,7 @@ var ts; callbacksCache.add(path, callback); return { close: function () { - var watcher = ts.Debug.assertDefined(cache.get(path)); + var watcher = ts.Debug.checkDefined(cache.get(path)); callbacksCache.remove(path, callback); watcher.refCount--; if (watcher.refCount) @@ -104222,7 +107991,7 @@ var ts; return { dirName: dirName, close: function () { - var directoryWatcher = ts.Debug.assertDefined(cache.get(dirPath)); + var directoryWatcher = ts.Debug.checkDefined(cache.get(dirPath)); if (callbackToAdd) callbackCache.remove(dirPath, callbackToAdd); directoryWatcher.refCount--; @@ -104409,7 +108178,7 @@ var ts; }; function watchFile(fileName, callback, pollingInterval, options) { options = updateOptionsForWatchFile(options, useNonPollingWatchers); - var watchFileKind = ts.Debug.assertDefined(options.watchFile); + var watchFileKind = ts.Debug.checkDefined(options.watchFile); switch (watchFileKind) { case ts.WatchFileKind.FixedPollingInterval: return pollingWatchFile(fileName, callback, PollingInterval.Low, /*options*/ undefined); @@ -104489,7 +108258,7 @@ var ts; function nonRecursiveWatchDirectory(directoryName, callback, recursive, options) { ts.Debug.assert(!recursive); options = updateOptionsForWatchDirectory(options); - var watchDirectoryKind = ts.Debug.assertDefined(options.watchDirectory); + var watchDirectoryKind = ts.Debug.checkDefined(options.watchDirectory); switch (watchDirectoryKind) { case ts.WatchDirectoryKind.FixedPollingInterval: return pollingWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, @@ -104669,7 +108438,7 @@ var ts; enableCPUProfiler: enableCPUProfiler, disableCPUProfiler: disableCPUProfiler, realpath: realpath, - debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), + debugMode: !!process.env.NODE_INSPECTOR_IPC || ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { try { __webpack_require__(662).install(); @@ -105095,48 +108864,8 @@ var ts; return hash.digest("hex"); } } - function getChakraSystem() { - var realpath = ChakraHost.realpath && (function (path) { return ChakraHost.realpath(path); }); - return { - newLine: ChakraHost.newLine || "\r\n", - args: ChakraHost.args, - useCaseSensitiveFileNames: !!ChakraHost.useCaseSensitiveFileNames, - write: ChakraHost.echo, - readFile: function (path, _encoding) { - // encoding is automatically handled by the implementation in ChakraHost - return ChakraHost.readFile(path); - }, - writeFile: function (path, data, writeByteOrderMark) { - // If a BOM is required, emit one - if (writeByteOrderMark) { - data = byteOrderMarkIndicator + data; - } - ChakraHost.writeFile(path, data); - }, - resolvePath: ChakraHost.resolvePath, - fileExists: ChakraHost.fileExists, - deleteFile: ChakraHost.deleteFile, - getModifiedTime: ChakraHost.getModifiedTime, - setModifiedTime: ChakraHost.setModifiedTime, - directoryExists: ChakraHost.directoryExists, - createDirectory: ChakraHost.createDirectory, - getExecutingFilePath: function () { return ChakraHost.executingFile; }, - getCurrentDirectory: function () { return ChakraHost.currentDirectory; }, - getDirectories: ChakraHost.getDirectories, - getEnvironmentVariable: ChakraHost.getEnvironmentVariable || (function () { return ""; }), - readDirectory: function (path, extensions, excludes, includes, _depth) { - var pattern = ts.getFileMatcherPatterns(path, excludes, includes, !!ChakraHost.useCaseSensitiveFileNames, ChakraHost.currentDirectory); - return ChakraHost.readDirectory(path, extensions, pattern.basePaths, pattern.excludePattern, pattern.includeFilePattern, pattern.includeDirectoryPattern); - }, - exit: ChakraHost.quit, - realpath: realpath - }; - } var sys; - if (typeof ChakraHost !== "undefined") { - sys = getChakraSystem(); - } - else if (typeof process !== "undefined" && process.nextTick && !process.browser && "function" !== "undefined") { + if (typeof process !== "undefined" && process.nextTick && !process.browser && "function" !== "undefined") { // process and process.nextTick checks if current environment is node-like // process.browser check excludes webpack and browserify sys = getNodeSystem(); @@ -105149,9 +108878,9 @@ var ts; })(); if (ts.sys && ts.sys.getEnvironmentVariable) { setCustomPollingValues(ts.sys); - ts.Debug.currentAssertionLevel = /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) + ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV")) ? 1 /* Normal */ - : 0 /* None */; + : 0 /* None */); } if (ts.sys && ts.sys.debugMode) { ts.Debug.isDebugging = true; @@ -105579,6 +109308,7 @@ var ts; * * ```ts * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"] + * ``` */ function getNormalizedPathComponents(path, currentDirectory) { return reducePathComponents(getPathComponents(path, currentDirectory)); @@ -105823,6 +109553,10 @@ var ts; } } ts.forEachAncestorDirectory = forEachAncestorDirectory; + function isNodeModulesDirectory(dirPath) { + return ts.endsWith(dirPath, "/node_modules"); + } + ts.isNodeModulesDirectory = isNodeModulesDirectory; })(ts || (ts = {})); // // generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' @@ -105854,6 +109588,7 @@ var ts; An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), An_index_signature_parameter_type_must_be_either_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_either_string_or_number_1023", "An index signature parameter type must be either 'string' or 'number'."), readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), + An_index_signature_cannot_have_a_trailing_comma: diag(1025, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_trailing_comma_1025", "An index signature cannot have a trailing comma."), Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), @@ -105986,6 +109721,7 @@ var ts; Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), + export_Asterisk_does_not_re_export_a_default: diag(1195, ts.DiagnosticCategory.Error, "export_Asterisk_does_not_re_export_a_default_1195", "'export *' does not re-export a default."), Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), @@ -106117,7 +109853,10 @@ var ts; Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1378, ts.DiagnosticCategory.Error, "Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_t_1378", "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."), An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type: diag(1379, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type_1379", "An import alias cannot reference a declaration that was exported using 'export type'."), An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type: diag(1380, ts.DiagnosticCategory.Error, "An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type_1380", "An import alias cannot reference a declaration that was imported using 'import type'."), + Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"), + Unexpected_token_Did_you_mean_or_gt: diag(1382, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `>`?"), Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."), + A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list: diag(1384, ts.DiagnosticCategory.Error, "A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list_1384", "A 'new' expression with type arguments must always be followed by a parenthesized argument list."), The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), @@ -106131,7 +109870,7 @@ var ts; Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), - Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), + Cannot_find_module_0_or_its_corresponding_type_declarations: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_or_its_corresponding_type_declarations_2307", "Cannot find module '{0}' or its corresponding type declarations."), Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), @@ -106196,8 +109935,8 @@ var ts; A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."), - Parameter_0_cannot_be_referenced_in_its_initializer: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_be_referenced_in_its_initializer_2372", "Parameter '{0}' cannot be referenced in its initializer."), - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it."), + Parameter_0_cannot_reference_itself: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_itself_2372", "Parameter '{0}' cannot reference itself."), + Parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Parameter '{0}' cannot reference identifier '{1}' declared after it."), Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."), Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."), A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties, parameter properties, or private identifiers."), @@ -106222,6 +109961,7 @@ var ts; Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: diag(2395, ts.DiagnosticCategory.Error, "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", "Individual declarations in merged declaration '{0}' must be all exported or all local."), Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: diag(2396, ts.DiagnosticCategory.Error, "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters."), Declaration_name_conflicts_with_built_in_global_identifier_0: diag(2397, ts.DiagnosticCategory.Error, "Declaration_name_conflicts_with_built_in_global_identifier_0_2397", "Declaration name conflicts with built-in global identifier '{0}'."), + constructor_cannot_be_used_as_a_parameter_property_name: diag(2398, ts.DiagnosticCategory.Error, "constructor_cannot_be_used_as_a_parameter_property_name_2398", "'constructor' cannot be used as a parameter property name."), Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."), Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."), Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: diag(2401, ts.DiagnosticCategory.Error, "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference."), @@ -106362,7 +110102,6 @@ var ts; Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference: diag(2543, ts.DiagnosticCategory.Error, "Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_me_2543", "Duplicate identifier '_newTarget'. Compiler uses variable declaration '_newTarget' to capture 'new.target' meta-property reference."), Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: diag(2544, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference."), A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: diag(2545, ts.DiagnosticCategory.Error, "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", "A mixin class must have a constructor with a single rest parameter of type 'any[]'."), - Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: diag(2546, ts.DiagnosticCategory.Error, "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'."), The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: diag(2547, ts.DiagnosticCategory.Error, "The_type_returned_by_the_0_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_pro_2547", "The type returned by the '{0}()' method of an async iterator must be a promise for a type with a 'value' property."), Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2548, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator."), Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: diag(2549, ts.DiagnosticCategory.Error, "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator."), @@ -106391,6 +110130,7 @@ var ts; No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments: diag(2575, ts.DiagnosticCategory.Error, "No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments_2575", "No overload expects {0} arguments, but overloads do exist that expect either {1} or {2} arguments."), Property_0_is_a_static_member_of_type_1: diag(2576, ts.DiagnosticCategory.Error, "Property_0_is_a_static_member_of_type_1_2576", "Property '{0}' is a static member of type '{1}'"), Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."), + Unused_ts_expect_error_directive: diag(2578, ts.DiagnosticCategory.Error, "Unused_ts_expect_error_directive_2578", "Unused '@ts-expect-error' directive."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode: diag(2580, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_types_Slashnode_2580", "Cannot find name '{0}'. Do you need to install type definitions for node? Try `npm i @types/node`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery: diag(2581, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_2581", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery`."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha: diag(2582, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2582", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`."), @@ -106406,6 +110146,10 @@ var ts; Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_and_then_add_jquery_to_the_types_field_in_your_tsconfig: diag(2592, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_types_Slashjquery_an_2592", "Cannot find name '{0}'. Do you need to install type definitions for jQuery? Try `npm i @types/jquery` and then add `jquery` to the types field in your tsconfig."), Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashjest_or_npm_i_types_Slashmocha_and_then_add_jest_or_mocha_to_the_types_field_in_your_tsconfig: diag(2593, ts.DiagnosticCategory.Error, "Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_a_test_runner_Try_npm_i_types_Slashje_2593", "Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha` and then add `jest` or `mocha` to the types field in your tsconfig."), This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag: diag(2594, ts.DiagnosticCategory.Error, "This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the__2594", "This module is declared with using 'export =', and can only be used with a default import when using the '{0}' flag."), + _0_can_only_be_imported_by_using_a_default_import: diag(2595, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_default_import_2595", "'{0}' can only be imported by using a default import."), + _0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2596, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import_2596", "'{0}' can only be imported by turning on the 'esModuleInterop' flag and using a default import."), + _0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import: diag(2597, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import_2597", "'{0}' can only be imported by using a 'require' call or by using a default import."), + _0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2598, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using__2598", "'{0}' can only be imported by using a 'require' call or by turning on the 'esModuleInterop' flag and using a default import."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -106421,6 +110165,9 @@ var ts; Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(2613, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(2614, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), + Type_of_property_0_circularly_references_itself_in_mapped_type_1: diag(2615, ts.DiagnosticCategory.Error, "Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615", "Type of property '{0}' circularly references itself in mapped type '{1}'."), + _0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import: diag(2616, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import_2616", "'{0}' can only be imported by using 'import {1} = require({2})' or a default import."), + _0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import: diag(2617, ts.DiagnosticCategory.Error, "_0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_us_2617", "'{0}' can only be imported by using 'import {1} = require({2})' or by turning on the 'esModuleInterop' flag and using a default import."), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -106503,7 +110250,7 @@ var ts; Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String: diag(2731, ts.DiagnosticCategory.Error, "Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_i_2731", "Implicit conversion of a 'symbol' to a 'string' will fail at runtime. Consider wrapping this expression in 'String(...)'."), Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension: diag(2732, ts.DiagnosticCategory.Error, "Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension_2732", "Cannot find module '{0}'. Consider using '--resolveJsonModule' to import module with '.json' extension"), Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."), - It_is_highly_likely_that_you_are_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "It_is_highly_likely_that_you_are_missing_a_semicolon_2734", "It is highly likely that you are missing a semicolon."), + Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"), Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1: diag(2735, ts.DiagnosticCategory.Error, "Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1_2735", "Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?"), Operator_0_cannot_be_applied_to_type_1: diag(2736, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_type_1_2736", "Operator '{0}' cannot be applied to type '{1}'."), BigInt_literals_are_not_available_when_targeting_lower_than_ES2020: diag(2737, ts.DiagnosticCategory.Error, "BigInt_literals_are_not_available_when_targeting_lower_than_ES2020_2737", "BigInt literals are not available when targeting lower than ES2020."), @@ -106518,7 +110265,7 @@ var ts; This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided: diag(2746, ts.DiagnosticCategory.Error, "This_JSX_tag_s_0_prop_expects_a_single_child_of_type_1_but_multiple_children_were_provided_2746", "This JSX tag's '{0}' prop expects a single child of type '{1}', but multiple children were provided."), _0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_type_of_1_is_2: diag(2747, ts.DiagnosticCategory.Error, "_0_components_don_t_accept_text_as_child_elements_Text_in_JSX_has_the_type_string_but_the_expected_t_2747", "'{0}' components don't accept text as child elements. Text in JSX has the type 'string', but the expected type of '{1}' is '{2}'."), Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided: diag(2748, ts.DiagnosticCategory.Error, "Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided_2748", "Cannot access ambient const enums when the '--isolatedModules' flag is provided."), - _0_refers_to_a_value_but_is_being_used_as_a_type_here: diag(2749, ts.DiagnosticCategory.Error, "_0_refers_to_a_value_but_is_being_used_as_a_type_here_2749", "'{0}' refers to a value, but is being used as a type here."), + _0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0: diag(2749, ts.DiagnosticCategory.Error, "_0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0_2749", "'{0}' refers to a value, but is being used as a type here. Did you mean 'typeof {0}'?"), The_implementation_signature_is_declared_here: diag(2750, ts.DiagnosticCategory.Error, "The_implementation_signature_is_declared_here_2750", "The implementation signature is declared here."), Circularity_originates_in_type_at_this_location: diag(2751, ts.DiagnosticCategory.Error, "Circularity_originates_in_type_at_this_location_2751", "Circularity originates in type at this location."), The_first_export_default_is_here: diag(2752, ts.DiagnosticCategory.Error, "The_first_export_default_is_here_2752", "The first export default is here."), @@ -106552,6 +110299,13 @@ var ts; The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), _0_needs_an_explicit_type_annotation: diag(2782, ts.DiagnosticCategory.Message, "_0_needs_an_explicit_type_annotation_2782", "'{0}' needs an explicit type annotation."), + _0_is_specified_more_than_once_so_this_usage_will_be_overwritten: diag(2783, ts.DiagnosticCategory.Error, "_0_is_specified_more_than_once_so_this_usage_will_be_overwritten_2783", "'{0}' is specified more than once, so this usage will be overwritten."), + get_and_set_accessors_cannot_declare_this_parameters: diag(2784, ts.DiagnosticCategory.Error, "get_and_set_accessors_cannot_declare_this_parameters_2784", "'get' and 'set' accessors cannot declare 'this' parameters."), + This_spread_always_overwrites_this_property: diag(2785, ts.DiagnosticCategory.Error, "This_spread_always_overwrites_this_property_2785", "This spread always overwrites this property."), + _0_cannot_be_used_as_a_JSX_component: diag(2786, ts.DiagnosticCategory.Error, "_0_cannot_be_used_as_a_JSX_component_2786", "'{0}' cannot be used as a JSX component."), + Its_return_type_0_is_not_a_valid_JSX_element: diag(2787, ts.DiagnosticCategory.Error, "Its_return_type_0_is_not_a_valid_JSX_element_2787", "Its return type '{0}' is not a valid JSX element."), + Its_instance_type_0_is_not_a_valid_JSX_element: diag(2788, ts.DiagnosticCategory.Error, "Its_instance_type_0_is_not_a_valid_JSX_element_2788", "Its instance type '{0}' is not a valid JSX element."), + Its_element_type_0_is_not_a_valid_JSX_element: diag(2789, ts.DiagnosticCategory.Error, "Its_element_type_0_is_not_a_valid_JSX_element_2789", "Its element type '{0}' is not a valid JSX element."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -106686,6 +110440,8 @@ var ts; Unknown_watch_option_0_Did_you_mean_1: diag(5079, ts.DiagnosticCategory.Error, "Unknown_watch_option_0_Did_you_mean_1_5079", "Unknown watch option '{0}'. Did you mean '{1}'?"), Watch_option_0_requires_a_value_of_type_1: diag(5080, ts.DiagnosticCategory.Error, "Watch_option_0_requires_a_value_of_type_1_5080", "Watch option '{0}' requires a value of type {1}."), Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0: diag(5081, ts.DiagnosticCategory.Error, "Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0_5081", "Cannot find a tsconfig.json file at the current directory: {0}."), + _0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1: diag(5082, ts.DiagnosticCategory.Error, "_0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1_5082", "'{0}' could be instantiated with an arbitrary type which could be unrelated to '{1}'."), + Cannot_read_file_0: diag(5083, ts.DiagnosticCategory.Error, "Cannot_read_file_0_5083", "Cannot read file '{0}'."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -106900,7 +110656,11 @@ var ts; Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling: diag(6226, ts.DiagnosticCategory.Message, "Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively__6226", "Specify strategy for watching directory on platforms that don't support recursive watching natively: 'UseFsEvents' (default), 'FixedPollingInterval', 'DynamicPriorityPolling'."), Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority: diag(6227, ts.DiagnosticCategory.Message, "Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_6227", "Specify strategy for creating a polling watch when it fails to create using file system events: 'FixedInterval' (default), 'PriorityInterval', 'DynamicPriority'."), Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively: diag(6228, ts.DiagnosticCategory.Message, "Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_supp_6228", "Synchronously call callbacks and update the state of directory watchers on platforms that don't support recursive watching natively."), + Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3: diag(6229, ts.DiagnosticCategory.Error, "Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3_6229", "Tag '{0}' expects at least '{1}' arguments, but the JSX factory '{2}' provides at most '{3}'."), Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line: diag(6230, ts.DiagnosticCategory.Error, "Option_0_can_only_be_specified_in_tsconfig_json_file_or_set_to_false_or_null_on_command_line_6230", "Option '{0}' can only be specified in 'tsconfig.json' file or set to 'false' or 'null' on command line."), + Could_not_resolve_the_path_0_with_the_extensions_Colon_1: diag(6231, ts.DiagnosticCategory.Error, "Could_not_resolve_the_path_0_with_the_extensions_Colon_1_6231", "Could not resolve the path '{0}' with the extensions: {1}."), + Declaration_augments_declaration_in_another_file_This_cannot_be_serialized: diag(6232, ts.DiagnosticCategory.Error, "Declaration_augments_declaration_in_another_file_This_cannot_be_serialized_6232", "Declaration augments declaration in another file. This cannot be serialized."), + This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file: diag(6233, ts.DiagnosticCategory.Error, "This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_fil_6233", "This is the declaration being augmented. Consider moving the augmenting declaration into the same file."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), @@ -107097,6 +110857,7 @@ var ts; Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""), Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""), Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"), + Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"), Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."), Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), @@ -107162,6 +110923,8 @@ var ts; Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"), Convert_to_async_function: diag(95065, ts.DiagnosticCategory.Message, "Convert_to_async_function_95065", "Convert to async function"), Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"), + Add_missing_call_parentheses: diag(95067, ts.DiagnosticCategory.Message, "Add_missing_call_parentheses_95067", "Add missing call parentheses"), + Add_all_missing_call_parentheses: diag(95068, ts.DiagnosticCategory.Message, "Add_all_missing_call_parentheses_95068", "Add all missing call parentheses"), Add_unknown_conversion_for_non_overlapping_types: diag(95069, ts.DiagnosticCategory.Message, "Add_unknown_conversion_for_non_overlapping_types_95069", "Add 'unknown' conversion for non-overlapping types"), Add_unknown_to_all_conversions_of_non_overlapping_types: diag(95070, ts.DiagnosticCategory.Message, "Add_unknown_to_all_conversions_of_non_overlapping_types_95070", "Add 'unknown' to all conversions of non-overlapping types"), Add_missing_new_operator_to_call: diag(95071, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_call_95071", "Add missing 'new' operator to call"), @@ -107193,6 +110956,23 @@ var ts; Add_export_to_make_this_file_into_a_module: diag(95097, ts.DiagnosticCategory.Message, "Add_export_to_make_this_file_into_a_module_95097", "Add 'export {}' to make this file into a module"), Set_the_target_option_in_your_configuration_file_to_0: diag(95098, ts.DiagnosticCategory.Message, "Set_the_target_option_in_your_configuration_file_to_0_95098", "Set the 'target' option in your configuration file to '{0}'"), Set_the_module_option_in_your_configuration_file_to_0: diag(95099, ts.DiagnosticCategory.Message, "Set_the_module_option_in_your_configuration_file_to_0_95099", "Set the 'module' option in your configuration file to '{0}'"), + Convert_invalid_character_to_its_html_entity_code: diag(95100, ts.DiagnosticCategory.Message, "Convert_invalid_character_to_its_html_entity_code_95100", "Convert invalid character to its html entity code"), + Convert_all_invalid_characters_to_HTML_entity_code: diag(95101, ts.DiagnosticCategory.Message, "Convert_all_invalid_characters_to_HTML_entity_code_95101", "Convert all invalid characters to HTML entity code"), + Add_class_tag: diag(95102, ts.DiagnosticCategory.Message, "Add_class_tag_95102", "Add '@class' tag"), + Add_this_tag: diag(95103, ts.DiagnosticCategory.Message, "Add_this_tag_95103", "Add '@this' tag"), + Add_this_parameter: diag(95104, ts.DiagnosticCategory.Message, "Add_this_parameter_95104", "Add 'this' parameter."), + Convert_function_expression_0_to_arrow_function: diag(95105, ts.DiagnosticCategory.Message, "Convert_function_expression_0_to_arrow_function_95105", "Convert function expression '{0}' to arrow function"), + Convert_function_declaration_0_to_arrow_function: diag(95106, ts.DiagnosticCategory.Message, "Convert_function_declaration_0_to_arrow_function_95106", "Convert function declaration '{0}' to arrow function"), + Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"), + Wrap_invalid_character_in_an_expression_container: diag(95108, ts.DiagnosticCategory.Message, "Wrap_invalid_character_in_an_expression_container_95108", "Wrap invalid character in an expression container"), + Wrap_all_invalid_characters_in_an_expression_container: diag(95109, ts.DiagnosticCategory.Message, "Wrap_all_invalid_characters_in_an_expression_container_95109", "Wrap all invalid characters in an expression container"), + Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file: diag(95110, ts.DiagnosticCategory.Message, "Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file_95110", "Visit https://aka.ms/tsconfig.json to read more about this file"), + Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"), + Remove_block_body_braces: diag(95112, ts.DiagnosticCategory.Message, "Remove_block_body_braces_95112", "Remove block body braces"), + Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal: diag(95113, ts.DiagnosticCategory.Message, "Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal_95113", "Wrap the following body with parentheses which should be an object literal"), + Add_all_missing_return_statement: diag(95114, ts.DiagnosticCategory.Message, "Add_all_missing_return_statement_95114", "Add all missing return statement"), + Remove_all_incorrect_body_block_braces: diag(95115, ts.DiagnosticCategory.Message, "Remove_all_incorrect_body_block_braces_95115", "Remove all incorrect body block braces"), + Wrap_all_object_literal_with_parentheses: diag(95116, ts.DiagnosticCategory.Message, "Wrap_all_object_literal_with_parentheses_95116", "Wrap all object literal with parentheses"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -107215,6 +110995,9 @@ var ts; Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher: diag(18028, ts.DiagnosticCategory.Error, "Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher_18028", "Private identifiers are only available when targeting ECMAScript 2015 and higher."), Private_identifiers_are_not_allowed_in_variable_declarations: diag(18029, ts.DiagnosticCategory.Error, "Private_identifiers_are_not_allowed_in_variable_declarations_18029", "Private identifiers are not allowed in variable declarations."), An_optional_chain_cannot_contain_private_identifiers: diag(18030, ts.DiagnosticCategory.Error, "An_optional_chain_cannot_contain_private_identifiers_18030", "An optional chain cannot contain private identifiers."), + The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents: diag(18031, ts.DiagnosticCategory.Error, "The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituent_18031", "The intersection '{0}' was reduced to 'never' because property '{1}' has conflicting types in some constituents."), + The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some: diag(18032, ts.DiagnosticCategory.Error, "The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_pr_18032", "The intersection '{0}' was reduced to 'never' because property '{1}' exists in multiple constituents and is private in some."), + Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead: diag(18033, ts.DiagnosticCategory.Error, "Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhau_18033", "Only numeric enums can have computed members, but this expression has type '{0}'. If you do not need exhaustiveness checks, consider using an object literal instead."), }; })(ts || (ts = {})); var ts; @@ -107365,6 +111148,14 @@ var ts; */ var unicodeESNextIdentifierStart = [65, 90, 97, 122, 170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 880, 884, 886, 887, 890, 893, 895, 895, 902, 902, 904, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1488, 1514, 1519, 1522, 1568, 1610, 1646, 1647, 1649, 1747, 1749, 1749, 1765, 1766, 1774, 1775, 1786, 1788, 1791, 1791, 1808, 1808, 1810, 1839, 1869, 1957, 1969, 1969, 1994, 2026, 2036, 2037, 2042, 2042, 2048, 2069, 2074, 2074, 2084, 2084, 2088, 2088, 2112, 2136, 2144, 2154, 2208, 2228, 2230, 2237, 2308, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2417, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2493, 2493, 2510, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2556, 2556, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2785, 2809, 2809, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2929, 2929, 2947, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3024, 3024, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3133, 3160, 3162, 3168, 3169, 3200, 3200, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3261, 3294, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3389, 3406, 3406, 3412, 3414, 3423, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3807, 3840, 3840, 3904, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4159, 4176, 4181, 4186, 4189, 4193, 4193, 4197, 4198, 4206, 4208, 4213, 4225, 4238, 4238, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6103, 6103, 6108, 6108, 6176, 6264, 6272, 6312, 6314, 6314, 6320, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6656, 6678, 6688, 6740, 6823, 6823, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7401, 7404, 7406, 7411, 7413, 7414, 7418, 7418, 7424, 7615, 7680, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8305, 8305, 8319, 8319, 8336, 8348, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11502, 11506, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12348, 12353, 12438, 12443, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42527, 42538, 42539, 42560, 42606, 42623, 42653, 42656, 42735, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43259, 43261, 43262, 43274, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43471, 43471, 43488, 43492, 43494, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43638, 43642, 43642, 43646, 43695, 43697, 43697, 43701, 43702, 43705, 43709, 43712, 43712, 43714, 43714, 43739, 43741, 43744, 43754, 43762, 43764, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66176, 66204, 66208, 66256, 66304, 66335, 66349, 66378, 66384, 66421, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68096, 68112, 68115, 68117, 68119, 68121, 68149, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68324, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68899, 69376, 69404, 69415, 69415, 69424, 69445, 69600, 69622, 69635, 69687, 69763, 69807, 69840, 69864, 69891, 69926, 69956, 69956, 69968, 70002, 70006, 70006, 70019, 70066, 70081, 70084, 70106, 70106, 70108, 70108, 70144, 70161, 70163, 70187, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70366, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70461, 70461, 70480, 70480, 70493, 70497, 70656, 70708, 70727, 70730, 70751, 70751, 70784, 70831, 70852, 70853, 70855, 70855, 71040, 71086, 71128, 71131, 71168, 71215, 71236, 71236, 71296, 71338, 71352, 71352, 71424, 71450, 71680, 71723, 71840, 71903, 71935, 71935, 72096, 72103, 72106, 72144, 72161, 72161, 72163, 72163, 72192, 72192, 72203, 72242, 72250, 72250, 72272, 72272, 72284, 72329, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72750, 72768, 72768, 72818, 72847, 72960, 72966, 72968, 72969, 72971, 73008, 73030, 73030, 73056, 73061, 73063, 73064, 73066, 73097, 73112, 73112, 73440, 73458, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92880, 92909, 92928, 92975, 92992, 92995, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94032, 94032, 94099, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 123136, 123180, 123191, 123197, 123214, 123214, 123584, 123627, 124928, 125124, 125184, 125251, 125259, 125259, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101]; var unicodeESNextIdentifierPart = [48, 57, 65, 90, 95, 95, 97, 122, 170, 170, 181, 181, 183, 183, 186, 186, 192, 214, 216, 246, 248, 705, 710, 721, 736, 740, 748, 748, 750, 750, 768, 884, 886, 887, 890, 893, 895, 895, 902, 906, 908, 908, 910, 929, 931, 1013, 1015, 1153, 1155, 1159, 1162, 1327, 1329, 1366, 1369, 1369, 1376, 1416, 1425, 1469, 1471, 1471, 1473, 1474, 1476, 1477, 1479, 1479, 1488, 1514, 1519, 1522, 1552, 1562, 1568, 1641, 1646, 1747, 1749, 1756, 1759, 1768, 1770, 1788, 1791, 1791, 1808, 1866, 1869, 1969, 1984, 2037, 2042, 2042, 2045, 2045, 2048, 2093, 2112, 2139, 2144, 2154, 2208, 2228, 2230, 2237, 2259, 2273, 2275, 2403, 2406, 2415, 2417, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2500, 2503, 2504, 2507, 2510, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2556, 2556, 2558, 2558, 2561, 2563, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2641, 2641, 2649, 2652, 2654, 2654, 2662, 2677, 2689, 2691, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2787, 2790, 2799, 2809, 2815, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2876, 2884, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2915, 2918, 2927, 2929, 2929, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3024, 3024, 3031, 3031, 3046, 3055, 3072, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3160, 3162, 3168, 3171, 3174, 3183, 3200, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3260, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3299, 3302, 3311, 3313, 3314, 3328, 3331, 3333, 3340, 3342, 3344, 3346, 3396, 3398, 3400, 3402, 3406, 3412, 3415, 3423, 3427, 3430, 3439, 3450, 3455, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3558, 3567, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3718, 3722, 3724, 3747, 3749, 3749, 3751, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3807, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3948, 3953, 3972, 3974, 3991, 3993, 4028, 4038, 4038, 4096, 4169, 4176, 4253, 4256, 4293, 4295, 4295, 4301, 4301, 4304, 4346, 4348, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4957, 4959, 4969, 4977, 4992, 5007, 5024, 5109, 5112, 5117, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5870, 5880, 5888, 5900, 5902, 5908, 5920, 5940, 5952, 5971, 5984, 5996, 5998, 6000, 6002, 6003, 6016, 6099, 6103, 6103, 6108, 6109, 6112, 6121, 6155, 6157, 6160, 6169, 6176, 6264, 6272, 6314, 6320, 6389, 6400, 6430, 6432, 6443, 6448, 6459, 6470, 6509, 6512, 6516, 6528, 6571, 6576, 6601, 6608, 6618, 6656, 6683, 6688, 6750, 6752, 6780, 6783, 6793, 6800, 6809, 6823, 6823, 6832, 6845, 6912, 6987, 6992, 7001, 7019, 7027, 7040, 7155, 7168, 7223, 7232, 7241, 7245, 7293, 7296, 7304, 7312, 7354, 7357, 7359, 7376, 7378, 7380, 7418, 7424, 7673, 7675, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8276, 8276, 8305, 8305, 8319, 8319, 8336, 8348, 8400, 8412, 8417, 8417, 8421, 8432, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8472, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8505, 8508, 8511, 8517, 8521, 8526, 8526, 8544, 8584, 11264, 11310, 11312, 11358, 11360, 11492, 11499, 11507, 11520, 11557, 11559, 11559, 11565, 11565, 11568, 11623, 11631, 11631, 11647, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 11744, 11775, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12348, 12353, 12438, 12441, 12447, 12449, 12538, 12540, 12543, 12549, 12591, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40943, 40960, 42124, 42192, 42237, 42240, 42508, 42512, 42539, 42560, 42607, 42612, 42621, 42623, 42737, 42775, 42783, 42786, 42888, 42891, 42943, 42946, 42950, 42999, 43047, 43072, 43123, 43136, 43205, 43216, 43225, 43232, 43255, 43259, 43259, 43261, 43309, 43312, 43347, 43360, 43388, 43392, 43456, 43471, 43481, 43488, 43518, 43520, 43574, 43584, 43597, 43600, 43609, 43616, 43638, 43642, 43714, 43739, 43741, 43744, 43759, 43762, 43766, 43777, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43824, 43866, 43868, 43879, 43888, 44010, 44012, 44013, 44016, 44025, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65024, 65039, 65056, 65071, 65075, 65076, 65101, 65103, 65136, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 65536, 65547, 65549, 65574, 65576, 65594, 65596, 65597, 65599, 65613, 65616, 65629, 65664, 65786, 65856, 65908, 66045, 66045, 66176, 66204, 66208, 66256, 66272, 66272, 66304, 66335, 66349, 66378, 66384, 66426, 66432, 66461, 66464, 66499, 66504, 66511, 66513, 66517, 66560, 66717, 66720, 66729, 66736, 66771, 66776, 66811, 66816, 66855, 66864, 66915, 67072, 67382, 67392, 67413, 67424, 67431, 67584, 67589, 67592, 67592, 67594, 67637, 67639, 67640, 67644, 67644, 67647, 67669, 67680, 67702, 67712, 67742, 67808, 67826, 67828, 67829, 67840, 67861, 67872, 67897, 67968, 68023, 68030, 68031, 68096, 68099, 68101, 68102, 68108, 68115, 68117, 68119, 68121, 68149, 68152, 68154, 68159, 68159, 68192, 68220, 68224, 68252, 68288, 68295, 68297, 68326, 68352, 68405, 68416, 68437, 68448, 68466, 68480, 68497, 68608, 68680, 68736, 68786, 68800, 68850, 68864, 68903, 68912, 68921, 69376, 69404, 69415, 69415, 69424, 69456, 69600, 69622, 69632, 69702, 69734, 69743, 69759, 69818, 69840, 69864, 69872, 69881, 69888, 69940, 69942, 69951, 69956, 69958, 69968, 70003, 70006, 70006, 70016, 70084, 70089, 70092, 70096, 70106, 70108, 70108, 70144, 70161, 70163, 70199, 70206, 70206, 70272, 70278, 70280, 70280, 70282, 70285, 70287, 70301, 70303, 70312, 70320, 70378, 70384, 70393, 70400, 70403, 70405, 70412, 70415, 70416, 70419, 70440, 70442, 70448, 70450, 70451, 70453, 70457, 70459, 70468, 70471, 70472, 70475, 70477, 70480, 70480, 70487, 70487, 70493, 70499, 70502, 70508, 70512, 70516, 70656, 70730, 70736, 70745, 70750, 70751, 70784, 70853, 70855, 70855, 70864, 70873, 71040, 71093, 71096, 71104, 71128, 71133, 71168, 71232, 71236, 71236, 71248, 71257, 71296, 71352, 71360, 71369, 71424, 71450, 71453, 71467, 71472, 71481, 71680, 71738, 71840, 71913, 71935, 71935, 72096, 72103, 72106, 72151, 72154, 72161, 72163, 72164, 72192, 72254, 72263, 72263, 72272, 72345, 72349, 72349, 72384, 72440, 72704, 72712, 72714, 72758, 72760, 72768, 72784, 72793, 72818, 72847, 72850, 72871, 72873, 72886, 72960, 72966, 72968, 72969, 72971, 73014, 73018, 73018, 73020, 73021, 73023, 73031, 73040, 73049, 73056, 73061, 73063, 73064, 73066, 73102, 73104, 73105, 73107, 73112, 73120, 73129, 73440, 73462, 73728, 74649, 74752, 74862, 74880, 75075, 77824, 78894, 82944, 83526, 92160, 92728, 92736, 92766, 92768, 92777, 92880, 92909, 92912, 92916, 92928, 92982, 92992, 92995, 93008, 93017, 93027, 93047, 93053, 93071, 93760, 93823, 93952, 94026, 94031, 94087, 94095, 94111, 94176, 94177, 94179, 94179, 94208, 100343, 100352, 101106, 110592, 110878, 110928, 110930, 110948, 110951, 110960, 111355, 113664, 113770, 113776, 113788, 113792, 113800, 113808, 113817, 113821, 113822, 119141, 119145, 119149, 119154, 119163, 119170, 119173, 119179, 119210, 119213, 119362, 119364, 119808, 119892, 119894, 119964, 119966, 119967, 119970, 119970, 119973, 119974, 119977, 119980, 119982, 119993, 119995, 119995, 119997, 120003, 120005, 120069, 120071, 120074, 120077, 120084, 120086, 120092, 120094, 120121, 120123, 120126, 120128, 120132, 120134, 120134, 120138, 120144, 120146, 120485, 120488, 120512, 120514, 120538, 120540, 120570, 120572, 120596, 120598, 120628, 120630, 120654, 120656, 120686, 120688, 120712, 120714, 120744, 120746, 120770, 120772, 120779, 120782, 120831, 121344, 121398, 121403, 121452, 121461, 121461, 121476, 121476, 121499, 121503, 121505, 121519, 122880, 122886, 122888, 122904, 122907, 122913, 122915, 122916, 122918, 122922, 123136, 123180, 123184, 123197, 123200, 123209, 123214, 123214, 123584, 123641, 124928, 125124, 125136, 125142, 125184, 125259, 125264, 125273, 126464, 126467, 126469, 126495, 126497, 126498, 126500, 126500, 126503, 126503, 126505, 126514, 126516, 126519, 126521, 126521, 126523, 126523, 126530, 126530, 126535, 126535, 126537, 126537, 126539, 126539, 126541, 126543, 126545, 126546, 126548, 126548, 126551, 126551, 126553, 126553, 126555, 126555, 126557, 126557, 126559, 126559, 126561, 126562, 126564, 126564, 126567, 126570, 126572, 126578, 126580, 126583, 126585, 126588, 126590, 126590, 126592, 126601, 126603, 126619, 126625, 126627, 126629, 126633, 126635, 126651, 131072, 173782, 173824, 177972, 177984, 178205, 178208, 183969, 183984, 191456, 194560, 195101, 917760, 917999]; + /** + * Test for whether a single line comment's text contains a directive. + */ + var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/; + /** + * Test for whether a multi-line comment's last line contains a directive. + */ + var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/; function lookupInUnicodeMap(code, map) { // Bail out quickly if it couldn't possibly be in the map. if (code < map[0]) { @@ -107489,11 +111280,20 @@ var ts; } ts.getLineStarts = getLineStarts; /* @internal */ + function computeLineAndCharacterOfPosition(lineStarts, position) { + var lineNumber = computeLineOfPosition(lineStarts, position); + return { + line: lineNumber, + character: position - lineStarts[lineNumber] + }; + } + ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; /** + * @internal * We assume the first line starts at position 0 and 'position' is non-negative. */ - function computeLineAndCharacterOfPosition(lineStarts, position) { - var lineNumber = ts.binarySearch(lineStarts, position, ts.identity, ts.compareValues); + function computeLineOfPosition(lineStarts, position, lowerBound) { + var lineNumber = ts.binarySearch(lineStarts, position, ts.identity, ts.compareValues, lowerBound); if (lineNumber < 0) { // If the actual position was not found, // the binary search returns the 2's-complement of the next line start @@ -107505,12 +111305,22 @@ var ts; lineNumber = ~lineNumber - 1; ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file"); } - return { - line: lineNumber, - character: position - lineStarts[lineNumber] - }; + return lineNumber; } - ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition; + ts.computeLineOfPosition = computeLineOfPosition; + /** @internal */ + function getLinesBetweenPositions(sourceFile, pos1, pos2) { + if (pos1 === pos2) + return 0; + var lineStarts = getLineStarts(sourceFile); + var lower = Math.min(pos1, pos2); + var isNegative = lower === pos2; + var upper = isNegative ? pos1 : pos2; + var lowerLine = computeLineOfPosition(lineStarts, lower); + var upperLine = computeLineOfPosition(lineStarts, upper, lowerLine); + return isNegative ? lowerLine - upperLine : upperLine - lowerLine; + } + ts.getLinesBetweenPositions = getLinesBetweenPositions; function getLineAndCharacterOfPosition(sourceFile, position) { return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } @@ -107557,6 +111367,12 @@ var ts; function isDigit(ch) { return ch >= 48 /* _0 */ && ch <= 57 /* _9 */; } + function isHexDigit(ch) { + return isDigit(ch) || ch >= 65 /* A */ && ch <= 70 /* F */ || ch >= 97 /* a */ && ch <= 102 /* f */; + } + function isCodePoint(code) { + return code <= 0x10FFFF; + } /* @internal */ function isOctalDigit(ch) { return ch >= 48 /* _0 */ && ch <= 55 /* _7 */; @@ -107890,20 +111706,22 @@ var ts; ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion); } ts.isIdentifierStart = isIdentifierStart; - function isIdentifierPart(ch, languageVersion) { + function isIdentifierPart(ch, languageVersion, identifierVariant) { return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || + // "-" and ":" are valid in JSX Identifiers + (identifierVariant === 1 /* JSX */ ? (ch === 45 /* minus */ || ch === 58 /* colon */) : false) || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion); } ts.isIdentifierPart = isIdentifierPart; /* @internal */ - function isIdentifierText(name, languageVersion) { + function isIdentifierText(name, languageVersion, identifierVariant) { var ch = codePointAt(name, 0); if (!isIdentifierStart(ch, languageVersion)) { return false; } for (var i = charSize(ch); i < name.length; i += charSize(ch)) { - if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion)) { + if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion, identifierVariant)) { return false; } } @@ -107925,6 +111743,7 @@ var ts; var token; var tokenValue; var tokenFlags; + var commentDirectives; var inJSDocType = 0; setText(text, start, length); var scanner = { @@ -107940,10 +111759,12 @@ var ts; isIdentifier: function () { return token === 75 /* Identifier */ || token > 112 /* LastReservedWord */; }, isReservedWord: function () { return token >= 77 /* FirstReservedWord */ && token <= 112 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, + getCommentDirectives: function () { return commentDirectives; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, + reScanTemplateHeadOrNoSubstitutionTemplate: reScanTemplateHeadOrNoSubstitutionTemplate, scanJsxIdentifier: scanJsxIdentifier, scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxAttributeValue: reScanJsxAttributeValue, @@ -107954,6 +111775,7 @@ var ts; scanJsDocToken: scanJsDocToken, scan: scan, getText: getText, + clearCommentDirectives: clearCommentDirectives, setText: setText, setScriptTarget: setScriptTarget, setLanguageVariant: setLanguageVariant, @@ -108192,7 +112014,7 @@ var ts; * Sets the current 'tokenValue' and returns a NoSubstitutionTemplateLiteral or * a literal component of a TemplateExpression. */ - function scanTemplateAndSetTokenValue() { + function scanTemplateAndSetTokenValue(isTaggedTemplate) { var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; pos++; var start = pos; @@ -108224,7 +112046,7 @@ var ts; // Escape character if (currChar === 92 /* backslash */) { contents += text.substring(start, pos); - contents += scanEscapeSequence(); + contents += scanEscapeSequence(isTaggedTemplate); start = pos; continue; } @@ -108246,7 +112068,8 @@ var ts; tokenValue = contents; return resultingToken; } - function scanEscapeSequence() { + function scanEscapeSequence(isTaggedTemplate) { + var start = pos; pos++; if (pos >= end) { error(ts.Diagnostics.Unexpected_end_of_text); @@ -108256,6 +112079,12 @@ var ts; pos++; switch (ch) { case 48 /* _0 */: + // '\01' + if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) { + pos++; + tokenFlags |= 2048 /* ContainsInvalidEscape */; + return text.substring(start, pos); + } return "\0"; case 98 /* b */: return "\b"; @@ -108274,16 +112103,55 @@ var ts; case 34 /* doubleQuote */: return "\""; case 117 /* u */: + if (isTaggedTemplate) { + // '\u' or '\u0' or '\u00' or '\u000' + for (var escapePos = pos; escapePos < pos + 4; escapePos++) { + if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123 /* openBrace */) { + pos = escapePos; + tokenFlags |= 2048 /* ContainsInvalidEscape */; + return text.substring(start, pos); + } + } + } // '\u{DDDDDDDD}' if (pos < end && text.charCodeAt(pos) === 123 /* openBrace */) { - tokenFlags |= 8 /* ExtendedUnicodeEscape */; pos++; + // '\u{' + if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) { + tokenFlags |= 2048 /* ContainsInvalidEscape */; + return text.substring(start, pos); + } + if (isTaggedTemplate) { + var savePos = pos; + var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false); + var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1; + // '\u{Not Code Point' or '\u{CodePoint' + if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125 /* closeBrace */) { + tokenFlags |= 2048 /* ContainsInvalidEscape */; + return text.substring(start, pos); + } + else { + pos = savePos; + } + } + tokenFlags |= 8 /* ExtendedUnicodeEscape */; return scanExtendedUnicodeEscape(); } tokenFlags |= 1024 /* UnicodeEscape */; // '\uDDDD' return scanHexadecimalEscape(/*numDigits*/ 4); case 120 /* x */: + if (isTaggedTemplate) { + if (!isHexDigit(text.charCodeAt(pos))) { + tokenFlags |= 2048 /* ContainsInvalidEscape */; + return text.substring(start, pos); + } + else if (!isHexDigit(text.charCodeAt(pos + 1))) { + pos++; + tokenFlags |= 2048 /* ContainsInvalidEscape */; + return text.substring(start, pos); + } + } // '\xDD' return scanHexadecimalEscape(/*numDigits*/ 2); // when encountering a LineContinuation (i.e. a backslash and a line terminator sequence), @@ -108557,7 +112425,7 @@ var ts; tokenValue = scanString(); return token = 10 /* StringLiteral */; case 96 /* backtick */: - return token = scanTemplateAndSetTokenValue(); + return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ false); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { return pos += 2, token = 68 /* PercentEqualsToken */; @@ -108637,6 +112505,7 @@ var ts; } pos++; } + commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(tokenPos, pos), commentDirectiveRegExSingleLine, tokenPos); if (skipTrivia) { continue; } @@ -108651,6 +112520,7 @@ var ts; tokenFlags |= 2 /* PrecedingJSDocComment */; } var commentClosed = false; + var lastLineStart = tokenPos; while (pos < end) { var ch_1 = text.charCodeAt(pos); if (ch_1 === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -108658,11 +112528,13 @@ var ts; commentClosed = true; break; } + pos++; if (isLineBreak(ch_1)) { + lastLineStart = pos; tokenFlags |= 1 /* PrecedingLineBreak */; } - pos++; } + commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart); if (!commentClosed) { error(ts.Diagnostics.Asterisk_Slash_expected); } @@ -108991,13 +112863,40 @@ var ts; } return token; } + function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) { + var type = getDirectiveFromComment(text, commentDirectiveRegEx); + if (type === undefined) { + return commentDirectives; + } + return ts.append(commentDirectives, { + range: { pos: lineStart, end: pos }, + type: type, + }); + } + function getDirectiveFromComment(text, commentDirectiveRegEx) { + var match = commentDirectiveRegEx.exec(text); + if (!match) { + return undefined; + } + switch (match[1]) { + case "ts-expect-error": + return 0 /* ExpectError */; + case "ts-ignore": + return 1 /* Ignore */; + } + return undefined; + } /** * Unconditionally back up and scan a template expression portion. */ - function reScanTemplateToken() { + function reScanTemplateToken(isTaggedTemplate) { ts.Debug.assert(token === 19 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; - return token = scanTemplateAndSetTokenValue(); + return token = scanTemplateAndSetTokenValue(isTaggedTemplate); + } + function reScanTemplateHeadOrNoSubstitutionTemplate() { + pos = tokenPos; + return token = scanTemplateAndSetTokenValue(/* isTaggedTemplate */ true); } function reScanJsxToken() { pos = tokenPos = startPos; @@ -109055,6 +112954,12 @@ var ts; } break; } + if (char === 62 /* greaterThan */) { + error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1); + } + if (char === 125 /* closeBrace */) { + error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1); + } if (lastNonWhitespace > 0) lastNonWhitespace++; // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. @@ -109220,6 +113125,7 @@ var ts; var saveToken = token; var saveTokenValue = tokenValue; var saveTokenFlags = tokenFlags; + var saveErrorExpectations = commentDirectives; setText(text, start, length); var result = callback(); end = saveEnd; @@ -109229,6 +113135,7 @@ var ts; token = saveToken; tokenValue = saveTokenValue; tokenFlags = saveTokenFlags; + commentDirectives = saveErrorExpectations; return result; } function lookAhead(callback) { @@ -109240,6 +113147,9 @@ var ts; function getText() { return text; } + function clearCommentDirectives() { + commentDirectives = undefined; + } function setText(newText, start, length) { text = newText || ""; end = length === undefined ? text.length : start + length; @@ -109803,8 +113713,8 @@ var ts; switch (declaration.kind) { case 75 /* Identifier */: return declaration; - case 322 /* JSDocPropertyTag */: - case 316 /* JSDocParameterTag */: { + case 323 /* JSDocPropertyTag */: + case 317 /* JSDocParameterTag */: { var name = declaration.name; if (name.kind === 153 /* QualifiedName */) { return name.right; @@ -109828,9 +113738,9 @@ var ts; return undefined; } } - case 321 /* JSDocTypedefTag */: + case 322 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 315 /* JSDocEnumTag */: + case 316 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); case 259 /* ExportAssignment */: { var expression = declaration.expression; @@ -109934,6 +113844,11 @@ var ts; return getFirstJSDocTag(node, isJSDocAugmentsTag); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; + /** Gets the JSDoc implements tags for the node if present */ + function getJSDocImplementsTags(node) { + return getAllJSDocTags(node, isJSDocImplementsTag); + } + ts.getJSDocImplementsTags = getJSDocImplementsTags; /** Gets the JSDoc class tag for the node if present */ function getJSDocClassTag(node) { return getFirstJSDocTag(node, isJSDocClassTag); @@ -110026,7 +113941,7 @@ var ts; var sig = ts.find(type.members, isCallSignatureDeclaration); return sig && sig.type; } - if (isFunctionTypeNode(type)) { + if (isFunctionTypeNode(type) || isJSDocFunctionType(type)) { return type.type; } } @@ -110048,7 +113963,12 @@ var ts; function getFirstJSDocTag(node, predicate) { return ts.find(getJSDocTags(node), predicate); } - /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ + /** Gets all JSDoc tags that match a specified predicate */ + function getAllJSDocTags(node, predicate) { + return getJSDocTags(node).filter(predicate); + } + ts.getAllJSDocTags = getAllJSDocTags; + /** Gets all JSDoc tags of a specified kind */ function getAllJSDocTagsOfKind(node, kind) { return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; }); } @@ -110335,12 +114255,13 @@ var ts; return !!(node.flags & 32 /* OptionalChain */) && (kind === 194 /* PropertyAccessExpression */ || kind === 195 /* ElementAccessExpression */ - || kind === 196 /* CallExpression */); + || kind === 196 /* CallExpression */ + || kind === 218 /* NonNullExpression */); } ts.isOptionalChain = isOptionalChain; /* @internal */ function isOptionalChainRoot(node) { - return isOptionalChain(node) && !!node.questionDotToken; + return isOptionalChain(node) && !isNonNullExpression(node) && !!node.questionDotToken; } ts.isOptionalChainRoot = isOptionalChainRoot; /** @@ -110355,17 +114276,18 @@ var ts; * Determines whether a node is the outermost `OptionalChain` in an ECMAScript `OptionalExpression`: * * 1. For `a?.b.c`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.`) - * 2. For `(a?.b.c).d`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.` since parens end the chain) - * 3. For `a?.b.c?.d`, both `a?.b.c` and `a?.b.c?.d` are outermost (`c` is the end of the chain starting at `a?.`, and `d` is + * 2. For `a?.b!`, the outermost chain is `a?.b` (`b` is the end of the chain starting at `a?.`) + * 3. For `(a?.b.c).d`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.` since parens end the chain) + * 4. For `a?.b.c?.d`, both `a?.b.c` and `a?.b.c?.d` are outermost (`c` is the end of the chain starting at `a?.`, and `d` is * the end of the chain starting at `c?.`) - * 4. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is + * 5. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is * the end of the chain starting at `a?.`) */ /* @internal */ function isOutermostOptionalChain(node) { - return !isOptionalChain(node.parent) // cases 1 and 2 - || isOptionalChainRoot(node.parent) // case 3 - || node !== node.parent.expression; // case 4 + return !isOptionalChain(node.parent) // cases 1, 2, and 3 + || isOptionalChainRoot(node.parent) // case 4 + || node !== node.parent.expression; // case 5 } ts.isOutermostOptionalChain = isOutermostOptionalChain; function isNullishCoalesce(node) { @@ -110394,10 +114316,7 @@ var ts; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 325 /* PartiallyEmittedExpression */) { - node = node.expression; - } - return node; + return ts.skipOuterExpressions(node, 8 /* PartiallyEmittedExpressions */); } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { @@ -110472,6 +114391,10 @@ var ts; return node.kind === 218 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; + function isNonNullChain(node) { + return isNonNullExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isNonNullChain = isNonNullChain; function isMetaProperty(node) { return node.kind === 219 /* MetaProperty */; } @@ -110818,67 +114741,71 @@ var ts; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 308 /* JSDocAuthorTag */; + return node.kind === 309 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { return node.kind === 307 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; + function isJSDocImplementsTag(node) { + return node.kind === 308 /* JSDocImplementsTag */; + } + ts.isJSDocImplementsTag = isJSDocImplementsTag; function isJSDocClassTag(node) { - return node.kind === 309 /* JSDocClassTag */; + return node.kind === 310 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocPublicTag(node) { - return node.kind === 310 /* JSDocPublicTag */; + return node.kind === 311 /* JSDocPublicTag */; } ts.isJSDocPublicTag = isJSDocPublicTag; function isJSDocPrivateTag(node) { - return node.kind === 311 /* JSDocPrivateTag */; + return node.kind === 312 /* JSDocPrivateTag */; } ts.isJSDocPrivateTag = isJSDocPrivateTag; function isJSDocProtectedTag(node) { - return node.kind === 312 /* JSDocProtectedTag */; + return node.kind === 313 /* JSDocProtectedTag */; } ts.isJSDocProtectedTag = isJSDocProtectedTag; function isJSDocReadonlyTag(node) { - return node.kind === 313 /* JSDocReadonlyTag */; + return node.kind === 314 /* JSDocReadonlyTag */; } ts.isJSDocReadonlyTag = isJSDocReadonlyTag; function isJSDocEnumTag(node) { - return node.kind === 315 /* JSDocEnumTag */; + return node.kind === 316 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 318 /* JSDocThisTag */; + return node.kind === 319 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 316 /* JSDocParameterTag */; + return node.kind === 317 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 317 /* JSDocReturnTag */; + return node.kind === 318 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 319 /* JSDocTypeTag */; + return node.kind === 320 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 320 /* JSDocTemplateTag */; + return node.kind === 321 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 321 /* JSDocTypedefTag */; + return node.kind === 322 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 322 /* JSDocPropertyTag */; + return node.kind === 323 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 322 /* JSDocPropertyTag */ || node.kind === 316 /* JSDocParameterTag */; + return node.kind === 323 /* JSDocPropertyTag */ || node.kind === 317 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { @@ -110886,7 +114813,7 @@ var ts; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 314 /* JSDocCallbackTag */; + return node.kind === 315 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { @@ -110901,7 +114828,7 @@ var ts; // they may be used with transformations. /* @internal */ function isSyntaxList(n) { - return n.kind === 323 /* SyntaxList */; + return n.kind === 324 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -111037,6 +114964,7 @@ var ts; function isPropertyName(node) { var kind = node.kind; return kind === 75 /* Identifier */ + || kind === 76 /* PrivateIdentifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ || kind === 154 /* ComputedPropertyName */; @@ -111373,8 +115301,8 @@ var ts; case 213 /* SpreadElement */: case 217 /* AsExpression */: case 215 /* OmittedExpression */: - case 326 /* CommaListExpression */: - case 325 /* PartiallyEmittedExpression */: + case 327 /* CommaListExpression */: + case 326 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -111388,17 +115316,17 @@ var ts; ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 325 /* PartiallyEmittedExpression */; + return node.kind === 326 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 324 /* NotEmittedStatement */; + return node.kind === 325 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ function isSyntheticReference(node) { - return node.kind === 329 /* SyntheticReferenceExpression */; + return node.kind === 330 /* SyntheticReferenceExpression */; } ts.isSyntheticReference = isSyntheticReference; /* @internal */ @@ -111531,9 +115459,9 @@ var ts; || kind === 247 /* TypeAliasDeclaration */ || kind === 155 /* TypeParameter */ || kind === 242 /* VariableDeclaration */ - || kind === 321 /* JSDocTypedefTag */ - || kind === 314 /* JSDocCallbackTag */ - || kind === 322 /* JSDocPropertyTag */; + || kind === 322 /* JSDocTypedefTag */ + || kind === 315 /* JSDocCallbackTag */ + || kind === 323 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { return kind === 244 /* FunctionDeclaration */ @@ -111568,14 +115496,14 @@ var ts; || kind === 225 /* VariableStatement */ || kind === 229 /* WhileStatement */ || kind === 236 /* WithStatement */ - || kind === 324 /* NotEmittedStatement */ - || kind === 328 /* EndOfDeclarationMarker */ - || kind === 327 /* MergeDeclarationMarker */; + || kind === 325 /* NotEmittedStatement */ + || kind === 329 /* EndOfDeclarationMarker */ + || kind === 328 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { if (node.kind === 155 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 320 /* JSDocTemplateTag */) || ts.isInJSFile(node); + return (node.parent && node.parent.kind !== 321 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -111670,18 +115598,18 @@ var ts; /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 294 /* FirstJSDocNode */ && node.kind <= 322 /* LastJSDocNode */; + return node.kind >= 294 /* FirstJSDocNode */ && node.kind <= 323 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 303 /* JSDocComment */ || isJSDocTag(node) || isJSDocTypeLiteral(node) || isJSDocSignature(node); + return node.kind === 303 /* JSDocComment */ || node.kind === 302 /* JSDocNamepathType */ || isJSDocTag(node) || isJSDocTypeLiteral(node) || isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 306 /* FirstJSDocTagNode */ && node.kind <= 322 /* LastJSDocTagNode */; + return node.kind >= 306 /* FirstJSDocTagNode */ && node.kind <= 323 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { @@ -111713,9 +115641,19 @@ var ts; } ts.hasInitializer = hasInitializer; /** True if has initializer node attached to it. */ - /* @internal */ function hasOnlyExpressionInitializer(node) { - return hasInitializer(node) && !isForStatement(node) && !isForInStatement(node) && !isForOfStatement(node) && !isJsxAttribute(node); + switch (node.kind) { + case 242 /* VariableDeclaration */: + case 156 /* Parameter */: + case 191 /* BindingElement */: + case 158 /* PropertySignature */: + case 159 /* PropertyDeclaration */: + case 281 /* PropertyAssignment */: + case 284 /* EnumMember */: + return true; + default: + return false; + } } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { @@ -111766,6 +115704,7 @@ var ts; ts.emptyUnderscoreEscapedMap = ts.emptyMap; ts.externalHelpersModuleNameText = "tslib"; ts.defaultMaximumTruncationLength = 160; + ts.noTruncationMaximumTruncationLength = 1000000; function getDeclarationOfKind(symbol, kind) { var declarations = symbol.declarations; if (declarations) { @@ -112182,6 +116121,33 @@ var ts; text.charCodeAt(start + 2) === 33 /* exclamation */; } ts.isPinnedComment = isPinnedComment; + function createCommentDirectivesMap(sourceFile, commentDirectives) { + var directivesByLine = ts.createMapFromEntries(commentDirectives.map(function (commentDirective) { return ([ + "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line, + commentDirective, + ]); })); + var usedLines = ts.createMap(); + return { getUnusedExpectations: getUnusedExpectations, markUsed: markUsed }; + function getUnusedExpectations() { + return ts.arrayFrom(directivesByLine.entries()) + .filter(function (_a) { + var line = _a[0], directive = _a[1]; + return directive.type === 0 /* ExpectError */ && !usedLines.get(line); + }) + .map(function (_a) { + var _ = _a[0], directive = _a[1]; + return directive; + }); + } + function markUsed(line) { + if (!directivesByLine.has("" + line)) { + return false; + } + usedLines.set("" + line, true); + return true; + } + } + ts.createCommentDirectivesMap = createCommentDirectivesMap; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. @@ -112192,13 +116158,13 @@ var ts; return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } if (includeJsDoc && ts.hasJSDocNodes(node)) { - return getTokenPosOfNode(node.jsDoc[0]); + return getTokenPosOfNode(node.jsDoc[0], sourceFile); } // For a syntax list, it is possible that one of its children has JSDocComment nodes, while // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 323 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 324 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -112456,8 +116422,8 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 314 /* JSDocCallbackTag */: - case 321 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 322 /* JSDocTypedefTag */: case 305 /* JSDocSignature */: return true; default: @@ -112479,7 +116445,7 @@ var ts; case 214 /* ClassExpression */: case 246 /* InterfaceDeclaration */: case 247 /* TypeAliasDeclaration */: - case 320 /* JSDocTemplateTag */: + case 321 /* JSDocTemplateTag */: case 244 /* FunctionDeclaration */: case 161 /* MethodDeclaration */: case 162 /* Constructor */: @@ -112542,6 +116508,10 @@ var ts; return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; } ts.getNameFromIndexInfo = getNameFromIndexInfo; + function isComputedNonLiteralName(name) { + return name.kind === 154 /* ComputedPropertyName */ && !isStringOrNumericLiteralLike(name.expression); + } + ts.isComputedNonLiteralName = isComputedNonLiteralName; function getTextOfPropertyName(name) { switch (name.kind) { case 75 /* Identifier */: @@ -112562,12 +116532,15 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { + case 104 /* ThisKeyword */: + return "this"; + case 76 /* PrivateIdentifier */: case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); case 153 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); case 194 /* PropertyAccessExpression */: - if (ts.isIdentifier(name.name)) { + if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) { return entityNameToString(name.expression) + "." + entityNameToString(name.name); } else { @@ -112607,6 +116580,17 @@ var ts; }; } ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain; + function createDiagnosticForRange(sourceFile, range, message) { + return { + file: sourceFile, + start: range.pos, + length: range.end - range.pos, + code: message.code, + category: message.category, + messageText: message.message, + }; + } + ts.createDiagnosticForRange = createDiagnosticForRange; function getSpanOfTokenAtPosition(sourceFile, pos) { var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ true, sourceFile.languageVariant, sourceFile.text, /*onError:*/ undefined, pos); scanner.scan(); @@ -112734,6 +116718,25 @@ var ts; && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; + function isCustomPrologue(node) { + return !!(getEmitFlags(node) & 1048576 /* CustomPrologue */); + } + ts.isCustomPrologue = isCustomPrologue; + function isHoistedFunction(node) { + return isCustomPrologue(node) + && ts.isFunctionDeclaration(node); + } + ts.isHoistedFunction = isHoistedFunction; + function isHoistedVariable(node) { + return ts.isIdentifier(node.name) + && !node.initializer; + } + function isHoistedVariableStatement(node) { + return isCustomPrologue(node) + && ts.isVariableStatement(node) + && ts.every(node.declarationList.declarations, isHoistedVariable); + } + ts.isHoistedVariableStatement = isHoistedVariableStatement; function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { return node.kind !== 11 /* JsxText */ ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined; } @@ -112817,7 +116820,7 @@ var ts; return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); case 155 /* TypeParameter */: return node === parent.constraint; - case 320 /* JSDocTemplateTag */: + case 321 /* JSDocTemplateTag */: return node === parent.constraint; case 159 /* PropertyDeclaration */: case 158 /* PropertySignature */: @@ -113503,6 +117506,15 @@ var ts; return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; + function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) { + return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(node.initializer, requireStringLiteralLikeArgument); + } + ts.isRequireVariableDeclaration = isRequireVariableDeclaration; + function isRequireVariableDeclarationStatement(node, requireStringLiteralLikeArgument) { + if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; } + return ts.isVariableStatement(node) && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); }); + } + ts.isRequireVariableDeclarationStatement = isRequireVariableDeclarationStatement; function isSingleOrDoubleQuote(charCode) { return charCode === 39 /* singleQuote */ || charCode === 34 /* doubleQuote */; } @@ -113702,10 +117714,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; + function isModuleIdentifier(node) { + return ts.isIdentifier(node) && node.escapedText === "module"; + } + ts.isModuleIdentifier = isModuleIdentifier; function isModuleExportsAccessExpression(node) { return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) - && ts.isIdentifier(node.expression) - && node.expression.escapedText === "module" + && isModuleIdentifier(node.expression) && getElementOrPropertyAccessName(node) === "exports"; } ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; @@ -113739,7 +117754,7 @@ var ts; ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; /** Any series of property and element accesses. */ function isBindableStaticAccessExpression(node, excludeThisKeyword) { - return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 104 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 104 /* ThisKeyword */ || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) || isBindableStaticElementAccessExpression(node, excludeThisKeyword); } ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; @@ -113842,7 +117857,7 @@ var ts; // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... return 1 /* ExportsProperty */; } - if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs) && lhs.expression.kind !== 104 /* ThisKeyword */)) { + if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) { // F.G...x = expr return 5 /* Property */; } @@ -113868,6 +117883,17 @@ var ts; !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; + function setValueDeclaration(symbol, node) { + var valueDeclaration = symbol.valueDeclaration; + if (!valueDeclaration || + !(node.flags & 8388608 /* Ambient */ && !(valueDeclaration.flags & 8388608 /* Ambient */)) && + (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) || + (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) { + // other kinds of value declarations take precedence over modules and assignment declarations + symbol.valueDeclaration = node; + } + } + ts.setValueDeclaration = setValueDeclaration; function isFunctionSymbol(symbol) { if (!symbol || !symbol.valueDeclaration) { return false; @@ -113966,7 +117992,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 321 /* JSDocTypedefTag */ || node.kind === 314 /* JSDocCallbackTag */ || node.kind === 315 /* JSDocEnumTag */; + return node.kind === 322 /* JSDocTypedefTag */ || node.kind === 315 /* JSDocCallbackTag */ || node.kind === 316 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -114081,21 +118107,24 @@ var ts; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; function getHostSignatureFromJSDoc(node) { - return getHostSignatureFromJSDocHost(getJSDocHost(node)); + var host = getEffectiveJSDocHost(node); + return host && ts.isFunctionLike(host) ? host : undefined; } ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc; - function getHostSignatureFromJSDocHost(host) { + function getEffectiveJSDocHost(node) { + var host = getJSDocHost(node); var decl = getSourceOfDefaultedAssignment(host) || getSourceOfAssignment(host) || getSingleInitializerOfVariableStatementOrPropertyDeclaration(host) || getSingleVariableOfVariableStatement(host) || getNestedModuleDeclaration(host) || host; - return decl && ts.isFunctionLike(decl) ? decl : undefined; + return decl; } - ts.getHostSignatureFromJSDocHost = getHostSignatureFromJSDocHost; + ts.getEffectiveJSDocHost = getEffectiveJSDocHost; + /** Use getEffectiveJSDocHost if you additionally need to look for jsdoc on parent nodes, like assignments. */ function getJSDocHost(node) { - return ts.Debug.assertDefined(findAncestor(node.parent, ts.isJSDoc)).parent; + return ts.Debug.checkDefined(findAncestor(node.parent, ts.isJSDoc)).parent; } ts.getJSDocHost = getJSDocHost; function getTypeParameterFromJsDoc(node) { @@ -114219,10 +118248,7 @@ var ts; } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 200 /* ParenthesizedExpression */) { - node = node.expression; - } - return node; + return ts.skipOuterExpressions(node, 1 /* Parentheses */); } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { @@ -114409,15 +118435,20 @@ var ts; return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; - function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 113 /* ImplementsKeyword */); - return heritageClause ? heritageClause.types : undefined; + function getEffectiveImplementsTypeNodes(node) { + if (isInJSFile(node)) { + return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; }); + } + else { + var heritageClause = getHeritageClause(node.heritageClauses, 113 /* ImplementsKeyword */); + return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types; + } } - ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; + ts.getEffectiveImplementsTypeNodes = getEffectiveImplementsTypeNodes; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : - ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getEffectiveImplementsTypeNodes(node)) || ts.emptyArray : ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; @@ -114740,7 +118771,7 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 326 /* CommaListExpression */: + case 327 /* CommaListExpression */: return 0; case 213 /* SpreadElement */: return 1; @@ -114932,6 +118963,13 @@ var ts; function escapeTemplateSubstitution(str) { return str.replace(templateSubstitutionRegExp, "\\${"); } + /** @internal */ + function hasInvalidEscape(template) { + return template && !!(ts.isNoSubstitutionTemplateLiteral(template) + ? template.templateFlags + : (template.head.templateFlags || ts.some(template.templateSpans, function (span) { return !!span.literal.templateFlags; }))); + } + ts.hasInvalidEscape = hasInvalidEscape; // This consists of the first 19 unprintable ASCII characters, canonical escapes, lineSeparator, // paragraphSeparator, and nextLine. The latter three are just desirable to suppress new lines in // the language service. These characters should be escaped when printing, and if any characters are added, @@ -114940,7 +118978,7 @@ var ts; var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; // Template strings should be preserved as much as possible - var backtickQuoteEscapedCharsRegExp = /[\\\`]/g; + var backtickQuoteEscapedCharsRegExp = /[\\`]/g; var escapedCharsMap = ts.createMapFromTemplate({ "\t": "\\t", "\v": "\\v", @@ -115114,8 +119152,8 @@ var ts; write(s); } } - function writeLine() { - if (!lineStart) { + function writeLine(force) { + if (!lineStart || force) { output += newLine; lineCount++; linePos = output.length; @@ -115226,6 +119264,14 @@ var ts; } }); } ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; + function hostUsesCaseSensitiveFileNames(host) { + return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false; + } + ts.hostUsesCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames; + function hostGetCanonicalFileName(host) { + return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host)); + } + ts.hostGetCanonicalFileName = hostGetCanonicalFileName; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -115346,12 +119392,13 @@ var ts; } } ts.writeFileEnsuringDirectories = writeFileEnsuringDirectories; - function getLineOfLocalPosition(currentSourceFile, pos) { - return ts.getLineAndCharacterOfPosition(currentSourceFile, pos).line; + function getLineOfLocalPosition(sourceFile, pos) { + var lineStarts = ts.getLineStarts(sourceFile); + return ts.computeLineOfPosition(lineStarts, pos); } ts.getLineOfLocalPosition = getLineOfLocalPosition; function getLineOfLocalPositionFromLineMap(lineMap, pos) { - return ts.computeLineAndCharacterOfPosition(lineMap, pos).line; + return ts.computeLineOfPosition(lineMap, pos); } ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { @@ -115425,9 +119472,11 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { + // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { + // eslint-disable-next-line setAccessor = member; } } @@ -115700,6 +119749,9 @@ var ts; } ts.getSelectedModifierFlags = getSelectedModifierFlags; function getModifierFlags(node) { + if (node.kind >= 0 /* FirstToken */ && node.kind <= 152 /* LastToken */) { + return 0 /* None */; + } if (node.modifierFlagsCache & 536870912 /* HasComputedFlags */) { return node.modifierFlagsCache & ~536870912 /* HasComputedFlags */; } @@ -115821,7 +119873,7 @@ var ts; } ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { - return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); + return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isEntityNameExpression(node.expression); } ts.isPropertyAccessEntityNameExpression = isPropertyAccessEntityNameExpression; function tryGetPropertyAccessOrIdentifierToString(expr) { @@ -116114,7 +120166,7 @@ var ts; } ts.rangeIsOnSingleLine = rangeIsOnSingleLine; function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), getStartPositionOfRange(range2, sourceFile), sourceFile); + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, /*includeComments*/ false), getStartPositionOfRange(range2, sourceFile, /*includeComments*/ false), sourceFile); } ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine; function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) { @@ -116122,26 +120174,53 @@ var ts; } ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine; function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) { - return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile), range2.end, sourceFile); + return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, /*includeComments*/ false), range2.end, sourceFile); } ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd; function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) { - return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile), sourceFile); + return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile, /*includeComments*/ false), sourceFile); } ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart; + function getLinesBetweenRangeEndAndRangeStart(range1, range2, sourceFile, includeSecondRangeComments) { + var range2Start = getStartPositionOfRange(range2, sourceFile, includeSecondRangeComments); + return ts.getLinesBetweenPositions(sourceFile, range1.end, range2Start); + } + ts.getLinesBetweenRangeEndAndRangeStart = getLinesBetweenRangeEndAndRangeStart; + function getLinesBetweenRangeEndPositions(range1, range2, sourceFile) { + return ts.getLinesBetweenPositions(sourceFile, range1.end, range2.end); + } + ts.getLinesBetweenRangeEndPositions = getLinesBetweenRangeEndPositions; function isNodeArrayMultiLine(list, sourceFile) { return !positionsAreOnSameLine(list.pos, list.end, sourceFile); } ts.isNodeArrayMultiLine = isNodeArrayMultiLine; function positionsAreOnSameLine(pos1, pos2, sourceFile) { - return pos1 === pos2 || - getLineOfLocalPosition(sourceFile, pos1) === getLineOfLocalPosition(sourceFile, pos2); + return ts.getLinesBetweenPositions(sourceFile, pos1, pos2) === 0; } ts.positionsAreOnSameLine = positionsAreOnSameLine; - function getStartPositionOfRange(range, sourceFile) { - return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos); + function getStartPositionOfRange(range, sourceFile, includeComments) { + return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos, /*stopAfterLineBreak*/ false, includeComments); } ts.getStartPositionOfRange = getStartPositionOfRange; + function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) { + var startPos = ts.skipTrivia(sourceFile.text, pos, /*stopAfterLineBreak*/ false, includeComments); + var prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile); + return ts.getLinesBetweenPositions(sourceFile, prevPos !== null && prevPos !== void 0 ? prevPos : stopPos, startPos); + } + ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter = getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter; + function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) { + var nextPos = ts.skipTrivia(sourceFile.text, pos, /*stopAfterLineBreak*/ false, includeComments); + return ts.getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos)); + } + ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter = getLinesBetweenPositionAndNextNonWhitespaceCharacter; + function getPreviousNonWhitespacePosition(pos, stopPos, sourceFile) { + if (stopPos === void 0) { stopPos = 0; } + while (pos-- > stopPos) { + if (!ts.isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) { + return pos; + } + } + } /** * Determines whether a name was originally the declaration name of an enum or namespace * declaration. @@ -116433,6 +120512,14 @@ var ts; return node.kind === 194 /* PropertyAccessExpression */ || node.kind === 195 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; + function getNameOfAccessExpression(node) { + if (node.kind === 194 /* PropertyAccessExpression */) { + return node.name; + } + ts.Debug.assert(node.kind === 195 /* ElementAccessExpression */); + return node.argumentExpression; + } + ts.getNameOfAccessExpression = getNameOfAccessExpression; function isBundleFileTextLike(section) { switch (section.kind) { case "text" /* Text */: @@ -116443,10 +120530,6 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; - function getDotOrQuestionDotToken(node) { - return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); - } - ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; function isNamedImportsOrExports(node) { return node.kind === 257 /* NamedImports */ || node.kind === 261 /* NamedExports */; } @@ -116483,6 +120566,26 @@ var ts; this.parent = undefined; this.original = undefined; } + function Token(kind, pos, end) { + this.pos = pos; + this.end = end; + this.kind = kind; + this.id = 0; + this.flags = 0 /* None */; + this.transformFlags = 0 /* None */; + this.parent = undefined; + } + function Identifier(kind, pos, end) { + this.pos = pos; + this.end = end; + this.kind = kind; + this.id = 0; + this.flags = 0 /* None */; + this.transformFlags = 0 /* None */; + this.parent = undefined; + this.original = undefined; + this.flowNode = undefined; + } function SourceMapSource(fileName, text, skipTrivia) { this.fileName = fileName; this.text = text; @@ -116491,8 +120594,8 @@ var ts; // eslint-disable-next-line prefer-const ts.objectAllocator = { getNodeConstructor: function () { return Node; }, - getTokenConstructor: function () { return Node; }, - getIdentifierConstructor: function () { return Node; }, + getTokenConstructor: function () { return Token; }, + getIdentifierConstructor: function () { return Identifier; }, getPrivateIdentifierConstructor: function () { return Node; }, getSourceFileConstructor: function () { return Node; }, getSymbolConstructor: function () { return Symbol; }, @@ -116506,7 +120609,7 @@ var ts; ts.setObjectAllocator = setObjectAllocator; function formatStringFromArgs(text, args, baseIndex) { if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); }); } ts.formatStringFromArgs = formatStringFromArgs; /* @internal */ @@ -117506,7 +121609,7 @@ var ts; function isValidTypeOnlyAliasUseSite(useSite) { return !!(useSite.flags & 8388608 /* Ambient */) || isPartOfTypeQuery(useSite) - || isFirstIdentifierOfNonEmittingHeritageClause(useSite) + || isIdentifierInNonEmittingHeritageClause(useSite) || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) || !isExpressionNode(useSite); } @@ -117528,13 +121631,40 @@ var ts; var containerKind = node.parent.parent.kind; return containerKind === 246 /* InterfaceDeclaration */ || containerKind === 173 /* TypeLiteral */; } - /** Returns true for the first identifier of 1) an `implements` clause, and 2) an `extends` clause of an interface. */ - function isFirstIdentifierOfNonEmittingHeritageClause(node) { - var _a, _b; - // Number of parents to climb from identifier is 2 for `implements I`, 3 for `implements x.I` - var heritageClause = (_a = ts.tryCast(node.parent.parent, ts.isHeritageClause)) !== null && _a !== void 0 ? _a : ts.tryCast((_b = node.parent.parent) === null || _b === void 0 ? void 0 : _b.parent, ts.isHeritageClause); + /** Returns true for an identifier in 1) an `implements` clause, and 2) an `extends` clause of an interface. */ + function isIdentifierInNonEmittingHeritageClause(node) { + if (node.kind !== 75 /* Identifier */) + return false; + var heritageClause = findAncestor(node.parent, function (parent) { + switch (parent.kind) { + case 279 /* HeritageClause */: + return true; + case 194 /* PropertyAccessExpression */: + case 216 /* ExpressionWithTypeArguments */: + return false; + default: + return "quit"; + } + }); return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 113 /* ImplementsKeyword */ || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 246 /* InterfaceDeclaration */; } + function isIdentifierTypeReference(node) { + return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName); + } + ts.isIdentifierTypeReference = isIdentifierTypeReference; + function arrayIsHomogeneous(array, comparer) { + if (comparer === void 0) { comparer = ts.equateValues; } + if (array.length < 2) + return true; + var first = array[0]; + for (var i = 1, length_1 = array.length; i < length_1; i++) { + var target = array[i]; + if (!comparer(first, target)) + return false; + } + return true; + } + ts.arrayIsHomogeneous = arrayIsHomogeneous; })(ts || (ts = {})); var ts; (function (ts) { @@ -117963,7 +122093,7 @@ var ts; return visitNode(cbNode, node.expression); case 264 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 326 /* CommaListExpression */: + case 327 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); case 266 /* JsxElement */: return visitNode(cbNode, node.openingElement) || @@ -118003,24 +122133,27 @@ var ts; visitNode(cbNode, node.type); case 303 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 316 /* JSDocParameterTag */: - case 322 /* JSDocPropertyTag */: + case 317 /* JSDocParameterTag */: + case 323 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 308 /* JSDocAuthorTag */: + case 309 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); + case 308 /* JSDocImplementsTag */: + return visitNode(cbNode, node.tagName) || + visitNode(cbNode, node.class); case 307 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 320 /* JSDocTemplateTag */: + case 321 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 321 /* JSDocTypedefTag */: + case 322 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && node.typeExpression.kind === 294 /* JSDocTypeExpression */ @@ -118028,14 +122161,14 @@ var ts; visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 314 /* JSDocCallbackTag */: + case 315 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 317 /* JSDocReturnTag */: - case 319 /* JSDocTypeTag */: - case 318 /* JSDocThisTag */: - case 315 /* JSDocEnumTag */: + case 318 /* JSDocReturnTag */: + case 320 /* JSDocTypeTag */: + case 319 /* JSDocThisTag */: + case 316 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); case 305 /* JSDocSignature */: @@ -118045,17 +122178,85 @@ var ts; case 304 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); case 306 /* JSDocTag */: - case 309 /* JSDocClassTag */: - case 310 /* JSDocPublicTag */: - case 311 /* JSDocPrivateTag */: - case 312 /* JSDocProtectedTag */: - case 313 /* JSDocReadonlyTag */: + case 310 /* JSDocClassTag */: + case 311 /* JSDocPublicTag */: + case 312 /* JSDocPrivateTag */: + case 313 /* JSDocProtectedTag */: + case 314 /* JSDocReadonlyTag */: return visitNode(cbNode, node.tagName); - case 325 /* PartiallyEmittedExpression */: + case 326 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } ts.forEachChild = forEachChild; + /** @internal */ + /** + * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes + * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; additionally, + * unlike `forEachChild`, embedded arrays are flattened and the 'cbNode' callback is invoked for each element. + * If a callback returns a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. + * + * @param node a given node to visit its children + * @param cbNode a callback to be invoked for all child nodes + * @param cbNodes a callback to be invoked for embedded array + * + * @remarks Unlike `forEachChild`, `forEachChildRecursively` handles recursively invoking the traversal on each child node found, + * and while doing so, handles traversing the structure without relying on the callstack to encode the tree structure. + */ + function forEachChildRecursively(rootNode, cbNode, cbNodes) { + var stack = [rootNode]; + while (stack.length) { + var parent = stack.pop(); + var res = visitAllPossibleChildren(parent, gatherPossibleChildren(parent)); + if (res) { + return res; + } + } + return; + function gatherPossibleChildren(node) { + var children = []; + forEachChild(node, addWorkItem, addWorkItem); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal + return children; + function addWorkItem(n) { + children.unshift(n); + } + } + function visitAllPossibleChildren(parent, children) { + for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { + var child = children_1[_i]; + if (ts.isArray(child)) { + if (cbNodes) { + var res = cbNodes(child, parent); + if (res) { + if (res === "skip") + continue; + return res; + } + } + for (var i = child.length - 1; i >= 0; i--) { + var realChild = child[i]; + var res = cbNode(realChild, parent); + if (res) { + if (res === "skip") + continue; + return res; + } + stack.push(realChild); + } + } + else { + stack.push(child); + var res = cbNode(child, parent); + if (res) { + if (res === "skip") + continue; + return res; + } + } + } + } + } + ts.forEachChildRecursively = forEachChildRecursively; function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) { if (setParentNodes === void 0) { setParentNodes = false; } ts.performance.mark("beforeParse"); @@ -118356,6 +122557,7 @@ var ts; } function clearState() { // Clear out the text the scanner is pointing at, so it doesn't keep anything alive unnecessarily. + scanner.clearCommentDirectives(); scanner.setText(""); scanner.setOnError(undefined); // Clear any data. We don't want to accidentally hold onto it for too long. @@ -118382,6 +122584,7 @@ var ts; ts.Debug.assert(token() === 1 /* EndOfFileToken */); sourceFile.endOfFileToken = addJSDocComment(parseTokenNode()); setExternalModuleIndicator(sourceFile); + sourceFile.commentDirectives = scanner.getCommentDirectives(); sourceFile.nodeCount = nodeCount; sourceFile.identifierCount = identifierCount; sourceFile.identifiers = identifiers; @@ -118406,30 +122609,14 @@ var ts; // a syntax tree, and no semantic features, then the binding process is an unnecessary // overhead. This functions allows us to set all the parents, without all the expense of // binding. - var stack = [rootNode]; - while (stack.length) { - var parent = stack.pop(); - bindParentToChildren(parent, gatherChildren(parent)); - } - return; - function gatherChildren(node) { - var children = []; - forEachChild(node, function (n) { children.unshift(n); }); // By using a stack above and `unshift` here, we emulate a depth-first preorder traversal - return children; - } - function bindParentToChildren(parent, children) { - for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { - var child = children_1[_i]; - if (child.parent === parent) - continue; // already bound, assume subtree is bound - child.parent = parent; - stack.push(child); - if (ts.hasJSDocNodes(child)) { - for (var _a = 0, _b = child.jsDoc; _a < _b.length; _a++) { - var jsDoc = _b[_a]; - jsDoc.parent = child; - stack.push(jsDoc); - } + forEachChildRecursively(rootNode, bindParentToChild); + function bindParentToChild(child, parent) { + child.parent = parent; + if (ts.hasJSDocNodes(child)) { + for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) { + var doc = _a[_i]; + bindParentToChild(doc, child); + forEachChildRecursively(doc, bindParentToChild); } } } @@ -118601,8 +122788,11 @@ var ts; function reScanSlashToken() { return currentToken = scanner.reScanSlashToken(); } - function reScanTemplateToken() { - return currentToken = scanner.reScanTemplateToken(); + function reScanTemplateToken(isTaggedTemplate) { + return currentToken = scanner.reScanTemplateToken(isTaggedTemplate); + } + function reScanTemplateHeadOrNoSubstitutionTemplate() { + return currentToken = scanner.reScanTemplateHeadOrNoSubstitutionTemplate(); } function reScanLessThanToken() { return currentToken = scanner.reScanLessThanToken(); @@ -118767,7 +122957,7 @@ var ts; } function createNodeWithJSDoc(kind, pos) { var node = createNode(kind, pos); - if (scanner.getTokenFlags() & 2 /* PrecedingJSDocComment */) { + if (scanner.getTokenFlags() & 2 /* PrecedingJSDocComment */ && (kind !== 226 /* ExpressionStatement */ || token() !== 20 /* OpenParenToken */)) { addJSDocComment(node); } return node; @@ -119622,24 +123812,24 @@ var ts; } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } - function parseTemplateExpression() { + function parseTemplateExpression(isTaggedTemplate) { var template = createNode(211 /* TemplateExpression */); - template.head = parseTemplateHead(); + template.head = parseTemplateHead(isTaggedTemplate); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; var listPos = getNodePos(); do { - list.push(parseTemplateSpan()); + list.push(parseTemplateSpan(isTaggedTemplate)); } while (ts.last(list).literal.kind === 16 /* TemplateMiddle */); template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } - function parseTemplateSpan() { + function parseTemplateSpan(isTaggedTemplate) { var span = createNode(221 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { - reScanTemplateToken(); + reScanTemplateToken(isTaggedTemplate); literal = parseTemplateMiddleOrTemplateTail(); } else { @@ -119651,7 +123841,10 @@ var ts; function parseLiteralNode() { return parseLiteralLikeNode(token()); } - function parseTemplateHead() { + function parseTemplateHead(isTaggedTemplate) { + if (isTaggedTemplate) { + reScanTemplateHeadOrNoSubstitutionTemplate(); + } var fragment = parseLiteralLikeNode(token()); ts.Debug.assert(fragment.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); return fragment; @@ -119689,6 +123882,9 @@ var ts; if (node.kind === 8 /* NumericLiteral */) { node.numericLiteralFlags = scanner.getTokenFlags() & 1008 /* NumericLiteralFlags */; } + if (ts.isTemplateLiteralKind(node.kind)) { + node.templateFlags = scanner.getTokenFlags() & 2048 /* ContainsInvalidEscape */; + } nextToken(); finishNode(node); return node; @@ -121550,7 +125746,11 @@ var ts; parseErrorAtRange(openingTag, ts.Diagnostics.JSX_fragment_has_no_corresponding_closing_tag); } else { - parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); + // We want the error span to cover only 'Foo.Bar' in < Foo.Bar > + // or to cover only 'Foo' in < Foo > + var tag = openingTag.tagName; + var start = ts.skipTrivia(sourceText, tag.pos); + parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; case 30 /* LessThanSlashToken */: @@ -121734,12 +125934,33 @@ var ts; return token() === 28 /* QuestionDotToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); } + function tryReparseOptionalChain(node) { + if (node.flags & 32 /* OptionalChain */) { + return true; + } + // check for an optional chain in a non-null expression + if (ts.isNonNullExpression(node)) { + var expr = node.expression; + while (ts.isNonNullExpression(expr) && !(expr.flags & 32 /* OptionalChain */)) { + expr = expr.expression; + } + if (expr.flags & 32 /* OptionalChain */) { + // this is part of an optional chain. Walk down from `node` to `expression` and set the flag. + while (ts.isNonNullExpression(node)) { + node.flags |= 32 /* OptionalChain */; + node = node.expression; + } + return true; + } + } + return false; + } function parsePropertyAccessExpressionRest(expression, questionDotToken) { var propertyAccess = createNode(194 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.questionDotToken = questionDotToken; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true, /*allowPrivateIdentifiers*/ true); - if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + if (questionDotToken || tryReparseOptionalChain(expression)) { propertyAccess.flags |= 32 /* OptionalChain */; if (ts.isPrivateIdentifier(propertyAccess.name)) { parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers); @@ -121762,7 +125983,7 @@ var ts; indexedAccess.argumentExpression = argument; } parseExpected(23 /* CloseBracketToken */); - if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + if (questionDotToken || tryReparseOptionalChain(expression)) { indexedAccess.flags |= 32 /* OptionalChain */; } return finishNode(indexedAccess); @@ -121810,8 +126031,8 @@ var ts; tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ - ? parseLiteralNode() - : parseTemplateExpression(); + ? (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) + : parseTemplateExpression(/*isTaggedTemplate*/ true); if (questionDotToken || tag.flags & 32 /* OptionalChain */) { tagExpression.flags |= 32 /* OptionalChain */; } @@ -121838,7 +126059,7 @@ var ts; callExpr.questionDotToken = questionDotToken; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); - if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + if (questionDotToken || tryReparseOptionalChain(expression)) { callExpr.flags |= 32 /* OptionalChain */; } expression = finishNode(callExpr); @@ -121850,7 +126071,7 @@ var ts; callExpr.expression = expression; callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); - if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + if (questionDotToken || tryReparseOptionalChain(expression)) { callExpr.flags |= 32 /* OptionalChain */; } expression = finishNode(callExpr); @@ -121972,7 +126193,7 @@ var ts; } break; case 15 /* TemplateHead */: - return parseTemplateExpression(); + return parseTemplateExpression(/* isTaggedTemplate */ false); } return parseIdentifier(ts.Diagnostics.Expression_expected); } @@ -122054,12 +126275,18 @@ var ts; } function parseObjectLiteralExpression() { var node = createNode(193 /* ObjectLiteralExpression */); + var openBracePosition = scanner.getTokenPos(); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(19 /* CloseBraceToken */); + if (!parseExpected(19 /* CloseBraceToken */)) { + var lastError = ts.lastOrUndefined(parseDiagnostics); + if (lastError && lastError.code === ts.Diagnostics._0_expected.code) { + ts.addRelatedInfo(lastError, ts.createFileDiagnostic(sourceFile, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here)); + } + } return finishNode(node); } function parseFunctionExpression() { @@ -122117,9 +126344,12 @@ var ts; var node = createNode(197 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; - if (node.typeArguments || token() === 20 /* OpenParenToken */) { + if (token() === 20 /* OpenParenToken */) { node.arguments = parseArgumentList(); } + else if (node.typeArguments) { + parseErrorAt(fullStart, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list); + } return finishNode(node); } // STATEMENTS @@ -122358,7 +126588,7 @@ var ts; // Avoiding having to do the lookahead for a labeled statement by just trying to parse // out an expression, seeing if it is identifier and then seeing if it is followed by // a colon. - var node = createNodeWithJSDoc(0 /* Unknown */); + var node = createNodeWithJSDoc(token() === 75 /* Identifier */ ? 0 /* Unknown */ : 226 /* ExpressionStatement */); var expression = allowInAnd(parseExpression); if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { node.kind = 238 /* LabeledStatement */; @@ -123733,25 +127963,28 @@ var ts; case "author": tag = parseAuthorTag(start, tagName, margin); break; + case "implements": + tag = parseImplementsTag(start, tagName); + break; case "augments": case "extends": tag = parseAugmentsTag(start, tagName); break; case "class": case "constructor": - tag = parseSimpleTag(start, 309 /* JSDocClassTag */, tagName); + tag = parseSimpleTag(start, 310 /* JSDocClassTag */, tagName); break; case "public": - tag = parseSimpleTag(start, 310 /* JSDocPublicTag */, tagName); + tag = parseSimpleTag(start, 311 /* JSDocPublicTag */, tagName); break; case "private": - tag = parseSimpleTag(start, 311 /* JSDocPrivateTag */, tagName); + tag = parseSimpleTag(start, 312 /* JSDocPrivateTag */, tagName); break; case "protected": - tag = parseSimpleTag(start, 312 /* JSDocProtectedTag */, tagName); + tag = parseSimpleTag(start, 313 /* JSDocProtectedTag */, tagName); break; case "readonly": - tag = parseSimpleTag(start, 313 /* JSDocReadonlyTag */, tagName); + tag = parseSimpleTag(start, 314 /* JSDocReadonlyTag */, tagName); break; case "this": tag = parseThisTag(start, tagName); @@ -123803,10 +128036,12 @@ var ts; comments.push(text); indent += text.length; } - if (initialMargin) { + if (initialMargin !== undefined) { // jump straight to saving comments if there is some initial indentation - pushComment(initialMargin); - state = 2 /* SavingComments */; + if (initialMargin !== "") { + pushComment(initialMargin); + } + state = 1 /* SawAsterisk */; } var tok = token(); loop: while (true) { @@ -123947,8 +128182,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(322 /* JSDocPropertyTag */, start) : - createNode(316 /* JSDocParameterTag */, start); + createNode(323 /* JSDocPropertyTag */, start) : + createNode(317 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -123971,7 +128206,7 @@ var ts; var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 316 /* JSDocParameterTag */ || child.kind === 322 /* JSDocPropertyTag */) { + if (child.kind === 317 /* JSDocParameterTag */ || child.kind === 323 /* JSDocPropertyTag */) { children = ts.append(children, child); } } @@ -123990,7 +128225,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(317 /* JSDocReturnTag */, start); + var result = createNode(318 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -123999,13 +128234,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(319 /* JSDocTypeTag */, start); + var result = createNode(320 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(308 /* JSDocAuthorTag */, start); + var result = createNode(309 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -124058,6 +128293,12 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } } + function parseImplementsTag(start, tagName) { + var result = createNode(308 /* JSDocImplementsTag */, start); + result.tagName = tagName; + result.class = parseExpressionWithTypeArgumentsForAugments(); + return finishNode(result); + } function parseAugmentsTag(start, tagName) { var result = createNode(307 /* JSDocAugmentsTag */, start); result.tagName = tagName; @@ -124091,14 +128332,14 @@ var ts; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(318 /* JSDocThisTag */, start); + var tag = createNode(319 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(315 /* JSDocEnumTag */, start); + var tag = createNode(316 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -124107,7 +128348,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(321 /* JSDocTypedefTag */, start); + var typedefTag = createNode(322 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -124123,7 +128364,7 @@ var ts; if (!jsdocTypeLiteral) { jsdocTypeLiteral = createNode(304 /* JSDocTypeLiteral */, start); } - if (child.kind === 319 /* JSDocTypeTag */) { + if (child.kind === 320 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -124169,7 +128410,7 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(314 /* JSDocCallbackTag */, start); + var callbackTag = createNode(315 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); @@ -124184,7 +128425,7 @@ var ts; var returnTag = tryParse(function () { if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 317 /* JSDocReturnTag */) { + if (tag && tag.kind === 318 /* JSDocReturnTag */) { return tag; } } @@ -124229,7 +128470,7 @@ var ts; case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 316 /* JSDocParameterTag */ || child.kind === 322 /* JSDocPropertyTag */) && + if (child && (child.kind === 317 /* JSDocParameterTag */ || child.kind === 323 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -124296,10 +128537,10 @@ var ts; var typeParameter = createNode(155 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); - skipWhitespace(); + skipWhitespaceOrAsterisk(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(320 /* JSDocTemplateTag */, start); + var result = createNode(321 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -124418,9 +128659,51 @@ var ts; // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind); + result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks); return result; } IncrementalParser.updateSourceFile = updateSourceFile; + function getNewCommentDirectives(oldDirectives, newDirectives, changeStart, changeRangeOldEnd, delta, oldText, newText, aggressiveChecks) { + if (!oldDirectives) + return newDirectives; + var commentDirectives; + var addedNewlyScannedDirectives = false; + for (var _i = 0, oldDirectives_1 = oldDirectives; _i < oldDirectives_1.length; _i++) { + var directive = oldDirectives_1[_i]; + var range = directive.range, type = directive.type; + // Range before the change + if (range.end < changeStart) { + commentDirectives = ts.append(commentDirectives, directive); + } + else if (range.pos > changeRangeOldEnd) { + addNewlyScannedDirectives(); + // Node is entirely past the change range. We need to move both its pos and + // end, forward or backward appropriately. + var updatedDirective = { + range: { pos: range.pos + delta, end: range.end + delta }, + type: type + }; + commentDirectives = ts.append(commentDirectives, updatedDirective); + if (aggressiveChecks) { + ts.Debug.assert(oldText.substring(range.pos, range.end) === newText.substring(updatedDirective.range.pos, updatedDirective.range.end)); + } + } + // Ignore ranges that fall in change range + } + addNewlyScannedDirectives(); + return commentDirectives; + function addNewlyScannedDirectives() { + if (addedNewlyScannedDirectives) + return; + addedNewlyScannedDirectives = true; + if (!commentDirectives) { + commentDirectives = newDirectives; + } + else if (newDirectives) { + commentDirectives.push.apply(commentDirectives, newDirectives); + } + } + } function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) { if (isArray) { visitArray(element); @@ -125106,7 +129389,9 @@ var ts; ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], - ["esnext.bigint", "lib.es2020.bigint.d.ts"] + ["esnext.bigint", "lib.es2020.bigint.d.ts"], + ["esnext.string", "lib.esnext.string.d.ts"], + ["esnext.promise", "lib.esnext.promise.d.ts"] ]; /** * An array of supported "lib" reference file names used to determine the order for inclusion @@ -126128,7 +130413,8 @@ var ts; target: 1 /* ES5 */, strict: true, esModuleInterop: true, - forceConsistentCasingInFileNames: true + forceConsistentCasingInFileNames: true, + skipLibCheck: true }; /* @internal */ function convertEnableAutoDiscoveryToEnable(typeAcquisition) { @@ -126230,9 +130516,9 @@ var ts; } } function parseResponseFile(fileName) { - var text = readFile ? readFile(fileName) : ts.sys.readFile(fileName); - if (!text) { - errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, fileName)); + var text = tryReadFile(fileName, readFile || (function (fileName) { return ts.sys.readFile(fileName); })); + if (!ts.isString(text)) { + errors.push(text); return; } var args = []; @@ -126412,19 +130698,10 @@ var ts; /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ - function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend) { - var configFileText; - try { - configFileText = host.readFile(configFileName); - } - catch (e) { - var error = ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, configFileName, e.message); - host.onUnRecoverableConfigFileDiagnostic(error); - return undefined; - } - if (!configFileText) { - var error = ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, configFileName); - host.onUnRecoverableConfigFileDiagnostic(error); + function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend, extraFileExtensions) { + var configFileText = tryReadFile(configFileName, function (fileName) { return host.readFile(fileName); }); + if (!ts.isString(configFileText)) { + host.onUnRecoverableConfigFileDiagnostic(configFileText); return undefined; } var result = ts.parseJsonText(configFileName, configFileText); @@ -126433,8 +130710,7 @@ var ts; result.resolvedPath = result.path; result.originalFileName = result.fileName; return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd), - /*resolutionStack*/ undefined, - /*extraFileExtension*/ undefined, extendedConfigCache, watchOptionsToExtend); + /*resolutionStack*/ undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend); } ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile; /** @@ -126468,6 +130744,7 @@ var ts; return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { parseDiagnostics: [textOrDiagnostic] }; } ts.readJsonConfigFile = readJsonConfigFile; + /*@internal*/ function tryReadFile(fileName, readFile) { var text; try { @@ -126476,8 +130753,9 @@ var ts; catch (e) { return ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message); } - return text === undefined ? ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, fileName) : text; + return text === undefined ? ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0, fileName) : text; } + ts.tryReadFile = tryReadFile; function commandLineOptionsToMap(options) { return ts.arrayToMap(options, getOptionName); } @@ -126616,7 +130894,7 @@ var ts; if (!isDoubleQuotedString(element.name)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, ts.Diagnostics.String_literal_with_double_quotes_expected)); } - var textOfKey = ts.getTextOfPropertyName(element.name); + var textOfKey = ts.isComputedNonLiteralName(element.name) ? undefined : ts.getTextOfPropertyName(element.name); var keyText = textOfKey && ts.unescapeLeadingUnderscores(textOfKey); var option = keyText && knownOptions ? knownOptions.get(keyText) : undefined; if (keyText && extraKeyDiagnostics && !option) { @@ -126932,15 +131210,12 @@ var ts; // Serialize all options and their descriptions var marginLength = 0; var seenKnownKeys = 0; - var nameColumn = []; - var descriptionColumn = []; + var entries = []; categorizedOptions.forEach(function (options, category) { - if (nameColumn.length !== 0) { - nameColumn.push(""); - descriptionColumn.push(""); + if (entries.length !== 0) { + entries.push({ value: "" }); } - nameColumn.push("/* " + category + " */"); - descriptionColumn.push(""); + entries.push({ value: "/* " + category + " */" }); for (var _i = 0, options_1 = options; _i < options_1.length; _i++) { var option = options_1[_i]; var optionName = void 0; @@ -126950,8 +131225,10 @@ var ts; else { optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; } - nameColumn.push(optionName); - descriptionColumn.push("/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"); + entries.push({ + value: optionName, + description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */" + }); marginLength = Math.max(optionName.length, marginLength); } }); @@ -126960,11 +131237,13 @@ var ts; var result = []; result.push("{"); result.push(tab + "\"compilerOptions\": {"); + result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */"); + result.push(""); // Print out each row, aligning all the descriptions on the same column. - for (var i = 0; i < nameColumn.length; i++) { - var optionName = nameColumn[i]; - var description = descriptionColumn[i]; - result.push(optionName && "" + tab + tab + optionName + (description && (makePadding(marginLength - optionName.length + 2) + description))); + for (var _a = 0, entries_3 = entries; _a < entries_3.length; _a++) { + var entry = entries_3[_a]; + var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b; + result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description))); } if (fileNames.length) { result.push(tab + "},"); @@ -127905,7 +132184,12 @@ var ts; ts.Debug.assert(ts.extensionIsTS(resolved.extension)); return { fileName: resolved.path, packageId: resolved.packageId }; } - function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { + function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) { + var _a; + if (resultFromCache) { + (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations); + return resultFromCache; + } return { resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId }, failedLookupLocations: failedLookupLocations @@ -128597,15 +132881,12 @@ var ts; } ts.nodeModuleNameResolver = nodeModuleNameResolver; function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) { + var _a, _b; var traceEnabled = isTraceEnabled(compilerOptions, host); var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); }); - if (result && result.value) { - var _a = result.value, resolved = _a.resolved, isExternalLibraryImport = _a.isExternalLibraryImport; - return createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations); - } - return { resolvedModule: undefined, failedLookupLocations: failedLookupLocations }; + return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache); function tryResolve(extensions) { var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); }; var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state); @@ -129042,13 +133323,12 @@ var ts; } ts.unmangleScopedPackageName = unmangleScopedPackageName; function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) { - var _a; var result = cache && cache.get(containingDirectory); if (result) { if (state.traceEnabled) { trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory); } - (_a = state.failedLookupLocations).push.apply(_a, result.failedLookupLocations); + state.resultFromCache = result; return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } }; } } @@ -129059,7 +133339,7 @@ var ts; var containingDirectory = ts.getDirectoryPath(containingFile); var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript); // No originalPath because classic resolution doesn't resolve realPath - return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations); + return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache); function tryResolve(extensions) { var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state); if (resolvedUsingSettings) { @@ -129104,7 +133384,7 @@ var ts; var failedLookupLocations = []; var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations }; var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false); - return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations); + return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache); } ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache; /** @@ -129397,16 +133677,7 @@ var ts; symbol.constEnumOnlyModule = false; } if (symbolFlags & 111551 /* Value */) { - setValueDeclaration(symbol, node); - } - } - function setValueDeclaration(symbol, node) { - var valueDeclaration = symbol.valueDeclaration; - if (!valueDeclaration || - (ts.isAssignmentDeclaration(valueDeclaration) && !ts.isAssignmentDeclaration(node)) || - (valueDeclaration.kind !== node.kind && ts.isEffectiveModuleDeclaration(valueDeclaration))) { - // other kinds of value declarations take precedence over modules and assignment declarations - symbol.valueDeclaration = node; + ts.setValueDeclaration(symbol, node); } } // Should not be called on a declaration with a computed property name, @@ -129485,7 +133756,7 @@ var ts; } } function getDisplayName(node) { - return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(ts.Debug.assertDefined(getDeclarationName(node))); + return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(ts.Debug.checkDefined(getDeclarationName(node))); } /** * Declares a Symbol for the node and adds it to symbols. Reports errors for conflicting identifier names. @@ -129497,7 +133768,7 @@ var ts; */ function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod) { ts.Debug.assert(!ts.hasDynamicName(node)); - var isDefaultExport = ts.hasModifier(node, 512 /* Default */); + var isDefaultExport = ts.hasModifier(node, 512 /* Default */) || ts.isExportSpecifier(node) && node.name.escapedText === "default"; // The exported symbol for an export default function/class node is always named "default" var name = isDefaultExport && parent ? "default" /* Default */ : getDeclarationName(node); var symbol; @@ -129886,9 +134157,12 @@ var ts; case 196 /* CallExpression */: bindCallExpressionFlow(node); break; - case 321 /* JSDocTypedefTag */: - case 314 /* JSDocCallbackTag */: - case 315 /* JSDocEnumTag */: + case 218 /* NonNullExpression */: + bindNonNullExpressionFlow(node); + break; + case 322 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 316 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime @@ -129995,9 +134269,12 @@ var ts; function createLoopLabel() { return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); } + function createReduceLabel(target, antecedents, antecedent) { + return initFlowNode({ flags: 1024 /* ReduceLabel */, target: target, antecedents: antecedents, antecedent: antecedent }); + } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; + flow.flags |= flow.flags & 2048 /* Referenced */ ? 4096 /* Shared */ : 2048 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -130228,35 +134505,36 @@ var ts; } } function bindTryStatement(node) { - var preFinallyLabel = createBranchLabel(); // We conservatively assume that *any* code in the try block can cause an exception, but we only need // to track code that causes mutations (because only mutations widen the possible control flow type of - // a variable). The currentExceptionTarget is the target label for control flows that result from - // exceptions. We add all mutation flow nodes as antecedents of this label such that we can analyze them - // as possible antecedents of the start of catch or finally blocks. Furthermore, we add the current - // control flow to represent exceptions that occur before any mutations. + // a variable). The exceptionLabel is the target label for control flows that result from exceptions. + // We add all mutation flow nodes as antecedents of this label such that we can analyze them as possible + // antecedents of the start of catch or finally blocks. Furthermore, we add the current control flow to + // represent exceptions that occur before any mutations. var saveReturnTarget = currentReturnTarget; var saveExceptionTarget = currentExceptionTarget; - currentReturnTarget = createBranchLabel(); - currentExceptionTarget = node.catchClause ? createBranchLabel() : currentReturnTarget; - addAntecedent(currentExceptionTarget, currentFlow); + var normalExitLabel = createBranchLabel(); + var returnLabel = createBranchLabel(); + var exceptionLabel = createBranchLabel(); + if (node.finallyBlock) { + currentReturnTarget = returnLabel; + } + addAntecedent(exceptionLabel, currentFlow); + currentExceptionTarget = exceptionLabel; bind(node.tryBlock); - addAntecedent(preFinallyLabel, currentFlow); - var flowAfterTry = currentFlow; - var flowAfterCatch = unreachableFlow; + addAntecedent(normalExitLabel, currentFlow); if (node.catchClause) { // Start of catch clause is the target of exceptions from try block. - currentFlow = finishFlowLabel(currentExceptionTarget); + currentFlow = finishFlowLabel(exceptionLabel); // The currentExceptionTarget now represents control flows from exceptions in the catch clause. // Effectively, in a try-catch-finally, if an exception occurs in the try block, the catch block // acts like a second try block. - currentExceptionTarget = currentReturnTarget; - addAntecedent(currentExceptionTarget, currentFlow); + exceptionLabel = createBranchLabel(); + addAntecedent(exceptionLabel, currentFlow); + currentExceptionTarget = exceptionLabel; bind(node.catchClause); - addAntecedent(preFinallyLabel, currentFlow); - flowAfterCatch = currentFlow; + addAntecedent(normalExitLabel, currentFlow); } - var exceptionTarget = finishFlowLabel(currentExceptionTarget); currentReturnTarget = saveReturnTarget; currentExceptionTarget = saveExceptionTarget; if (node.finallyBlock) { @@ -130269,35 +134547,33 @@ var ts; // When analyzing a control flow graph that starts inside a finally block we want to consider all // five possibilities above. However, when analyzing a control flow graph that starts outside (past) // the finally block, we only want to consider the first two (if we're past a finally block then it - // must have completed normally). To make this possible, we inject two extra nodes into the control - // flow graph: An after-finally with an antecedent of the control flow at the end of the finally - // block, and a pre-finally with an antecedent that represents all exceptional control flows. The - // 'lock' property of the pre-finally references the after-finally, and the after-finally has a - // boolean 'locked' property that we set to true when analyzing a control flow that contained the - // the after-finally node. When the lock associated with a pre-finally is locked, the antecedent of - // the pre-finally (i.e. the exceptional control flows) are skipped. - var preFinallyFlow = initFlowNode({ flags: 4096 /* PreFinally */, antecedent: exceptionTarget, lock: {} }); - addAntecedent(preFinallyLabel, preFinallyFlow); - currentFlow = finishFlowLabel(preFinallyLabel); + // must have completed normally). Likewise, when analyzing a control flow graph from return statements + // in try or catch blocks in an IIFE, we only want to consider the third. To make this possible, we + // inject a ReduceLabel node into the control flow graph. This node contains an alternate reduced + // set of antecedents for the pre-finally label. As control flow analysis passes by a ReduceLabel + // node, the pre-finally label is temporarily switched to the reduced antecedent set. + var finallyLabel = createBranchLabel(); + finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents); + currentFlow = finallyLabel; bind(node.finallyBlock); - // If the end of the finally block is reachable, but the end of the try and catch blocks are not, - // convert the current flow to unreachable. For example, 'try { return 1; } finally { ... }' should - // result in an unreachable current control flow. - if (!(currentFlow.flags & 1 /* Unreachable */)) { - if ((flowAfterTry.flags & 1 /* Unreachable */) && (flowAfterCatch.flags & 1 /* Unreachable */)) { - currentFlow = flowAfterTry === reportedUnreachableFlow || flowAfterCatch === reportedUnreachableFlow - ? reportedUnreachableFlow - : unreachableFlow; - } + if (currentFlow.flags & 1 /* Unreachable */) { + // If the end of the finally block is unreachable, the end of the entire try statement is unreachable. + currentFlow = unreachableFlow; } - if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = initFlowNode({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); - preFinallyFlow.lock = afterFinallyFlow; - currentFlow = afterFinallyFlow; + else { + // If we have an IIFE return target and return statements in the try or catch blocks, add a control + // flow that goes back through the finally block and back through only the return statements. + if (currentReturnTarget && returnLabel.antecedents) { + addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow)); + } + // If the end of the finally block is reachable, but the end of the try and catch blocks are not, + // convert the current flow to unreachable. For example, 'try { return 1; } finally { ... }' should + // result in an unreachable current control flow. + currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow; } } else { - currentFlow = finishFlowLabel(preFinallyLabel); + currentFlow = finishFlowLabel(normalExitLabel); } } function bindSwitchStatement(node) { @@ -130638,7 +134914,7 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.kind !== 315 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 316 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } @@ -130657,15 +134933,17 @@ var ts; } } function bindOptionalChainRest(node) { - bind(node.questionDotToken); switch (node.kind) { case 194 /* PropertyAccessExpression */: + bind(node.questionDotToken); bind(node.name); break; case 195 /* ElementAccessExpression */: + bind(node.questionDotToken); bind(node.argumentExpression); break; case 196 /* CallExpression */: + bind(node.questionDotToken); bindEach(node.typeArguments); bindEach(node.arguments); break; @@ -130683,7 +134961,7 @@ var ts; // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost // chain node. We then treat the entire node as the right side of the expression. - var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + var preChainLabel = ts.isOptionalChainRoot(node) ? createBranchLabel() : undefined; bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); if (preChainLabel) { currentFlow = finishFlowLabel(preChainLabel); @@ -130704,6 +134982,14 @@ var ts; bindOptionalChain(node, currentTrueTarget, currentFalseTarget); } } + function bindNonNullExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + bindEachChild(node); + } + } function bindAccessExpressionFlow(node) { if (ts.isOptionalChain(node)) { bindOptionalChainFlow(node); @@ -130854,8 +135140,8 @@ var ts; case 201 /* FunctionExpression */: case 202 /* ArrowFunction */: case 300 /* JSDocFunctionType */: - case 321 /* JSDocTypedefTag */: - case 314 /* JSDocCallbackTag */: + case 322 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: case 247 /* TypeAliasDeclaration */: case 186 /* MappedType */: // All the children of these container types are never visible through another @@ -131477,7 +135763,7 @@ var ts; case 304 /* JSDocTypeLiteral */: case 186 /* MappedType */: return bindAnonymousTypeWorker(node); - case 309 /* JSDocClassTag */: + case 310 /* JSDocClassTag */: return bindJSDocClassTag(node); case 193 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); @@ -131545,7 +135831,7 @@ var ts; // falls through case 250 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 316 /* JSDocParameterTag */: + case 317 /* JSDocParameterTag */: if (node.parent.kind === 305 /* JSDocSignature */) { return bindParameter(node); } @@ -131553,15 +135839,15 @@ var ts; break; } // falls through - case 322 /* JSDocPropertyTag */: + case 323 /* JSDocPropertyTag */: var propTag = node; var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 299 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 321 /* JSDocTypedefTag */: - case 314 /* JSDocCallbackTag */: - case 315 /* JSDocEnumTag */: + case 322 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 316 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -131603,7 +135889,7 @@ var ts; var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863 /* All */); if (node.isExportEquals) { // Will be an error later, since the module already has other exports. Just make sure this has a valueDeclaration set. - setValueDeclaration(symbol, node); + ts.setValueDeclaration(symbol, node); } } } @@ -131705,7 +135991,7 @@ var ts; ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); - setValueDeclaration(symbol, node); + ts.setValueDeclaration(symbol, node); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); @@ -131845,15 +136131,13 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } + else if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } else { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } - else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); - } + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); } } /** @@ -131861,6 +136145,7 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { + ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -132071,7 +136356,7 @@ var ts; } } function bindParameter(node) { - if (node.kind === 316 /* JSDocParameterTag */ && container.kind !== 305 /* JSDocSignature */) { + if (node.kind === 317 /* JSDocParameterTag */ && container.kind !== 305 /* JSDocSignature */) { return; } if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { @@ -132331,6 +136616,9 @@ var ts; return computePropertyAccess(node, subtreeFlags); case 195 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); + case 267 /* JsxSelfClosingElement */: + case 268 /* JsxOpeningElement */: + return computeJsxOpeningLikeElement(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); } @@ -132373,6 +136661,14 @@ var ts; node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; return transformFlags & ~536879104 /* ArrayLiteralOrCallOrNewExcludes */; } + function computeJsxOpeningLikeElement(node, subtreeFlags) { + var transformFlags = subtreeFlags | 2 /* AssertJsx */; + if (node.typeArguments) { + transformFlags |= 1 /* AssertTypeScript */; + } + node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; + return transformFlags & ~536870912 /* NodeExcludes */; + } function computeBinaryExpression(node, subtreeFlags) { var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; @@ -132788,7 +137084,7 @@ var ts; break; case 199 /* TypeAssertionExpression */: case 217 /* AsExpression */: - case 325 /* PartiallyEmittedExpression */: + case 326 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; @@ -132807,8 +137103,6 @@ var ts; transformFlags |= 1 /* AssertTypeScript */; break; case 266 /* JsxElement */: - case 267 /* JsxSelfClosingElement */: - case 268 /* JsxOpeningElement */: case 11 /* JsxText */: case 269 /* JsxClosingElement */: case 270 /* JsxFragment */: @@ -132825,8 +137119,18 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 211 /* TemplateExpression */: + if (node.templateFlags) { + transformFlags |= 32 /* AssertES2018 */; + break; + } + // falls through case 198 /* TaggedTemplateExpression */: + if (ts.hasInvalidEscape(node.template)) { + transformFlags |= 32 /* AssertES2018 */; + break; + } + // falls through + case 211 /* TemplateExpression */: case 282 /* ShorthandPropertyAssignment */: case 120 /* StaticKeyword */: case 219 /* MetaProperty */: @@ -133053,7 +137357,7 @@ var ts; return 536879104 /* BindingPatternExcludes */; case 199 /* TypeAssertionExpression */: case 217 /* AsExpression */: - case 325 /* PartiallyEmittedExpression */: + case 326 /* PartiallyEmittedExpression */: case 200 /* ParenthesizedExpression */: case 102 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; @@ -133283,7 +137587,9 @@ var ts; var WideningKind; (function (WideningKind) { WideningKind[WideningKind["Normal"] = 0] = "Normal"; - WideningKind[WideningKind["GeneratorYield"] = 1] = "GeneratorYield"; + WideningKind[WideningKind["FunctionReturn"] = 1] = "FunctionReturn"; + WideningKind[WideningKind["GeneratorNext"] = 2] = "GeneratorNext"; + WideningKind[WideningKind["GeneratorYield"] = 3] = "GeneratorYield"; })(WideningKind || (WideningKind = {})); var TypeFacts; (function (TypeFacts) { @@ -133419,6 +137725,8 @@ var ts; IntersectionState[IntersectionState["None"] = 0] = "None"; IntersectionState[IntersectionState["Source"] = 1] = "Source"; IntersectionState[IntersectionState["Target"] = 2] = "Target"; + IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck"; + IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck"; })(IntersectionState || (IntersectionState = {})); var MappedTypeModifiers; (function (MappedTypeModifiers) { @@ -133461,6 +137769,11 @@ var ts; DeclarationSpaces[DeclarationSpaces["ExportType"] = 2] = "ExportType"; DeclarationSpaces[DeclarationSpaces["ExportNamespace"] = 4] = "ExportNamespace"; })(DeclarationSpaces || (DeclarationSpaces = {})); + function SymbolLinks() { + } + function NodeLinks() { + this.flags = 0; + } function getNodeId(node) { if (!node.id) { node.id = nextNodeId; @@ -133514,12 +137827,12 @@ var ts; var typeCount = 0; var symbolCount = 0; var enumCount = 0; + var totalInstantiationCount = 0; var instantiationCount = 0; var instantiationDepth = 0; var constraintDepth = 0; var currentNode; var emptySymbols = ts.createSymbolTable(); - var identityMapper = ts.identity; var arrayVariances = [1 /* Covariant */]; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); @@ -133556,6 +137869,7 @@ var ts; getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; }, getTypeCount: function () { return typeCount; }, + getInstantiationCount: function () { return totalInstantiationCount; }, getRelationCacheSizes: function () { return ({ assignable: assignableRelation.size, identity: identityRelation.size, @@ -133623,7 +137937,8 @@ var ts; }, getSymbolAtLocation: function (node) { node = ts.getParseTreeNode(node); - return node ? getSymbolAtLocation(node) : undefined; + // set ignoreErrors: true because any lookups invoked by the API shouldn't cause any new errors + return node ? getSymbolAtLocation(node, /*ignoreErrors*/ true) : undefined; }, getShorthandAssignmentValueSymbol: function (node) { node = ts.getParseTreeNode(node); @@ -133763,9 +138078,7 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, - isTypeAssignableTo: function (source, target) { - return isTypeAssignableTo(source, target); - }, + isTypeAssignableTo: isTypeAssignableTo, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -133805,6 +138118,9 @@ var ts; getJsxNamespace: function (n) { return ts.unescapeLeadingUnderscores(getJsxNamespace(n)); }, getAccessibleSymbolChain: getAccessibleSymbolChain, getTypePredicateOfSignature: getTypePredicateOfSignature, + resolveExternalModuleName: function (moduleSpecifier) { + return resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true); + }, resolveExternalModuleSymbol: resolveExternalModuleSymbol, tryGetThisTypeAt: function (node, includeGlobalThis) { node = ts.getParseTreeNode(node); @@ -133911,6 +138227,8 @@ var ts; var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; var numberOrBigIntType = getUnionType([numberType, bigintType]); + var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(t) : t; }); + var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 /* TypeParameter */ ? wildcardType : t; }); var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); emptyJsxObjectType.objectFlags |= 4096 /* JsxAttributes */; @@ -134088,6 +138406,7 @@ var ts; if (jsxPragma) { var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); + ts.visitNode(file.localJsxFactory, markAsSynthetic); if (file.localJsxFactory) { return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText; } @@ -134098,6 +138417,7 @@ var ts; _jsxNamespace = "React"; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); + ts.visitNode(_jsxFactoryEntity, markAsSynthetic); if (_jsxFactoryEntity) { _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText; } @@ -134106,7 +138426,15 @@ var ts; _jsxNamespace = ts.escapeLeadingUnderscores(compilerOptions.reactNamespace); } } + if (!_jsxFactoryEntity) { + _jsxFactoryEntity = ts.createQualifiedName(ts.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement"); + } return _jsxNamespace; + function markAsSynthetic(node) { + node.pos = -1; + node.end = -1; + return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext); + } } function getEmitResolver(sourceFile, cancellationToken) { // Ensure we have all the type information in place for this file so that all the @@ -134243,12 +138571,8 @@ var ts; target.constEnumOnlyModule = false; } target.flags |= source.flags; - if (source.valueDeclaration && - (!target.valueDeclaration || - ts.isAssignmentDeclaration(target.valueDeclaration) && !ts.isAssignmentDeclaration(source.valueDeclaration) || - ts.isEffectiveModuleDeclaration(target.valueDeclaration) && !ts.isEffectiveModuleDeclaration(source.valueDeclaration))) { - // other kinds of value declarations take precedence over modules and assignment declarations - target.valueDeclaration = source.valueDeclaration; + if (source.valueDeclaration) { + ts.setValueDeclaration(target, source.valueDeclaration); } ts.addRange(target.declarations, source.declarations); if (source.members) { @@ -134306,24 +138630,32 @@ var ts; function addDuplicateLocations(locs, symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.pushIfUnique(locs, (ts.getExpandoInitializer(decl, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(decl) : ts.getNameOfDeclaration(decl)) || decl); + ts.pushIfUnique(locs, decl); } } } function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) { ts.forEach(target.declarations, function (node) { - var errorNode = (ts.getExpandoInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node; - addDuplicateDeclarationError(errorNode, message, symbolName, source.declarations); + addDuplicateDeclarationError(node, message, symbolName, source.declarations); }); } - function addDuplicateDeclarationError(errorNode, message, symbolName, relatedNodes) { + function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) { + var errorNode = (ts.getExpandoInitializer(node, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node; var err = lookupOrIssueError(errorNode, message, symbolName); + var _loop_6 = function (relatedNode) { + var adjustedNode = (ts.getExpandoInitializer(relatedNode, /*isPrototypeAssignment*/ false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode; + if (adjustedNode === errorNode) + return "continue"; + err.relatedInformation = err.relatedInformation || []; + var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName); + var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here); + if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 /* EqualTo */ || ts.compareDiagnostics(r, leadingMessage) === 0 /* EqualTo */; })) + return "continue"; + ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage); + }; for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) { var relatedNode = _a[_i]; - err.relatedInformation = err.relatedInformation || []; - if (ts.length(err.relatedInformation) >= 5) - continue; - ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? ts.createDiagnosticForNode(relatedNode, ts.Diagnostics._0_was_also_declared_here, symbolName) : ts.createDiagnosticForNode(relatedNode, ts.Diagnostics.and_here)); + _loop_6(relatedNode); } } function combineSymbolTables(first, second) { @@ -134344,6 +138676,7 @@ var ts; }); } function mergeModuleAugmentation(moduleName) { + var _a, _b; var moduleAugmentation = moduleName.parent; if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) { // this is a combined symbol for multiple augmentations within the same file. @@ -134382,6 +138715,16 @@ var ts; patternAmbientModuleAugmentations.set(moduleName.text, merged); } else { + if (((_a = mainModule_1.exports) === null || _a === void 0 ? void 0 : _a.get("__export" /* ExportStar */)) && ((_b = moduleAugmentation.symbol.exports) === null || _b === void 0 ? void 0 : _b.size)) { + // We may need to merge the module augmentation's exports into the target symbols of the resolved exports + var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports" /* resolvedExports */); + for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) { + var _d = _c[_i], key = _d[0], value = _d[1]; + if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) { + mergeSymbol(resolvedExports.get(key), value); + } + } + } mergeSymbol(mainModule_1, moduleAugmentation.symbol); } } @@ -134410,18 +138753,18 @@ var ts; if (symbol.flags & 33554432 /* Transient */) return symbol; var id = getSymbolId(symbol); - return symbolLinks[id] || (symbolLinks[id] = {}); + return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks()); } function getNodeLinks(node) { var nodeId = getNodeId(node); - return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks()); } function isGlobalSourceFile(node) { return node.kind === 290 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { - var symbol = symbols.get(name); + var symbol = getMergedSymbol(symbols.get(name)); if (symbol) { ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { @@ -134457,6 +138800,7 @@ var ts; function isBlockScopedNameDeclaredBeforeUse(declaration, usage) { var declarationFile = ts.getSourceFileOfNode(declaration); var useFile = ts.getSourceFileOfNode(usage); + var declContainer = ts.getEnclosingBlockScopeContainer(declaration); if (declarationFile !== useFile) { if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || @@ -134498,11 +138842,10 @@ var ts; return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ false); } else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) { - var container_3 = ts.getEnclosingBlockScopeContainer(declaration.parent); // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property return !(compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields && ts.getContainingClass(declaration) === ts.getContainingClass(usage) - && isUsedInFunctionOrInstanceProperty(usage, declaration, container_3)); + && isUsedInFunctionOrInstanceProperty(usage, declaration)); } return true; } @@ -134524,40 +138867,42 @@ var ts; if (usage.kind === 259 /* ExportAssignment */ && usage.isExportEquals) { return true; } - var container = ts.getEnclosingBlockScopeContainer(declaration); - if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage)) { + if (!!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) { return true; } - if (isUsedInFunctionOrInstanceProperty(usage, declaration, container)) { - if (compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields) { - return (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent)) && - !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); + if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { + if (compilerOptions.target === 99 /* ESNext */ && !!compilerOptions.useDefineForClassFields + && ts.getContainingClass(declaration) + && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) { + return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); } else { return true; } } return false; + function usageInTypeDeclaration() { + return !!ts.findAncestor(usage, function (node) { return ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node); }); + } function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { - var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { case 225 /* VariableStatement */: case 230 /* ForStatement */: case 232 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) - if (isSameScopeDescendentOf(usage, declaration, container)) { + if (isSameScopeDescendentOf(usage, declaration, declContainer)) { return true; } break; } // ForIn/ForOf case - use site should not be used in expression part var grandparent = declaration.parent.parent; - return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, container); + return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, declContainer); } - function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { + function isUsedInFunctionOrInstanceProperty(usage, declaration) { return !!ts.findAncestor(usage, function (current) { - if (current === container) { + if (current === declContainer) { return "quit"; } if (ts.isFunctionLike(current)) { @@ -134619,6 +138964,61 @@ var ts; return ancestorChangingReferenceScope === undefined; } } + function useOuterVariableScopeInParameter(result, location, lastLocation) { + var target = ts.getEmitScriptTarget(compilerOptions); + var functionLocation = location; + if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + // check for several cases where we introduce temporaries that require moving the name/initializer of the parameter to the body + // - static field in a class expression + // - optional chaining pre-es2020 + // - nullish coalesce pre-es2020 + // - spread assignment in binding pattern pre-es2017 + if (target >= 2 /* ES2015 */) { + var links = getNodeLinks(functionLocation); + if (links.declarationRequiresScopeChange === undefined) { + links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false; + } + return !links.declarationRequiresScopeChange; + } + } + return false; + function requiresScopeChange(node) { + return requiresScopeChangeWorker(node.name) + || !!node.initializer && requiresScopeChangeWorker(node.initializer); + } + function requiresScopeChangeWorker(node) { + switch (node.kind) { + case 202 /* ArrowFunction */: + case 201 /* FunctionExpression */: + case 244 /* FunctionDeclaration */: + case 162 /* Constructor */: + // do not descend into these + return false; + case 161 /* MethodDeclaration */: + case 163 /* GetAccessor */: + case 164 /* SetAccessor */: + case 281 /* PropertyAssignment */: + return requiresScopeChangeWorker(node.name); + case 159 /* PropertyDeclaration */: + // static properties in classes introduce temporary variables + if (ts.hasStaticModifier(node)) { + return target < 99 /* ESNext */ || !compilerOptions.useDefineForClassFields; + } + return requiresScopeChangeWorker(node.name); + default: + // null coalesce and optional chain pre-es2020 produce temporary variables + if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) { + return target < 7 /* ES2020 */; + } + if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) { + return target < 4 /* ES2017 */; + } + if (ts.isTypeNode(node)) + return false; + return ts.forEachChild(node, requiresScopeChangeWorker) || false; + } + } + } /** * Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with @@ -134636,7 +139036,7 @@ var ts; var lastLocation; var lastSelfReferenceLocation; var propertyWithInvalidInitializer; - var associatedDeclarationForContainingInitializer; + var associatedDeclarationForContainingInitializerOrBindingName; var withinDeferredContext = false; var errorLocation = location; var grandparent; @@ -134664,9 +139064,7 @@ var ts; } if (meaning & result.flags & 3 /* Variable */) { // expression inside parameter will lookup as normal variable scope when targeting es2015+ - var functionLocation = location; - if (compilerOptions.target && compilerOptions.target >= 2 /* ES2015 */ && ts.isParameter(lastLocation) && - functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) { + if (useOuterVariableScopeInParameter(result, location, lastLocation)) { useResult = false; } else if (result.flags & 1 /* FunctionScopedVariable */) { @@ -134880,22 +139278,28 @@ var ts; location = location.parent; } break; - case 321 /* JSDocTypedefTag */: - case 314 /* JSDocCallbackTag */: - case 315 /* JSDocEnumTag */: + case 322 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 316 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; case 156 /* Parameter */: - if (lastLocation && lastLocation === location.initializer) { - associatedDeclarationForContainingInitializer = location; + if (lastLocation && (lastLocation === location.initializer || + lastLocation === location.name && ts.isBindingPattern(lastLocation))) { + if (!associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location; + } } break; case 191 /* BindingElement */: - if (lastLocation && lastLocation === location.initializer) { + if (lastLocation && (lastLocation === location.initializer || + lastLocation === location.name && ts.isBindingPattern(lastLocation))) { var root = ts.getRootDeclaration(location); if (root.kind === 156 /* Parameter */) { - associatedDeclarationForContainingInitializer = location; + if (!associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location; + } } } break; @@ -134995,17 +139399,17 @@ var ts; errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); } } - // If we're in a parameter initializer, we can't reference the values of the parameter whose initializer we're within or parameters to the right - if (result && associatedDeclarationForContainingInitializer && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { + // If we're in a parameter initializer or binding name, we can't reference the values of the parameter whose initializer we're within or parameters to the right + if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551 /* Value */) === 111551 /* Value */) { var candidate = getMergedSymbol(getLateBoundSymbol(result)); - var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializer); + var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName); // A parameter initializer or binding pattern initializer within a parameter cannot refer to itself - if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializer)) { - error(errorLocation, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.declarationNameToString(associatedDeclarationForContainingInitializer.name)); + if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) { + error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name)); } // And it cannot refer to any declarations which come after it - else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializer.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) { - error(errorLocation, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializer.name), ts.declarationNameToString(errorLocation)); + else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) { + error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation)); } } if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) { @@ -135156,7 +139560,7 @@ var ts; if (meaning & (788968 /* Type */ & ~1920 /* Namespace */)) { var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 /* Type */ & 111551 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1920 /* Namespace */)) { - error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, ts.unescapeLeadingUnderscores(name)); + error(errorLocation, ts.Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here_Did_you_mean_typeof_0, ts.unescapeLeadingUnderscores(name)); return true; } } @@ -135401,12 +139805,7 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); - } - else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); - } + reportNonDefaultExport(moduleSymbol, node); } } else if (hasSyntheticDefault) { @@ -135419,6 +139818,25 @@ var ts; return exportDefaultSymbol; } } + function reportNonDefaultExport(moduleSymbol, node) { + var _a, _b; + if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export" /* ExportStar */); + if (exportStar) { + var defaultExport = ts.find(exportStar.declarations, function (decl) { + var _a, _b; + return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier && ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default" /* Default */))); + }); + if (defaultExport) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default)); + } + } + } + } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; var immediate = resolveExternalModuleName(node, moduleSpecifier); @@ -135488,8 +139906,8 @@ var ts; } } function getExternalModuleMember(node, specifier, dontResolveAlias) { - if (dontResolveAlias === void 0) { dontResolveAlias = false; } var _a; + if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 var name = specifier.propertyName || specifier.name; var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); @@ -135535,7 +139953,7 @@ var ts; error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); } else { - reportNonExportedMember(name, declarationName, moduleSymbol, moduleName); + reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName); } } } @@ -135543,25 +139961,48 @@ var ts; } } } - function reportNonExportedMember(name, declarationName, moduleSymbol, moduleName) { + function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) { var _a; var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText); var exports = moduleSymbol.exports; if (localSymbol) { - var exportedSymbol = exports && !exports.has("export=" /* ExportEquals */) - ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) - : undefined; - var diagnostic = exportedSymbol - ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) - : error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName); - ts.addRelatedInfo.apply(void 0, __spreadArrays([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { - return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); - }))); + var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=" /* ExportEquals */); + if (exportedEqualsSymbol) { + getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) : + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } + else { + var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined; + var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) : + error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName); + ts.addRelatedInfo.apply(void 0, __spreadArrays([diagnostic], ts.map(localSymbol.declarations, function (decl, index) { + return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName); + }))); + } } else { error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); } } + function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) { + if (moduleKind >= ts.ModuleKind.ES2015) { + var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import : + ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; + error(name, message, declarationName); + } + else { + if (ts.isInJSFile(node)) { + var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import : + ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; + error(name, message, declarationName); + } + else { + var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import : + ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; + error(name, message, declarationName, declarationName, moduleName); + } + } + } function getTargetOfImportSpecifier(node, dontResolveAlias) { var resolved = getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false); @@ -135580,7 +140021,7 @@ var ts; return resolved; } function getTargetOfExportAssignment(node, dontResolveAlias) { - var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + var expression = ts.isExportAssignment(node) ? node.expression : node.right; var resolved = getTargetOfAliasLikeExpression(expression, dontResolveAlias); markSymbolOfAliasDeclarationIfTypeOnly(node, /*immediateTarget*/ undefined, resolved, /*overwriteEmpty*/ false); return resolved; @@ -135673,6 +140114,13 @@ var ts; } return links.target; } + function tryResolveAlias(symbol) { + var links = getSymbolLinks(symbol); + if (links.target !== resolvingSymbol) { + return resolveAlias(symbol); + } + return undefined; + } /** * Marks a symbol as type-only if its declaration is syntactically type-only. * If it is not itself marked type-only, but resolves to a type-only alias @@ -135801,11 +140249,11 @@ var ts; var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; if (name.kind === 75 /* Identifier */) { - var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); - var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; - symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); + var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); + var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; + symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true)); if (!symbol) { - return symbolFromJSPrototype; + return getMergedSymbol(symbolFromJSPrototype); } } else if (name.kind === 153 /* QualifiedName */ || name.kind === 194 /* PropertyAccessExpression */) { @@ -135833,7 +140281,7 @@ var ts; } } } - symbol = getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning); + symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning)); if (!symbol) { if (!ignoreErrors) { error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(namespace), ts.declarationNameToString(right)); @@ -135845,7 +140293,7 @@ var ts; throw ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); - if (ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 259 /* ExportAssignment */)) { + if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 /* Alias */ || name.parent.kind === 259 /* ExportAssignment */)) { markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, /*finalTarget*/ undefined, /*overwriteEmpty*/ true); } return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -135888,8 +140336,8 @@ var ts; return getDeclarationOfJSPrototypeContainer(symbol); } } - var sig = ts.getHostSignatureFromJSDocHost(host); - if (sig) { + var sig = ts.getEffectiveJSDocHost(node); + if (sig && ts.isFunctionLike(sig)) { var symbol = getSymbolOfNode(sig); return symbol && symbol.valueDeclaration; } @@ -135924,7 +140372,7 @@ var ts; } } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { - return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); + return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations); } function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } @@ -136033,7 +140481,7 @@ var ts; return getPackagesSet().has(ts.getTypesPackageName(packageName)); } function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { - if (moduleSymbol) { + if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; @@ -136309,11 +140757,14 @@ var ts; } return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; }); function fileSymbolIfFileSymbolExportEqualsContainer(d) { - var fileSymbol = getExternalModuleContainer(d); - var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; + return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container); } } + function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) { + var fileSymbol = getExternalModuleContainer(d); + var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); + return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; + } function getAliasForSymbolInContainer(container, symbol) { if (container === getParentOfSymbol(symbol)) { // fast path, `symbol` is either already the alias or isn't aliased @@ -136433,7 +140884,7 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - var _loop_6 = function (location) { + var _loop_7 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { @@ -136479,7 +140930,7 @@ var ts; } }; for (var location = enclosingDeclaration; location; location = location.parent) { - var state_2 = _loop_6(location); + var state_2 = _loop_7(location); if (typeof state_2 === "object") return state_2.value; } @@ -136668,7 +141119,7 @@ var ts; // If we're trying to reference some object literal in, eg `var a = { x: 1 }`, the symbol for the literal, `__object`, is distinct // from the symbol of the declaration it is being assigned to. Since we can use the declaration to refer to the literal, however, // we'd like to make that connection here - potentially causing us to paint the declaration's visibility, and therefore the literal. - var firstDecl = ts.first(symbol.declarations); + var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations); if (!ts.length(containers) && meaning & 111551 /* Value */ && firstDecl && ts.isObjectLiteralExpression(firstDecl)) { if (firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent) && firstDecl === firstDecl.parent.initializer) { containers = [getSymbolOfNode(firstDecl.parent)]; @@ -136863,7 +141314,7 @@ var ts; var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); - var maxLength = noTruncation ? undefined : ts.defaultMaximumTruncationLength * 2; + var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2; if (maxLength && result && result.length >= maxLength) { return result.substr(0, maxLength - "...".length) + "..."; } @@ -136883,7 +141334,7 @@ var ts; } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } - return flags & 277904747 /* NodeBuilderFlagsMask */; + return flags & 814775659 /* NodeBuilderFlagsMask */; } function createNodeBuilder() { return { @@ -136922,10 +141373,15 @@ var ts; flags: flags || 0 /* None */, // If no full tracker is provided, fake up a dummy one with a basic limited-functionality moduleResolverHost tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { - getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + redirectTargetsMap: host.redirectTargetsMap, + getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); }, + isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); }, + fileExists: function (fileName) { return host.fileExists(fileName); }, } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -136939,7 +141395,7 @@ var ts; function checkTruncationLength(context) { if (context.truncating) return context.truncating; - return context.truncating = !(context.flags & 1 /* NoTruncation */) && context.approximateLength > ts.defaultMaximumTruncationLength; + return context.truncating = context.approximateLength > ((context.flags & 1 /* NoTruncation */) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength); } function typeToTypeNodeHelper(type, context) { if (cancellationToken && cancellationToken.throwIfCancellationRequested) { @@ -136948,8 +141404,15 @@ var ts; var inTypeAlias = context.flags & 8388608 /* InTypeAlias */; context.flags &= ~8388608 /* InTypeAlias */; if (!type) { - context.encounteredError = true; - return undefined; // TODO: GH#18217 + if (!(context.flags & 262144 /* AllowEmptyUnionOrIntersection */)) { + context.encounteredError = true; + return undefined; // TODO: GH#18217 + } + context.approximateLength += 3; + return ts.createKeywordTypeNode(125 /* AnyKeyword */); + } + if (!(context.flags & 536870912 /* NoTypeReduction */)) { + type = getReducedType(type); } if (type.flags & 1 /* Any */) { context.approximateLength += 3; @@ -137125,7 +141588,7 @@ var ts; return ts.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } if (type.flags & 33554432 /* Substitution */) { - return typeToTypeNodeHelper(type.typeVariable, context); + return typeToTypeNodeHelper(type.baseType, context); } return ts.Debug.fail("Should be unreachable."); function createMappedTypeNodeFromType(type) { @@ -137299,14 +141762,14 @@ var ts; var i = 0; var resultType = void 0; if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { // Find group of type arguments for type parameters with the same declaring container. var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { @@ -137473,7 +141936,7 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(125 /* AnyKeyword */); + propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.createKeywordTypeNode(125 /* AnyKeyword */); } context.flags = savedFlags; var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(138 /* ReadonlyKeyword */)] : undefined; @@ -137485,8 +141948,8 @@ var ts; typeElements.push(preserveCommentsOn(propertySignature)); } function preserveCommentsOn(node) { - if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 322 /* JSDocPropertyTag */; })) { - var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 322 /* JSDocPropertyTag */; }); + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 323 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 323 /* JSDocPropertyTag */; }); var commentText = d.comment; if (commentText) { ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); @@ -137513,28 +141976,63 @@ var ts; ]; } } - var result = []; + var mayHaveNameCollisions = !(context.flags & 64 /* UseFullyQualifiedType */); + /** Map from type reference identifier text to [type, index in `result` where the type node is] */ + var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined; + var result_3 = []; var i = 0; for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { var type = types_1[_i]; i++; if (checkTruncationLength(context) && (i + 2 < types.length - 1)) { - result.push(ts.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); + result_3.push(ts.createTypeReferenceNode("... " + (types.length - i) + " more ...", /*typeArguments*/ undefined)); var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context); if (typeNode_1) { - result.push(typeNode_1); + result_3.push(typeNode_1); } break; } context.approximateLength += 2; // Account for whitespace + separator var typeNode = typeToTypeNodeHelper(type, context); if (typeNode) { - result.push(typeNode); + result_3.push(typeNode); + if (seenNames && ts.isIdentifierTypeReference(typeNode)) { + seenNames.add(typeNode.typeName.escapedText, [type, result_3.length - 1]); + } } } - return result; + if (seenNames) { + // To avoid printing types like `[Foo, Foo]` or `Bar & Bar` where + // occurrences of the same name actually come from different + // namespaces, go through the single-identifier type reference nodes + // we just generated, and see if any names were generated more than + // once while referring to different types. If so, regenerate the + // type node for each entry by that name with the + // `UseFullyQualifiedType` flag enabled. + var saveContextFlags = context.flags; + context.flags |= 64 /* UseFullyQualifiedType */; + seenNames.forEach(function (types) { + if (!ts.arrayIsHomogeneous(types, function (_a, _b) { + var a = _a[0]; + var b = _b[0]; + return typesAreSameReference(a, b); + })) { + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var _a = types_2[_i], type = _a[0], resultIndex = _a[1]; + result_3[resultIndex] = typeToTypeNodeHelper(type, context); + } + } + }); + context.flags = saveContextFlags; + } + return result_3; } } + function typesAreSameReference(a, b) { + return a === b + || !!a.symbol && a.symbol === b.symbol + || !!a.aliasSymbol && a.aliasSymbol === b.aliasSymbol; + } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 143 /* StringKeyword */ : 140 /* NumberKeyword */); @@ -137552,7 +142050,7 @@ var ts; return ts.createIndexSignature( /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(138 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } - function signatureToSignatureDeclarationHelper(signature, kind, context) { + function signatureToSignatureDeclarationHelper(signature, kind, context, privateSymbolVisitor, bundledImports) { var suppressAny = context.flags & 256 /* SuppressAnyReturnType */; if (suppressAny) context.flags &= ~256 /* SuppressAnyReturnType */; // suppress only toplevel `any`s @@ -137564,7 +142062,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 162 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 162 /* Constructor */, privateSymbolVisitor, bundledImports); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -137584,7 +142082,7 @@ var ts; else { var returnType = getReturnTypeOfSignature(signature); if (returnType && !(suppressAny && isTypeAny(returnType))) { - returnTypeNode = typeToTypeNodeHelper(returnType, context); + returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, privateSymbolVisitor, bundledImports); } else if (!suppressAny) { returnTypeNode = ts.createKeywordTypeNode(125 /* AnyKeyword */); @@ -137607,16 +142105,16 @@ var ts; var constraintNode = constraint && typeToTypeNodeHelper(constraint, context); return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } - function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { + function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) { var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 156 /* Parameter */); if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 316 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 317 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { parameterType = getOptionalType(parameterType); } - var parameterTypeNode = typeToTypeNodeHelper(parameterType, context); + var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; @@ -137667,7 +142165,7 @@ var ts; var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64 /* UseFullyQualifiedType */) && !(context.flags & 134217728 /* DoNotIncludeSymbolChain */)) { - chain = ts.Debug.assertDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); + chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, /*endOfChain*/ true)); ts.Debug.assert(chain && chain.length > 0); } else { @@ -137761,10 +142259,10 @@ var ts; var typeParameterNodes; if (context.flags & 512 /* WriteTypeParametersInQualifiedName */ && index < (chain.length - 1)) { var parentSymbol = symbol; - var nextSymbol = chain[index + 1]; - if (ts.getCheckFlags(nextSymbol) & 1 /* Instantiated */) { + var nextSymbol_1 = chain[index + 1]; + if (ts.getCheckFlags(nextSymbol_1) & 1 /* Instantiated */) { var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 /* Alias */ ? resolveAlias(parentSymbol) : parentSymbol); - typeParameterNodes = mapToTypeNodes(ts.map(params, nextSymbol.mapper), context); + typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context); } else { typeParameterNodes = typeParametersToTypeParameterDeclarations(symbol, context); @@ -137783,6 +142281,12 @@ var ts; } function getSpecifierForModuleSymbol(symbol, context) { var file = ts.getDeclarationOfKind(symbol, 290 /* SourceFile */); + if (!file) { + var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); }); + if (equivalentFileSymbol) { + file = ts.getDeclarationOfKind(equivalentFileSymbol, 290 /* SourceFile */); + } + } if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -137819,7 +142323,7 @@ var ts; // specifier preference var moduleResolverHost = context.tracker.moduleResolverHost; var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions; - specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, host.getSourceFiles(), { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" }, host.redirectTargetsMap)); + specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative" })); links.specifierCache = links.specifierCache || ts.createMap(); links.specifierCache.set(contextFile.path, specifier); } @@ -137921,8 +142425,15 @@ var ts; return identifier; } } - function typeParameterShadowsNameInScope(escapedName, context) { - return !!resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + function typeParameterShadowsNameInScope(escapedName, context, type) { + var result = resolveName(context.enclosingDeclaration, escapedName, 788968 /* Type */, /*nameNotFoundArg*/ undefined, escapedName, /*isUse*/ false); + if (result) { + if (result.flags & 262144 /* TypeParameter */ && result === type.symbol) { + return false; + } + return true; + } + return false; } function typeParameterToName(type, context) { if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && context.typeParameterNames) { @@ -137939,7 +142450,7 @@ var ts; var rawtext = result.escapedText; var i = 0; var text = rawtext; - while ((context.typeParameterNamesByText && context.typeParameterNamesByText.get(text)) || typeParameterShadowsNameInScope(text, context)) { + while ((context.typeParameterNamesByText && context.typeParameterNamesByText.get(text)) || typeParameterShadowsNameInScope(text, context, type)) { i++; text = rawtext + "_" + i; } @@ -138060,7 +142571,7 @@ var ts; } } function createPropertyNameNodeForIdentifierOrLiteral(name, singleQuote) { - return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name, !!singleQuote); + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) && +name >= 0 ? +name : name, !!singleQuote); } function cloneNodeBuilderContext(context) { var initial = __assign({}, context); @@ -138087,6 +142598,179 @@ var ts; } return initial; } + function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { + return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); + } + function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { + return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { + if (type !== errorType && enclosingDeclaration) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { + var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); + if (result_4) { + return result_4; + } + } + } + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + } + function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { + if (type !== errorType && context.enclosingDeclaration) { + var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { + var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); + if (result) { + return result; + } + } + } + return typeToTypeNodeHelper(type, context); + } + function serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled) { + if (cancellationToken && cancellationToken.throwIfCancellationRequested) { + cancellationToken.throwIfCancellationRequested(); + } + var hadError = false; + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + if (hadError) { + return undefined; + } + return transformed === existing ? ts.getMutableClone(existing) : transformed; + function visitExistingNodeTreeSymbols(node) { + var _a, _b; + // We don't _actually_ support jsdoc namepath types, emit `any` instead + if (ts.isJSDocAllType(node) || node.kind === 302 /* JSDocNamepathType */) { + return ts.createKeywordTypeNode(125 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(148 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(100 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(146 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if (ts.isJSDocVariadicType(node)) { + return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + if (ts.isJSDocTypeLiteral(node)) { + return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { + var name = ts.isIdentifier(t.name) ? t.name : t.name.right; + var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); + var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; + return ts.createPropertySignature( + /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), + /*initializer*/ undefined); + })); + } + if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { + return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), p.name || getEffectiveDotDotDotForParameter(p) ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), p.name || getEffectiveDotDotDotForParameter(p) ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { + return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = ts.getFirstIdentifier(node); + if (ts.isInJSFile(node) && (ts.isExportsIdentifier(leftmost) || ts.isModuleExportsAccessExpression(leftmost.parent) || (ts.isQualifiedName(leftmost.parent) && ts.isModuleIdentifier(leftmost.parent.left) && ts.isExportsIdentifier(leftmost.parent.right)))) { + hadError = true; + return node; + } + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863 /* All */, /*shouldComputeAliasesToMakeVisible*/ false).accessibility !== 0 /* Accessible */) { + hadError = true; + } + else { + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.trackSymbol) === null || _b === void 0 ? void 0 : _b.call(_a, sym, context.enclosingDeclaration, 67108863 /* All */); + includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym); + } + if (ts.isIdentifier(node)) { + var name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.getMutableClone(node); + name.symbol = sym; // for quickinfo, which uses identifier symbol information + return ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */); + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + function getEffectiveDotDotDotForParameter(p) { + return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.createToken(25 /* DotDotDotToken */) : undefined); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + } function symbolTableToDeclarationStatements(symbolTable, context, bundled) { var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 161 /* MethodDeclaration */, /*useAcessors*/ true); var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 160 /* MethodSignature */, /*useAcessors*/ false); @@ -138181,7 +142865,7 @@ var ts; if (ts.length(reexports) > 1) { var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); if (groups.length !== reexports.length) { - var _loop_7 = function (group_1) { + var _loop_8 = function (group_1) { if (group_1.length > 1) { // remove group members from statements and then merge group members and add back to statements statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ @@ -138193,7 +142877,7 @@ var ts; }; for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { var group_1 = groups_1[_i]; - _loop_7(group_1); + _loop_8(group_1); } } } @@ -138301,7 +142985,7 @@ var ts; function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); var isDefault = symbol.escapedName === "default" /* Default */; - if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + if (!(context.flags & 131072 /* AllowAnonymousIdentifier */) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) { // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( context.encounteredError = true; // TODO: Issue error via symbol tracker? @@ -138336,7 +143020,7 @@ var ts; serializeEnum(symbol, symbolName, modifierFlags); } if (symbol.flags & 32 /* Class */) { - if (symbol.flags & 4 /* Property */) { + if (symbol.flags & 4 /* Property */ && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) { // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. @@ -138376,7 +143060,7 @@ var ts; function includePrivateSymbol(symbol) { if (ts.some(symbol.declarations, ts.isParameterDeclaration)) return; - ts.Debug.assertDefined(deferredPrivates); + ts.Debug.assertIsDefined(deferredPrivates); getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol); // Call to cache unique name for symbol deferredPrivates.set("" + getSymbolId(symbol), symbol); } @@ -138437,7 +143121,7 @@ var ts; /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); } function getNamespaceMembersForSerialization(symbol) { - return !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember); } function isTypeOnlyNamespace(symbol) { return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); @@ -138456,13 +143140,19 @@ var ts; serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); } if (ts.length(mergedMembers)) { + var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration); var localName = getInternalSymbolName(symbol, symbolName); var nsBody = ts.createModuleBlock([ts.createExportDeclaration( /*decorators*/ undefined, - /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + /*modifiers*/ undefined, ts.createNamedExports(ts.mapDefined(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var _a, _b; var name = ts.unescapeLeadingUnderscores(s.escapedName); var localName = getInternalSymbolName(s, name); var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s); + if (containingFile_1 && (aliasDecl ? containingFile_1 !== ts.getSourceFileOfNode(aliasDecl) : !ts.some(s.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile_1; }))) { + (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportNonlocalAugmentation) === null || _b === void 0 ? void 0 : _b.call(_a, containingFile_1, symbol, s); + return undefined; + } var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); includePrivateSymbol(target || s); var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName; @@ -138507,7 +143197,7 @@ var ts; textRange = textRange.parent.parent; } var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ts.createVariableDeclaration(name, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], flags)), textRange); addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); if (name !== localName && !isPrivate) { @@ -138544,13 +143234,14 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; // Each overload becomes a separate function declaration, in order - var decl = signatureToSignatureDeclarationHelper(sig, 244 /* FunctionDeclaration */, context); + var decl = signatureToSignatureDeclarationHelper(sig, 244 /* FunctionDeclaration */, context, includePrivateSymbol, bundled); decl.name = ts.createIdentifier(localName); - addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + // for expressions assigned to `var`s, use the `var` as the text range + addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags); } // Module symbol emit will take care of module-y members, provided it has exports if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { - var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + var props = ts.filter(getPropertiesOfType(type), isNamespaceMember); serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); } } @@ -138603,24 +143294,32 @@ var ts; addResult(fakespace, modifierFlags); // namespaces can never be default exported } } + function isNamespaceMember(p) { + return !(p.flags & 4194304 /* Prototype */ || p.escapedName === "prototype" || p.valueDeclaration && ts.isClassLike(p.valueDeclaration.parent)); + } function serializeAsClass(symbol, localName, modifierFlags) { var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); var classType = getDeclaredTypeOfClassOrInterface(symbol); var baseTypes = getBaseTypes(classType); + var implementsTypes = getImplementsTypes(classType); var staticType = getTypeOfSymbol(symbol); var staticBaseType = getBaseConstructorTypeOfClass(staticType); - var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(90 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; - var symbolProps = getPropertiesOfType(classType); + var heritageClauses = __spreadArrays(!ts.length(baseTypes) ? [] : [ts.createHeritageClause(90 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))], !ts.length(implementsTypes) ? [] : [ts.createHeritageClause(113 /* ImplementsKeyword */, ts.map(implementsTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]); + var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType)); var publicSymbolProps = ts.filter(symbolProps, function (s) { + // `valueDeclaration` could be undefined if inherited from + // a union/intersection base type, but inherited properties + // don't matter here. var valueDecl = s.valueDeclaration; - ts.Debug.assertDefined(valueDecl); - return !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); + return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name)); }); var hasPrivateIdentifier = ts.some(symbolProps, function (s) { + // `valueDeclaration` could be undefined if inherited from + // a union/intersection base type, but inherited properties + // don't matter here. var valueDecl = s.valueDeclaration; - ts.Debug.assertDefined(valueDecl); - return ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); + return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name); }); // Boil down all private properties into a single one. var privateProperties = hasPrivateIdentifier ? @@ -138633,9 +143332,7 @@ var ts; ts.emptyArray; var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics - var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) - ? [] - : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var staticMembers = ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype" && !isNamespaceMember(p); }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 162 /* Constructor */); for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { var c = constructors_1[_i]; @@ -138767,7 +143464,7 @@ var ts; if (referenced || target) { includePrivateSymbol(referenced || target); } - // We disable the context's symbol traker for the duration of this name serialization + // We disable the context's symbol tracker for the duration of this name serialization // as, by virtue of being here, the name is required to print something, and we don't want to // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue // a visibility error here (as they're not visible within any scope), but we want to hoist them @@ -138803,14 +143500,14 @@ var ts; var varName = getUnusedName(name, symbol); // We have to use `getWidenedType` here since the object within a json file is unwidened within the file // (Unwidened types can only exist in expression contexts and should never be serialized) - var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol))); if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); } else { var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled)) ], 2 /* Const */)); addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); } @@ -138834,7 +143531,7 @@ var ts; !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK - !getDeclarationWithTypeAnnotation(hostSymbol) && + !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && @@ -138849,10 +143546,11 @@ var ts; // need to be merged namespace members return []; } - if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) - && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) - && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) - && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + if (p.flags & 4194304 /* Prototype */ || + (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { return []; } var flag = (modifierFlags & ~256 /* Async */) | (isStatic ? 32 /* Static */ : 0); @@ -138866,13 +143564,13 @@ var ts; /*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", - /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*questionToken*/ undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled))], /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); } if (p.flags & 32768 /* GetAccessor */) { var isPrivate_1 = modifierFlags & 8 /* Private */; result.push(ts.setTextRange(ts.createGetAccessor( - /*decorators*/ undefined, ts.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(flag), name, [], isPrivate_1 ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); } return result; @@ -138881,7 +143579,7 @@ var ts; // If this happens, we assume the accessor takes priority, as it imposes more constraints else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { return ts.setTextRange(createProperty( - /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | flag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, isPrivate ? undefined : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration, includePrivateSymbol, bundled), // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 // interface members can't have initializers, however class members _can_ /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); @@ -138918,115 +143616,6 @@ var ts; function serializePropertySymbolForInterface(p, baseType) { return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); } - function getDeclarationWithTypeAnnotation(symbol) { - return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); - } - /** - * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag - * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` - */ - function serializeTypeForDeclaration(type, symbol) { - var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); - if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { - // try to reuse the existing annotation - var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); - return transformed === existing ? ts.getMutableClone(existing) : transformed; - } - var oldFlags = context.flags; - if (type.flags & 8192 /* UniqueESSymbol */ && - type.symbol === symbol) { - context.flags |= 1048576 /* AllowUniqueESSymbolType */; - } - var result = typeToTypeNodeHelper(type, context); - context.flags = oldFlags; - return result; - function visitExistingNodeTreeSymbols(node) { - if (ts.isJSDocAllType(node)) { - return ts.createKeywordTypeNode(125 /* AnyKeyword */); - } - if (ts.isJSDocUnknownType(node)) { - return ts.createKeywordTypeNode(148 /* UnknownKeyword */); - } - if (ts.isJSDocNullableType(node)) { - return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(100 /* NullKeyword */)]); - } - if (ts.isJSDocOptionalType(node)) { - return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(146 /* UndefinedKeyword */)]); - } - if (ts.isJSDocNonNullableType(node)) { - return ts.visitNode(node.type, visitExistingNodeTreeSymbols); - } - if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { - return ts.createTypeLiteralNode([ts.createIndexSignature( - /*decorators*/ undefined, - /*modifiers*/ undefined, [ts.createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotdotdotToken*/ undefined, "x", - /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); - } - if (ts.isJSDocFunctionType(node)) { - if (ts.isJSDocConstructSignature(node)) { - var newTypeNode_1; - return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); - } - else { - return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), - /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); - } - } - if (ts.isLiteralImportTypeNode(node)) { - return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); - } - if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { - var leftmost = ts.getFirstIdentifier(node); - var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); - if (sym) { - includePrivateSymbol(sym); - if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { - var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); - if (ts.idText(name) !== ts.idText(node)) { - return name; - } - return node; - } - } - } - return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); - } - function rewriteModuleSpecifier(parent, lit) { - if (bundled) { - if (context.tracker && context.tracker.moduleResolverHost) { - var targetFile = getExternalModuleFileFromDeclaration(parent); - if (targetFile) { - var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); - var resolverHost = { - getCanonicalFileName: getCanonicalFileName, - getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, - getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } - }; - var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); - return ts.createLiteral(newName); - } - } - } - else { - if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { - var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); - if (moduleSym) { - context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); - } - } - } - return lit; - } - } function serializeSignatures(kind, input, baseType, outputKind) { var signatures = getSignaturesOfType(input, kind); if (kind === 1 /* Construct */) { @@ -139320,9 +143909,9 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 314 /* JSDocCallbackTag */: - case 321 /* JSDocTypedefTag */: - case 315 /* JSDocEnumTag */: + case 315 /* JSDocCallbackTag */: + case 322 /* JSDocTypedefTag */: + case 316 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); @@ -139458,8 +144047,8 @@ var ts; var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { // A cycle was found - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -139548,9 +144137,6 @@ var ts; var symbol = getSymbolOfNode(node); return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } - function isComputedNonLiteralName(name) { - return name.kind === 154 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); - } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); if (source.flags & 131072 /* Never */) { @@ -139655,9 +144241,14 @@ var ts; if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } + // Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined` + else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536 /* EQUndefined */)) { + parentType = getTypeWithFacts(parentType, 524288 /* NEUndefined */); + } var type; if (pattern.kind === 189 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { + parentType = getReducedType(parentType); if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); return errorType; @@ -139748,7 +144339,7 @@ var ts; // [Symbol.iterator] or next). This may be because we accessed properties from anyType, // or it may have led to an error inside getElementTypeOfIterable. var forOfStatement = declaration.parent.parent; - return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; + return checkRightHandSideOfForOf(forOfStatement) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); @@ -139959,28 +144550,55 @@ var ts; } return anyType; } + if (containsSameNamedThisProperty(expression.left, expression.right)) { + return anyType; + } var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right)); if (type.flags & 524288 /* Object */ && kind === 2 /* ModuleExports */ && symbol.escapedName === "export=" /* ExportEquals */) { - var exportedType_1 = resolveStructuredTypeMembers(type); + var exportedType = resolveStructuredTypeMembers(type); var members_4 = ts.createSymbolTable(); - ts.copyEntries(exportedType_1.members, members_4); + ts.copyEntries(exportedType.members, members_4); if (resolvedSymbol && !resolvedSymbol.exports) { resolvedSymbol.exports = ts.createSymbolTable(); } (resolvedSymbol || symbol).exports.forEach(function (s, name) { - if (members_4.has(name)) { - var exportedMember = exportedType_1.members.get(name); - var union = createSymbol(s.flags | exportedMember.flags, name); - union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]); - members_4.set(name, union); + var _a; + var exportedMember = members_4.get(name); + if (exportedMember && exportedMember !== s) { + if (s.flags & 111551 /* Value */) { + // If the member has an additional value-like declaration, union the types from the two declarations, + // but issue an error if they occurred in two different files. The purpose is to support a JS file with + // a pattern like: + // + // module.exports = { a: true }; + // module.exports.a = 3; + // + // but we may have a JS file with `module.exports = { a: true }` along with a TypeScript module augmentation + // declaring an `export const a: number`. In that case, we issue a duplicate identifier error, because + // it's unclear what that's supposed to mean, so it's probably a mistake. + if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) { + var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName); + var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration; + ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName)); + ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName)); + } + var union = createSymbol(s.flags | exportedMember.flags, name); + union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]); + union.valueDeclaration = exportedMember.valueDeclaration; + union.declarations = ts.concatenate(exportedMember.declarations, s.declarations); + members_4.set(name, union); + } + else { + members_4.set(name, mergeSymbol(s, exportedMember)); + } } else { members_4.set(name, s); } }); - var result = createAnonymousType(exportedType_1.symbol, members_4, exportedType_1.callSignatures, exportedType_1.constructSignatures, exportedType_1.stringIndexInfo, exportedType_1.numberIndexInfo); + var result = createAnonymousType(exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); result.objectFlags |= (ts.getObjectFlags(type) & 16384 /* JSLiteral */); // Propagate JSLiteral flag return result; } @@ -139990,6 +144608,11 @@ var ts; } return type; } + function containsSameNamedThisProperty(thisProperty, expression) { + return ts.isPropertyAccessExpression(thisProperty) + && thisProperty.expression.kind === 104 /* ThisKeyword */ + && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); }); + } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. @@ -140365,7 +144988,7 @@ var ts; var links = getSymbolLinks(symbol); var originalLinks = links; if (!links.type) { - var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); + var jsDeclaration = symbol.valueDeclaration && ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); if (merged) { @@ -140382,9 +145005,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 209 /* BinaryExpression */ || + else if (declaration && (declaration.kind === 209 /* BinaryExpression */ || ts.isAccessExpression(declaration) && - declaration.parent.kind === 209 /* BinaryExpression */) { + declaration.parent.kind === 209 /* BinaryExpression */)) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -140462,20 +145085,24 @@ var ts; function getTypeOfSymbolWithDeferredType(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - ts.Debug.assertDefined(links.deferralParent); - ts.Debug.assertDefined(links.deferralConstituents); + ts.Debug.assertIsDefined(links.deferralParent); + ts.Debug.assertIsDefined(links.deferralConstituents); links.type = links.deferralParent.flags & 1048576 /* Union */ ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents); } return links.type; } function getTypeOfSymbol(symbol) { - if (ts.getCheckFlags(symbol) & 65536 /* DeferredType */) { + var checkFlags = ts.getCheckFlags(symbol); + if (checkFlags & 65536 /* DeferredType */) { return getTypeOfSymbolWithDeferredType(symbol); } - if (ts.getCheckFlags(symbol) & 1 /* Instantiated */) { + if (checkFlags & 1 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (ts.getCheckFlags(symbol) & 8192 /* ReverseMapped */) { + if (checkFlags & 262144 /* Mapped */) { + return getTypeOfMappedSymbol(symbol); + } + if (checkFlags & 8192 /* ReverseMapped */) { return getTypeOfReverseMappedSymbol(symbol); } if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { @@ -140546,6 +145173,7 @@ var ts; return undefined; } switch (node.kind) { + case 225 /* VariableStatement */: case 245 /* ClassDeclaration */: case 214 /* ClassExpression */: case 246 /* InterfaceDeclaration */: @@ -140560,10 +145188,10 @@ var ts; case 201 /* FunctionExpression */: case 202 /* ArrowFunction */: case 247 /* TypeAliasDeclaration */: - case 320 /* JSDocTemplateTag */: - case 321 /* JSDocTypedefTag */: - case 315 /* JSDocEnumTag */: - case 314 /* JSDocCallbackTag */: + case 321 /* JSDocTemplateTag */: + case 322 /* JSDocTypedefTag */: + case 316 /* JSDocEnumTag */: + case 315 /* JSDocCallbackTag */: case 186 /* MappedType */: case 180 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); @@ -140573,6 +145201,9 @@ var ts; else if (node.kind === 180 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } + else if (node.kind === 225 /* VariableStatement */ && !ts.isInJSFile(node)) { + break; + } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && (node.kind === 245 /* ClassDeclaration */ || node.kind === 214 /* ClassExpression */ || node.kind === 246 /* InterfaceDeclaration */ || isJSConstructor(node)) && @@ -140694,6 +145325,28 @@ var ts; } return type.resolvedBaseConstructorType; } + function getImplementsTypes(type) { + var resolvedImplementsTypes = ts.emptyArray; + for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration); + if (!implementsTypeNodes) + continue; + for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) { + var node = implementsTypeNodes_1[_b]; + var implementsType = getTypeFromTypeNode(node); + if (implementsType !== errorType) { + if (resolvedImplementsTypes === ts.emptyArray) { + resolvedImplementsTypes = [implementsType]; + } + else { + resolvedImplementsTypes.push(implementsType); + } + } + } + } + return resolvedImplementsTypes; + } function getBaseTypes(type) { if (!type.resolvedBaseTypes) { if (type.objectFlags & 8 /* Tuple */) { @@ -140746,11 +145399,14 @@ var ts; if (baseType === errorType) { return type.resolvedBaseTypes = ts.emptyArray; } - if (!isValidBaseType(baseType)) { - error(baseTypeNode.expression, ts.Diagnostics.Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members, typeToString(baseType)); + var reducedBaseType = getReducedType(baseType); + if (!isValidBaseType(reducedBaseType)) { + var elaboration = elaborateNeverIntersection(/*errorInfo*/ undefined, baseType); + var diagnostic = ts.chainDiagnosticMessages(elaboration, ts.Diagnostics.Base_constructor_return_type_0_is_not_an_object_type_or_intersection_of_object_types_with_statically_known_members, typeToString(reducedBaseType)); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(baseTypeNode.expression, diagnostic)); return type.resolvedBaseTypes = ts.emptyArray; } - if (type === baseType || hasBaseType(baseType, type)) { + if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) { error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */)); return type.resolvedBaseTypes = ts.emptyArray; } @@ -140761,7 +145417,7 @@ var ts; // partial instantiation of the members without the base types fully resolved type.members = undefined; } - return type.resolvedBaseTypes = [baseType]; + return type.resolvedBaseTypes = [reducedBaseType]; } function areAllOuterTypeParametersApplied(type) { // An unapplied type parameter has its symbol still the same as the matching argument symbol. @@ -140784,8 +145440,8 @@ var ts; } // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? // There's no reason a `T` should be allowed while a `Readonly` should not. - return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || - !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); + return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || + type.flags & 2097152 /* Intersection */ && ts.every(type.types, isValidBaseType)); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; @@ -140794,7 +145450,7 @@ var ts; if (declaration.kind === 246 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; - var baseType = getTypeFromTypeNode(node); + var baseType = getReducedType(getTypeFromTypeNode(node)); if (baseType !== errorType) { if (isValidBaseType(baseType)) { if (type !== baseType && !hasBaseType(baseType, type)) { @@ -140889,7 +145545,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return errorType; } - var declaration = ts.Debug.assertDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found"); + var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found"); var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type; // If typeNode is missing, we will error in checkJSDocTypedefTag. var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType; @@ -141404,7 +146060,6 @@ var ts; var stringIndexInfo; var numberIndexInfo; if (ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { - mapper = identityMapper; members = source.symbol ? getMembersOfSymbol(source.symbol) : ts.createSymbolTable(source.declaredProperties); callSignatures = source.declaredCallSignatures; constructSignatures = source.declaredConstructSignatures; @@ -141621,7 +146276,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_8 = function (signatures) { + var _loop_9 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -141633,7 +146288,7 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_3 = _loop_8(signatures); + var state_3 = _loop_9(signatures); if (state_3 === "break") break; } @@ -141697,9 +146352,9 @@ var ts; function getUnionIndexInfo(types, kind) { var indexTypes = []; var isAnyReadonly = false; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type = types_2[_i]; - var indexInfo = getIndexInfoOfType(type, kind); + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type = types_3[_i]; + var indexInfo = getIndexInfoOfType(getApparentType(type), kind); if (!indexInfo) { return undefined; } @@ -141757,7 +146412,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_9 = function (i) { + var _loop_10 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -141780,19 +146435,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_9(i); + _loop_10(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_10 = function (sig) { + var _loop_11 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_10(sig); + _loop_11(sig); } return signatures; } @@ -141908,8 +146563,7 @@ var ts; var checkType = type.checkType; var constraint = getLowerBoundOfKeyType(checkType); if (constraint !== checkType) { - var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); - return getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); + return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); } } return type; @@ -141958,8 +146612,7 @@ var ts; // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. - var templateMapper = combineTypeMappers(type.mapper, createTypeMapper([typeParameter], [t])); - var propType = instantiateType(templateType, templateMapper); + var templateMapper = appendTypeMapping(type.mapper, typeParameter, t); // If the current iteration type constituent is a string literal type, create a property. // Otherwise, for type string create a string index signature. if (isTypeUsableAsPropertyName(t)) { @@ -141969,13 +146622,10 @@ var ts; !(templateModifiers & 8 /* ExcludeOptional */) && modifiersProp && modifiersProp.flags & 16777216 /* Optional */); var isReadonly = !!(templateModifiers & 1 /* IncludeReadonly */ || !(templateModifiers & 2 /* ExcludeReadonly */) && modifiersProp && isReadonlySymbol(modifiersProp)); - var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, isReadonly ? 8 /* Readonly */ : 0); - // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the - // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks - // mode, if the underlying property is optional we remove 'undefined' from the type. - prop.type = strictNullChecks && isOptional && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : - strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : - propType; + var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216 /* Optional */; + var prop = createSymbol(4 /* Property */ | (isOptional ? 16777216 /* Optional */ : 0), propName, 262144 /* Mapped */ | (isReadonly ? 8 /* Readonly */ : 0) | (stripOptional ? 524288 /* StripOptional */ : 0)); + prop.mappedType = type; + prop.mapper = templateMapper; if (modifiersProp) { prop.syntheticOrigin = modifiersProp; prop.declarations = modifiersProp.declarations; @@ -141983,13 +146633,38 @@ var ts; prop.nameType = t; members.set(propName, prop); } - else if (t.flags & (1 /* Any */ | 4 /* String */)) { - stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + else if (t.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 32 /* Enum */)) { + var propType = instantiateType(templateType, templateMapper); + if (t.flags & (1 /* Any */ | 4 /* String */)) { + stringIndexInfo = createIndexInfo(propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + } + else { + numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + } + } + } + } + function getTypeOfMappedSymbol(symbol) { + if (!symbol.type) { + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; } - else if (t.flags & (8 /* Number */ | 32 /* Enum */)) { - numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1 /* IncludeReadonly */)); + var templateType = getTemplateTypeFromMappedType(symbol.mappedType.target || symbol.mappedType); + var propType = instantiateType(templateType, symbol.mapper); + // When creating an optional property in strictNullChecks mode, if 'undefined' isn't assignable to the + // type, we include 'undefined' in the type. Similarly, when creating a non-optional property in strictNullChecks + // mode, if the underlying property is optional we remove 'undefined' from the type. + var type = strictNullChecks && symbol.flags & 16777216 /* Optional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType) : + symbol.checkFlags & 524288 /* StripOptional */ ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : + propType; + if (!popTypeResolution()) { + error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(symbol.mappedType)); + type = errorType; } + symbol.type = type; + symbol.mapper = undefined; } + return symbol.type; } function getTypeParameterFromMappedType(type) { return type.typeParameter || @@ -142002,7 +146677,7 @@ var ts; function getTemplateTypeFromMappedType(type) { return type.templateType || (type.templateType = type.declaration.type ? - instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper || identityMapper) : + instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4 /* IncludeOptional */)), type.mapper) : errorType); } function getConstraintDeclarationForMappedType(type) { @@ -142019,7 +146694,7 @@ var ts; // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. - type.modifiersType = instantiateType(getTypeFromTypeNode(getConstraintDeclarationForMappedType(type).type), type.mapper || identityMapper); + type.modifiersType = instantiateType(getTypeFromTypeNode(getConstraintDeclarationForMappedType(type).type), type.mapper); } else { // Otherwise, get the declared constraint type, and if the constraint type is a type parameter, @@ -142028,7 +146703,7 @@ var ts; var declaredType = getTypeFromMappedTypeNode(type.declaration); var constraint = getConstraintTypeFromMappedType(declaredType); var extendedConstraint = constraint && constraint.flags & 262144 /* TypeParameter */ ? getConstraintOfTypeParameter(constraint) : constraint; - type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper || identityMapper) : unknownType; + type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 /* Index */ ? instantiateType(extendedConstraint.type, type.mapper) : unknownType; } } return type.modifiersType; @@ -142115,8 +146790,8 @@ var ts; } } // The properties of a union type are those that are present in all constituent types, so - // we only need to check the properties of the first type - if (type.flags & 1048576 /* Union */) { + // we only need to check the properties of the first type without index signature + if (type.flags & 1048576 /* Union */ && !getIndexInfoOfType(current, 0 /* String */) && !getIndexInfoOfType(current, 1 /* Number */)) { break; } } @@ -142125,7 +146800,7 @@ var ts; return type.resolvedProperties; } function getPropertiesOfType(type) { - type = getApparentType(type); + type = getReducedApparentType(type); return type.flags & 3145728 /* UnionOrIntersection */ ? getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); @@ -142145,8 +146820,8 @@ var ts; return getAugmentedPropertiesOfType(unionType); } var props = ts.createSymbolTable(); - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var memberType = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var memberType = types_4[_i]; for (var _a = 0, _b = getAugmentedPropertiesOfType(memberType); _a < _b.length; _a++) { var escapedName = _b[_a].escapedName; if (!props.has(escapedName)) { @@ -142217,8 +146892,7 @@ var ts; var simplified = getSimplifiedType(type.checkType, /*writing*/ false); var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified; if (constraint && constraint !== type.checkType) { - var mapper = makeUnaryTypeMapper(type.root.checkType, constraint); - var instantiated = getConditionalTypeInstantiation(type, combineTypeMappers(mapper, type.mapper)); + var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper)); if (!(instantiated.flags & 131072 /* Never */)) { return instantiated; } @@ -142235,8 +146909,8 @@ var ts; function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var t = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var t = types_5[_i]; if (t.flags & 63176704 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). @@ -142261,8 +146935,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { - var t = types_5[_a]; + for (var _a = 0, types_6 = types; _a < types_6.length; _a++) { + var t = types_6[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -142348,8 +147022,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type_2 = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type_2 = types_7[_i]; var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); @@ -142435,8 +147109,7 @@ var ts; if (typeVariable) { var constraint = getConstraintOfTypeParameter(typeVariable); if (constraint && (isArrayType(constraint) || isTupleType(constraint))) { - var mapper = makeUnaryTypeMapper(typeVariable, constraint); - return instantiateType(type, combineTypeMappers(mapper, type.mapper)); + return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper)); } } return type; @@ -142444,7 +147117,7 @@ var ts; /** * For a type parameter, return the base constraint of the type parameter. For the string, number, * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the - * type itself. Note that the apparent type of a union type is the union type itself. + * type itself. */ function getApparentType(type) { var t = type.flags & 63176704 /* Instantiable */ ? getBaseConstraintOfType(type) || unknownType : type; @@ -142452,7 +147125,7 @@ var ts; t.flags & 2097152 /* Intersection */ ? getApparentTypeOfIntersectionType(t) : t.flags & 132 /* StringLike */ ? globalStringType : t.flags & 296 /* NumberLike */ ? globalNumberType : - t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 99 /* ESNext */) : + t.flags & 2112 /* BigIntLike */ ? getGlobalBigIntType(/*reportErrors*/ languageVersion >= 7 /* ES2020 */) : t.flags & 528 /* BooleanLike */ ? globalBooleanType : t.flags & 12288 /* ESSymbolLike */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : t.flags & 67108864 /* NonPrimitive */ ? emptyObjectType : @@ -142460,11 +147133,18 @@ var ts; t.flags & 2 /* Unknown */ && !strictNullChecks ? emptyObjectType : t; } + function getReducedApparentType(type) { + // Since getApparentType may return a non-reduced union or intersection type, we need to perform + // type reduction both before and after obtaining the apparent type. For example, given a type parameter + // 'T extends A | B', the type 'T & X' becomes 'A & X | B & X' after obtaining the apparent type, and + // that type may need futher reduction to remove empty intersections. + return getReducedType(getApparentType(getReducedType(type))); + } function createUnionOrIntersectionProperty(containingType, name) { - var propSet = ts.createMap(); + var singleProp; + var propSet; var indexTypes; var isUnion = containingType.flags & 1048576 /* Union */; - var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var optionalFlag = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; @@ -142472,19 +147152,28 @@ var ts; for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var current = _a[_i]; var type = getApparentType(current); - if (type !== errorType) { + if (!(type === errorType || type.flags & 131072 /* Never */)) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; - if (prop && !(modifiers & excludeModifiers)) { + if (prop) { if (isUnion) { optionalFlag |= (prop.flags & 16777216 /* Optional */); } else { optionalFlag &= prop.flags; } - var id = "" + getSymbolId(prop); - if (!propSet.has(id)) { - propSet.set(id, prop); + if (!singleProp) { + singleProp = prop; + } + else if (prop !== singleProp) { + if (!propSet) { + propSet = ts.createMap(); + propSet.set("" + getSymbolId(singleProp), singleProp); + } + var id = "" + getSymbolId(prop); + if (!propSet.has(id)) { + propSet.set(id, prop); + } } checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 256 /* ContainsPublic */ : 0) | @@ -142511,13 +147200,15 @@ var ts; } } } - if (!propSet.size) { + if (!singleProp || isUnion && (propSet || checkFlags & 48 /* Partial */) && checkFlags & (1024 /* ContainsPrivate */ | 512 /* ContainsProtected */)) { + // No property was found, or, in a union, a property has a private or protected declaration in one + // constituent, but is missing or has a different declaration in another constituent. return undefined; } - var props = ts.arrayFrom(propSet.values()); - if (props.length === 1 && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { - return props[0]; + if (!propSet && !(checkFlags & 16 /* ReadPartial */) && !indexTypes) { + return singleProp; } + var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp]; var declarations; var firstType; var nameType; @@ -142529,7 +147220,7 @@ var ts; if (!firstValueDeclaration) { firstValueDeclaration = prop.valueDeclaration; } - else if (prop.valueDeclaration !== firstValueDeclaration) { + else if (prop.valueDeclaration && prop.valueDeclaration !== firstValueDeclaration) { hasNonUniformValueDeclaration = true; } declarations = ts.addRange(declarations, prop.declarations); @@ -142544,6 +147235,9 @@ var ts; if (isLiteralType(type)) { checkFlags |= 128 /* HasLiteralType */; } + if (type.flags & 131072 /* Never */) { + checkFlags |= 131072 /* HasNeverType */; + } propTypes.push(type); } ts.addRange(propTypes, indexTypes); @@ -142590,6 +147284,63 @@ var ts; // We need to filter out partial properties in union types return property && !(ts.getCheckFlags(property) & 16 /* ReadPartial */) ? property : undefined; } + /** + * Return the reduced form of the given type. For a union type, it is a union of the normalized constituent types. + * For an intersection of types containing one or more mututally exclusive discriminant properties, it is 'never'. + * For all other types, it is simply the type itself. Discriminant properties are considered mutually exclusive when + * no constituent property has type 'never', but the intersection of the constituent property types is 'never'. + */ + function getReducedType(type) { + if (type.flags & 1048576 /* Union */ && type.objectFlags & 268435456 /* ContainsIntersections */) { + return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type)); + } + else if (type.flags & 2097152 /* Intersection */) { + if (!(type.objectFlags & 268435456 /* IsNeverIntersectionComputed */)) { + type.objectFlags |= 268435456 /* IsNeverIntersectionComputed */ | + (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 /* IsNeverIntersection */ : 0); + } + return type.objectFlags & 536870912 /* IsNeverIntersection */ ? neverType : type; + } + return type; + } + function getReducedUnionType(unionType) { + var reducedTypes = ts.sameMap(unionType.types, getReducedType); + if (reducedTypes === unionType.types) { + return unionType; + } + var reduced = getUnionType(reducedTypes); + if (reduced.flags & 1048576 /* Union */) { + reduced.resolvedReducedType = reduced; + } + return reduced; + } + function isNeverReducedProperty(prop) { + return isDiscriminantWithNeverType(prop) || isConflictingPrivateProperty(prop); + } + function isDiscriminantWithNeverType(prop) { + // Return true for a synthetic non-optional property with non-uniform types, where at least one is + // a literal type and none is never, that reduces to never. + return !(prop.flags & 16777216 /* Optional */) && + (ts.getCheckFlags(prop) & (192 /* Discriminant */ | 131072 /* HasNeverType */)) === 192 /* Discriminant */ && + !!(getTypeOfSymbol(prop).flags & 131072 /* Never */); + } + function isConflictingPrivateProperty(prop) { + // Return true for a synthetic property with multiple declarations, at least one of which is private. + return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */); + } + function elaborateNeverIntersection(errorInfo, type) { + if (ts.getObjectFlags(type) & 536870912 /* IsNeverIntersection */) { + var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType); + if (neverProp) { + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_has_conflicting_types_in_some_constituents, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(neverProp)); + } + var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty); + if (privateProp) { + return ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_intersection_0_was_reduced_to_never_because_property_1_exists_in_multiple_constituents_and_is_private_in_some, typeToString(type, /*enclosingDeclaration*/ undefined, 536870912 /* NoTypeReduction */), symbolToString(privateProp)); + } + } + return errorInfo; + } /** * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when * necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from @@ -142599,7 +147350,7 @@ var ts; * @param name a name of property to look up in a given type */ function getPropertyOfType(type, name) { - type = getApparentType(type); + type = getReducedApparentType(type); if (type.flags & 524288 /* Object */) { var resolved = resolveStructuredTypeMembers(type); var symbol = resolved.members.get(name); @@ -142635,7 +147386,7 @@ var ts; * maps primitive types and type parameters are to their apparent types. */ function getSignaturesOfType(type, kind) { - return getSignaturesOfStructuredType(getApparentType(type), kind); + return getSignaturesOfStructuredType(getReducedApparentType(type), kind); } function getIndexInfoOfStructuredType(type, kind) { if (type.flags & 3670016 /* StructuredType */) { @@ -142650,12 +147401,12 @@ var ts; // Return the indexing info of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. function getIndexInfoOfType(type, kind) { - return getIndexInfoOfStructuredType(getApparentType(type), kind); + return getIndexInfoOfStructuredType(getReducedApparentType(type), kind); } // Return the index type of the given kind in the given type. Creates synthetic union index types when necessary and // maps primitive types and type parameters are to their apparent types. function getIndexTypeOfType(type, kind) { - return getIndexTypeOfStructuredType(getApparentType(type), kind); + return getIndexTypeOfStructuredType(getReducedApparentType(type), kind); } function getImplicitIndexTypeOfType(type, kind) { if (isObjectTypeWithInferableIndex(type)) { @@ -142670,7 +147421,7 @@ var ts; ts.append(propTypes, getIndexTypeOfType(type, 1 /* Number */)); } if (propTypes.length) { - return getUnionType(propTypes, 2 /* Subtype */); + return getUnionType(propTypes); } } return undefined; @@ -142719,7 +147470,7 @@ var ts; var signature = getSignatureFromDeclaration(node.parent); var parameterIndex = node.parent.parameters.indexOf(node); ts.Debug.assert(parameterIndex >= 0); - return parameterIndex >= getMinArgumentCount(signature); + return parameterIndex >= getMinArgumentCount(signature, /*strongArityForUntypedJS*/ true); } var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent); if (iife) { @@ -142794,6 +147545,9 @@ var ts; ts.isValueSignatureDeclaration(declaration) && !ts.hasJSDocParameterTags(declaration) && !ts.getJSDocType(declaration); + if (isUntypedSignatureInJSFile) { + flags |= 16 /* IsUntypedSignatureInJSFile */; + } // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct // signature. @@ -142820,7 +147574,6 @@ var ts; var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || param.initializer || param.questionToken || param.dotDotDotToken || iife && parameters.length > iife.arguments.length && !type || - isUntypedSignatureInJSFile || isJSDocOptionalParameter(param); if (!isOptionalParameter_1) { minArgumentCount = parameters.length; @@ -142873,7 +147626,10 @@ var ts; return true; } function getSignatureOfTypeTag(node) { - var typeTag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined; + // should be attached to a function declaration or expression + if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node))) + return undefined; + var typeTag = ts.getJSDocTypeTag(node); var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression)); return signature && getErasedSignature(signature); } @@ -143218,8 +147974,18 @@ var ts; } else { var constraintDeclaration = getConstraintDeclaration(typeParameter); - typeParameter.constraint = constraintDeclaration ? getTypeFromTypeNode(constraintDeclaration) : - getInferredTypeParameterConstraint(typeParameter) || noConstraintType; + if (!constraintDeclaration) { + typeParameter.constraint = getInferredTypeParameterConstraint(typeParameter) || noConstraintType; + } + else { + var type = getTypeFromTypeNode(constraintDeclaration); + if (type.flags & 1 /* Any */ && type !== errorType) { // Allow errorType to propegate to keep downstream errors suppressed + // use keyofConstraintType as the base constraint for mapped type key constraints (unknown isn;t assignable to that, but `any` was), + // use unknown otherwise + type = constraintDeclaration.parent.parent.kind === 186 /* MappedType */ ? keyofConstraintType : unknownType; + } + typeParameter.constraint = type; + } } } return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; @@ -143232,12 +147998,12 @@ var ts; function getTypeListId(types) { var result = ""; if (types) { - var length_3 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_3) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_3 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -143258,8 +148024,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -143350,7 +148116,7 @@ var ts; return errorType; } } - if (node.kind === 169 /* TypeReference */ && isAliasedType(node)) { + if (node.kind === 169 /* TypeReference */ && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) { return createDeferredTypeReference(type, node, /*mapper*/ undefined); } // In a type reference, the outer type parameters of the referenced class or interface are automatically @@ -143428,9 +148194,7 @@ var ts; // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { - return checkNoTypeArguments(node, symbol) ? - res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : - errorType; + return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType; } if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { var jsdocType = getTypeFromJSDocValueReference(node, symbol); @@ -143476,17 +148240,17 @@ var ts; } return links.resolvedJSDocType; } - function getSubstitutionType(typeVariable, substitute) { - if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === typeVariable) { - return typeVariable; + function getSubstitutionType(baseType, substitute) { + if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === baseType) { + return baseType; } - var id = getTypeId(typeVariable) + ">" + getTypeId(substitute); + var id = getTypeId(baseType) + ">" + getTypeId(substitute); var cached = substitutionTypes.get(id); if (cached) { return cached; } var result = createType(33554432 /* Substitution */); - result.typeVariable = typeVariable; + result.baseType = baseType; result.substitute = substitute; substitutionTypes.set(id, result); return result; @@ -143494,24 +148258,24 @@ var ts; function isUnaryTupleTypeNode(node) { return node.kind === 175 /* TupleType */ && node.elementTypes.length === 1; } - function getImpliedConstraint(typeVariable, checkNode, extendsNode) { - return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : - getActualTypeVariable(getTypeFromTypeNode(checkNode)) === typeVariable ? getTypeFromTypeNode(extendsNode) : + function getImpliedConstraint(type, checkNode, extendsNode) { + return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : + getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) : undefined; } - function getConstrainedTypeVariable(typeVariable, node) { + function getConditionalFlowTypeOfType(type, node) { var constraints; while (node && !ts.isStatement(node) && node.kind !== 303 /* JSDocComment */) { var parent = node.parent; if (parent.kind === 180 /* ConditionalType */ && node === parent.trueType) { - var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); + var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); } } node = parent; } - return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; + return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type; } function isJSDocTypeReference(node) { return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 169 /* TypeReference */ || node.kind === 188 /* ImportType */); @@ -143575,6 +148339,11 @@ var ts; function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { + // handle LS queries on the `const` in `x as const` by resolving to the type of `x` + if (ts.isConstTypeReference(node) && ts.isAssertionExpression(node.parent)) { + links.resolvedSymbol = unknownSymbol; + return links.resolvedType = checkExpressionCached(node.parent.expression); + } var symbol = void 0; var type = void 0; var meaning = 788968 /* Type */; @@ -143753,10 +148522,17 @@ var ts; var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 176 /* OptionalType */ && n !== restElement; }) + 1; return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); } + // Return true if the given type reference node is directly aliased or if it needs to be deferred + // because it is possibly contained in a circular chain of eagerly resolved types. + function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) { + return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 174 /* ArrayType */ ? mayResolveTypeAlias(node.elementType) : + node.kind === 175 /* TupleType */ ? ts.some(node.elementTypes, mayResolveTypeAlias) : + hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias)); + } // Return true when the given node is transitively contained in type constructs that eagerly // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments // of type aliases are eagerly resolved. - function isAliasedType(node) { + function isResolvedByTypeAlias(node) { var parent = node.parent; switch (parent.kind) { case 182 /* ParenthesizedType */: @@ -143766,12 +148542,44 @@ var ts; case 185 /* IndexedAccessType */: case 180 /* ConditionalType */: case 184 /* TypeOperator */: - return isAliasedType(parent); + case 174 /* ArrayType */: + case 175 /* TupleType */: + return isResolvedByTypeAlias(parent); case 247 /* TypeAliasDeclaration */: return true; } return false; } + // Return true if resolving the given node (i.e. getTypeFromTypeNode) possibly causes resolution + // of a type alias. + function mayResolveTypeAlias(node) { + switch (node.kind) { + case 169 /* TypeReference */: + return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968 /* Type */).flags & 524288 /* TypeAlias */); + case 172 /* TypeQuery */: + return true; + case 184 /* TypeOperator */: + return node.operator !== 147 /* UniqueKeyword */ && mayResolveTypeAlias(node.type); + case 182 /* ParenthesizedType */: + case 176 /* OptionalType */: + case 299 /* JSDocOptionalType */: + case 297 /* JSDocNullableType */: + case 298 /* JSDocNonNullableType */: + case 294 /* JSDocTypeExpression */: + return mayResolveTypeAlias(node.type); + case 177 /* RestType */: + return node.type.kind !== 174 /* ArrayType */ || mayResolveTypeAlias(node.type.elementType); + case 178 /* UnionType */: + case 179 /* IntersectionType */: + return ts.some(node.types, mayResolveTypeAlias); + case 185 /* IndexedAccessType */: + return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType); + case 180 /* ConditionalType */: + return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) || + mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType); + } + return false; + } function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { @@ -143779,7 +148587,7 @@ var ts; if (target === emptyGenericType) { links.resolvedType = emptyObjectType; } - else if (isAliasedType(node)) { + else if (isDeferredTypeReferenceNode(node)) { links.resolvedType = node.kind === 175 /* TupleType */ && node.elementTypes.length === 0 ? target : createDeferredTypeReference(target, node, /*mapper*/ undefined); } @@ -143895,14 +148703,14 @@ var ts; } // We ignore 'never' types in unions if (!(flags & 131072 /* Never */)) { - includes |= flags & 68943871 /* IncludesMask */; + includes |= flags & 71041023 /* IncludesMask */; if (flags & 66846720 /* StructuredOrInstantiable */) includes |= 262144 /* IncludesStructuredOrInstantiable */; if (type === wildcardType) - includes |= 4194304 /* IncludesWildcard */; + includes |= 8388608 /* IncludesWildcard */; if (!strictNullChecks && flags & 98304 /* Nullable */) { if (!(ts.getObjectFlags(type) & 524288 /* ContainsWideningType */)) - includes |= 2097152 /* IncludesNonWideningType */; + includes |= 4194304 /* IncludesNonWideningType */; } else { var len = typeSet.length; @@ -143917,8 +148725,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -143947,8 +148755,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var target = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var target = types_10[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -144008,7 +148816,7 @@ var ts; var includes = addTypesToUnion(typeSet, 0, types); if (unionReduction !== 0 /* None */) { if (includes & 3 /* AnyOrUnknown */) { - return includes & 1 /* Any */ ? includes & 4194304 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; + return includes & 1 /* Any */ ? includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType : unknownType; } switch (unionReduction) { case 1 /* Literal */: @@ -144023,12 +148831,14 @@ var ts; break; } if (typeSet.length === 0) { - return includes & 65536 /* Null */ ? includes & 2097152 /* IncludesNonWideningType */ ? nullType : nullWideningType : - includes & 32768 /* Undefined */ ? includes & 2097152 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : + return includes & 65536 /* Null */ ? includes & 4194304 /* IncludesNonWideningType */ ? nullType : nullWideningType : + includes & 32768 /* Undefined */ ? includes & 4194304 /* IncludesNonWideningType */ ? undefinedType : undefinedWideningType : neverType; } } - return getUnionTypeFromSortedList(typeSet, includes & 66994211 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */, aliasSymbol, aliasTypeArguments); + var objectFlags = (includes & 66994211 /* NotPrimitiveUnion */ ? 0 : 262144 /* PrimitiveUnion */) | + (includes & 2097152 /* Intersection */ ? 268435456 /* ContainsIntersections */ : 0); + return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures) { var first; @@ -144100,15 +148910,15 @@ var ts; return addTypesToIntersection(typeSet, includes, type.types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & 8388608 /* IncludesEmptyObject */)) { - includes |= 8388608 /* IncludesEmptyObject */; + if (!(includes & 16777216 /* IncludesEmptyObject */)) { + includes |= 16777216 /* IncludesEmptyObject */; typeSet.set(type.id.toString(), type); } } else { if (flags & 3 /* AnyOrUnknown */) { if (type === wildcardType) - includes |= 4194304 /* IncludesWildcard */; + includes |= 8388608 /* IncludesWildcard */; } else if ((strictNullChecks || !(flags & 98304 /* Nullable */)) && !typeSet.has(type.id.toString())) { if (type.flags & 109440 /* Unit */ && includes & 109440 /* Unit */) { @@ -144118,15 +148928,15 @@ var ts; } typeSet.set(type.id.toString(), type); } - includes |= flags & 68943871 /* IncludesMask */; + includes |= flags & 71041023 /* IncludesMask */; } return includes; } // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var type = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var type = types_11[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -144251,7 +149061,7 @@ var ts; // a void-like type and a type known to be non-void-like, or // a non-primitive type and a type known to be primitive. if (includes & 131072 /* Never */ || - strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 8388608 /* IncludesEmptyObject */) || + strictNullChecks && includes & 98304 /* Nullable */ && includes & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 16777216 /* IncludesEmptyObject */) || includes & 67108864 /* NonPrimitive */ && includes & (67238908 /* DisjointDomains */ & ~67108864 /* NonPrimitive */) || includes & 132 /* StringLike */ && includes & (67238908 /* DisjointDomains */ & ~132 /* StringLike */) || includes & 296 /* NumberLike */ && includes & (67238908 /* DisjointDomains */ & ~296 /* NumberLike */) || @@ -144261,7 +149071,7 @@ var ts; return neverType; } if (includes & 1 /* Any */) { - return includes & 4194304 /* IncludesWildcard */ ? wildcardType : anyType; + return includes & 8388608 /* IncludesWildcard */ ? wildcardType : anyType; } if (!strictNullChecks && includes & 98304 /* Nullable */) { return includes & 32768 /* Undefined */ ? undefinedType : nullType; @@ -144272,7 +149082,7 @@ var ts; includes & 4096 /* ESSymbol */ && includes & 8192 /* UniqueESSymbol */) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & 8388608 /* IncludesEmptyObject */ && includes & 524288 /* Object */) { + if (includes & 16777216 /* IncludesEmptyObject */ && includes & 524288 /* Object */) { ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType)); } if (typeSet.length === 0) { @@ -144377,6 +149187,7 @@ var ts; } function getIndexType(type, stringsOnly, noIndexSignatures) { if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; } + type = getReducedType(type); return type.flags & 1048576 /* Union */ ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : type.flags & 2097152 /* Intersection */ ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) : maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */) ? getIndexTypeForGenericType(type, stringsOnly) : @@ -144609,10 +149420,24 @@ var ts; accessNode; } function isGenericObjectType(type) { - return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); + if (type.flags & 3145728 /* UnionOrIntersection */) { + if (!(type.objectFlags & 4194304 /* IsGenericObjectTypeComputed */)) { + type.objectFlags |= 4194304 /* IsGenericObjectTypeComputed */ | + (ts.some(type.types, isGenericObjectType) ? 8388608 /* IsGenericObjectType */ : 0); + } + return !!(type.objectFlags & 8388608 /* IsGenericObjectType */); + } + return !!(type.flags & 58982400 /* InstantiableNonPrimitive */) || isGenericMappedType(type); } function isGenericIndexType(type) { - return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */); + if (type.flags & 3145728 /* UnionOrIntersection */) { + if (!(type.objectFlags & 16777216 /* IsGenericIndexTypeComputed */)) { + type.objectFlags |= 16777216 /* IsGenericIndexTypeComputed */ | + (ts.some(type.types, isGenericIndexType) ? 33554432 /* IsGenericIndexType */ : 0); + } + return !!(type.objectFlags & 33554432 /* IsGenericIndexType */); + } + return !!(type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */)); } function isThisTypeParameter(type) { return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType); @@ -144752,7 +149577,7 @@ var ts; // In the following we resolve T[K] to the type of the property in T selected by K. // We treat boolean as different from other unions to improve errors; // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. - var apparentObjectType = getApparentType(objectType); + var apparentObjectType = getReducedApparentType(objectType); if (indexType.flags & 1048576 /* Union */ && !(indexType.flags & 16 /* Boolean */)) { var propTypes = []; var wasMissingProp = false; @@ -144787,7 +149612,7 @@ var ts; links.resolvedType = resolved.flags & 8388608 /* IndexedAccess */ && resolved.objectType === objectType && resolved.indexType === indexType ? - getConstrainedTypeVariable(resolved, node) : resolved; + getConditionalFlowTypeOfType(resolved, node) : resolved; } return links.resolvedType; } @@ -144807,7 +149632,7 @@ var ts; } function getActualTypeVariable(type) { if (type.flags & 33554432 /* Substitution */) { - return type.typeVariable; + return type.baseType; } if (type.flags & 8388608 /* IndexedAccess */ && (type.objectType.flags & 33554432 /* Substitution */ || type.indexType.flags & 33554432 /* Substitution */)) { @@ -144816,65 +149641,89 @@ var ts; return type; } function getConditionalType(root, mapper) { - var checkType = instantiateType(root.checkType, mapper); - var extendsType = instantiateType(root.extendsType, mapper); - if (checkType === wildcardType || extendsType === wildcardType) { - return wildcardType; + var result; + var extraTypes; + var _loop_12 = function () { + var checkType = instantiateType(root.checkType, mapper); + var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType); + var extendsType = instantiateType(root.extendsType, mapper); + if (checkType === wildcardType || extendsType === wildcardType) { + return { value: wildcardType }; + } + var combinedMapper = void 0; + if (root.inferTypeParameters) { + var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); + // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type + // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to + // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint + // so in those cases we refain from performing inference and retain the uninfered type parameter + if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) { + // We don't want inferences from constraints as they may cause us to eagerly resolve the + // conditional type instead of deferring resolution. Also, we always want strict function + // types rules (i.e. proper contravariance) for inferences. + inferTypes(context.inferences, checkType, extendsType, 128 /* NoConstraints */ | 256 /* AlwaysStrict */); + } + combinedMapper = mergeTypeMappers(mapper, context.mapper); + } + // Instantiate the extends type including inferences for 'infer T' type parameters + var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType; + // We attempt to resolve the conditional type only when the check and extends types are non-generic + if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) { + // Return falseType for a definitely false extends check. We check an instantiations of the two + // types with type parameters mapped to the wildcard type, the most permissive instantiations + // possible (the wildcard type is assignable to and from all types). If those are not related, + // then no instantiations will be and we can just return the false branch type. + if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) { + // Return union of trueType and falseType for 'any' since it matches anything + if (checkType.flags & 1 /* Any */) { + (extraTypes || (extraTypes = [])).push(instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper)); + } + // If falseType is an immediately nested conditional type that isn't distributive or has an + // identical checkType, switch to that type and loop. + var falseType_1 = root.falseType; + if (falseType_1.flags & 16777216 /* Conditional */) { + var newRoot = falseType_1.root; + if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) { + root = newRoot; + return "continue"; + } + } + result = instantiateTypeWithoutDepthIncrease(falseType_1, mapper); + return "break"; + } + // Return trueType for a definitely true extends check. We check instantiations of the two + // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter + // that has no constraint. This ensures that, for example, the type + // type Foo = T extends { x: string } ? string : number + // doesn't immediately resolve to 'string' instead of being deferred. + if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { + result = instantiateTypeWithoutDepthIncrease(root.trueType, combinedMapper || mapper); + return "break"; + } + } + // Return a deferred type for a check that is neither definitely true nor definitely false + var erasedCheckType = getActualTypeVariable(checkType); + result = createType(16777216 /* Conditional */); + result.root = root; + result.checkType = erasedCheckType; + result.extendsType = extendsType; + result.mapper = mapper; + result.combinedMapper = combinedMapper; + result.aliasSymbol = root.aliasSymbol; + result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 + return "break"; + }; + // We loop here for an immediately nested conditional type in the false position, effectively treating + // types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for + // purposes of resolution. This means such types aren't subject to the instatiation depth limiter. + while (true) { + var state_4 = _loop_12(); + if (typeof state_4 === "object") + return state_4.value; + if (state_4 === "break") + break; } - var checkTypeInstantiable = maybeTypeOfKind(checkType, 63176704 /* Instantiable */ | 131072 /* GenericMappedType */); - var combinedMapper; - if (root.inferTypeParameters) { - var context = createInferenceContext(root.inferTypeParameters, /*signature*/ undefined, 0 /* None */); - // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type - // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to - // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint - // so in those cases we refain from performing inference and retain the uninfered type parameter - if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) { - // We don't want inferences from constraints as they may cause us to eagerly resolve the - // conditional type instead of deferring resolution. Also, we always want strict function - // types rules (i.e. proper contravariance) for inferences. - inferTypes(context.inferences, checkType, extendsType, 128 /* NoConstraints */ | 256 /* AlwaysStrict */); - } - combinedMapper = combineTypeMappers(mapper, context.mapper); - } - // Instantiate the extends type including inferences for 'infer T' type parameters - var inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType; - // We attempt to resolve the conditional type only when the check and extends types are non-generic - if (!checkTypeInstantiable && !maybeTypeOfKind(inferredExtendsType, 63176704 /* Instantiable */ | 131072 /* GenericMappedType */)) { - if (inferredExtendsType.flags & 3 /* AnyOrUnknown */) { - return instantiateType(root.trueType, combinedMapper || mapper); - } - // Return union of trueType and falseType for 'any' since it matches anything - if (checkType.flags & 1 /* Any */) { - return getUnionType([instantiateType(root.trueType, combinedMapper || mapper), instantiateType(root.falseType, mapper)]); - } - // Return falseType for a definitely false extends check. We check an instantiations of the two - // types with type parameters mapped to the wildcard type, the most permissive instantiations - // possible (the wildcard type is assignable to and from all types). If those are not related, - // then no instantiations will be and we can just return the false branch type. - if (!isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType))) { - return instantiateType(root.falseType, mapper); - } - // Return trueType for a definitely true extends check. We check instantiations of the two - // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter - // that has no constraint. This ensures that, for example, the type - // type Foo = T extends { x: string } ? string : number - // doesn't immediately resolve to 'string' instead of being deferred. - if (isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) { - return instantiateType(root.trueType, combinedMapper || mapper); - } - } - // Return a deferred type for a check that is neither definitely true nor definitely false - var erasedCheckType = getActualTypeVariable(checkType); - var result = createType(16777216 /* Conditional */); - result.root = root; - result.checkType = erasedCheckType; - result.extendsType = extendsType; - result.mapper = mapper; - result.combinedMapper = combinedMapper; - result.aliasSymbol = root.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217 - return result; + return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result; } function getTrueTypeFromConditionalType(type) { return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(type.root.trueType, type.mapper)); @@ -145226,7 +150075,7 @@ var ts; } function getRegularTypeOfLiteralType(type) { return type.flags & 2944 /* Literal */ ? type.regularType : - type.flags & 1048576 /* Union */ ? getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)) : + type.flags & 1048576 /* Union */ ? (type.regularType || (type.regularType = getUnionType(ts.sameMap(type.types, getRegularTypeOfLiteralType)))) : type; } function isFreshLiteralType(type) { @@ -145304,6 +150153,9 @@ var ts; return links.resolvedType; } function getTypeFromTypeNode(node) { + return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node); + } + function getTypeFromTypeNodeWorker(node) { switch (node.kind) { case 125 /* AnyKeyword */: case 295 /* JSDocAllType */: @@ -145417,27 +150269,41 @@ var ts; function instantiateSignatures(signatures, mapper) { return instantiateList(signatures, mapper, instantiateSignature); } - function makeUnaryTypeMapper(source, target) { - return function (t) { return t === source ? target : t; }; + function createTypeMapper(sources, targets) { + return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : makeArrayTypeMapper(sources, targets); + } + function getMappedType(type, mapper) { + switch (mapper.kind) { + case 0 /* Simple */: + return type === mapper.source ? mapper.target : type; + case 1 /* Array */: + var sources = mapper.sources; + var targets = mapper.targets; + for (var i = 0; i < sources.length; i++) { + if (type === sources[i]) { + return targets ? targets[i] : anyType; + } + } + return type; + case 2 /* Function */: + return mapper.func(type); + case 3 /* Composite */: + case 4 /* Merged */: + var t1 = getMappedType(type, mapper.mapper1); + return t1 !== type && mapper.kind === 3 /* Composite */ ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2); + } } - function makeBinaryTypeMapper(source1, target1, source2, target2) { - return function (t) { return t === source1 ? target1 : t === source2 ? target2 : t; }; + function makeUnaryTypeMapper(source, target) { + return { kind: 0 /* Simple */, source: source, target: target }; } function makeArrayTypeMapper(sources, targets) { - return function (t) { - for (var i = 0; i < sources.length; i++) { - if (t === sources[i]) { - return targets ? targets[i] : anyType; - } - } - return t; - }; + return { kind: 1 /* Array */, sources: sources, targets: targets }; } - function createTypeMapper(sources, targets) { - ts.Debug.assert(targets === undefined || sources.length === targets.length); - return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : - sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : - makeArrayTypeMapper(sources, targets); + function makeFunctionTypeMapper(func) { + return { kind: 2 /* Function */, func: func }; + } + function makeCompositeTypeMapper(kind, mapper1, mapper2) { + return { kind: kind, mapper1: mapper1, mapper2: mapper2 }; } function createTypeEraser(sources) { return createTypeMapper(sources, /*targets*/ undefined); @@ -145447,29 +150313,25 @@ var ts; * This is used during inference when instantiating type parameter defaults. */ function createBackreferenceMapper(context, index) { - return function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }; + return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; }); } function combineTypeMappers(mapper1, mapper2) { - if (!mapper1) - return mapper2; - if (!mapper2) - return mapper1; - return function (t) { return instantiateType(mapper1(t), mapper2); }; + return mapper1 ? makeCompositeTypeMapper(3 /* Composite */, mapper1, mapper2) : mapper2; + } + function mergeTypeMappers(mapper1, mapper2) { + return mapper1 ? makeCompositeTypeMapper(4 /* Merged */, mapper1, mapper2) : mapper2; } - function createReplacementMapper(source, target, baseMapper) { - return function (t) { return t === source ? target : baseMapper(t); }; + function prependTypeMapping(source, target, mapper) { + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, makeUnaryTypeMapper(source, target), mapper); } - function permissiveMapper(type) { - return type.flags & 262144 /* TypeParameter */ ? wildcardType : type; + function appendTypeMapping(mapper, source, target) { + return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4 /* Merged */, mapper, makeUnaryTypeMapper(source, target)); } function getRestrictiveTypeParameter(tp) { return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol), tp.restrictiveInstantiation.constraint = unknownType, tp.restrictiveInstantiation); } - function restrictiveMapper(type) { - return type.flags & 262144 /* TypeParameter */ ? getRestrictiveTypeParameter(type) : type; - } function cloneTypeParameter(typeParameter) { var result = createTypeParameter(typeParameter.symbol); result.target = typeParameter; @@ -145503,7 +150365,7 @@ var ts; } function instantiateSymbol(symbol, mapper) { var links = getSymbolLinks(symbol); - if (links.type && !maybeTypeOfKind(links.type, 524288 /* Object */ | 63176704 /* Instantiable */)) { + if (links.type && !couldContainTypeVariables(links.type)) { // If the type of the symbol is already resolved, and if that type could not possibly // be affected by instantiation, simply return the symbol itself. return symbol; @@ -145569,7 +150431,8 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); + var combinedMapper_1 = combineTypeMappers(type.mapper, mapper); + var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); }); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { @@ -145608,7 +150471,7 @@ var ts; return !!tp.isThisType; case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && - getTypeFromTypeNode(node) === tp; + getTypeFromTypeNodeWorker(node) === tp; // use worker because we're looking for === equality case 172 /* TypeQuery */: return true; } @@ -145640,9 +150503,9 @@ var ts; if (typeVariable) { var mappedTypeVariable = instantiateType(typeVariable, mapper); if (typeVariable !== mappedTypeVariable) { - return mapType(mappedTypeVariable, function (t) { + return mapType(getReducedType(mappedTypeVariable), function (t) { if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && t !== errorType) { - var replacementMapper = createReplacementMapper(typeVariable, t, mapper); + var replacementMapper = prependTypeMapping(typeVariable, t, mapper); return isArrayType(t) ? instantiateMappedArrayType(t, type, replacementMapper) : isTupleType(t) ? instantiateMappedTupleType(t, type, replacementMapper) : instantiateAnonymousType(type, replacementMapper); @@ -145675,10 +150538,10 @@ var ts; createTupleType(elementTypes, newMinLength, tupleType.target.hasRestElement, newReadonly, tupleType.target.associatedNames); } function instantiateMappedTypeTemplate(type, key, isOptional, mapper) { - var templateMapper = combineTypeMappers(mapper, createTypeMapper([getTypeParameterFromMappedType(type)], [key])); + var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key); var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper); var modifiers = getMappedTypeModifiers(type); - return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !isTypeAssignableTo(undefinedType, propType) ? getOptionalType(propType) : + return strictNullChecks && modifiers & 4 /* IncludeOptional */ && !maybeTypeOfKind(propType, 32768 /* Undefined */ | 16384 /* Void */) ? getOptionalType(propType) : strictNullChecks && modifiers & 8 /* ExcludeOptional */ && isOptional ? getTypeWithFacts(propType, 524288 /* NEUndefined */) : propType; } @@ -145705,7 +150568,7 @@ var ts; // We are instantiating a conditional type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var typeArguments = ts.map(root.outerTypeParameters, mapper); + var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); }); var id = getTypeListId(typeArguments); var result = root.instantiations.get(id); if (!result) { @@ -145723,15 +150586,15 @@ var ts; // type A | B, we produce (A extends U ? X : Y) | (B extends U ? X : Y). if (root.isDistributive) { var checkType_1 = root.checkType; - var instantiatedType = mapper(checkType_1); + var instantiatedType = getMappedType(checkType_1, mapper); if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 /* Union */ | 131072 /* Never */)) { - return mapType(instantiatedType, function (t) { return getConditionalType(root, createReplacementMapper(checkType_1, t, mapper)); }); + return mapType(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }); } } return getConditionalType(root, mapper); } function instantiateType(type, mapper) { - if (!type || !mapper || mapper === identityMapper) { + if (!type || !mapper) { return type; } if (instantiationDepth === 50 || instantiationCount >= 5000000) { @@ -145741,16 +150604,27 @@ var ts; error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite); return errorType; } + totalInstantiationCount++; instantiationCount++; instantiationDepth++; var result = instantiateTypeWorker(type, mapper); instantiationDepth--; return result; } + /** + * This can be used to avoid the penalty on instantiation depth for types which result from immediate + * simplification. It essentially removes the depth increase done in `instantiateType`. + */ + function instantiateTypeWithoutDepthIncrease(type, mapper) { + instantiationDepth--; + var result = instantiateType(type, mapper); + instantiationDepth++; + return result; + } function instantiateTypeWorker(type, mapper) { var flags = type.flags; if (flags & 262144 /* TypeParameter */) { - return mapper(type); + return getMappedType(type, mapper); } if (flags & 524288 /* Object */) { var objectFlags = type.objectFlags; @@ -145774,15 +150648,17 @@ var ts; } return type; } - if (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */)) { - var types = type.types; - var newTypes = instantiateTypes(types, mapper); - return newTypes !== types ? getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; - } - if (flags & 2097152 /* Intersection */) { + if ((flags & 2097152 /* Intersection */) || (flags & 1048576 /* Union */ && !(flags & 131068 /* Primitive */))) { + if (!couldContainTypeVariables(type)) { + return type; + } var types = type.types; var newTypes = instantiateTypes(types, mapper); - return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; + return newTypes === types + ? type + : (flags & 2097152 /* Intersection */) + ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) + : getUnionType(newTypes, 1 /* Literal */, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } if (flags & 4194304 /* Index */) { return getIndexType(instantiateType(type.type, mapper)); @@ -145794,7 +150670,7 @@ var ts; return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper)); } if (flags & 33554432 /* Substitution */) { - var maybeVariable = instantiateType(type.typeVariable, mapper); + var maybeVariable = instantiateType(type.baseType, mapper); if (maybeVariable.flags & 8650752 /* TypeVariable */) { return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper)); } @@ -145894,7 +150770,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 223 /* Block */ && isContextSensitive(node.body); + return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 223 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -146067,6 +150943,13 @@ var ts; if (target.symbol && ts.length(target.symbol.declarations)) { ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(target.symbol.declarations[0], ts.Diagnostics.The_expected_type_comes_from_the_return_type_of_this_signature)); } + if ((ts.getFunctionFlags(node) & 2 /* Async */) === 0 + // exclude cases where source itself is promisy - this way we don't make a suggestion when relating + // an IPromise and a Promise that are slightly different + && !getTypeOfPropertyOfType(sourceReturn, "then") + && checkTypeRelatedTo(createPromiseType(sourceReturn), targetReturn, relation, /*errorNode*/ undefined)) { + ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async)); + } return true; } } @@ -146084,6 +150967,15 @@ var ts; } } } + function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) { + next.contextualType = sourcePropType; + try { + return checkExpressionForMutableLocation(next, 1 /* Contextual */, sourcePropType); + } + finally { + next.contextualType = undefined; + } + } /** * For every element returned from the iterator, checks that element to issue an error on a property of that element's type * If that element would issue an error, we first attempt to dive into that element's inner expression and issue a more specific error by recuring into `elaborateError` @@ -146107,7 +150999,7 @@ var ts; // Issue error on the prop itself, since the prop couldn't elaborate the error var resultObj = errorOutputContainer || {}; // Use the expression type, if available - var specificSource = next ? checkExpressionForMutableLocation(next, 0 /* Normal */, sourcePropType) : sourcePropType; + var specificSource = next ? checkExpressionForMutableLocationWithContextualType(next, sourcePropType) : sourcePropType; var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj); if (result && specificSource !== sourcePropType) { // If for whatever reason the expression type doesn't yield an error, make sure we still issue an error on the sourcePropType @@ -146324,11 +151216,20 @@ var ts; return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer); } // recreate a tuple from the elements, if possible - var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); - if (isTupleLikeType(tupleizedType)) { - return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); + // Since we're re-doing the expression type, we need to reapply the contextual type + var oldContext = node.contextualType; + node.contextualType = target; + try { + var tupleizedType = checkArrayLiteral(node, 1 /* Contextual */, /*forceTuple*/ true); + node.contextualType = oldContext; + if (isTupleLikeType(tupleizedType)) { + return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer); + } + return false; + } + finally { + node.contextualType = oldContext; } - return false; } function generateObjectLiteralElements(node) { var _i, _a, prop, type, _b; @@ -146361,7 +151262,7 @@ var ts; case 3: _c.sent(); return [3 /*break*/, 7]; - case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; + case 4: return [4 /*yield*/, { errorNode: prop.name, innerExpression: prop.initializer, nameType: type, errorMessage: ts.isComputedNonLiteralName(prop.name) ? ts.Diagnostics.Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1 : undefined }]; case 5: _c.sent(); return [3 /*break*/, 7]; @@ -146674,11 +151575,19 @@ var ts; if (isFreshLiteralType(target)) { target = target.regularType; } - if (source === target || - relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || - relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { + if (source === target) { return true; } + if (relation !== identityRelation) { + if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) { + return true; + } + } + else { + if (!(source.flags & 3145728 /* UnionOrIntersection */) && !(target.flags & 3145728 /* UnionOrIntersection */) && + source.flags !== target.flags && !(source.flags & 66584576 /* Substructure */)) + return false; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var related = relation.get(getRelationKey(source, target, 0 /* None */, relation)); if (related !== undefined) { @@ -146694,11 +151603,18 @@ var ts; return ts.getObjectFlags(source) & 4096 /* JsxAttributes */ && !isUnhyphenatedJsxName(sourceProp.escapedName); } function getNormalizedType(type, writing) { - return isFreshLiteralType(type) ? type.regularType : - ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : - type.flags & 33554432 /* Substitution */ ? writing ? type.typeVariable : type.substitute : - type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : - type; + while (true) { + var t = isFreshLiteralType(type) ? type.regularType : + ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? createTypeReference(type.target, getTypeArguments(type)) : + type.flags & 3145728 /* UnionOrIntersection */ ? getReducedType(type) : + type.flags & 33554432 /* Substitution */ ? writing ? type.baseType : type.substitute : + type.flags & 25165824 /* Simplifiable */ ? getSimplifiedType(type, writing) : + type; + if (t === type) + break; + type = t; + } + return type; } /** * Checks if 'source' is related to 'target' (e.g.: is a assignable to). @@ -146724,13 +151640,14 @@ var ts; var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid var lastSkippedInfo; var incompatibleStack = []; + var inPropertyCheck = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); if (incompatibleStack.length) { reportIncompatibleStack(); } if (overflow) { - var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); + var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); } @@ -146911,8 +151828,15 @@ var ts; if (incompatibleStack.length) reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; - if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { - reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); + if (target.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(target); + var constraintElab = constraint && isTypeAssignableTo(source, constraint); + if (constraintElab) { + reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(constraint)); + } + else { + reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, sourceType); + } } if (!message) { if (relation === comparableRelation) { @@ -146980,12 +151904,34 @@ var ts; function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) { if (reportErrors === void 0) { reportErrors = false; } if (intersectionState === void 0) { intersectionState = 0 /* None */; } + // Before normalization: if `source` is type an object type, and `target` is primitive, + // skip all the checks we don't need and just return `isSimpleTypeRelatedTo` result + if (originalSource.flags & 524288 /* Object */ && originalTarget.flags & 131068 /* Primitive */) { + if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) { + return -1 /* True */; + } + reportErrorResults(originalSource, originalTarget, 0 /* False */, !!(ts.getObjectFlags(originalSource) & 4096 /* JsxAttributes */)); + return 0 /* False */; + } // Normalize the source and target types: Turn fresh literal types into regular literal types, // turn deferred type references into regular type references, simplify indexed access and // conditional types, and resolve substitution types to either the substitution (on the source // side) or the type variable (on the target side). var source = getNormalizedType(originalSource, /*writing*/ false); var target = getNormalizedType(originalTarget, /*writing*/ true); + if (source === target) + return -1 /* True */; + if (relation === identityRelation) { + return isIdenticalTo(source, target); + } + // We fastpath comparing a type parameter to exactly its constraint, as this is _super_ common, + // and otherwise, for type parameters in large unions, causes us to need to compare the union to itself, + // as we break down the _target_ union first, _then_ get the source constraint - so for every + // member of the target, we attempt to find a match in the source. This avoids that in cases where + // the target is exactly the constraint. + if (source.flags & 262144 /* TypeParameter */ && getConstraintOfType(source) === target) { + return -1 /* True */; + } // Try to see if we're relating something like `Foo` -> `Bar | null | undefined`. // If so, reporting the `null` and `undefined` in the type is hardly useful. // First, see if we're even relating an object type to a union. @@ -146999,15 +151945,11 @@ var ts; target.types.length <= 3 && maybeTypeOfKind(target, 98304 /* Nullable */)) { var nullStrippedTarget = extractTypesOfKind(target, ~98304 /* Nullable */); if (!(nullStrippedTarget.flags & (1048576 /* Union */ | 131072 /* Never */))) { + if (source === nullStrippedTarget) + return -1 /* True */; target = nullStrippedTarget; } } - // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases - if (source === target) - return -1 /* True */; - if (relation === identityRelation) { - return isIdenticalTo(source, target); - } if (relation === comparableRelation && !(target.flags & 131072 /* Never */) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return -1 /* True */; @@ -147047,7 +151989,7 @@ var ts; if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState) : - eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); + eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), intersectionState); } else { if (target.flags & 1048576 /* Union */) { @@ -147055,12 +151997,6 @@ var ts; } else if (target.flags & 2097152 /* Intersection */) { result = typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */); - if (result && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks)) { - // Validate against excess props using the original `source` - if (!propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */)) { - return 0 /* False */; - } - } } else if (source.flags & 2097152 /* Intersection */) { // Check to see if any constituents of the intersection are immediately related to the target. @@ -147108,59 +152044,85 @@ var ts; } } } - if (!result && reportErrors) { - source = originalSource.aliasSymbol ? originalSource : source; - target = originalTarget.aliasSymbol ? originalTarget : target; - var maybeSuppress = overrideNextErrorInfo > 0; - if (maybeSuppress) { - overrideNextErrorInfo--; - } - if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var currentError = errorInfo; - tryElaborateArrayLikeErrors(source, target, reportErrors); - if (errorInfo !== currentError) { - maybeSuppress = !!errorInfo; + // For certain combinations involving intersections and optional, excess, or mismatched properties we need + // an extra property check where the intersection is viewed as a single object. The following are motivating + // examples that all should be errors, but aren't without this extra property check: + // + // let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property + // + // declare let wrong: { a: { y: string } }; + // let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type + // + // function foo(x: { a?: string }, y: T & { a: boolean }) { + // x = y; // Mismatched property in source intersection + // } + // + // We suppress recursive intersection property checks because they can generate lots of work when relating + // recursive intersections that are structurally similar but not exactly identical. See #37854. + if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + inPropertyCheck = true; + result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); + inPropertyCheck = false; + } + reportErrorResults(source, target, result, isComparingJsxAttributes); + return result; + function reportErrorResults(source, target, result, isComparingJsxAttributes) { + if (!result && reportErrors) { + source = originalSource.aliasSymbol ? originalSource : source; + target = originalTarget.aliasSymbol ? originalTarget : target; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } + if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { + var currentError = errorInfo; + tryElaborateArrayLikeErrors(source, target, reportErrors); + if (errorInfo !== currentError) { + maybeSuppress = !!errorInfo; + } } - } - if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { - tryElaborateErrorsForPrimitivesAndObjects(source, target); - } - else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { - reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); - } - else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) { - var targetTypes = target.types; - var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); - var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); - if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && - (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) { - // do not report top error + if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { + tryElaborateErrorsForPrimitivesAndObjects(source, target); + } + else if (source.symbol && source.flags & 524288 /* Object */ && globalObjectType === source) { + reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead); + } + else if (isComparingJsxAttributes && target.flags & 2097152 /* Intersection */) { + var targetTypes = target.types; + var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode); + var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode); + if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType && + (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) { + // do not report top error + return result; + } + } + else { + errorInfo = elaborateNeverIntersection(errorInfo, originalTarget); + } + if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; + // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } + reportRelationError(headMessage, source, target); } - if (!headMessage && maybeSuppress) { - lastSkippedInfo = [source, target]; - // Used by, eg, missing property checking to replace the top-level message with a more informative one - return result; - } - reportRelationError(headMessage, source, target); } - return result; } function isIdenticalTo(source, target) { - var result; var flags = source.flags & target.flags; - if (flags & 524288 /* Object */ || flags & 8388608 /* IndexedAccess */ || flags & 16777216 /* Conditional */ || flags & 4194304 /* Index */ || flags & 33554432 /* Substitution */) { - return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */); + if (!(flags & 66584576 /* Substructure */)) { + return 0 /* False */; } - if (flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { - if (result = eachTypeRelatedToSomeType(source, target)) { - if (result &= eachTypeRelatedToSomeType(target, source)) { - return result; - } + if (flags & 3145728 /* UnionOrIntersection */) { + var result_5 = eachTypeRelatedToSomeType(source, target); + if (result_5) { + result_5 &= eachTypeRelatedToSomeType(target, source); } + return result_5; } - return 0 /* False */; + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false, 0 /* None */); } function getTypeOfPropertyInTypes(types, name) { var appendPropType = function (propTypes, type) { @@ -147186,7 +152148,7 @@ var ts; reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target); checkTypes = reducedTarget.flags & 1048576 /* Union */ ? reducedTarget.types : [reducedTarget]; } - var _loop_11 = function (prop) { + var _loop_13 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) { if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { @@ -147242,9 +152204,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_4 = _loop_11(prop); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_13(prop); + if (typeof state_5 === "object") + return state_5.value; } return false; } @@ -147309,12 +152271,20 @@ var ts; } return 0 /* False */; } - function eachTypeRelatedToType(source, target, reportErrors) { + function eachTypeRelatedToType(source, target, reportErrors, intersectionState) { var result = -1 /* True */; var sourceTypes = source.types; - for (var _i = 0, sourceTypes_2 = sourceTypes; _i < sourceTypes_2.length; _i++) { - var sourceType = sourceTypes_2[_i]; - var related = isRelatedTo(sourceType, target, reportErrors); + for (var i = 0; i < sourceTypes.length; i++) { + var sourceType = sourceTypes[i]; + if (target.flags & 1048576 /* Union */ && target.types.length === sourceTypes.length) { + // many unions are mappings of one another; in such cases, simply comparing members at the same index can shortcut the comparison + var related_1 = isRelatedTo(sourceType, target.types[i], /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState); + if (related_1) { + result &= related_1; + continue; + } + } + var related = isRelatedTo(sourceType, target, reportErrors, /*headMessage*/ undefined, intersectionState); if (!related) { return 0 /* False */; } @@ -147390,7 +152360,7 @@ var ts; if (overflow) { return 0 /* False */; } - var id = getRelationKey(source, target, intersectionState, relation); + var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 8 /* InPropertyCheck */ : 0), relation); var entry = relation.get(id); if (entry !== undefined) { if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { @@ -147402,10 +152372,10 @@ var ts; // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component var saved = entry & 24 /* ReportsMask */; if (saved & 8 /* ReportsUnmeasurable */) { - instantiateType(source, reportUnmeasurableMarkers); + instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers)); } if (saved & 16 /* ReportsUnreliable */) { - instantiateType(source, reportUnreliableMarkers); + instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)); } } return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; @@ -147472,26 +152442,29 @@ var ts; return result; } function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) { + if (intersectionState & 4 /* PropertyCheck */) { + return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* None */); + } var flags = source.flags & target.flags; if (relation === identityRelation && !(flags & 524288 /* Object */)) { if (flags & 4194304 /* Index */) { return isRelatedTo(source.type, target.type, /*reportErrors*/ false); } - var result_3 = 0 /* False */; + var result_6 = 0 /* False */; if (flags & 8388608 /* IndexedAccess */) { - if (result_3 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { - if (result_3 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { - return result_3; + if (result_6 = isRelatedTo(source.objectType, target.objectType, /*reportErrors*/ false)) { + if (result_6 &= isRelatedTo(source.indexType, target.indexType, /*reportErrors*/ false)) { + return result_6; } } } if (flags & 16777216 /* Conditional */) { if (source.root.isDistributive === target.root.isDistributive) { - if (result_3 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { - if (result_3 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { - if (result_3 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { - if (result_3 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { - return result_3; + if (result_6 = isRelatedTo(source.checkType, target.checkType, /*reportErrors*/ false)) { + if (result_6 &= isRelatedTo(source.extendsType, target.extendsType, /*reportErrors*/ false)) { + if (result_6 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), /*reportErrors*/ false)) { + if (result_6 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), /*reportErrors*/ false)) { + return result_6; } } } @@ -147668,6 +152641,8 @@ var ts; } } else { + // conditionals aren't related to one another via distributive constraint as it is much too inaccurate and allows way + // more assignments than are desirable (since it maps the source check type to its constraint, it loses information) var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { @@ -147675,12 +152650,14 @@ var ts; return result; } } - var defaultConstraint = getDefaultConstraintOfConditionalType(source); - if (defaultConstraint) { - if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - resetErrorInfo(saveErrorInfo); - return result; - } + } + // conditionals _can_ be related to one another via normal constraint, as, eg, `A extends B ? O : never` should be assignable to `O` + // when `O` is a conditional (`never` is trivially aissgnable to `O`, as is `O`!). + var defaultConstraint = getDefaultConstraintOfConditionalType(source); + if (defaultConstraint) { + if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { + resetErrorInfo(saveErrorInfo); + return result; } } } @@ -147772,9 +152749,9 @@ var ts; if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) { var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */); if (objectOnlyTarget.flags & 1048576 /* Union */) { - var result_4 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); - if (result_4) { - return result_4; + var result_7 = typeRelatedToDiscriminatedType(source, objectOnlyTarget); + if (result_7) { + return result_7; } } } @@ -147841,12 +152818,12 @@ var ts; var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) : getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target)); if (modifiersRelated) { - var result_5; + var result_8; var targetConstraint = getConstraintTypeFromMappedType(target); - var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers); - if (result_5 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { + var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers)); + if (result_8 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) { var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]); - return result_5 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); + return result_8 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors); } } return 0 /* False */; @@ -147894,11 +152871,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_12 = function (combination) { + var _loop_14 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_13 = function (i) { + var _loop_15 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfType(type, sourceProperty.escapedName); if (!targetProperty) @@ -147906,7 +152883,7 @@ var ts; if (sourceProperty === targetProperty) return "continue"; // We compare the source property to the target in the context of a single discriminant type. - var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */); + var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, /*reportErrors*/ false, 0 /* None */, /*skipOptional*/ strictNullChecks || relation === comparableRelation); // If the target property could not be found, or if the properties were not related, // then this constituent is not a match. if (!related) { @@ -147914,8 +152891,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_6 = _loop_13(i); - switch (state_6) { + var state_7 = _loop_15(i); + switch (state_7) { case "continue-outer": continue outer; } } @@ -147928,9 +152905,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_5 = _loop_12(combination); - if (typeof state_5 === "object") - return state_5.value; + var state_6 = _loop_14(combination); + if (typeof state_6 === "object") + return state_6.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -147977,10 +152954,10 @@ var ts; if (ts.getCheckFlags(targetProp) & 65536 /* DeferredType */ && !getSymbolLinks(targetProp).type) { // Rather than resolving (and normalizing) the type, relate constituent-by-constituent without performing normalization or seconadary passes var links = getSymbolLinks(targetProp); - ts.Debug.assertDefined(links.deferralParent); - ts.Debug.assertDefined(links.deferralConstituents); + ts.Debug.assertIsDefined(links.deferralParent); + ts.Debug.assertIsDefined(links.deferralConstituents); var unionParent = !!(links.deferralParent.flags & 1048576 /* Union */); - var result_6 = unionParent ? 0 /* False */ : -1 /* True */; + var result_9 = unionParent ? 0 /* False */ : -1 /* True */; var targetTypes = links.deferralConstituents; for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) { var targetType = targetTypes_3[_i]; @@ -147990,7 +152967,7 @@ var ts; // Can't assign to a target individually - have to fallback to assigning to the _whole_ intersection (which forces normalization) return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); } - result_6 &= related; + result_9 &= related; } else { if (related) { @@ -147998,34 +152975,27 @@ var ts; } } } - if (unionParent && !result_6 && targetIsOptional) { - result_6 = isRelatedTo(source, undefinedType); + if (unionParent && !result_9 && targetIsOptional) { + result_9 = isRelatedTo(source, undefinedType); } - if (unionParent && !result_6 && reportErrors) { + if (unionParent && !result_9 && reportErrors) { // The easiest way to get the right errors here is to un-defer (which may be costly) // If it turns out this is too costly too often, we can replicate the error handling logic within // typeRelatedToSomeType without the discriminatable type branch (as that requires a manifest union // type on which to hand discriminable properties, which we are expressly trying to avoid here) return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors); } - return result_6; + return result_9; } else { return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, /*headMessage*/ undefined, intersectionState); } } - function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) { + function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { - var hasDifferingDeclarations = sourceProp.valueDeclaration !== targetProp.valueDeclaration; - if (ts.getCheckFlags(sourceProp) & 1024 /* ContainsPrivate */ && hasDifferingDeclarations) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); - } - return 0 /* False */; - } - if (hasDifferingDeclarations) { + if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { if (sourcePropFlags & 8 /* Private */ && targetPropFlags & 8 /* Private */) { reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); @@ -148060,7 +153030,7 @@ var ts; return 0 /* False */; } // When checking for comparability, be more lenient with optional properties. - if (relation !== comparableRelation && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { + if (!skipOptional && sourceProp.flags & 16777216 /* Optional */ && !(targetProp.flags & 16777216 /* Optional */)) { // TypeScript 1.0 spec (April 2014): 3.8.3 // S is a subtype of a type T, and T is a supertype of S if ... // S' and T are object types and, for each member M in T.. @@ -148185,7 +153155,7 @@ var ts; if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { - var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState); + var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation); if (!related) { return 0 /* False */; } @@ -148311,7 +153281,7 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, reportUnreliableMarkers); + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 /* StrictArity */ : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers)); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -148433,18 +153403,22 @@ var ts; } function getBestMatchingType(source, target, isRelatedTo) { if (isRelatedTo === void 0) { isRelatedTo = compareTypesAssignable; } - return findMatchingDiscriminantType(source, target, isRelatedTo) || + return findMatchingDiscriminantType(source, target, isRelatedTo, /*skipPartial*/ true) || findMatchingTypeReferenceOrTypeAliasReference(source, target) || findBestTypeForObjectLiteral(source, target) || findBestTypeForInvokable(source, target) || findMostOverlappyType(source, target); } - function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue) { + function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) { // undefined=unknown, true=discriminated, false=not discriminated // The state of each type progresses from left to right. Discriminated types stop at 'true'. var discriminable = target.types.map(function (_) { return undefined; }); for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) { var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1]; + var targetProp = getUnionOrIntersectionProperty(target, propertyName); + if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16 /* ReadPartial */) { + continue; + } var i = 0; for (var _b = 0, _c = target.types; _b < _c.length; _b++) { var type = _c[_b]; @@ -148515,7 +153489,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_14 = function (tp) { + var _loop_16 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -148547,7 +153521,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_14(tp); + _loop_16(tp); } cache.variances = variances; } @@ -148830,8 +153804,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -148959,7 +153933,7 @@ var ts; } /** * Check if a Type was written as a tuple type literal. - * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. + * Prefer using isTupleLikeType() unless the use of `elementTypes`/`getTypeArguments` is required. */ function isTupleType(type) { return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); @@ -148980,8 +153954,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getFalsyFlags(t); } return result; @@ -149352,7 +154326,7 @@ var ts; case 201 /* FunctionExpression */: case 202 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { - if (wideningKind === 1 /* GeneratorYield */) { + if (wideningKind === 3 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); } else { @@ -149361,7 +154335,7 @@ var ts; return; } diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage : - wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : + wideningKind === 3 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; case 186 /* MappedType */: @@ -149375,7 +154349,7 @@ var ts; errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration, type, wideningKind) { - if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 /* ContainsWideningType */) { + if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 /* ContainsWideningType */ && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type, wideningKind); @@ -149426,8 +154400,8 @@ var ts; signature: signature, flags: flags, compareTypes: compareTypes, - mapper: function (t) { return mapToInferredType(context, t, /*fix*/ true); }, - nonFixingMapper: function (t) { return mapToInferredType(context, t, /*fix*/ false); }, + mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ true); }), + nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, /*fix*/ false); }), }; return context; } @@ -149489,17 +154463,18 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); - return !!(type.flags & 63176704 /* Instantiable */ || + if (objectFlags & 67108864 /* CouldContainTypeVariablesComputed */) { + return !!(objectFlags & 134217728 /* CouldContainTypeVariables */); + } + var result = !!(type.flags & 63176704 /* Instantiable */ || objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 131072 /* ObjectRestType */) || - type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); - } - function couldUnionOrIntersectionContainTypeVariables(type) { - if (type.couldContainTypeVariables === undefined) { - type.couldContainTypeVariables = ts.some(type.types, couldContainTypeVariables); + type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && ts.some(type.types, couldContainTypeVariables)); + if (type.flags & 3899393 /* ObjectFlagsType */) { + type.objectFlags |= 67108864 /* CouldContainTypeVariablesComputed */ | (result ? 134217728 /* CouldContainTypeVariables */ : 0); } - return type.couldContainTypeVariables; + return result; } function isTypeParameterAtTopLevel(type, typeParameter) { return !!(type === typeParameter || @@ -149654,7 +154629,7 @@ var ts; function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) { if (priority === void 0) { priority = 0; } if (contravariant === void 0) { contravariant = false; } - var symbolStack; + var symbolOrTypeStack; var visited; var bivariant = false; var propagationType; @@ -149835,12 +154810,13 @@ var ts; else if (source.flags & 1048576 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; - for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { - var sourceType = sourceTypes_3[_e]; + for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) { + var sourceType = sourceTypes_2[_e]; inferFromTypes(sourceType, target); } } else { + source = getReducedType(source); if (!(priority & 128 /* NoConstraints */ && source.flags & (2097152 /* Intersection */ | 63176704 /* Instantiable */))) { var apparentSource = getApparentType(source); // getApparentType can return _any_ type, since an indexed access or conditional may simplify to any other type. @@ -149943,8 +154919,8 @@ var ts; } function getSingleTypeVariableFromIntersectionTypes(types) { var typeVariable; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var type = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var type = types_14[_i]; var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); if (!t || typeVariable && t !== typeVariable) { return undefined; @@ -150089,15 +155065,15 @@ var ts; // its symbol with the instance side which would lead to false positives. var isNonConstructorObject = target.flags & 524288 /* Object */ && !(ts.getObjectFlags(target) & 16 /* Anonymous */ && target.symbol && target.symbol.flags & 32 /* Class */); - var symbol = isNonConstructorObject ? target.symbol : undefined; - if (symbol) { - if (ts.contains(symbolStack, symbol)) { + var symbolOrType = isNonConstructorObject ? isTupleType(target) ? target.target : target.symbol : undefined; + if (symbolOrType) { + if (ts.contains(symbolOrTypeStack, symbolOrType)) { inferencePriority = -1 /* Circularity */; return; } - (symbolStack || (symbolStack = [])).push(symbol); + (symbolOrTypeStack || (symbolOrTypeStack = [])).push(symbolOrType); inferFromObjectTypesWorker(source, target); - symbolStack.pop(); + symbolOrTypeStack.pop(); } else { inferFromObjectTypesWorker(source, target); @@ -150123,6 +155099,32 @@ var ts; } // Infer from the members of source and target only if the two types are possibly related if (!typesDefinitelyUnrelated(source, target)) { + if (isArrayType(source) || isTupleType(source)) { + if (isTupleType(target)) { + var sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0; + var targetLength = getLengthOfTupleType(target); + var sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source); + var targetRestType = getRestTypeOfTupleType(target); + var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; + for (var i = 0; i < fixedLength; i++) { + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); + } + if (targetRestType) { + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; + if (sourceRestType) { + types.push(sourceRestType); + } + if (types.length) { + inferFromTypes(getUnionType(types), targetRestType); + } + } + return; + } + if (isArrayType(target)) { + inferFromIndexTypes(source, target); + return; + } + } inferFromProperties(source, target); inferFromSignatures(source, target, 0 /* Call */); inferFromSignatures(source, target, 1 /* Construct */); @@ -150130,32 +155132,6 @@ var ts; } } function inferFromProperties(source, target) { - if (isArrayType(source) || isTupleType(source)) { - if (isTupleType(target)) { - var sourceLength = isTupleType(source) ? getLengthOfTupleType(source) : 0; - var targetLength = getLengthOfTupleType(target); - var sourceRestType = isTupleType(source) ? getRestTypeOfTupleType(source) : getElementTypeOfArrayType(source); - var targetRestType = getRestTypeOfTupleType(target); - var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; - for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); - } - if (targetRestType) { - var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; - if (sourceRestType) { - types.push(sourceRestType); - } - if (types.length) { - inferFromTypes(getUnionType(types), targetRestType); - } - } - return; - } - if (isArrayType(target)) { - inferFromIndexTypes(source, target); - return; - } - } var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var targetProp = properties_3[_i]; @@ -150173,7 +155149,7 @@ var ts; var len = sourceLen < targetLen ? sourceLen : targetLen; var skipParameters = !!(ts.getObjectFlags(source) & 2097152 /* NonInferrableType */); for (var i = 0; i < len; i++) { - inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getBaseSignature(targetSignatures[targetLen - len + i]), skipParameters); + inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters); } } function inferFromSignature(source, target, skipParameters) { @@ -150208,7 +155184,7 @@ var ts; } } function isTypeOrBaseIdenticalTo(s, t) { - return isTypeIdenticalTo(s, t) || !!(s.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) && isTypeIdenticalTo(getBaseTypeOfLiteralType(s), t); + return isTypeIdenticalTo(s, t) || !!(t.flags & 4 /* String */ && s.flags & 128 /* StringLiteral */ || t.flags & 8 /* Number */ && s.flags & 256 /* NumberLiteral */); } function isTypeCloselyMatchedBy(s, t) { return !!(s.flags & 524288 /* Object */ && t.flags & 524288 /* Object */ && s.symbol && s.symbol === t.symbol || @@ -150289,7 +155265,7 @@ var ts; if (defaultType) { // Instantiate the default type. Any forward reference to a type // parameter should be instantiated to the empty object type. - inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper)); + inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper)); } } } @@ -150426,6 +155402,12 @@ var ts; } return false; } + // Given a source x, check if target matches x or is an && operation with an operand that matches x. + function containsTruthyCheck(source, target) { + return isMatchingReference(source, target) || + (target.kind === 209 /* BinaryExpression */ && target.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && + (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right))); + } function getAccessedPropertyName(access) { return access.kind === 194 /* PropertyAccessExpression */ ? access.name.escapedText : ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : @@ -150463,9 +155445,6 @@ var ts; } return false; } - function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 104 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); - } function findDiscriminantProperties(sourceProperties, target) { var result; for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) { @@ -150541,8 +155520,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; result |= getTypeFacts(t); } return result; @@ -150610,6 +155589,9 @@ var ts; if (flags & 67108864 /* NonPrimitive */) { return strictNullChecks ? 7888800 /* ObjectStrictFacts */ : 16736160 /* ObjectFacts */; } + if (flags & 131072 /* Never */) { + return 0 /* None */; + } if (flags & 63176704 /* Instantiable */) { return getTypeFacts(getBaseConstraintOfType(type) || unknownType); } @@ -150675,7 +155657,7 @@ var ts; case 231 /* ForInStatement */: return stringType; case 232 /* ForOfStatement */: - return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; + return checkRightHandSideOfForOf(parent) || errorType; case 209 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); case 203 /* DeleteExpression */: @@ -150716,7 +155698,7 @@ var ts; return stringType; } if (node.parent.parent.kind === 232 /* ForOfStatement */) { - return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; + return checkRightHandSideOfForOf(node.parent.parent) || errorType; } return errorType; } @@ -150769,9 +155751,7 @@ var ts; } return links.switchTypes; } - // Get the types from all cases in a switch on `typeof`. An - // `undefined` element denotes an explicit `default` clause. - function getSwitchClauseTypeOfWitnesses(switchStatement) { + function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) { var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; @@ -150782,7 +155762,8 @@ var ts; } return ts.emptyArray; } - witnesses.push(/*explicitDefaultStatement*/ undefined); + if (retainDefault) + witnesses.push(/*explicitDefaultStatement*/ undefined); } return witnesses; } @@ -150819,7 +155800,7 @@ var ts; var filtered = ts.filter(types, f); return filtered === types ? type : getUnionTypeFromSortedList(filtered, type.objectFlags); } - return f(type) ? type : neverType; + return type.flags & 131072 /* Never */ || f(type) ? type : neverType; } function countTypes(type) { return type.flags & 1048576 /* Union */ ? type.types.length : 1; @@ -150911,8 +155892,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -150949,20 +155930,31 @@ var ts; return isLengthPushOrUnshift || isElementAssignment; } function isDeclarationWithExplicitTypeAnnotation(declaration) { - return !!(declaration && (declaration.kind === 242 /* VariableDeclaration */ || declaration.kind === 156 /* Parameter */ || + return (declaration.kind === 242 /* VariableDeclaration */ || declaration.kind === 156 /* Parameter */ || declaration.kind === 159 /* PropertyDeclaration */ || declaration.kind === 158 /* PropertySignature */) && - ts.getEffectiveTypeAnnotationNode(declaration)); + !!ts.getEffectiveTypeAnnotationNode(declaration); } function getExplicitTypeOfSymbol(symbol, diagnostic) { if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { return getTypeOfSymbol(symbol); } if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { - if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { - return getTypeOfSymbol(symbol); - } - if (diagnostic && symbol.valueDeclaration) { - ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol))); + var declaration = symbol.valueDeclaration; + if (declaration) { + if (isDeclarationWithExplicitTypeAnnotation(declaration)) { + return getTypeOfSymbol(symbol); + } + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 232 /* ForOfStatement */) { + var statement = declaration.parent.parent; + var expressionType = getTypeOfDottedName(statement.expression, /*diagnostic*/ undefined); + if (expressionType) { + var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + return checkIteratedTypeOrElementType(use, expressionType, undefinedType, /*errorNode*/ undefined); + } + } + if (diagnostic) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol))); + } } } } @@ -151035,14 +156027,11 @@ var ts; diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } function isReachableFlowNode(flow) { - var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + var result = isReachableFlowNodeWorker(flow, /*noCacheCheck*/ false); lastFlowNode = flow; lastFlowNodeReachable = result; return result; } - function isUnlockedReachableFlowNode(flow) { - return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); - } function isFalseExpression(expr) { var node = ts.skipParentheses(expr); return node.kind === 91 /* FalseKeyword */ || node.kind === 209 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || @@ -151054,15 +156043,15 @@ var ts; return lastFlowNodeReachable; } var flags = flow.flags; - if (flags & 2048 /* Shared */) { + if (flags & 4096 /* Shared */) { if (!noCacheCheck) { var id = getFlowNodeId(flow); var reachable = flowNodeReachable[id]; - return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*noCacheCheck*/ true)); } noCacheCheck = false; } - if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */)) { flow = flow.antecedent; } else if (flags & 512 /* Call */) { @@ -151083,7 +156072,7 @@ var ts; } else if (flags & 4 /* BranchLabel */) { // A branching point is reachable if any branch is reachable. - return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, /*noCacheCheck*/ false); }); } else if (flags & 8 /* LoopLabel */) { // A loop is reachable if the control flow path that leads to the top is reachable. @@ -151097,12 +156086,14 @@ var ts; } flow = flow.antecedent; } - else if (flags & 8192 /* AfterFinally */) { - // Cache is unreliable once we start locking nodes + else if (flags & 1024 /* ReduceLabel */) { + // Cache is unreliable once we start adjusting labels lastFlowNode = undefined; - flow.locked = true; - var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); - flow.locked = false; + var target = flow.target; + var saveAntecedents = target.antecedents; + target.antecedents = flow.antecedents; + var result = isReachableFlowNodeWorker(flow.antecedent, /*noCacheCheck*/ false); + target.antecedents = saveAntecedents; return result; } else { @@ -151152,7 +156143,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 2048 /* Shared */) { + if (flags & 4096 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -151164,19 +156155,7 @@ var ts; } } var type = void 0; - if (flags & 8192 /* AfterFinally */) { - // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement - flow.locked = true; - type = getTypeAtFlowNode(flow.antecedent); - flow.locked = false; - } - else if (flags & 4096 /* PreFinally */) { - // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel - // so here just redirect to antecedent - flow = flow.antecedent; - continue; - } - else if (flags & 16 /* Assignment */) { + if (flags & 16 /* Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; @@ -151212,6 +156191,13 @@ var ts; continue; } } + else if (flags & 1024 /* ReduceLabel */) { + var target = flow.target; + var saveAntecedents = target.antecedents; + target.antecedents = flow.antecedents; + type = getTypeAtFlowNode(flow.antecedent); + target.antecedents = saveAntecedents; + } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.node; @@ -151230,7 +156216,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 2048 /* Shared */) { + if (flags & 4096 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -151316,7 +156302,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); + var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -151414,12 +156400,6 @@ var ts; var bypassFlow; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { - // if flow correspond to branch from pre-try to finally and this branch is locked - this means that - // we initially have started following the flow outside the finally block. - // in this case we should ignore this branch. - continue; - } if (!bypassFlow && antecedent.flags & 128 /* SwitchClause */ && antecedent.clauseStart === antecedent.clauseEnd) { // The antecedent is the bypass branch of a potentially exhaustive switch statement. bypassFlow = antecedent; @@ -151641,6 +156621,12 @@ var ts; if (isMatchingReferenceDiscriminant(right_1, declaredType)) { return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); }); } + if (isMatchingConstructorReference(left_1)) { + return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue); + } + if (isMatchingConstructorReference(right_1)) { + return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue); + } break; case 98 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); @@ -151714,7 +156700,7 @@ var ts; } if (isUnitType(valueType)) { var regularType_1 = getRegularTypeOfLiteralType(valueType); - return filterType(type, function (t) { return getRegularTypeOfLiteralType(t) !== regularType_1; }); + return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; }); } return type; } @@ -151728,24 +156714,27 @@ var ts; if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the - // narrowed type of 'y' to its declared type. - if (containsMatchingReference(reference, target)) { - return declaredType; - } return type; } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } + if (assumeTrue && type.flags & 2 /* Unknown */ && literal.text === "object") { + // The pattern x && typeof x === 'object', where x is of type unknown, narrows x to type object. We don't + // need to check for the reverse typeof x === 'object' && x since that already narrows correctly. + if (typeOfExpr.parent.parent.kind === 209 /* BinaryExpression */) { + var expr = typeOfExpr.parent.parent; + if (expr.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) { + return nonPrimitiveType; + } + } + return getUnionType([nonPrimitiveType, nullType]); + } var facts = assumeTrue ? typeofEQFacts.get(literal.text) || 128 /* TypeofEQHostObject */ : typeofNEFacts.get(literal.text) || 32768 /* TypeofNEHostObject */; return getTypeWithFacts(assumeTrue ? mapType(type, narrowTypeForTypeof) : type, facts); function narrowTypeForTypeof(type) { - if (type.flags & 2 /* Unknown */ && literal.text === "object") { - return getUnionType([nonPrimitiveType, nullType]); - } // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. @@ -151837,7 +156826,7 @@ var ts; }; } function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) { - var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement); + var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, /*retainDefault*/ true); if (!switchWitnesses.length) { return type; } @@ -151900,22 +156889,57 @@ var ts; } return getTypeWithFacts(mapType(type, narrowTypeForTypeofSwitch(impliedType)), switchFacts); } + function isMatchingConstructorReference(expr) { + return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" || + ts.isElementAccessExpression(expr) && ts.isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") && + isMatchingReference(reference, expr.expression); + } + function narrowTypeByConstructor(type, operator, identifier, assumeTrue) { + // Do not narrow when checking inequality. + if (assumeTrue ? (operator !== 34 /* EqualsEqualsToken */ && operator !== 36 /* EqualsEqualsEqualsToken */) : (operator !== 35 /* ExclamationEqualsToken */ && operator !== 37 /* ExclamationEqualsEqualsToken */)) { + return type; + } + // Get the type of the constructor identifier expression, if it is not a function then do not narrow. + var identifierType = getTypeOfExpression(identifier); + if (!isFunctionType(identifierType) && !isConstructorType(identifierType)) { + return type; + } + // Get the prototype property of the type identifier so we can find out its type. + var prototypeProperty = getPropertyOfType(identifierType, "prototype"); + if (!prototypeProperty) { + return type; + } + // Get the type of the prototype, if it is undefined, or the global `Object` or `Function` types then do not narrow. + var prototypeType = getTypeOfSymbol(prototypeProperty); + var candidate = !isTypeAny(prototypeType) ? prototypeType : undefined; + if (!candidate || candidate === globalObjectType || candidate === globalFunctionType) { + return type; + } + // If the type that is being narrowed is `any` then just return the `candidate` type since every type is a subtype of `any`. + if (isTypeAny(type)) { + return candidate; + } + // Filter out types that are not considered to be "constructed by" the `candidate` type. + return filterType(type, function (t) { return isConstructedBy(t, candidate); }); + function isConstructedBy(source, target) { + // If either the source or target type are a class type then we need to check that they are the same exact type. + // This is because you may have a class `A` that defines some set of properties, and another class `B` + // that defines the same set of properties as class `A`, in that case they are structurally the same + // type, but when you do something like `instanceOfA.constructor === B` it will return false. + if (source.flags & 524288 /* Object */ && ts.getObjectFlags(source) & 1 /* Class */ || + target.flags & 524288 /* Object */ && ts.getObjectFlags(target) & 1 /* Class */) { + return source.symbol === target.symbol; + } + // For all other types just check that the `source` type is a subtype of the `target` type. + return isTypeSubtypeOf(source, target); + } + } function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the - // narrowed type of 'y' to its declared type. We do this because preceding 'x.y' - // references might reference a different 'y' property. However, we make an exception - // for property accesses where x is a synthetic 'this' expression, indicating that we - // were called from isPropertyInitializedInConstructor. Without this exception, - // initializations of 'this' properties that occur before a 'this instanceof XXX' - // check would not be considered. - if (containsMatchingReference(reference, left) && !isSyntheticThisPropertyAccess(reference)) { - return declaredType; - } return type; } // Check that right operand is a function type with a prototype property @@ -151986,10 +157010,10 @@ var ts; } if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { - return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (containsMatchingReference(reference, predicateArgument)) { - return declaredType; + if (isMatchingReferenceDiscriminant(predicateArgument, declaredType)) { + return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); }); } } } @@ -152099,12 +157123,19 @@ var ts; } /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { - var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 156 /* Parameter */ && - declaration.initializer && - getFalsyFlags(declaredType) & 32768 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); - return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + if (pushTypeResolution(declaration.symbol, 2 /* DeclaredType */)) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 156 /* Parameter */ && + declaration.initializer && + getFalsyFlags(declaredType) & 32768 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); + popTypeResolution(); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288 /* NEUndefined */) : declaredType; + } + else { + reportCircularityError(declaration.symbol); + return declaredType; + } } function isConstraintPosition(node) { var parent = node.parent; @@ -152475,7 +157506,7 @@ var ts; break; case 159 /* PropertyDeclaration */: case 158 /* PropertySignature */: - if (ts.hasModifier(container, 32 /* Static */)) { + if (ts.hasModifier(container, 32 /* Static */) && !(compilerOptions.target === 99 /* ESNext */ && compilerOptions.useDefineForClassFields)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } @@ -152520,7 +157551,9 @@ var ts; var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; - return getFlowTypeOfReference(node, classType); + if (classType) { + return getFlowTypeOfReference(node, classType); + } } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -152947,7 +157980,7 @@ var ts; var name = declaration.propertyName || declaration.name; var parentType = getContextualTypeForVariableLikeDeclaration(parent) || parent.kind !== 191 /* BindingElement */ && parent.initializer && checkDeclarationInitializer(parent); - if (parentType && !ts.isBindingPattern(name) && !isComputedNonLiteralName(name)) { + if (parentType && !ts.isBindingPattern(name) && !ts.isComputedNonLiteralName(name)) { var nameType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(nameType)) { var text = getPropertyNameFromType(nameType); @@ -152986,7 +158019,7 @@ var ts; var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { if (functionFlags & 2 /* Async */) { // Async function - var contextualAwaitedType = getAwaitedTypeOfPromise(contextualReturnType); + var contextualAwaitedType = mapType(contextualReturnType, getAwaitedTypeOfPromise); return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]); } return contextualReturnType; // Regular function @@ -153640,8 +158673,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var current = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var current = types_17[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -153677,58 +158710,73 @@ var ts; function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; var elementCount = elements.length; - var hasNonEndingSpreadElement = false; var elementTypes = []; - var inDestructuringPattern = ts.isAssignmentTarget(node); + var hasEndingSpreadElement = false; + var hasNonEndingSpreadElement = false; var contextualType = getApparentTypeOfContextualType(node); + var inDestructuringPattern = ts.isAssignmentTarget(node); var inConstContext = isConstContext(node); - for (var index = 0; index < elementCount; index++) { - var e = elements[index]; - if (inDestructuringPattern && e.kind === 213 /* SpreadElement */) { - // Given the following situation: - // var c: {}; - // [...c] = ["", 0]; - // - // c is represented in the tree as a spread element in an array literal. - // But c really functions as a rest element, and its purpose is to provide - // a contextual type for the right hand side of the assignment. Therefore, - // instead of calling checkExpression on "...c", which will give an error - // if c is not iterable/array-like, we need to act as if we are trying to - // get the contextual element type from it. So we do something similar to - // getContextualTypeForElementExpression, which will crucially not error - // if there is no index type / iterated type. - var restArrayType = checkExpression(e.expression, checkMode, forceTuple); - var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - getIteratedTypeOrElementType(65 /* Destructuring */, restArrayType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); - if (restElementType) { - elementTypes.push(restElementType); + for (var i = 0; i < elementCount; i++) { + var e = elements[i]; + var spread = e.kind === 213 /* SpreadElement */ && e.expression; + var spreadType = spread && checkExpression(spread, checkMode, forceTuple); + if (spreadType && isTupleType(spreadType)) { + elementTypes.push.apply(elementTypes, getTypeArguments(spreadType)); + if (spreadType.target.hasRestElement) { + if (i === elementCount - 1) + hasEndingSpreadElement = true; + else + hasNonEndingSpreadElement = true; } } else { - var elementContextualType = getContextualTypeForElementExpression(contextualType, index); - var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); - elementTypes.push(type); - } - if (index < elementCount - 1 && e.kind === 213 /* SpreadElement */) { - hasNonEndingSpreadElement = true; + if (inDestructuringPattern && spreadType) { + // Given the following situation: + // var c: {}; + // [...c] = ["", 0]; + // + // c is represented in the tree as a spread element in an array literal. + // But c really functions as a rest element, and its purpose is to provide + // a contextual type for the right hand side of the assignment. Therefore, + // instead of calling checkExpression on "...c", which will give an error + // if c is not iterable/array-like, we need to act as if we are trying to + // get the contextual element type from it. So we do something similar to + // getContextualTypeForElementExpression, which will crucially not error + // if there is no index type / iterated type. + var restElementType = getIndexTypeOfType(spreadType, 1 /* Number */) || + getIteratedTypeOrElementType(65 /* Destructuring */, spreadType, undefinedType, /*errorNode*/ undefined, /*checkAssignability*/ false); + if (restElementType) { + elementTypes.push(restElementType); + } + } + else { + var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length); + var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); + elementTypes.push(type); + } + if (spread) { // tuples are done above, so these are only arrays + if (i === elementCount - 1) + hasEndingSpreadElement = true; + else + hasNonEndingSpreadElement = true; + } } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 213 /* SpreadElement */; - var minLength = elementCount - (hasRestElement ? 1 : 0); + var minLength = elementTypes.length - (hasEndingSpreadElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". var tupleResult = void 0; if (inDestructuringPattern && minLength > 0) { - var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); + var type = cloneTypeReference(createTupleType(elementTypes, minLength, hasEndingSpreadElement)); type.pattern = node; return type; } - else if (tupleResult = getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasRestElement, elementCount, inConstContext)) { + else if (tupleResult = getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasEndingSpreadElement, elementTypes.length, inConstContext)) { return createArrayLiteralType(tupleResult); } else if (forceTuple) { - return createArrayLiteralType(createTupleType(elementTypes, minLength, hasRestElement)); + return createArrayLiteralType(createTupleType(elementTypes, minLength, hasEndingSpreadElement)); } } return createArrayLiteralType(createArrayType(elementTypes.length ? @@ -153841,7 +158889,8 @@ var ts; var inDestructuringPattern = ts.isAssignmentTarget(node); // Grammar checking checkGrammarObjectLiteralExpression(node, inDestructuringPattern); - var propertiesTable; + var allPropertiesTable = strictNullChecks ? ts.createSymbolTable() : undefined; + var propertiesTable = ts.createSymbolTable(); var propertiesArray = []; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); @@ -153856,7 +158905,15 @@ var ts; var patternWithComputedProperties = false; var hasComputedStringProperty = false; var hasComputedNumberProperty = false; - propertiesTable = ts.createSymbolTable(); + // Spreads may cause an early bail; ensure computed names are always checked (this is cached) + // As otherwise they may not be checked until exports for the type at this position are retrieved, + // which may never occur. + for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { + var elem = _a[_i]; + if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) { + checkComputedPropertyName(elem.name); + } + } var offset = 0; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; @@ -153915,6 +158972,7 @@ var ts; prop.type = type; prop.target = member; member = prop; + allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop); } else if (memberDecl.kind === 283 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { @@ -153927,11 +158985,14 @@ var ts; hasComputedStringProperty = false; hasComputedNumberProperty = false; } - var type = checkExpression(memberDecl.expression); + var type = getReducedType(checkExpression(memberDecl.expression)); if (!isValidSpreadType(type)) { error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return errorType; } + if (allPropertiesTable) { + checkSpreadPropOverrides(type, allPropertiesTable, memberDecl); + } spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); offset = i + 1; continue; @@ -153965,10 +159026,12 @@ var ts; } // If object literal is contextually typed by the implied type of a binding pattern, augment the result // type with those properties for which the binding pattern specifies a default value. - if (contextualTypeHasPattern) { - for (var _i = 0, _a = getPropertiesOfType(contextualType); _i < _a.length; _i++) { - var prop = _a[_i]; - if (!propertiesTable.get(prop.escapedName) && !(spread && getPropertyOfType(spread, prop.escapedName))) { + // If the object literal is spread into another object literal, skip this step and let the top-level object + // literal handle it instead. + if (contextualTypeHasPattern && node.parent.kind !== 283 /* SpreadAssignment */) { + for (var _b = 0, _c = getPropertiesOfType(contextualType); _b < _c.length; _b++) { + var prop = _c[_b]; + if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { if (!(prop.flags & 16777216 /* Optional */)) { error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } @@ -154019,6 +159082,7 @@ var ts; } function checkJsxSelfClosingElementDeferred(node) { checkJsxOpeningLikeElementOrOpeningFragment(node); + resolveUntypedCall(node); // ensure type arguments and parameters are typechecked, even if there is an arity error } function checkJsxSelfClosingElement(node, _checkMode) { checkNodeDeferred(node); @@ -154079,6 +159143,7 @@ var ts; */ function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) { var attributes = openingLikeElement.attributes; + var allAttributesTable = strictNullChecks ? ts.createSymbolTable() : undefined; var attributesTable = ts.createSymbolTable(); var spread = emptyJsxObjectType; var hasSpreadAnyType = false; @@ -154101,6 +159166,7 @@ var ts; attributeSymbol.type = exprType; attributeSymbol.target = member; attributesTable.set(attributeSymbol.escapedName, attributeSymbol); + allAttributesTable === null || allAttributesTable === void 0 ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol); if (attributeDecl.name.escapedText === jsxChildrenPropertyName) { explicitlySpecifyChildrenAttribute = true; } @@ -154111,12 +159177,15 @@ var ts; spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); } - var exprType = checkExpressionCached(attributeDecl.expression, checkMode); + var exprType = getReducedType(checkExpressionCached(attributeDecl.expression, checkMode)); if (isTypeAny(exprType)) { hasSpreadAnyType = true; } if (isValidSpreadType(exprType)) { spread = getSpreadType(spread, exprType, attributes.symbol, objectFlags, /*readonly*/ false); + if (allAttributesTable) { + checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl); + } } else { typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; @@ -154192,6 +159261,17 @@ var ts; } return childrenTypes; } + function checkSpreadPropOverrides(type, props, spread) { + for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) { + var right = _a[_i]; + var left = props.get(right.escapedName); + var rightType = getTypeOfSymbol(right); + if (left && !maybeTypeOfKind(rightType, 98304 /* Nullable */) && !(maybeTypeOfKind(rightType, 3 /* AnyOrUnknown */) && right.flags & 16777216 /* Optional */)) { + var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName)); + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property)); + } + } + } /** * Check attributes property of opening-like element. This function is called during chooseOverload to get call signature of a JSX opening-like element. * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) @@ -154367,14 +159447,14 @@ var ts; if (refKind === 1 /* Function */) { var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement); if (sfcReturnConstraint) { - checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } else if (refKind === 0 /* Component */) { var classConstraint = getJsxElementClassTypeAt(openingLikeElement); if (classConstraint) { - // Issue an error if this return type isn't assignable to JSX.ElementClass or JSX.Element, failing that - checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + // Issue an error if this return type isn't assignable to JSX.ElementClass, failing that + checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_instance_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); } } else { // Mixed @@ -154384,7 +159464,11 @@ var ts; return; } var combined = getUnionType([sfcReturnConstraint, classConstraint]); - checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement, ts.Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements); + checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_element_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain); + } + function generateInitialErrorChain() { + var componentName = ts.getTextOfNode(openingLikeElement.tagName); + return ts.chainDiagnosticMessages(/* details */ undefined, ts.Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName); } } /** @@ -154465,8 +159549,9 @@ var ts; } } if (isNodeOpeningLikeElement) { - var sig = getResolvedSignature(node); - checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(node), getReturnTypeOfSignature(sig), node); + var jsxOpeningLikeNode = node; + var sig = getResolvedSignature(jsxOpeningLikeNode); + checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode); } } /** @@ -154550,11 +159635,6 @@ var ts; function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); var errorNode = node.kind === 153 /* QualifiedName */ ? node.right : node.kind === 188 /* ImportType */ ? node : node.name; - if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { - // Synthetic property with private constituent property - error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); - return false; - } if (isSuper) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or @@ -154628,7 +159708,7 @@ var ts; return false; } var thisType = getTypeFromTypeNode(thisParameter.type); - enclosingClass = ((thisType.flags & 262144 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType); + enclosingClass = ((thisType.flags & 262144 /* TypeParameter */) ? getConstraintOfTypeParameter(thisType) : thisType).target; } // No further restrictions for static properties if (flags & 32 /* Static */) { @@ -154984,7 +160064,7 @@ var ts; relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName); } else { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); + errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); } } } @@ -155071,7 +160151,19 @@ var ts; return ts.getSpellingSuggestion(name, symbols, getCandidateName); function getCandidateName(candidate) { var candidateName = ts.symbolName(candidate); - return !ts.startsWith(candidateName, "\"") && candidate.flags & meaning ? candidateName : undefined; + if (ts.startsWith(candidateName, "\"")) { + return undefined; + } + if (candidate.flags & meaning) { + return candidateName; + } + if (candidate.flags & 2097152 /* Alias */) { + var alias = tryResolveAlias(candidate); + if (alias && alias.flags & meaning) { + return candidateName; + } + } + return undefined; } } function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) { @@ -155084,7 +160176,7 @@ var ts; if (!hasPrivateModifier && !hasPrivateIdentifier) { return; } - if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */ && !(prop.flags & 32768 /* GetAccessor */))) { + if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536 /* SetAccessor */)) { return; } if (isThisAccess) { @@ -155586,8 +160678,83 @@ var ts; // can be specified by users through attributes property. var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node); var attributesType = checkExpressionWithContextualType(node.attributes, paramType, /*inferenceContext*/ undefined, checkMode); - return checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes, + return checkTagNameDoesNotExpectTooManyArguments() && checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes, /*headMessage*/ undefined, containingMessageChain, errorOutputContainer); + function checkTagNameDoesNotExpectTooManyArguments() { + var _a; + var tagType = ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) && !isJsxIntrinsicIdentifier(node.tagName) ? checkExpression(node.tagName) : undefined; + if (!tagType) { + return true; + } + var tagCallSignatures = getSignaturesOfType(tagType, 0 /* Call */); + if (!ts.length(tagCallSignatures)) { + return true; + } + var factory = getJsxFactoryEntity(node); + if (!factory) { + return true; + } + var factorySymbol = resolveEntityName(factory, 111551 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, node); + if (!factorySymbol) { + return true; + } + var factoryType = getTypeOfSymbol(factorySymbol); + var callSignatures = getSignaturesOfType(factoryType, 0 /* Call */); + if (!ts.length(callSignatures)) { + return true; + } + var hasFirstParamSignatures = false; + var maxParamCount = 0; + // Check that _some_ first parameter expects a FC-like thing, and that some overload of the SFC expects an acceptable number of arguments + for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) { + var sig = callSignatures_1[_i]; + var firstparam = getTypeAtPosition(sig, 0); + var signaturesOfParam = getSignaturesOfType(firstparam, 0 /* Call */); + if (!ts.length(signaturesOfParam)) + continue; + for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) { + var paramSig = signaturesOfParam_1[_b]; + hasFirstParamSignatures = true; + if (hasEffectiveRestParameter(paramSig)) { + return true; // some signature has a rest param, so function components can have an arbitrary number of arguments + } + var paramCount = getParameterCount(paramSig); + if (paramCount > maxParamCount) { + maxParamCount = paramCount; + } + } + } + if (!hasFirstParamSignatures) { + // Not a single signature had a first parameter which expected a signature - for back compat, and + // to guard against generic factories which won't have signatures directly, do not error + return true; + } + var absoluteMinArgCount = Infinity; + for (var _c = 0, tagCallSignatures_1 = tagCallSignatures; _c < tagCallSignatures_1.length; _c++) { + var tagSig = tagCallSignatures_1[_c]; + var tagRequiredArgCount = getMinArgumentCount(tagSig); + if (tagRequiredArgCount < absoluteMinArgCount) { + absoluteMinArgCount = tagRequiredArgCount; + } + } + if (absoluteMinArgCount <= maxParamCount) { + return true; // some signature accepts the number of arguments the function component provides + } + if (reportErrors) { + var diag = ts.createDiagnosticForNode(node.tagName, ts.Diagnostics.Tag_0_expects_at_least_1_arguments_but_the_JSX_factory_2_provides_at_most_3, ts.entityNameToString(node.tagName), absoluteMinArgCount, ts.entityNameToString(factory), maxParamCount); + var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration; + if (tagNameDeclaration) { + ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName))); + } + if (errorOutputContainer && errorOutputContainer.skipLogging) { + (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag); + } + if (!errorOutputContainer.skipLogging) { + diagnostics.add(diag); + } + } + return false; + } } function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors, containingMessageChain) { var errorOutputContainer = { errors: undefined, skipLogging: true }; @@ -155799,8 +160966,8 @@ var ts; } function getDiagnosticForCallNode(node, message, arg0, arg1, arg2, arg3) { if (ts.isCallExpression(node)) { - var _a = getDiagnosticSpanForCallNode(node), sourceFile = _a.sourceFile, start = _a.start, length_4 = _a.length; - return ts.createFileDiagnostic(sourceFile, start, length_4, message, arg0, arg1, arg2, arg3); + var _a = getDiagnosticSpanForCallNode(node), sourceFile = _a.sourceFile, start = _a.start, length_5 = _a.length; + return ts.createFileDiagnostic(sourceFile, start, length_5, message, arg0, arg1, arg2, arg3); } else { return ts.createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3); @@ -156016,7 +161183,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_15 = function (c) { + var _loop_17 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -156034,15 +161201,15 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_15(c); + _loop_17(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call); var related = ts.flatMap(diags_3, function (d) { return d.relatedInformation; }); if (ts.every(diags_3, function (d) { return d.start === diags_3[0].start && d.length === diags_3[0].length && d.file === diags_3[0].file; })) { - var _b = diags_3[0], file = _b.file, start = _b.start, length_5 = _b.length; - diagnostics.add({ file: file, start: start, length: length_5, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }); + var _b = diags_3[0], file = _b.file, start = _b.start, length_6 = _b.length; + diagnostics.add({ file: file, start: start, length: length_6, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related }); } else { diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(node, chain, related)); @@ -156068,7 +161235,7 @@ var ts; } } } - return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); + return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); function chooseOverload(candidates, relation, signatureHelpTrailingComma) { if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; } candidatesForArgumentError = undefined; @@ -156150,9 +161317,9 @@ var ts; } } // No signature was applicable. We have already reported the errors for the invalid signature. - // If this is a type resolution session, e.g. Language Service, try to get better information than anySignature. function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) { ts.Debug.assert(candidates.length > 0); // Else should not have called this. + checkNodeDeferred(node); // Normally we will combine overloads. Skip this if they have type parameters since that's hard to combine. // Don't do this if there is a `candidatesOutArray`, // because then we want the chosen best candidate to be one of the overloads, not a combination. @@ -156168,7 +161335,7 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_16 = function (i) { + var _loop_18 = function (i) { var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : i < s.parameters.length ? s.parameters[i] : undefined; }); @@ -156176,7 +161343,7 @@ var ts; parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_16(i); + _loop_18(i); } var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); var flags = 0 /* None */; @@ -156327,7 +161494,7 @@ var ts; if (node.arguments.length === 1) { var text = ts.getSourceFileOfNode(node).text; if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, /* stopAfterLineBreak */ true) - 1))) { - relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.It_is_highly_likely_that_you_are_missing_a_semicolon); + relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon); } } invocationError(node.expression, apparentType, 0 /* Call */, relatedInformation); @@ -156511,8 +161678,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var constituent = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var constituent = types_18[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -156566,9 +161733,9 @@ var ts; ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(errorTarget, relatedInfo)); } if (ts.isCallExpression(errorTarget.parent)) { - var _b = getDiagnosticSpanForCallNode(errorTarget.parent, /* doNotIncludeArguments */ true), start = _b.start, length_6 = _b.length; + var _b = getDiagnosticSpanForCallNode(errorTarget.parent, /* doNotIncludeArguments */ true), start = _b.start, length_7 = _b.length; diagnostic.start = start; - diagnostic.length = length_6; + diagnostic.length = length_7; } diagnostics.add(diagnostic); invocationErrorRecovery(apparentType, kind, relatedInformation ? ts.addRelatedInfo(diagnostic, relatedInformation) : diagnostic); @@ -157037,8 +162204,14 @@ var ts; } return targetType; } + function checkNonNullChain(node) { + var leftType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(leftType, node.expression); + return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType); + } function checkNonNullAssertion(node) { - return getNonNullableType(checkExpression(node.expression)); + return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) : + getNonNullableType(checkExpression(node.expression)); } function checkMetaProperty(node) { checkGrammarMetaProperty(node); @@ -157149,7 +162322,7 @@ var ts; } return length; } - function getMinArgumentCount(signature) { + function getMinArgumentCount(signature, strongArityForUntypedJS) { if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { @@ -157159,6 +162332,9 @@ var ts; } } } + if (!strongArityForUntypedJS && signature.flags & 16 /* IsUntypedSignatureInJSFile */) { + return 0; + } return signature.minArgumentCount; } function hasEffectiveRestParameter(signature) { @@ -157177,7 +162353,7 @@ var ts; } function getNonArrayRestType(signature) { var restType = getEffectiveRestType(signature); - return restType && !isArrayType(restType) && !isTypeAny(restType) ? restType : undefined; + return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072 /* Never */) === 0 ? restType : undefined; } function getTypeOfFirstParameterOfSignature(signature) { return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType); @@ -157360,18 +162536,16 @@ var ts; returnType = getUnionType(types, 2 /* Subtype */); } if (returnType || yieldType || nextType) { - var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); - if (!contextualSignature) { - if (yieldType) - reportErrorsFromWidening(func, yieldType, 1 /* GeneratorYield */); - if (returnType) - reportErrorsFromWidening(func, returnType); - if (nextType) - reportErrorsFromWidening(func, nextType); - } + if (yieldType) + reportErrorsFromWidening(func, yieldType, 3 /* GeneratorYield */); + if (returnType) + reportErrorsFromWidening(func, returnType, 1 /* FunctionReturn */); + if (nextType) + reportErrorsFromWidening(func, nextType, 2 /* GeneratorNext */); if (returnType && isUnitType(returnType) || yieldType && isUnitType(yieldType) || nextType && isUnitType(nextType)) { + var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); var contextualType = !contextualSignature ? undefined : contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType : instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func); @@ -157509,8 +162683,7 @@ var ts; function computeExhaustiveSwitchStatement(node) { if (node.expression.kind === 204 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); - // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. - var witnesses = getSwitchClauseTypeOfWitnesses(node); + var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false); // notEqualFacts states that the type of the switched value is not equal to every type in the switch. var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true); var type_3 = getBaseConstraintOfType(operandType) || operandType; @@ -157590,7 +162763,7 @@ var ts; return; } var functionFlags = ts.getFunctionFlags(func); - var type = returnType && getReturnOrPromisedType(returnType, functionFlags); + var type = returnType && unwrapReturnType(returnType, functionFlags); // Functions with with an explicitly specified 'void' or 'any' return type don't need any return expressions. if (type && maybeTypeOfKind(type, 1 /* Any */ | 16384 /* Void */)) { return; @@ -157699,13 +162872,6 @@ var ts; } } } - function getReturnOrPromisedType(type, functionFlags) { - var isGenerator = !!(functionFlags & 1 /* Generator */); - var isAsync = !!(functionFlags & 2 /* Async */); - return type && isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, type, isAsync) || errorType : - type && isAsync ? getAwaitedType(type) || errorType : - type; - } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { ts.Debug.assert(node.kind !== 161 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); @@ -157730,7 +162896,7 @@ var ts; // check assignability of the awaited type of the expression body against the promised type of // its return type annotation. var exprType = checkExpression(node.body); - var returnOrPromisedType = getReturnOrPromisedType(returnType, functionFlags); + var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags); if (returnOrPromisedType) { if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) { // Async function var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -157843,7 +163009,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. - var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); + var node = ts.skipOuterExpressions(expr, 6 /* Assertions */ | 1 /* Parentheses */); if (node.kind !== 75 /* Identifier */ && !ts.isAccessExpression(node)) { error(expr, invalidReferenceMessage); return false; @@ -157861,6 +163027,7 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } + // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } @@ -158008,13 +163175,13 @@ var ts; // Return true if type might be of the given kind. A union or intersection type might be of a given // kind if at least one constituent type is of the given kind. function maybeTypeOfKind(type, kind) { - if (type.flags & kind & ~131072 /* GenericMappedType */ || kind & 131072 /* GenericMappedType */ && isGenericMappedType(type)) { + if (type.flags & kind) { return true; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -158599,8 +163766,8 @@ var ts; var name = prop.escapedName; var symbol = resolveName(prop.valueDeclaration, name, 788968 /* Type */, undefined, name, /*isUse*/ false); if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) { - grammarErrorOnNode(symbol.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); - return grammarErrorOnNode(prop.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name)); + addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop); + addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol); } } } @@ -158781,7 +163948,8 @@ var ts; return getContextualIterationType(2 /* Next */, func) || anyType; } function checkConditionalExpression(node, checkMode) { - checkTruthinessExpression(node.condition); + var type = checkTruthinessExpression(node.condition); + checkTestingKnownTruthyCallableType(node.condition, node.whenTrue, type); var type1 = checkExpression(node.whenTrue, checkMode); var type2 = checkExpression(node.whenFalse, checkMode); return getUnionType([type1, type2], 2 /* Subtype */); @@ -159344,6 +164512,9 @@ var ts; if (!(func.kind === 162 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } + if (func.kind === 162 /* Constructor */ && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") { + error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name); + } } if (node.questionToken && ts.isBindingPattern(node.name) && func.body) { error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature); @@ -159358,10 +164529,13 @@ var ts; if (func.kind === 202 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } + if (func.kind === 163 /* GetAccessor */ || func.kind === 164 /* SetAccessor */) { + error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters); + } } // Only check rest parameter type if it's not a binding pattern. Since binding patterns are // not allowed in a rest parameter, we already have an error from checkGrammarParameterList. - if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isTypeAssignableTo(getTypeOfSymbol(node.symbol), anyReadonlyArrayType)) { + if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) { error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } @@ -159763,8 +164937,9 @@ var ts; // - The containing class is a derived class. // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. - var superCallShouldBeFirst = ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || - ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92 /* ParameterPropertyModifier */); }); + var superCallShouldBeFirst = (compilerOptions.target !== 99 /* ESNext */ || !compilerOptions.useDefineForClassFields) && + (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || + ts.some(node.parameters, function (p) { return ts.hasModifier(p, 92 /* ParameterPropertyModifier */); })); // Skip past any prologue directives to find the first statement // to ensure that it was a super call. if (superCallShouldBeFirst) { @@ -160224,7 +165399,7 @@ var ts; // entirely unable to merge - a more helpful message like "Class declaration cannot implement overload list" // might be warranted. :shrug: ts.forEach(declarations, function (declaration) { - addDuplicateDeclarationError(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), ts.filter(declarations, function (d) { return d !== declaration; })); + addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations); }); } // Abstract methods can't have an implementation -- in particular, they don't need one. @@ -160312,9 +165487,9 @@ var ts; case 247 /* TypeAliasDeclaration */: // A jsdoc typedef and callback are, by definition, type aliases. // falls through - case 321 /* JSDocTypedefTag */: - case 314 /* JSDocCallbackTag */: - case 315 /* JSDocEnumTag */: + case 322 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 316 /* JSDocEnumTag */: return 2 /* ExportType */; case 249 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ @@ -160337,10 +165512,10 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 256 /* NamespaceImport */: case 255 /* ImportClause */: - var result_7 = 0 /* None */; + var result_10 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); - ts.forEach(target.declarations, function (d) { result_7 |= getDeclarationSpaces(d); }); - return result_7; + ts.forEach(target.declarations, function (d) { result_10 |= getDeclarationSpaces(d); }); + return result_10; case 242 /* VariableDeclaration */: case 191 /* BindingElement */: case 244 /* FunctionDeclaration */: @@ -160367,9 +165542,9 @@ var ts; * @param type The type of the promise. * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. */ - function getPromisedTypeOfPromise(promise, errorNode) { + function getPromisedTypeOfPromise(type, errorNode) { // - // { // promise + // { // type // then( // thenFunction // onfulfilled: ( // onfulfilledParameterType // value: T // valueParameterType @@ -160377,17 +165552,17 @@ var ts; // ): any; // } // - if (isTypeAny(promise)) { + if (isTypeAny(type)) { return undefined; } - var typeAsPromise = promise; + var typeAsPromise = type; if (typeAsPromise.promisedTypeOfPromise) { return typeAsPromise.promisedTypeOfPromise; } - if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; + if (isReferenceToType(type, getGlobalPromiseType(/*reportErrors*/ false))) { + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0]; } - var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 + var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { return undefined; } @@ -160422,28 +165597,44 @@ var ts; var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0); return awaitedType || errorType; } + /** + * Determines whether a type has a callable `then` member. + */ + function isThenableType(type) { + var thenFunction = getTypeOfPropertyOfType(type, "then"); + return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152 /* NEUndefinedOrNull */), 0 /* Call */).length > 0; + } + /** + * Gets the "awaited type" of a type. + * + * The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. If the "promised + * type" is itself a Promise-like, the "promised type" is recursively unwrapped until a + * non-promise type is found. + * + * This is used to reflect the runtime behavior of the `await` keyword. + */ function getAwaitedType(type, errorNode, diagnosticMessage, arg0) { + if (isTypeAny(type)) { + return type; + } var typeAsAwaitable = type; if (typeAsAwaitable.awaitedTypeOfType) { return typeAsAwaitable.awaitedTypeOfType; } - if (isTypeAny(type)) { - return typeAsAwaitable.awaitedTypeOfType = type; - } - if (type.flags & 1048576 /* Union */) { - var types = void 0; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types = ts.append(types, getAwaitedType(constituentType, errorNode, diagnosticMessage, arg0)); - } - if (!types) { - return undefined; - } - return typeAsAwaitable.awaitedTypeOfType = getUnionType(types); + // For a union, get a union of the awaited types of each constituent. + // + return typeAsAwaitable.awaitedTypeOfType = + mapType(type, errorNode ? function (constituentType) { return getAwaitedTypeWorker(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeWorker); + } + function getAwaitedTypeWorker(type, errorNode, diagnosticMessage, arg0) { + var typeAsAwaitable = type; + if (typeAsAwaitable.awaitedTypeOfType) { + return typeAsAwaitable.awaitedTypeOfType; } var promisedType = getPromisedTypeOfPromise(type); if (promisedType) { - if (type.id === promisedType.id || awaitedTypeStack.indexOf(promisedType.id) >= 0) { + if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) { // Verify that we don't have a bad actor in the form of a promise whose // promised type is the same as the promise type, or a mutually recursive // promise. If so, we return undefined as we cannot guess the shape. If this @@ -160457,6 +165648,7 @@ var ts; // onfulfilled: (value: BadPromise) => any, // onrejected: (error: any) => any): BadPromise; // } + // // The above interface will pass the PromiseLike check, and return a // promised type of `BadPromise`. Since this is a self reference, we // don't want to keep recursing ad infinitum. @@ -160493,8 +165685,8 @@ var ts; } // The type was not a promise, so it could not be unwrapped any further. // As long as the type does not have a callable "then" property, it is - // safe to return the type; otherwise, an error will be reported in - // the call to getNonThenableType and we will return undefined. + // safe to return the type; otherwise, an error is reported and we return + // undefined. // // An example of a non-promise "thenable" might be: // @@ -160506,8 +165698,7 @@ var ts; // of a runtime problem. If the user wants to return this value from an async // function, they would need to wrap it in some other value. If they want it to // be treated as a promise, they can cast to . - var thenFunction = getTypeOfPropertyOfType(type, "then"); - if (thenFunction && getSignaturesOfType(thenFunction, 0 /* Call */).length > 0) { + if (isThenableType(type)) { if (errorNode) { if (!diagnosticMessage) return ts.Debug.fail(); @@ -160698,8 +165889,8 @@ var ts; } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { - var typeNode = types_19[_i]; + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var typeNode = types_20[_i]; while (typeNode.kind === 182 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } @@ -160852,15 +166043,24 @@ var ts; } } } + function checkJSDocPropertyTag(node) { + checkSourceElement(node.typeExpression); + } function checkJSDocFunctionType(node) { if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) { reportImplicitAny(node, anyType); } checkSignatureDeclaration(node); } + function checkJSDocImplementsTag(node) { + var classLike = ts.getEffectiveJSDocHost(node); + if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) { + error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName)); + } + } function checkJSDocAugmentsTag(node) { - var classLike = ts.getJSDocHost(node); - if (!ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) { + var classLike = ts.getEffectiveJSDocHost(node); + if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) { error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName)); return; } @@ -161030,7 +166230,9 @@ var ts; break; } var symbol = getSymbolOfNode(member); - if (!symbol.isReferenced && (ts.hasModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))) { + if (!symbol.isReferenced + && (ts.hasModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name)) + && !(member.flags & 8388608 /* Ambient */)) { addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; @@ -161077,7 +166279,7 @@ var ts; ? ts.rangeOfNode(parent) // Include the `<>` in the error message : ts.rangeOfTypeParameters(parent.typeParameters); - var only = typeParameters.length === 1; + var only = parent.typeParameters.length === 1; var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused; var arg0 = only ? name : undefined; addDiagnostic(typeParameter, 1 /* Parameter */, ts.createFileDiagnostic(ts.getSourceFileOfNode(parent), range.pos, range.end - range.pos, message, arg0)); @@ -161104,6 +166306,16 @@ var ts; function tryGetRootParameterDeclaration(node) { return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } + function isValidUnusedLocalDeclaration(declaration) { + if (ts.isBindingElement(declaration) && isIdentifierThatStartsWithUnderscore(declaration.name)) { + return !!ts.findAncestor(declaration.parent, function (ancestor) { + return ts.isArrayBindingPattern(ancestor) || ts.isVariableDeclaration(ancestor) || ts.isVariableDeclarationList(ancestor) ? false : + ts.isForOfStatement(ancestor) ? true : "quit"; + }); + } + return ts.isAmbientModule(declaration) || + (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name); + } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -161117,8 +166329,7 @@ var ts; } for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (ts.isAmbientModule(declaration) || - (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name)) { + if (isValidUnusedLocalDeclaration(declaration)) { continue; } if (isImportedDeclaration(declaration)) { @@ -161595,21 +166806,21 @@ var ts; // Grammar checking checkGrammarStatementInAmbientContext(node); var type = checkTruthinessExpression(node.expression); - checkTestingKnownTruthyCallableType(node, type); + checkTestingKnownTruthyCallableType(node.expression, node.thenStatement, type); checkSourceElement(node.thenStatement); if (node.thenStatement.kind === 224 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } - function checkTestingKnownTruthyCallableType(ifStatement, type) { + function checkTestingKnownTruthyCallableType(condExpr, body, type) { if (!strictNullChecks) { return; } - var testedNode = ts.isIdentifier(ifStatement.expression) - ? ifStatement.expression - : ts.isPropertyAccessExpression(ifStatement.expression) - ? ifStatement.expression.name + var testedNode = ts.isIdentifier(condExpr) + ? condExpr + : ts.isPropertyAccessExpression(condExpr) + ? condExpr.name : undefined; if (!testedNode) { return; @@ -161631,17 +166842,39 @@ var ts; if (!testedFunctionSymbol) { return; } - var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + var functionIsUsedInBody = ts.forEachChild(body, function check(childNode) { if (ts.isIdentifier(childNode)) { var childSymbol = getSymbolAtLocation(childNode); - if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { - return true; + if (childSymbol && childSymbol === testedFunctionSymbol) { + // If the test was a simple identifier, the above check is sufficient + if (ts.isIdentifier(condExpr)) { + return true; + } + // Otherwise we need to ensure the symbol is called on the same target + var testedExpression = testedNode.parent; + var childExpression = childNode.parent; + while (testedExpression && childExpression) { + if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) || + testedExpression.kind === 104 /* ThisKeyword */ && childExpression.kind === 104 /* ThisKeyword */) { + return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression); + } + if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) { + if (getSymbolAtLocation(testedExpression.name) !== getSymbolAtLocation(childExpression.name)) { + return false; + } + childExpression = childExpression.expression; + testedExpression = testedExpression.expression; + } + else { + return false; + } + } } } return ts.forEachChild(childNode, check); }); if (!functionIsUsedInBody) { - error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + error(condExpr, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); } } function checkDoStatement(node) { @@ -161712,7 +166945,7 @@ var ts; } else { var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); + var iteratedType = checkRightHandSideOfForOf(node); // There may be a destructuring assignment on the left side if (varExpr.kind === 192 /* ArrayLiteralExpression */ || varExpr.kind === 193 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of @@ -161789,10 +167022,9 @@ var ts; checkVariableDeclaration(decl); } } - function checkRightHandSideOfForOf(rhsExpression, awaitModifier) { - var expressionType = checkNonNullExpression(rhsExpression); - var use = awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; - return checkIteratedTypeOrElementType(use, expressionType, undefinedType, rhsExpression); + function checkRightHandSideOfForOf(statement) { + var use = statement.awaitModifier ? 15 /* ForAwaitOf */ : 13 /* ForOf */; + return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); } function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) { if (isTypeAny(inputType)) { @@ -162408,10 +167640,11 @@ var ts; // TODO: Check that target label is valid } function unwrapReturnType(returnType, functionFlags) { + var _a, _b; var isGenerator = !!(functionFlags & 1 /* Generator */); var isAsync = !!(functionFlags & 2 /* Async */); - return isGenerator ? getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync) || errorType : - isAsync ? getPromisedTypeOfPromise(returnType) || errorType : + return isGenerator ? (_a = getIterationTypeOfGeneratorFunctionReturnType(1 /* Return */, returnType, isAsync)) !== null && _a !== void 0 ? _a : errorType : + isAsync ? (_b = getAwaitedType(returnType)) !== null && _b !== void 0 ? _b : errorType : returnType; } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { @@ -162419,6 +167652,7 @@ var ts; return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 /* Void */ | 3 /* AnyOrUnknown */); } function checkReturnStatement(node) { + var _a; // Grammar checking if (checkGrammarStatementInAmbientContext(node)) { return; @@ -162444,7 +167678,7 @@ var ts; } } else if (getReturnTypeFromAnnotation(func)) { - var unwrappedReturnType = unwrapReturnType(returnType, functionFlags); + var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType; var unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) : exprType; @@ -162625,6 +167859,9 @@ var ts; } var propDeclaration = prop.valueDeclaration; var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration); + if (name && ts.isPrivateIdentifier(name)) { + return; + } // index is numeric and property name is not valid numeric literal if (indexKind === 1 /* Number */ && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) { return; @@ -162876,7 +168113,7 @@ var ts; checkKindsOfPropertyMemberOverrides(type, baseType_1); } } - var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(node); + var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node); if (implementedTypeNodes) { for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) { var typeRefNode = implementedTypeNodes_1[_b]; @@ -162885,7 +168122,7 @@ var ts; } checkTypeReferenceNode(typeRefNode); if (produceDiagnostics) { - var t = getTypeFromTypeNode(typeRefNode); + var t = getReducedType(getTypeFromTypeNode(typeRefNode)); if (t !== errorType) { if (isValidBaseType(t)) { var genericDiag = t.symbol && t.symbol.flags & 32 /* Class */ ? @@ -162912,7 +168149,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_17 = function (member) { + var _loop_19 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -162931,7 +168168,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_17(member); + _loop_19(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -163090,6 +168327,25 @@ var ts; } } } + function getNonInterhitedProperties(type, baseTypes, properties) { + if (!ts.length(baseTypes)) { + return properties; + } + var seen = ts.createUnderscoreEscapedMap(); + ts.forEach(properties, function (p) { seen.set(p.escapedName, p); }); + for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { + var base = baseTypes_2[_i]; + var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); + for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) { + var prop = properties_4[_a]; + var existing = seen.get(prop.escapedName); + if (existing && !isPropertyIdenticalTo(existing, prop)) { + seen.delete(prop.escapedName); + } + } + } + return ts.arrayFrom(seen.values()); + } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); if (baseTypes.length < 2) { @@ -163098,11 +168354,11 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.escapedName, { prop: p, containingType: type }); }); var ok = true; - for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { - var base = baseTypes_2[_i]; + for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) { + var base = baseTypes_3[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_4 = properties; _a < properties_4.length; _a++) { - var prop = properties_4[_a]; + for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) { + var prop = properties_6[_a]; var existing = seen.get(prop.escapedName); if (!existing) { seen.set(prop.escapedName, { prop: prop, containingType: base }); @@ -163220,7 +168476,7 @@ var ts; } } function computeMemberValue(member, autoValue) { - if (isComputedNonLiteralName(member.name)) { + if (ts.isComputedNonLiteralName(member.name)) { error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums); } else { @@ -163271,7 +168527,13 @@ var ts; } else { // Only here do we need to check that the initializer is assignable to the enum type. - checkTypeAssignableTo(checkExpression(initializer), getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, /*headMessage*/ undefined); + var source = checkExpression(initializer); + if (!isTypeAssignableToKind(source, 296 /* NumberLike */)) { + error(initializer, ts.Diagnostics.Only_numeric_enums_can_have_computed_members_but_this_expression_has_type_0_If_you_do_not_need_exhaustiveness_checks_consider_using_an_object_literal_instead, typeToString(source)); + } + else { + checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, /*headMessage*/ undefined); + } } return value; function evaluate(expr) { @@ -163354,6 +168616,9 @@ var ts; error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return 0; } + else { + error(expr, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol)); + } } return undefined; } @@ -163627,7 +168892,7 @@ var ts; return false; } if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) { - // we have already reported errors on top level imports\exports in external module augmentations in checkModuleDeclaration + // we have already reported errors on top level imports/exports in external module augmentations in checkModuleDeclaration // no need to do this again. if (!isTopLevelInExternalModuleAugmentation(node)) { // TypeScript 1.0 spec (April 2013): 12.1.6 @@ -163746,17 +169011,15 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers); } + if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) { + checkExternalEmitHelpers(node, 1048576 /* CreateBinding */); + } checkGrammarExportDeclaration(node); if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { - if (node.exportClause) { + if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) { // export { x, y } // export { x, y } from "foo" - if (ts.isNamedExports(node.exportClause)) { - ts.forEach(node.exportClause.elements, checkExportSpecifier); - } - else if (!ts.isNamespaceExport(node.exportClause)) { - checkImportBinding(node.exportClause); - } + ts.forEach(node.exportClause.elements, checkExportSpecifier); var inAmbientExternalModule = node.parent.kind === 250 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 250 /* ModuleBlock */ && !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; @@ -163770,6 +169033,9 @@ var ts; if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } + else if (node.exportClause) { + checkAliasSymbol(node.exportClause); + } if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) { checkExternalEmitHelpers(node, 65536 /* ExportStar */); } @@ -164020,16 +169286,20 @@ var ts; return checkImportType(node); case 307 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 321 /* JSDocTypedefTag */: - case 314 /* JSDocCallbackTag */: - case 315 /* JSDocEnumTag */: + case 308 /* JSDocImplementsTag */: + return checkJSDocImplementsTag(node); + case 322 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 316 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 320 /* JSDocTemplateTag */: + case 321 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 319 /* JSDocTypeTag */: + case 320 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 316 /* JSDocParameterTag */: + case 317 /* JSDocParameterTag */: return checkJSDocParameterTag(node); + case 323 /* JSDocPropertyTag */: + return checkJSDocPropertyTag(node); case 300 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through @@ -164207,6 +169477,16 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { + case 196 /* CallExpression */: + case 197 /* NewExpression */: + case 198 /* TaggedTemplateExpression */: + case 157 /* Decorator */: + case 268 /* JsxOpeningElement */: + // These node kinds are deferred checked when overload resolution fails + // To save on work, we ensure the arguments are checked just once, in + // a deferred way + resolveUntypedCall(node); + break; case 201 /* FunctionExpression */: case 202 /* ArrowFunction */: case 161 /* MethodDeclaration */: @@ -164592,10 +169872,10 @@ var ts; return entityNameSymbol; } } - if (name.parent.kind === 316 /* JSDocParameterTag */) { + if (name.parent.kind === 317 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(name.parent); } - if (name.parent.kind === 155 /* TypeParameter */ && name.parent.parent.kind === 320 /* JSDocTemplateTag */) { + if (name.parent.kind === 155 /* TypeParameter */ && name.parent.parent.kind === 321 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(name)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(name.parent); return typeParameter && typeParameter.symbol; @@ -164636,7 +169916,7 @@ var ts; // Do we want to return undefined here? return undefined; } - function getSymbolAtLocation(node) { + function getSymbolAtLocation(node, ignoreErrors) { if (node.kind === 290 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } @@ -164709,7 +169989,7 @@ var ts; ((node.parent.kind === 254 /* ImportDeclaration */ || node.parent.kind === 260 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { - return resolveExternalModuleName(node, node); + return resolveExternalModuleName(node, node, ignoreErrors); } if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) { return getSymbolOfNode(parent); @@ -164729,9 +170009,9 @@ var ts; case 80 /* ClassKeyword */: return getSymbolOfNode(node.parent); case 188 /* ImportType */: - return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; + return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined; case 89 /* ExportKeyword */: - return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; + return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined; default: return undefined; } @@ -164813,7 +170093,7 @@ var ts; // for ( { a } of elems) { // } if (expr.parent.kind === 232 /* ForOfStatement */) { - var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); + var iteratedType = checkRightHandSideOfForOf(expr.parent); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer @@ -165378,6 +170658,9 @@ var ts; var type = getTypeOfSymbol(getSymbolOfNode(node)); return literalTypeToNode(type, node, tracker); } + function getJsxFactoryEntity(location) { + return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; + } function createResolver() { // this variable and functions that use it are deliberately moved here from the outer scope // to avoid scope pollution @@ -165391,9 +170674,11 @@ var ts; return; } var file = host.getSourceFile(resolvedDirective.resolvedFileName); - // Add the transitive closure of path references loaded by this file (as long as they are not) - // part of an existing type reference. - addReferencedFilesToTypeDirective(file, key); + if (file) { + // Add the transitive closure of path references loaded by this file (as long as they are not) + // part of an existing type reference. + addReferencedFilesToTypeDirective(file, key); + } }); } return { @@ -165448,7 +170733,7 @@ var ts; var symbol = node && getSymbolOfNode(node); return !!(symbol && ts.getCheckFlags(symbol) & 4096 /* Late */); }, - getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, + getJsxFactoryEntity: getJsxFactoryEntity, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 var otherKind = accessor.kind === 164 /* SetAccessor */ ? 163 /* GetAccessor */ : 164 /* SetAccessor */; @@ -165478,8 +170763,34 @@ var ts; return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); } return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); - } + }, + isImportRequiredByAugmentation: isImportRequiredByAugmentation, }; + function isImportRequiredByAugmentation(node) { + var file = ts.getSourceFileOfNode(node); + if (!file.symbol) + return false; + var importTarget = getExternalModuleFileFromDeclaration(node); + if (!importTarget) + return false; + if (importTarget === file) + return false; + var exports = getExportsOfModule(file.symbol); + for (var _i = 0, _a = ts.arrayFrom(exports.values()); _i < _a.length; _i++) { + var s = _a[_i]; + if (s.mergeId) { + var merged = getMergedSymbol(s); + for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) { + var d = _c[_b]; + var declFile = ts.getSourceFileOfNode(d); + if (declFile === importTarget) { + return true; + } + } + } + } + return false; + } function isInHeritageClause(node) { return node.parent && node.parent.kind === 216 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 279 /* HeritageClause */; } @@ -165714,7 +171025,7 @@ var ts; var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 524288 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* FirstEmitHelper */; helper <= 1048576 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); @@ -165750,6 +171061,7 @@ var ts; case 131072 /* MakeTemplateObject */: return "__makeTemplateObject"; case 262144 /* ClassPrivateFieldGet */: return "__classPrivateFieldGet"; case 524288 /* ClassPrivateFieldSet */: return "__classPrivateFieldSet"; + case 1048576 /* CreateBinding */: return "__createBinding"; default: return ts.Debug.fail("Unrecognized helper"); } } @@ -166153,6 +171465,7 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter); } } + checkGrammarForDisallowedTrailingComma(node.parameters, ts.Diagnostics.An_index_signature_cannot_have_a_trailing_comma); if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); } @@ -166521,7 +171834,7 @@ var ts; if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } - var parameter = ts.Debug.assertDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); + var parameter = ts.Debug.checkDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); if (parameter.dotDotDotToken) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } @@ -167160,13 +172473,13 @@ var ts; return type; } // Keep this up-to-date with the same logic within `getApparentTypeOfContextualType`, since they should behave similarly - function findMatchingDiscriminantType(source, target, isRelatedTo) { + function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) { if (target.flags & 1048576 /* Union */ && source.flags & (2097152 /* Intersection */ | 524288 /* Object */)) { var sourceProperties = getPropertiesOfType(source); if (sourceProperties) { var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target); if (sourcePropertiesFiltered) { - return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo); + return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo, /*defaultValue*/ undefined, skipPartial); } } } @@ -168176,10 +173489,8 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { - if (ts.isOptionalChain(node) && ts.isIdentifier(node.name) && ts.isIdentifier(name)) { - // Not sure why this cast was necessary: the previous line should already establish that node.name is an identifier - var theNode = node; - return updatePropertyAccessChain(theNode, expression, node.questionDotToken, name); + if (ts.isPropertyAccessChain(node)) { + return updatePropertyAccessChain(node, expression, node.questionDotToken, ts.cast(name, ts.isIdentifier)); } // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess @@ -168542,7 +173853,7 @@ var ts; } var token = rawTextScanner.scan(); if (token === 23 /* CloseBracketToken */) { - token = rawTextScanner.reScanTemplateToken(); + token = rawTextScanner.reScanTemplateToken(/* isTaggedTemplate */ false); } if (rawTextScanner.isUnterminated()) { rawTextScanner.setText(undefined); @@ -168604,9 +173915,11 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { + var asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; var node = createSynthesizedNode(212 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + node.asteriskToken = asteriskToken; + node.expression = expression && ts.parenthesizeExpressionForList(expression); return node; } ts.createYield = createYield; @@ -168689,11 +174002,28 @@ var ts; } ts.createNonNullExpression = createNonNullExpression; function updateNonNullExpression(node, expression) { + if (ts.isNonNullChain(node)) { + return updateNonNullChain(node, expression); + } return node.expression !== expression ? updateNode(createNonNullExpression(expression), node) : node; } ts.updateNonNullExpression = updateNonNullExpression; + function createNonNullChain(expression) { + var node = createSynthesizedNode(218 /* NonNullExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + return node; + } + ts.createNonNullChain = createNonNullChain; + function updateNonNullChain(node, expression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead."); + return node.expression !== expression + ? updateNode(createNonNullChain(expression), node) + : node; + } + ts.updateNonNullChain = updateNonNullChain; function createMetaProperty(keywordToken, name) { var node = createSynthesizedNode(219 /* MetaProperty */); node.keywordToken = keywordToken; @@ -169060,6 +174390,26 @@ var ts; : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; + /* @internal */ + function updateFunctionLikeBody(declaration, body) { + switch (declaration.kind) { + case 244 /* FunctionDeclaration */: + return createFunctionDeclaration(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body); + case 161 /* MethodDeclaration */: + return createMethod(declaration.decorators, declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.questionToken, declaration.typeParameters, declaration.parameters, declaration.type, body); + case 163 /* GetAccessor */: + return createGetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, declaration.type, body); + case 164 /* SetAccessor */: + return createSetAccessor(declaration.decorators, declaration.modifiers, declaration.name, declaration.parameters, body); + case 162 /* Constructor */: + return createConstructor(declaration.decorators, declaration.modifiers, declaration.parameters, body); + case 201 /* FunctionExpression */: + return createFunctionExpression(declaration.modifiers, declaration.asteriskToken, declaration.name, declaration.typeParameters, declaration.parameters, declaration.type, body); + case 202 /* ArrowFunction */: + return createArrowFunction(declaration.modifiers, declaration.typeParameters, declaration.parameters, declaration.type, declaration.equalsGreaterThanToken, body); + } + } + ts.updateFunctionLikeBody = updateFunctionLikeBody; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { var node = createSynthesizedNode(245 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); @@ -169393,7 +174743,7 @@ var ts; ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(319 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(320 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -169401,7 +174751,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(317 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(318 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -169409,14 +174759,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(318 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(319 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(316 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(317 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -169425,6 +174775,11 @@ var ts; } ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ + function createJSDocClassTag() { + return createJSDocTag(310 /* JSDocClassTag */, "class"); + } + ts.createJSDocClassTag = createJSDocClassTag; + /* @internal */ function createJSDocComment(comment, tags) { var node = createSynthesizedNode(303 /* JSDocComment */); node.comment = comment; @@ -169791,7 +175146,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(324 /* NotEmittedStatement */); + var node = createSynthesizedNode(325 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -169803,7 +175158,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(328 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(329 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -169815,7 +175170,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(327 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(328 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -169830,7 +175185,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(325 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(326 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -169846,7 +175201,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 326 /* CommaListExpression */) { + if (node.kind === 327 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -169856,7 +175211,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(326 /* CommaListExpression */); + var node = createSynthesizedNode(327 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -169869,7 +175224,7 @@ var ts; ts.updateCommaList = updateCommaList; /* @internal */ function createSyntheticReferenceExpression(expression, thisArg) { - var node = createSynthesizedNode(329 /* SyntheticReferenceExpression */); + var node = createSynthesizedNode(330 /* SyntheticReferenceExpression */); node.expression = expression; node.thisArg = thisArg; return node; @@ -169915,6 +175270,8 @@ var ts; ts.importDefaultHelper, ts.classPrivateFieldGetHelper, ts.classPrivateFieldSetHelper, + ts.createBindingHelper, + ts.setModuleDefaultHelper ], function (helper) { return helper.name; })); } function createUnparsedSource() { @@ -169943,7 +175300,7 @@ var ts; stripInternal = mapTextOrStripInternal; bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts; if (node.oldFileOfCurrentEmit) { - parseOldFileOfCurrentEmit(node, ts.Debug.assertDefined(bundleFileInfo)); + parseOldFileOfCurrentEmit(node, ts.Debug.checkDefined(bundleFileInfo)); return node; } } @@ -170108,13 +175465,13 @@ var ts; }; node.javascriptPath = declarationTextOrJavascriptPath; node.javascriptMapPath = javascriptMapPath; - node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath); + node.declarationPath = ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath); node.declarationMapPath = declarationMapPath; node.buildInfoPath = declarationMapTextOrBuildInfoPath; Object.defineProperties(node, { javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } }, javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } }, - declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } }, + declarationText: { get: function () { return definedTextGetter_1(ts.Debug.checkDefined(javascriptMapTextOrDeclarationPath)); } }, declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } }, buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } } }); @@ -170441,6 +175798,12 @@ var ts; return node; } ts.moveSyntheticComments = moveSyntheticComments; + /** @internal */ + function ignoreSourceNewlines(node) { + getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */; + return node; + } + ts.ignoreSourceNewlines = ignoreSourceNewlines; /** * Gets the constant value to emit for an expression. */ @@ -170592,11 +175955,14 @@ var ts; enableEmitNotification: ts.noop, enableSubstitution: ts.noop, endLexicalEnvironment: ts.returnUndefined, - getCompilerOptions: ts.notImplemented, + getCompilerOptions: function () { return ({}); }, getEmitHost: ts.notImplemented, getEmitResolver: ts.notImplemented, + setLexicalEnvironmentFlags: ts.noop, + getLexicalEnvironmentFlags: function () { return 0; }, hoistFunctionDeclaration: ts.noop, hoistVariableDeclaration: ts.noop, + addInitializationStatement: ts.noop, isEmitNotificationEnabled: ts.notImplemented, isSubstitutionEnabled: ts.notImplemented, onEmitNode: ts.noop, @@ -170769,10 +176135,10 @@ var ts; name: "typescript:spread", importName: "__spread", scoped: false, + dependencies: [ts.readHelper], text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" }; function createSpreadHelper(context, argumentList, location) { - context.requestEmitHelper(ts.readHelper); context.requestEmitHelper(ts.spreadHelper); return ts.setTextRange(ts.createCall(getUnscopedHelperName("__spread"), /*typeArguments*/ undefined, argumentList), location); @@ -170852,7 +176218,7 @@ var ts; } function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) { if (cacheIdentifiers === void 0) { cacheIdentifiers = false; } - var callee = skipOuterExpressions(expression, 7 /* All */); + var callee = skipOuterExpressions(expression, 15 /* All */); var thisArg; var target; if (ts.isSuperProperty(callee)) { @@ -170959,7 +176325,7 @@ var ts; function createExpressionForAccessorDeclaration(properties, property, receiver, multiLine) { var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor; if (property === firstAccessor) { - var properties_5 = []; + var properties_7 = []; if (getAccessor) { var getterFunction = ts.createFunctionExpression(getAccessor.modifiers, /*asteriskToken*/ undefined, @@ -170970,7 +176336,7 @@ var ts; ts.setTextRange(getterFunction, getAccessor); ts.setOriginalNode(getterFunction, getAccessor); var getter = ts.createPropertyAssignment("get", getterFunction); - properties_5.push(getter); + properties_7.push(getter); } if (setAccessor) { var setterFunction = ts.createFunctionExpression(setAccessor.modifiers, @@ -170982,15 +176348,15 @@ var ts; ts.setTextRange(setterFunction, setAccessor); ts.setOriginalNode(setterFunction, setAccessor); var setter = ts.createPropertyAssignment("set", setterFunction); - properties_5.push(setter); + properties_7.push(setter); } - properties_5.push(ts.createPropertyAssignment("enumerable", ts.createTrue())); - properties_5.push(ts.createPropertyAssignment("configurable", ts.createTrue())); + properties_7.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue())); + properties_7.push(ts.createPropertyAssignment("configurable", ts.createTrue())); var expression = ts.setTextRange(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ receiver, createExpressionForPropertyName(property.name), - ts.createObjectLiteral(properties_5, multiLine) + ts.createObjectLiteral(properties_7, multiLine) ]), /*location*/ firstAccessor); return ts.aggregateTransformFlags(expression); @@ -171213,11 +176579,12 @@ var ts; return statementOffset; } ts.addStandardPrologue = addStandardPrologue; - function addCustomPrologue(target, source, statementOffset, visitor) { + function addCustomPrologue(target, source, statementOffset, visitor, filter) { + if (filter === void 0) { filter = ts.returnTrue; } var numStatements = source.length; while (statementOffset !== undefined && statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */) { + if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */ && filter(statement)) { ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -171556,7 +176923,7 @@ var ts; if (kind === 201 /* FunctionExpression */ || kind === 202 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); - return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); + return recreateOuterExpressions(expression, mutableCall, 8 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; @@ -171632,7 +176999,7 @@ var ts; case 195 /* ElementAccessExpression */: case 194 /* PropertyAccessExpression */: case 218 /* NonNullExpression */: - case 325 /* PartiallyEmittedExpression */: + case 326 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -171649,54 +177016,44 @@ var ts; ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { return node.kind === 209 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 326 /* CommaListExpression */; + node.kind === 327 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; (function (OuterExpressionKinds) { OuterExpressionKinds[OuterExpressionKinds["Parentheses"] = 1] = "Parentheses"; - OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 2] = "Assertions"; - OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 4] = "PartiallyEmittedExpressions"; - OuterExpressionKinds[OuterExpressionKinds["All"] = 7] = "All"; + OuterExpressionKinds[OuterExpressionKinds["TypeAssertions"] = 2] = "TypeAssertions"; + OuterExpressionKinds[OuterExpressionKinds["NonNullAssertions"] = 4] = "NonNullAssertions"; + OuterExpressionKinds[OuterExpressionKinds["PartiallyEmittedExpressions"] = 8] = "PartiallyEmittedExpressions"; + OuterExpressionKinds[OuterExpressionKinds["Assertions"] = 6] = "Assertions"; + OuterExpressionKinds[OuterExpressionKinds["All"] = 15] = "All"; })(OuterExpressionKinds = ts.OuterExpressionKinds || (ts.OuterExpressionKinds = {})); function isOuterExpression(node, kinds) { - if (kinds === void 0) { kinds = 7 /* All */; } + if (kinds === void 0) { kinds = 15 /* All */; } switch (node.kind) { case 200 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; case 199 /* TypeAssertionExpression */: case 217 /* AsExpression */: + return (kinds & 2 /* TypeAssertions */) !== 0; case 218 /* NonNullExpression */: - return (kinds & 2 /* Assertions */) !== 0; - case 325 /* PartiallyEmittedExpression */: - return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; + return (kinds & 4 /* NonNullAssertions */) !== 0; + case 326 /* PartiallyEmittedExpression */: + return (kinds & 8 /* PartiallyEmittedExpressions */) !== 0; } return false; } ts.isOuterExpression = isOuterExpression; function skipOuterExpressions(node, kinds) { - if (kinds === void 0) { kinds = 7 /* All */; } - var previousNode; - do { - previousNode = node; - if (kinds & 1 /* Parentheses */) { - node = ts.skipParentheses(node); - } - if (kinds & 2 /* Assertions */) { - node = skipAssertions(node); - } - if (kinds & 4 /* PartiallyEmittedExpressions */) { - node = ts.skipPartiallyEmittedExpressions(node); - } - } while (previousNode !== node); + if (kinds === void 0) { kinds = 15 /* All */; } + while (isOuterExpression(node, kinds)) { + node = node.expression; + } return node; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 218 /* NonNullExpression */) { - node = node.expression; - } - return node; + return skipOuterExpressions(node, 6 /* Assertions */); } ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { @@ -171705,7 +177062,7 @@ var ts; case 199 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); case 217 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); case 218 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 325 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 326 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -171731,7 +177088,7 @@ var ts; && !ts.some(ts.getSyntheticTrailingComments(node)); } function recreateOuterExpressions(outerExpression, innerExpression, kinds) { - if (kinds === void 0) { kinds = 7 /* All */; } + if (kinds === void 0) { kinds = 15 /* All */; } if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression)); } @@ -172073,9 +177430,7 @@ var ts; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); if (target && ts.isPropertyName(target)) { - return ts.isComputedPropertyName(target) && isStringOrNumericLiteral(target.expression) - ? target.expression - : target; + return target; } } ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement; @@ -172267,18 +177622,70 @@ var ts; return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; - /** - * Starts a new lexical environment and visits a parameter list, suspending the lexical - * environment upon completion. - */ function visitParameterList(nodes, visitor, context, nodesVisitor) { if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } + var updated; context.startLexicalEnvironment(); - var updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); + if (nodes) { + context.setLexicalEnvironmentFlags(1 /* InParameters */, true); + updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); + // As of ES2015, any runtime execution of that occurs in for a parameter (such as evaluating an + // initializer or a binding pattern), occurs in its own lexical scope. As a result, any expression + // that we might transform that introduces a temporary variable would fail as the temporary variable + // exists in a different lexical scope. To address this, we move any binding patterns and initializers + // in a parameter list to the body if we detect a variable being hoisted while visiting a parameter list + // when the emit target is greater than ES2015. + if (context.getLexicalEnvironmentFlags() & 2 /* VariablesHoistedInParameters */ && + ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2 /* ES2015 */) { + updated = addDefaultValueAssignmentsIfNeeded(updated, context); + } + context.setLexicalEnvironmentFlags(1 /* InParameters */, false); + } context.suspendLexicalEnvironment(); return updated; } ts.visitParameterList = visitParameterList; + function addDefaultValueAssignmentsIfNeeded(parameters, context) { + var result; + for (var i = 0; i < parameters.length; i++) { + var parameter = parameters[i]; + var updated = addDefaultValueAssignmentIfNeeded(parameter, context); + if (result || updated !== parameter) { + if (!result) + result = parameters.slice(0, i); + result[i] = updated; + } + } + if (result) { + return ts.setTextRange(ts.createNodeArray(result, parameters.hasTrailingComma), parameters); + } + return parameters; + } + function addDefaultValueAssignmentIfNeeded(parameter, context) { + // A rest parameter cannot have a binding pattern or an initializer, + // so let's just ignore it. + return parameter.dotDotDotToken ? parameter : + ts.isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) : + parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) : + parameter; + } + function addDefaultValueAssignmentForBindingPattern(parameter, context) { + context.addInitializationStatement(ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(parameter.name, parameter.type, parameter.initializer ? + ts.createConditional(ts.createStrictEquality(ts.getGeneratedNameForNode(parameter), ts.createVoidZero()), parameter.initializer, ts.getGeneratedNameForNode(parameter)) : + ts.getGeneratedNameForNode(parameter)), + ]))); + return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, ts.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, + /*initializer*/ undefined); + } + function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) { + context.addInitializationStatement(ts.createIf(ts.createTypeCheck(ts.getSynthesizedClone(name), "undefined"), ts.setEmitFlags(ts.setTextRange(ts.createBlock([ + ts.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(ts.createAssignment(ts.setEmitFlags(ts.getMutableClone(name), 48 /* NoSourceMap */), ts.setEmitFlags(initializer, 48 /* NoSourceMap */ | ts.getEmitFlags(initializer) | 1536 /* NoComments */)), parameter), 1536 /* NoComments */)) + ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */))); + return ts.updateParameter(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, + /*initializer*/ undefined); + } function visitFunctionBody(node, visitor, context) { context.resumeLexicalEnvironment(); var updated = visitNode(node, visitor, ts.isConciseBody); @@ -172394,17 +177801,17 @@ var ts; return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); case 194 /* PropertyAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifierOrPrivateIdentifier)); case 195 /* ElementAccessExpression */: if (node.flags & 32 /* OptionalChain */) { - return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); case 196 /* CallExpression */: if (node.flags & 32 /* OptionalChain */) { - return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); case 197 /* NewExpression */: @@ -172418,7 +177825,7 @@ var ts; case 201 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 202 /* ArrowFunction */: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, tokenVisitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 203 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 204 /* TypeOfExpression */: @@ -172432,9 +177839,9 @@ var ts; case 208 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); case 209 /* BinaryExpression */: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, tokenVisitor, ts.isToken)); case 210 /* ConditionalExpression */: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, tokenVisitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 211 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 212 /* YieldExpression */: @@ -172472,7 +177879,7 @@ var ts; case 231 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 232 /* ForOfStatement */: - return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + return ts.updateForOf(node, visitNode(node.awaitModifier, tokenVisitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); case 233 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); case 234 /* BreakStatement */: @@ -172578,9 +177985,9 @@ var ts; case 290 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 325 /* PartiallyEmittedExpression */: + case 326 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 326 /* CommaListExpression */: + case 327 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -172637,7 +178044,7 @@ var ts; case 224 /* EmptyStatement */: case 215 /* OmittedExpression */: case 241 /* DebuggerStatement */: - case 324 /* NotEmittedStatement */: + case 325 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names @@ -173021,10 +178428,10 @@ var ts; result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 325 /* PartiallyEmittedExpression */: + case 326 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 326 /* CommaListExpression */: + case 327 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -173033,13 +178440,93 @@ var ts; return result; } ts.reduceEachChild = reduceEachChild; + function findSpanEnd(array, test, start) { + var i = start; + while (i < array.length && test(array[i])) { + i++; + } + return i; + } function mergeLexicalEnvironment(statements, declarations) { if (!ts.some(declarations)) { return statements; } - return ts.isNodeArray(statements) - ? ts.setTextRange(ts.createNodeArray(ts.insertStatementsAfterStandardPrologue(statements.slice(), declarations)), statements) - : ts.insertStatementsAfterStandardPrologue(statements, declarations); + // When we merge new lexical statements into an existing statement list, we merge them in the following manner: + // + // Given: + // + // | Left | Right | + // |------------------------------------|-------------------------------------| + // | [standard prologues (left)] | [standard prologues (right)] | + // | [hoisted functions (left)] | [hoisted functions (right)] | + // | [hoisted variables (left)] | [hoisted variables (right)] | + // | [lexical init statements (left)] | [lexical init statements (right)] | + // | [other statements (left)] | | + // + // The resulting statement list will be: + // + // | Result | + // |-------------------------------------| + // | [standard prologues (right)] | + // | [standard prologues (left)] | + // | [hoisted functions (right)] | + // | [hoisted functions (left)] | + // | [hoisted variables (right)] | + // | [hoisted variables (left)] | + // | [lexical init statements (right)] | + // | [lexical init statements (left)] | + // | [other statements (left)] | + // + // NOTE: It is expected that new lexical init statements must be evaluated before existing lexical init statements, + // as the prior transformation may depend on the evaluation of the lexical init statements to be in the correct state. + // find standard prologues on left in the following order: standard directives, hoisted functions, hoisted variables, other custom + var leftStandardPrologueEnd = findSpanEnd(statements, ts.isPrologueDirective, 0); + var leftHoistedFunctionsEnd = findSpanEnd(statements, ts.isHoistedFunction, leftStandardPrologueEnd); + var leftHoistedVariablesEnd = findSpanEnd(statements, ts.isHoistedVariableStatement, leftHoistedFunctionsEnd); + // find standard prologues on right in the following order: standard directives, hoisted functions, hoisted variables, other custom + var rightStandardPrologueEnd = findSpanEnd(declarations, ts.isPrologueDirective, 0); + var rightHoistedFunctionsEnd = findSpanEnd(declarations, ts.isHoistedFunction, rightStandardPrologueEnd); + var rightHoistedVariablesEnd = findSpanEnd(declarations, ts.isHoistedVariableStatement, rightHoistedFunctionsEnd); + var rightCustomPrologueEnd = findSpanEnd(declarations, ts.isCustomPrologue, rightHoistedVariablesEnd); + ts.Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues"); + // splice prologues from the right into the left. We do this in reverse order + // so that we don't need to recompute the index on the left when we insert items. + var left = ts.isNodeArray(statements) ? statements.slice() : statements; + // splice other custom prologues from right into left + if (rightCustomPrologueEnd > rightHoistedVariablesEnd) { + left.splice.apply(left, __spreadArrays([leftHoistedVariablesEnd, 0], declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd))); + } + // splice hoisted variables from right into left + if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) { + left.splice.apply(left, __spreadArrays([leftHoistedFunctionsEnd, 0], declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd))); + } + // splice hoisted functions from right into left + if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) { + left.splice.apply(left, __spreadArrays([leftStandardPrologueEnd, 0], declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd))); + } + // splice standard prologues from right into left (that are not already in left) + if (rightStandardPrologueEnd > 0) { + if (leftStandardPrologueEnd === 0) { + left.splice.apply(left, __spreadArrays([0, 0], declarations.slice(0, rightStandardPrologueEnd))); + } + else { + var leftPrologues = ts.createMap(); + for (var i = 0; i < leftStandardPrologueEnd; i++) { + var leftPrologue = statements[i]; + leftPrologues.set(leftPrologue.expression.text, true); + } + for (var i = rightStandardPrologueEnd - 1; i >= 0; i--) { + var rightPrologue = declarations[i]; + if (!leftPrologues.has(rightPrologue.expression.text)) { + left.unshift(rightPrologue); + } + } + } + } + if (ts.isNodeArray(statements)) { + return ts.setTextRange(ts.createNodeArray(left, statements.hasTrailingComma), statements); + } + return statements; } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; /** @@ -174173,9 +179660,6 @@ var ts; } return ts.aggregateTransformFlags(ts.inlineExpressions(expressions)) || ts.createOmittedExpression(); function emitExpression(expression) { - // NOTE: this completely disables source maps, but aligns with the behavior of - // `emitAssignment` in the old emitter. - ts.setEmitFlags(expression, 64 /* NoNestedSourceMaps */); ts.aggregateTransformFlags(expression); expressions = ts.append(expressions, expression); } @@ -174280,9 +179764,6 @@ var ts; /*type*/ undefined, pendingExpressions_1 ? ts.inlineExpressions(ts.append(pendingExpressions_1, value)) : value); variable.original = original; ts.setTextRange(variable, location); - if (ts.isIdentifier(name)) { - ts.setEmitFlags(variable, 64 /* NoNestedSourceMaps */); - } ts.aggregateTransformFlags(variable); declarations.push(variable); } @@ -174581,6 +180062,99 @@ var ts; })(ts || (ts = {})); /*@internal*/ var ts; +(function (ts) { + var ProcessLevel; + (function (ProcessLevel) { + ProcessLevel[ProcessLevel["LiftRestriction"] = 0] = "LiftRestriction"; + ProcessLevel[ProcessLevel["All"] = 1] = "All"; + })(ProcessLevel = ts.ProcessLevel || (ts.ProcessLevel = {})); + function processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, level) { + // Visit the tag expression + var tag = ts.visitNode(node.tag, visitor, ts.isExpression); + // Build up the template arguments and the raw and cooked strings for the template. + // We start out with 'undefined' for the first argument and revisit later + // to avoid walking over the template string twice and shifting all our arguments over after the fact. + var templateArguments = [undefined]; + var cookedStrings = []; + var rawStrings = []; + var template = node.template; + if (level === ProcessLevel.LiftRestriction && !ts.hasInvalidEscape(template)) + return node; + if (ts.isNoSubstitutionTemplateLiteral(template)) { + cookedStrings.push(createTemplateCooked(template)); + rawStrings.push(getRawLiteral(template, currentSourceFile)); + } + else { + cookedStrings.push(createTemplateCooked(template.head)); + rawStrings.push(getRawLiteral(template.head, currentSourceFile)); + for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { + var templateSpan = _a[_i]; + cookedStrings.push(createTemplateCooked(templateSpan.literal)); + rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile)); + templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); + } + } + var helperCall = createTemplateObjectHelper(context, ts.createArrayLiteral(cookedStrings), ts.createArrayLiteral(rawStrings)); + // Create a variable to cache the template object if we're in a module. + // Do not do this in the global scope, as any variable we currently generate could conflict with + // variables from outside of the current compilation. In the future, we can revisit this behavior. + if (ts.isExternalModule(currentSourceFile)) { + var tempVar = ts.createUniqueName("templateObject"); + recordTaggedTemplateString(tempVar); + templateArguments[0] = ts.createLogicalOr(tempVar, ts.createAssignment(tempVar, helperCall)); + } + else { + templateArguments[0] = helperCall; + } + return ts.createCall(tag, /*typeArguments*/ undefined, templateArguments); + } + ts.processTaggedTemplateExpression = processTaggedTemplateExpression; + function createTemplateCooked(template) { + return template.templateFlags ? ts.createIdentifier("undefined") : ts.createLiteral(template.text); + } + /** + * Creates an ES5 compatible literal from an ES6 template literal. + * + * @param node The ES6 template literal. + */ + function getRawLiteral(node, currentSourceFile) { + // Find original source text, since we need to emit the raw strings of the tagged template. + // The raw strings contain the (escaped) strings of what the user wrote. + // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". + var text = node.rawText; + if (text === undefined) { + text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); + // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), + // thus we need to remove those characters. + // First template piece starts with "`", others with "}" + // Last template piece ends with "`", others with "${" + var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; + text = text.substring(1, text.length - (isLast ? 1 : 2)); + } + // Newline normalization: + // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's + // and LineTerminatorSequences are normalized to for both TV and TRV. + text = text.replace(/\r\n?/g, "\n"); + return ts.setTextRange(ts.createLiteral(text), node); + } + function createTemplateObjectHelper(context, cooked, raw) { + context.requestEmitHelper(ts.templateObjectHelper); + return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), + /*typeArguments*/ undefined, [ + cooked, + raw + ]); + } + ts.templateObjectHelper = { + name: "typescript:makeTemplateObject", + importName: "__makeTemplateObject", + scoped: false, + priority: 0, + text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" + }; +})(ts || (ts = {})); +/*@internal*/ +var ts; (function (ts) { /** * Indicates whether to emit type metadata in the new format. @@ -174605,10 +180179,9 @@ var ts; ClassFacts[ClassFacts["IsNamedExternalExport"] = 16] = "IsNamedExternalExport"; ClassFacts[ClassFacts["IsDefaultExternalExport"] = 32] = "IsDefaultExternalExport"; ClassFacts[ClassFacts["IsDerivedClass"] = 64] = "IsDerivedClass"; - ClassFacts[ClassFacts["UseImmediatelyInvokedFunctionExpression"] = 128] = "UseImmediatelyInvokedFunctionExpression"; ClassFacts[ClassFacts["HasAnyDecorators"] = 6] = "HasAnyDecorators"; ClassFacts[ClassFacts["NeedsName"] = 5] = "NeedsName"; - ClassFacts[ClassFacts["MayNeedImmediatelyInvokedFunctionExpression"] = 7] = "MayNeedImmediatelyInvokedFunctionExpression"; + ClassFacts[ClassFacts["UseImmediatelyInvokedFunctionExpression"] = 7] = "UseImmediatelyInvokedFunctionExpression"; ClassFacts[ClassFacts["IsExported"] = 56] = "IsExported"; })(ClassFacts || (ClassFacts = {})); function transformTypeScript(context) { @@ -175044,6 +180617,10 @@ var ts; case 253 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); + case 267 /* JsxSelfClosingElement */: + return visitJsxSelfClosingElement(node); + case 268 /* JsxOpeningElement */: + return visitJsxJsxOpeningElement(node); default: // node contains some other TypeScript syntax return ts.visitEachChild(node, visitor, context); @@ -175091,8 +180668,6 @@ var ts; facts |= 32 /* IsDefaultExternalExport */; else if (isNamedExternalModuleExport(node)) facts |= 16 /* IsNamedExternalExport */; - if (languageVersion <= 1 /* ES5 */ && (facts & 7 /* MayNeedImmediatelyInvokedFunctionExpression */)) - facts |= 128 /* UseImmediatelyInvokedFunctionExpression */; return facts; } function hasTypeScriptClassSyntax(node) { @@ -175110,7 +180685,7 @@ var ts; } var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 7 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); } var name = node.name || (facts & 5 /* NeedsName */ ? ts.getGeneratedNameForNode(node) : undefined); @@ -175122,7 +180697,7 @@ var ts; addClassElementDecorationStatements(statements, node, /*isStatic*/ false); addClassElementDecorationStatements(statements, node, /*isStatic*/ true); addConstructorDecorationStatement(statements, node); - if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { + if (facts & 7 /* UseImmediatelyInvokedFunctionExpression */) { // When we emit a TypeScript class down to ES5, we must wrap it in an IIFE so that the // 'es2015' transformer can properly nest static initializers and decorators. The result // looks something like: @@ -175148,11 +180723,16 @@ var ts; ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment()); var iife = ts.createImmediatelyInvokedArrowFunction(statements); ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); + // Class comment is already added by the ES2015 transform when targeting ES5 or below. + // Only add if targetting ES2015+ to prevent duplicates + if (languageVersion > 1 /* ES5 */) { + ts.addSyntheticLeadingComment(iife, 3 /* MultiLineCommentTrivia */, "* @class "); + } var varStatement = ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), /*type*/ undefined, iife) - ])); + ], languageVersion > 1 /* ES5 */ ? 1 /* Let */ : undefined)); ts.setOriginalNode(varStatement, node); ts.setCommentRange(varStatement, node); ts.setSourceMapRange(varStatement, ts.moveRangePastDecorators(node)); @@ -175165,7 +180745,7 @@ var ts; if (facts & 8 /* IsExportOfNamespace */) { addExportMemberAssignment(statements, node); } - else if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { + else if (facts & 7 /* UseImmediatelyInvokedFunctionExpression */ || facts & 2 /* HasConstructorDecorators */) { if (facts & 32 /* IsDefaultExternalExport */) { statements.push(ts.createExportDefault(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true))); } @@ -175192,7 +180772,7 @@ var ts; // ${members} // } // we do not emit modifiers on the declaration if we are emitting an IIFE - var modifiers = !(facts & 128 /* UseImmediatelyInvokedFunctionExpression */) + var modifiers = !(facts & 7 /* UseImmediatelyInvokedFunctionExpression */) ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier) : undefined; var classDeclaration = ts.createClassDeclaration( @@ -175932,6 +181512,17 @@ var ts; case 183 /* ThisType */: case 188 /* ImportType */: break; + // handle JSDoc types from an invalid parse + case 295 /* JSDocAllType */: + case 296 /* JSDocUnknownType */: + case 300 /* JSDocFunctionType */: + case 301 /* JSDocVariadicType */: + case 302 /* JSDocNamepathType */: + break; + case 297 /* JSDocNullableType */: + case 298 /* JSDocNonNullableType */: + case 299 /* JSDocOptionalType */: + return serializeTypeNode(node.type); default: return ts.Debug.failBadSyntaxKind(node); } @@ -175941,8 +181532,8 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { - var typeNode = types_20[_i]; + for (var _i = 0, types_21 = types; _i < types_21.length; _i++) { + var typeNode = types_21[_i]; while (typeNode.kind === 182 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } @@ -176378,7 +181969,7 @@ var ts; /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } function visitParenthesizedExpression(node) { - var innerExpression = ts.skipOuterExpressions(node.expression, ~2 /* Assertions */); + var innerExpression = ts.skipOuterExpressions(node.expression, ~6 /* Assertions */); if (ts.isAssertionExpression(innerExpression)) { // Make sure we consider all nested cast expressions, e.g.: // (-A).x; @@ -176425,6 +182016,14 @@ var ts; return ts.updateTaggedTemplate(node, ts.visitNode(node.tag, visitor, ts.isExpression), /*typeArguments*/ undefined, ts.visitNode(node.template, visitor, ts.isExpression)); } + function visitJsxSelfClosingElement(node) { + return ts.updateJsxSelfClosingElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), + /*typeArguments*/ undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes)); + } + function visitJsxJsxOpeningElement(node) { + return ts.updateJsxOpeningElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), + /*typeArguments*/ undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes)); + } /** * Determines whether to emit an enum declaration. * @@ -176747,24 +182346,25 @@ var ts; startLexicalEnvironment(); var statementsLocation; var blockLocation; - var body = node.body; - if (body.kind === 250 /* ModuleBlock */) { - saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); - statementsLocation = body.statements; - blockLocation = body; - } - else { - var result = visitModuleDeclaration(body); - if (result) { - if (ts.isArray(result)) { - ts.addRange(statements, result); - } - else { - statements.push(result); + if (node.body) { + if (node.body.kind === 250 /* ModuleBlock */) { + saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); + statementsLocation = node.body.statements; + blockLocation = node.body; + } + else { + var result = visitModuleDeclaration(node.body); + if (result) { + if (ts.isArray(result)) { + ts.addRange(statements, result); + } + else { + statements.push(result); + } } + var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; + statementsLocation = ts.moveRangePos(moduleBlock.statements, -1); } - var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - statementsLocation = ts.moveRangePos(moduleBlock.statements, -1); } ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); currentNamespaceContainerName = savedCurrentNamespaceContainerName; @@ -176794,7 +182394,7 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 250 /* ModuleBlock */) { + if (!node.body || node.body.kind !== 250 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; @@ -176891,16 +182491,18 @@ var ts; if (node.isTypeOnly) { return undefined; } - if (!node.exportClause) { - // Elide a star export if the module it references does not export a value. - return compilerOptions.isolatedModules || resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + if (!node.exportClause || ts.isNamespaceExport(node.exportClause)) { + // never elide `export from ` declarations - + // they should be kept for sideffects/untyped exports, even when the + // type checker doesn't know about any exports + return node; } if (!resolver.isValueAliasDeclaration(node)) { // Elide the export declaration if it does not export a value. return undefined; } // Elide the export declaration if all of its named exports are elided. - var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedImportBindings); + var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedExportBindings); return exportClause ? ts.updateExportDeclaration(node, /*decorators*/ undefined, @@ -177669,7 +183271,7 @@ var ts; /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { - ts.Debug.assertDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); + ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); // Write any pending expressions from elided or moved computed property names if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) { pendingStatements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); @@ -177745,7 +183347,7 @@ var ts; } return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor( /*decorators*/ undefined, - /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); + /*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields; @@ -177811,8 +183413,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var property = properties_6[_i]; + for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { + var property = properties_8[_i]; var expression = transformProperty(property, receiver); if (!expression) { continue; @@ -177832,8 +183434,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { - var property = properties_7[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var expression = transformProperty(property, receiver); if (!expression) { continue; @@ -178743,6 +184345,30 @@ var ts; /** Enables substitutions for async methods with `super` calls. */ ESNextSubstitutionFlags[ESNextSubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; })(ESNextSubstitutionFlags || (ESNextSubstitutionFlags = {})); + // Facts we track as we traverse the tree + var HierarchyFacts; + (function (HierarchyFacts) { + HierarchyFacts[HierarchyFacts["None"] = 0] = "None"; + // + // Ancestor facts + // + HierarchyFacts[HierarchyFacts["HasLexicalThis"] = 1] = "HasLexicalThis"; + HierarchyFacts[HierarchyFacts["IterationContainer"] = 2] = "IterationContainer"; + // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below. + // + // Ancestor masks + // + HierarchyFacts[HierarchyFacts["AncestorFactsMask"] = 3] = "AncestorFactsMask"; + HierarchyFacts[HierarchyFacts["SourceFileIncludes"] = 1] = "SourceFileIncludes"; + HierarchyFacts[HierarchyFacts["SourceFileExcludes"] = 2] = "SourceFileExcludes"; + HierarchyFacts[HierarchyFacts["StrictModeSourceFileIncludes"] = 0] = "StrictModeSourceFileIncludes"; + HierarchyFacts[HierarchyFacts["ClassOrFunctionIncludes"] = 1] = "ClassOrFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ClassOrFunctionExcludes"] = 2] = "ClassOrFunctionExcludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionIncludes"] = 0] = "ArrowFunctionIncludes"; + HierarchyFacts[HierarchyFacts["ArrowFunctionExcludes"] = 2] = "ArrowFunctionExcludes"; + HierarchyFacts[HierarchyFacts["IterationStatementIncludes"] = 2] = "IterationStatementIncludes"; + HierarchyFacts[HierarchyFacts["IterationStatementExcludes"] = 0] = "IterationStatementExcludes"; + })(HierarchyFacts || (HierarchyFacts = {})); function transformES2018(context) { var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; var resolver = context.getEmitResolver(); @@ -178756,7 +184382,9 @@ var ts; var enabledSubstitutions; var enclosingFunctionFlags; var enclosingSuperContainerFlags = 0; - var hasLexicalThis; + var hierarchyFacts = 0; + var currentSourceFile; + var taggedTemplateStringDeclarations; /** Keeps track of property names accessed on super (`super.x`) within async functions. */ var capturedSuperProperties; /** Whether the async function contains an element access on super (`super[x]`). */ @@ -178764,14 +184392,39 @@ var ts; /** A set of node IDs for generated super accessors. */ var substitutedSuperAccessors = []; return ts.chainBundle(transformSourceFile); + function affectsSubtree(excludeFacts, includeFacts) { + return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts); + } + /** + * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. + * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. + * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. + */ + function enterSubtree(excludeFacts, includeFacts) { + var ancestorFacts = hierarchyFacts; + hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3 /* AncestorFactsMask */; + return ancestorFacts; + } + /** + * Restores the `HierarchyFacts` for this node's ancestor after visiting this node's + * subtree. + * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. + */ + function exitSubtree(ancestorFacts) { + hierarchyFacts = ancestorFacts; + } + function recordTaggedTemplateString(temp) { + taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, ts.createVariableDeclaration(temp)); + } function transformSourceFile(node) { if (node.isDeclarationFile) { return node; } - exportedVariableStatement = false; - hasLexicalThis = !ts.isEffectiveStrictModeSourceFile(node, compilerOptions); - var visited = ts.visitEachChild(node, visitor, context); + currentSourceFile = node; + var visited = visitSourceFile(node); ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + taggedTemplateStringDeclarations = undefined; return visited; } function visitor(node) { @@ -178786,11 +184439,11 @@ var ts; } return node; } - function doWithLexicalThis(cb, value) { - if (!hasLexicalThis) { - hasLexicalThis = true; + function doWithHierarchyFacts(cb, value, excludeFacts, includeFacts) { + if (affectsSubtree(excludeFacts, includeFacts)) { + var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var result = cb(value); - hasLexicalThis = false; + exitSubtree(ancestorFacts); return result; } return cb(value); @@ -178821,32 +184474,38 @@ var ts; return visitVariableStatement(node); case 242 /* VariableDeclaration */: return visitVariableDeclaration(node); + case 228 /* DoStatement */: + case 229 /* WhileStatement */: + case 231 /* ForInStatement */: + return doWithHierarchyFacts(visitDefault, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); case 232 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); case 230 /* ForStatement */: - return visitForStatement(node); + return doWithHierarchyFacts(visitForStatement, node, 0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); case 205 /* VoidExpression */: return visitVoidExpression(node); case 162 /* Constructor */: - return doWithLexicalThis(visitConstructorDeclaration, node); + return doWithHierarchyFacts(visitConstructorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); case 161 /* MethodDeclaration */: - return doWithLexicalThis(visitMethodDeclaration, node); + return doWithHierarchyFacts(visitMethodDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); case 163 /* GetAccessor */: - return doWithLexicalThis(visitGetAccessorDeclaration, node); + return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); case 164 /* SetAccessor */: - return doWithLexicalThis(visitSetAccessorDeclaration, node); + return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); case 244 /* FunctionDeclaration */: - return doWithLexicalThis(visitFunctionDeclaration, node); + return doWithHierarchyFacts(visitFunctionDeclaration, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); case 201 /* FunctionExpression */: - return doWithLexicalThis(visitFunctionExpression, node); + return doWithHierarchyFacts(visitFunctionExpression, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); case 202 /* ArrowFunction */: - return visitArrowFunction(node); + return doWithHierarchyFacts(visitArrowFunction, node, 2 /* ArrowFunctionExcludes */, 0 /* ArrowFunctionIncludes */); case 156 /* Parameter */: return visitParameter(node); case 226 /* ExpressionStatement */: return visitExpressionStatement(node); case 200 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); + case 198 /* TaggedTemplateExpression */: + return visitTaggedTemplateExpression(node); case 194 /* PropertyAccessExpression */: if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 102 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); @@ -178859,7 +184518,7 @@ var ts; return ts.visitEachChild(node, visitor, context); case 245 /* ClassDeclaration */: case 214 /* ClassExpression */: - return doWithLexicalThis(visitDefault, node); + return doWithHierarchyFacts(visitDefault, node, 2 /* ClassOrFunctionExcludes */, 1 /* ClassOrFunctionIncludes */); default: return ts.visitEachChild(node, visitor, context); } @@ -178895,7 +184554,7 @@ var ts; if (statement.kind === 232 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } - return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); + return ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, ts.liftToBlock), node); } return ts.visitEachChild(node, visitor, context); } @@ -178969,6 +184628,22 @@ var ts; function visitParenthesizedExpression(node, noDestructuringValue) { return ts.visitEachChild(node, noDestructuringValue ? visitorNoDestructuringValue : visitor, context); } + function visitSourceFile(node) { + var ancestorFacts = enterSubtree(2 /* SourceFileExcludes */, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ? + 0 /* StrictModeSourceFileIncludes */ : + 1 /* SourceFileIncludes */); + exportedVariableStatement = false; + var visited = ts.visitEachChild(node, visitor, context); + var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [ + ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList(taggedTemplateStringDeclarations)) + ]); + var result = ts.updateSourceFileNode(visited, ts.setTextRange(ts.createNodeArray(statement), node.statements)); + exitSubtree(ancestorFacts); + return result; + } + function visitTaggedTemplateExpression(node) { + return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction); + } /** * Visits a BinaryExpression that contains a destructuring assignment. * @@ -179045,15 +184720,15 @@ var ts; * @param node A ForOfStatement. */ function visitForOfStatement(node, outermostLabeledStatement) { + var ancestorFacts = enterSubtree(0 /* IterationStatementExcludes */, 2 /* IterationStatementIncludes */); if (node.initializer.transformFlags & 16384 /* ContainsObjectRestOrSpread */) { node = transformForOfStatementWithObjectRest(node); } - if (node.awaitModifier) { - return transformForAwaitOfStatement(node, outermostLabeledStatement); - } - else { - return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement); - } + var result = node.awaitModifier ? + transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) : + ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement); + exitSubtree(ancestorFacts); + return result; } function transformForOfStatementWithObjectRest(node) { var initializerWithoutParens = ts.skipParentheses(node.initializer); @@ -179101,7 +184776,7 @@ var ts; ? ts.createYield(/*asteriskToken*/ undefined, createAwaitHelper(context, expression)) : ts.createAwait(expression); } - function transformForAwaitOfStatement(node, outermostLabeledStatement) { + function transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) { var expression = ts.visitNode(node.expression, visitor, ts.isExpression); var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined); var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined); @@ -179115,9 +184790,13 @@ var ts; var callReturn = ts.createFunctionCall(returnMethod, iterator, []); hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); + // if we are enclosed in an outer loop ensure we reset 'errorRecord' per each iteration + var initializer = ancestorFacts & 2 /* IterationContainer */ ? + ts.inlineExpressions([ts.createAssignment(errorRecord, ts.createVoidZero()), callValues]) : + callValues; var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor( /*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ - ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, callValues), node.expression), + ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, initializer), node.expression), ts.createVariableDeclaration(result) ]), node.expression), 2097152 /* NoHoisting */), /*condition*/ ts.createComma(ts.createAssignment(result, createDownlevelAwait(callNext)), ts.createLogicalNot(getDone)), @@ -179247,7 +184926,7 @@ var ts; /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], - /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), hasLexicalThis)); + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HasLexicalThis */))); // Minor optimization, emit `_super` helper to capture `super` access in an arrow. // This step isn't needed if we eventually transform this to ES5. var emitSuperHelpers = languageVersion >= 2 /* ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* AsyncMethodWithSuperBinding */ | 2048 /* AsyncMethodWithSuper */); @@ -179455,13 +185134,13 @@ var ts; name: "typescript:asyncGenerator", importName: "__asyncGenerator", scoped: false, + dependencies: [ts.awaitHelper], text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n };" }; function createAsyncGeneratorHelper(context, generatorFunc, hasLexicalThis) { - context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncGeneratorHelper); // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */ | 524288 /* ReuseTempVariableScope */; return ts.createCall(ts.getUnscopedHelperName("__asyncGenerator"), /*typeArguments*/ undefined, [ hasLexicalThis ? ts.createThis() : ts.createVoidZero(), @@ -179473,10 +185152,10 @@ var ts; name: "typescript:asyncDelegator", importName: "__asyncDelegator", scoped: false, + dependencies: [ts.awaitHelper], text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\n };" }; function createAsyncDelegatorHelper(context, expression, location) { - context.requestEmitHelper(ts.awaitHelper); context.requestEmitHelper(ts.asyncDelegator); return ts.setTextRange(ts.createCall(ts.getUnscopedHelperName("__asyncDelegator"), /*typeArguments*/ undefined, [expression]), location); @@ -179562,9 +185241,11 @@ var ts; } } function flattenChain(chain) { + ts.Debug.assertNotNode(chain, ts.isNonNullChain); var links = [chain]; while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { - chain = ts.cast(chain.expression, ts.isOptionalChain); + chain = ts.cast(ts.skipPartiallyEmittedExpressions(chain.expression), ts.isOptionalChain); + ts.Debug.assertNotNode(chain, ts.isNonNullChain); links.unshift(chain); } return { expression: chain.expression, chain: links }; @@ -179590,6 +185271,7 @@ var ts; if (shouldCaptureInTempVariable(expression)) { thisArg = ts.createTempVariable(hoistVariableDeclaration); expression = ts.createAssignment(thisArg, expression); + // if (inParameterInitializer) tempVariableInParameter = true; } else { thisArg = expression; @@ -179625,6 +185307,7 @@ var ts; if (shouldCaptureInTempVariable(leftExpression)) { capturedLeft = ts.createTempVariable(hoistVariableDeclaration); leftExpression = ts.createAssignment(capturedLeft, leftExpression); + // if (inParameterInitializer) tempVariableInParameter = true; } var rightExpression = capturedLeft; var thisArg; @@ -179637,6 +185320,7 @@ var ts; if (shouldCaptureInTempVariable(rightExpression)) { thisArg = ts.createTempVariable(hoistVariableDeclaration); rightExpression = ts.createAssignment(thisArg, rightExpression); + // if (inParameterInitializer) tempVariableInParameter = true; } else { thisArg = rightExpression; @@ -179672,6 +185356,7 @@ var ts; if (shouldCaptureInTempVariable(left)) { right = ts.createTempVariable(hoistVariableDeclaration); left = ts.createAssignment(right, left); + // if (inParameterInitializer) tempVariableInParameter = true; } return ts.createConditional(createNotNullCondition(left, right), right, ts.visitNode(node.right, visitor, ts.isExpression)); } @@ -181468,7 +187153,7 @@ var ts; ts.setCommentRange(setter, ts.getCommentRange(setAccessor)); properties.push(setter); } - properties.push(ts.createPropertyAssignment("enumerable", ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); + properties.push(ts.createPropertyAssignment("enumerable", getAccessor || setAccessor ? ts.createFalse() : ts.createTrue()), ts.createPropertyAssignment("configurable", ts.createTrue())); var call = ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), /*typeArguments*/ undefined, [ target, @@ -181598,6 +187283,8 @@ var ts; // ensureUseStrict is false because no new prologue-directive should be added. // addStandardPrologue will put already-existing directives at the beginning of the target statement-array statementOffset = ts.addStandardPrologue(prologue, body.statements, /*ensureUseStrict*/ false); + statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedFunction); + statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor, ts.isHoistedVariableStatement); } multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine; multiLine = addRestParameterIfNeeded(statements, node, /*inConstructorWithSynthesizedSuper*/ false) || multiLine; @@ -181723,10 +187410,15 @@ var ts; } return ts.visitEachChild(node, visitor, context); } + function isVariableStatementOfTypeScriptClassWrapper(node) { + return node.declarationList.declarations.length === 1 + && !!node.declarationList.declarations[0].initializer + && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432 /* TypeScriptClassWrapper */); + } function visitVariableStatement(node) { var ancestorFacts = enterSubtree(0 /* None */, ts.hasModifier(node, 1 /* Export */) ? 32 /* ExportedVariableStatement */ : 0 /* None */); var updated; - if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0) { + if (convertedLoopState && (node.declarationList.flags & 3 /* BlockScoped */) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) { // we are inside a converted loop - hoist variable declarations var assignments = void 0; for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -182878,7 +188570,11 @@ var ts; // The class statements are the statements generated by visiting the first statement with initializer of the // body (1), while all other statements are added to remainingStatements (2) var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; }; + // visit the class body statements outside of any converted loop body. + var savedConvertedLoopState = convertedLoopState; + convertedLoopState = undefined; var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement); + convertedLoopState = savedConvertedLoopState; var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer); var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); }); var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement); @@ -183135,67 +188831,7 @@ var ts; * @param node A TaggedTemplateExpression node. */ function visitTaggedTemplateExpression(node) { - // Visit the tag expression - var tag = ts.visitNode(node.tag, visitor, ts.isExpression); - // Build up the template arguments and the raw and cooked strings for the template. - // We start out with 'undefined' for the first argument and revisit later - // to avoid walking over the template string twice and shifting all our arguments over after the fact. - var templateArguments = [undefined]; - var cookedStrings = []; - var rawStrings = []; - var template = node.template; - if (ts.isNoSubstitutionTemplateLiteral(template)) { - cookedStrings.push(ts.createLiteral(template.text)); - rawStrings.push(getRawLiteral(template)); - } - else { - cookedStrings.push(ts.createLiteral(template.head.text)); - rawStrings.push(getRawLiteral(template.head)); - for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) { - var templateSpan = _a[_i]; - cookedStrings.push(ts.createLiteral(templateSpan.literal.text)); - rawStrings.push(getRawLiteral(templateSpan.literal)); - templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression)); - } - } - var helperCall = createTemplateObjectHelper(context, ts.createArrayLiteral(cookedStrings), ts.createArrayLiteral(rawStrings)); - // Create a variable to cache the template object if we're in a module. - // Do not do this in the global scope, as any variable we currently generate could conflict with - // variables from outside of the current compilation. In the future, we can revisit this behavior. - if (ts.isExternalModule(currentSourceFile)) { - var tempVar = ts.createUniqueName("templateObject"); - recordTaggedTemplateString(tempVar); - templateArguments[0] = ts.createLogicalOr(tempVar, ts.createAssignment(tempVar, helperCall)); - } - else { - templateArguments[0] = helperCall; - } - return ts.createCall(tag, /*typeArguments*/ undefined, templateArguments); - } - /** - * Creates an ES5 compatible literal from an ES6 template literal. - * - * @param node The ES6 template literal. - */ - function getRawLiteral(node) { - // Find original source text, since we need to emit the raw strings of the tagged template. - // The raw strings contain the (escaped) strings of what the user wrote. - // Examples: `\n` is converted to "\\n", a template string with a newline to "\n". - var text = node.rawText; - if (text === undefined) { - text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - // text contains the original source, it will also contain quotes ("`"), dolar signs and braces ("${" and "}"), - // thus we need to remove those characters. - // First template piece starts with "`", others with "}" - // Last template piece ends with "`", others with "${" - var isLast = node.kind === 14 /* NoSubstitutionTemplateLiteral */ || node.kind === 17 /* TemplateTail */; - text = text.substring(1, text.length - (isLast ? 1 : 2)); - } - // Newline normalization: - // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's - // and LineTerminatorSequences are normalized to for both TV and TRV. - text = text.replace(/\r\n?/g, "\n"); - return ts.setTextRange(ts.createLiteral(text), node); + return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.All); } /** * Visits a TemplateExpression node. @@ -183488,14 +189124,6 @@ var ts; ts.createFileLevelUniqueName("_super") ]); } - function createTemplateObjectHelper(context, cooked, raw) { - context.requestEmitHelper(ts.templateObjectHelper); - return ts.createCall(ts.getUnscopedHelperName("__makeTemplateObject"), - /*typeArguments*/ undefined, [ - cooked, - raw - ]); - } ts.extendsHelper = { name: "typescript:extends", importName: "__extends", @@ -183503,13 +189131,6 @@ var ts; priority: 0, text: "\n var __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n })();" }; - ts.templateObjectHelper = { - name: "typescript:makeTemplateObject", - importName: "__makeTemplateObject", - scoped: false, - priority: 0, - text: "\n var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n };" - }; })(ts || (ts = {})); /*@internal*/ var ts; @@ -186327,16 +191948,14 @@ var ts; if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } + if (ts.length(currentModuleInfo.exportedNames)) { + ts.append(statements, ts.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(ts.idText(nextId))), prev); }, ts.createVoidZero()))); + } ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); - if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.addEmitHelper(updated, exportStarHelper); - } ts.addEmitHelpers(updated, context.readEmitHelpers()); return updated; } @@ -186546,6 +192165,9 @@ var ts; if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } + if (ts.length(currentModuleInfo.exportedNames)) { + ts.append(statements, ts.createExpressionStatement(ts.reduceLeft(currentModuleInfo.exportedNames, function (prev, nextId) { return ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(ts.idText(nextId))), prev); }, ts.createVoidZero()))); + } // Visit each statement of the module body. ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); if (moduleKind === ts.ModuleKind.AMD) { @@ -186558,11 +192180,6 @@ var ts; // and merge any new lexical declarations. ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment()); var body = ts.createBlock(statements, /*multiLine*/ true); - if (currentModuleInfo.hasExportStarsToExportValues && !compilerOptions.importHelpers) { - // If we have any `export * from ...` declarations - // we need to inform the emitter to add the __export helper. - ts.addEmitHelper(body, exportStarHelper); - } if (needUMDDynamicImportHelper) { ts.addEmitHelper(body, dynamicImportUMDHelper); } @@ -186619,9 +192236,9 @@ var ts; return visitFunctionDeclaration(node); case 245 /* ClassDeclaration */: return visitClassDeclaration(node); - case 327 /* MergeDeclarationMarker */: + case 328 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 328 /* EndOfDeclarationMarker */: + case 329 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -186979,8 +192596,13 @@ var ts; } for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { var specifier = _a[_i]; - var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); - statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue)), specifier), specifier)); + if (languageVersion === 0 /* ES3 */) { + statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createCreateBindingHelper(context, generatedName, ts.createLiteral(specifier.propertyName || specifier.name), specifier.propertyName ? ts.createLiteral(specifier.name) : undefined)), specifier), specifier)); + } + else { + var exportedValue = ts.createPropertyAccess(generatedName, specifier.propertyName || specifier.name); + statements.push(ts.setOriginalNode(ts.setTextRange(ts.createExpressionStatement(createExportExpression(ts.getExportName(specifier), exportedValue, /* location */ undefined, /* liveBinding */ true)), specifier), specifier)); + } } return ts.singleOrMany(statements); } @@ -187083,7 +192705,6 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { var modifiers = void 0; // If we're exporting these variables, then these just become assignments to 'exports.x'. - // We only want to emit assignments for variables with initializers. for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var variable = _a[_i]; if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) { @@ -187144,7 +192765,7 @@ var ts; } else { return ts.createAssignment(ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), node.name), - /*location*/ node.name), ts.visitNode(node.initializer, moduleExpressionElementVisitor)); + /*location*/ node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : ts.createVoidZero()); } } /** @@ -187222,7 +192843,7 @@ var ts; case 257 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; - statements = appendExportsOfDeclaration(statements, importBinding); + statements = appendExportsOfDeclaration(statements, importBinding, /* liveBinding */ true); } break; } @@ -187319,13 +192940,13 @@ var ts; * appended. * @param decl The declaration to export. */ - function appendExportsOfDeclaration(statements, decl) { + function appendExportsOfDeclaration(statements, decl, liveBinding) { var name = ts.getDeclarationName(decl); var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name)); if (exportSpecifiers) { for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) { var exportSpecifier = exportSpecifiers_1[_i]; - statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name); + statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name, /* allowComments */ undefined, liveBinding); } } return statements; @@ -187342,8 +192963,8 @@ var ts; * @param location The location to use for source maps and comments for the export. * @param allowComments Whether to allow comments on the export. */ - function appendExportStatement(statements, exportName, expression, location, allowComments) { - statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments)); + function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) { + statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding)); return statements; } function createUnderscoreUnderscoreESModule() { @@ -187372,8 +192993,8 @@ var ts; * @param location The location to use for source maps and comments for the export. * @param allowComments An optional value indicating whether to emit comments for the statement. */ - function createExportStatement(name, value, location, allowComments) { - var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value)), location); + function createExportStatement(name, value, location, allowComments, liveBinding) { + var statement = ts.setTextRange(ts.createExpressionStatement(createExportExpression(name, value, /* location */ undefined, liveBinding)), location); ts.startOnNewLine(statement); if (!allowComments) { ts.setEmitFlags(statement, 1536 /* NoComments */); @@ -187387,8 +193008,22 @@ var ts; * @param value The exported value. * @param location The location to use for source maps and comments for the export. */ - function createExportExpression(name, value, location) { - return ts.setTextRange(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); + function createExportExpression(name, value, location, liveBinding) { + return ts.setTextRange(liveBinding && languageVersion !== 0 /* ES3 */ ? ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), + /*typeArguments*/ undefined, [ + ts.createIdentifier("exports"), + ts.createLiteral(name), + ts.createObjectLiteral([ + ts.createPropertyAssignment("enumerable", ts.createLiteral(/*value*/ true)), + ts.createPropertyAssignment("get", ts.createFunctionExpression( + /*modifiers*/ undefined, + /*asteriskToken*/ undefined, + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, ts.createBlock([ts.createReturn(value)]))) + ]) + ]) : ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(name)), value), location); } // // Modifier Visitors @@ -187613,17 +193248,36 @@ var ts; } } ts.transformModule = transformModule; + ts.createBindingHelper = { + name: "typescript:commonjscreatebinding", + importName: "__createBinding", + scoped: false, + priority: 1, + text: "\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));" + }; + function createCreateBindingHelper(context, module, inputName, outputName) { + context.requestEmitHelper(ts.createBindingHelper); + return ts.createCall(ts.getUnscopedHelperName("__createBinding"), /*typeArguments*/ undefined, __spreadArrays([ts.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : []))); + } + ts.setModuleDefaultHelper = { + name: "typescript:commonjscreatevalue", + importName: "__setModuleDefault", + scoped: false, + priority: 1, + text: "\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});" + }; // emit output for the __export helper function var exportStarHelper = { name: "typescript:export-star", - scoped: true, - text: "\n function __export(m) {\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\n }" + importName: "__exportStar", + scoped: false, + dependencies: [ts.createBindingHelper], + priority: 2, + text: "\n var __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);\n };" }; function createExportStarHelper(context, module) { - var compilerOptions = context.getCompilerOptions(); - return compilerOptions.importHelpers - ? ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]) - : ts.createCall(ts.createIdentifier("__export"), /*typeArguments*/ undefined, [module]); + context.requestEmitHelper(exportStarHelper); + return ts.createCall(ts.getUnscopedHelperName("__exportStar"), /*typeArguments*/ undefined, [module, ts.createIdentifier("exports")]); } // emit helper for dynamic import var dynamicImportUMDHelper = { @@ -187636,7 +193290,9 @@ var ts; name: "typescript:commonjsimportstar", importName: "__importStar", scoped: false, - text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n result[\"default\"] = mod;\n return result;\n};" + dependencies: [ts.createBindingHelper, ts.setModuleDefaultHelper], + priority: 2, + text: "\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};" }; // emit helper for `import Name from "foo"` ts.importDefaultHelper = { @@ -188100,7 +193756,7 @@ var ts; return ts.singleOrMany(statements); } function visitExportDeclaration(node) { - ts.Debug.assertDefined(node); + ts.Debug.assertIsDefined(node); return undefined; } /** @@ -188596,9 +194252,9 @@ var ts; return visitCatchClause(node); case 223 /* Block */: return visitBlock(node); - case 327 /* MergeDeclarationMarker */: + case 328 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 328 /* EndOfDeclarationMarker */: + case 329 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -189741,7 +195397,8 @@ var ts; reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError, moduleResolverHost: host, trackReferencedAmbientModule: trackReferencedAmbientModule, - trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode + trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode, + reportNonlocalAugmentation: reportNonlocalAugmentation }; var errorNameNode; var currentSourceFile; @@ -189832,6 +195489,14 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } + function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) { + var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; }); + var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; }); + for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) { + var augmentations = augmentingDeclarations_1[_i]; + context.addDiagnostic(ts.addRelatedInfo(ts.createDiagnosticForNode(augmentations, ts.Diagnostics.Declaration_augments_declaration_in_another_file_This_cannot_be_serialized), ts.createDiagnosticForNode(primaryDeclaration, ts.Diagnostics.This_is_the_declaration_being_augmented_Consider_moving_the_augmenting_declaration_into_the_same_file))); + } + } function transformDeclarationsForJS(sourceFile, bundled) { var oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = function (s) { return ({ @@ -189970,8 +195635,8 @@ var ts; declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName; } if (declFileName) { - var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, host.getSourceFiles(), - /*preferences*/ undefined, host.redirectTargetsMap); + var specifier = ts.moduleSpecifiers.getModuleSpecifier(__assign(__assign({}, options), { baseUrl: options.baseUrl && ts.toPath(options.baseUrl, host.getCurrentDirectory(), host.getCanonicalFileName) }), currentSourceFile, ts.toPath(outputFilePath, host.getCurrentDirectory(), host.getCanonicalFileName), ts.toPath(declFileName, host.getCurrentDirectory(), host.getCanonicalFileName), host, + /*preferences*/ undefined); if (!ts.pathIsRelative(specifier)) { // If some compiler option/symlink/whatever allows access to the file containing the ambient module declaration // via a non-relative name, emit a type reference directive to that non-relative name, rather than @@ -189986,7 +195651,7 @@ var ts; } // omit references to files from node_modules (npm may disambiguate module // references when installing this package, making the path is unreliable). - if (ts.startsWith(fileName, "node_modules/") || fileName.indexOf("/node_modules/") !== -1) { + if (ts.startsWith(fileName, "node_modules/") || ts.pathContainsNodeModules(fileName)) { return; } references.push({ pos: -1, end: -1, fileName: fileName }); @@ -190259,6 +195924,12 @@ var ts; return ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, bindingList && bindingList.length ? ts.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined, decl.importClause.isTypeOnly), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } + // Augmentation of export depends on import + if (resolver.isImportRequiredByAugmentation(decl)) { + return ts.updateImportDeclaration(decl, + /*decorators*/ undefined, decl.modifiers, + /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier)); + } // Nothing visible } function transformAndReplaceLatePaintedStatements(statements) { @@ -191092,11 +196763,15 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(330 /* Count */); + var enabledSyntaxKindFeatures = new Array(331 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; + var lexicalEnvironmentStatements; + var lexicalEnvironmentFlags = 0 /* None */; var lexicalEnvironmentVariableDeclarationsStack = []; var lexicalEnvironmentFunctionDeclarationsStack = []; + var lexicalEnvironmentStatementsStack = []; + var lexicalEnvironmentFlagsStack = []; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; @@ -191114,8 +196789,11 @@ var ts; suspendLexicalEnvironment: suspendLexicalEnvironment, resumeLexicalEnvironment: resumeLexicalEnvironment, endLexicalEnvironment: endLexicalEnvironment, + setLexicalEnvironmentFlags: setLexicalEnvironmentFlags, + getLexicalEnvironmentFlags: getLexicalEnvironmentFlags, hoistVariableDeclaration: hoistVariableDeclaration, hoistFunctionDeclaration: hoistFunctionDeclaration, + addInitializationStatement: addInitializationStatement, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, enableSubstitution: enableSubstitution, @@ -191245,6 +196923,9 @@ var ts; else { lexicalEnvironmentVariableDeclarations.push(decl); } + if (lexicalEnvironmentFlags & 1 /* InParameters */) { + lexicalEnvironmentFlags |= 2 /* VariablesHoistedInParameters */; + } } /** * Records a hoisted function declaration within a lexical environment. @@ -191252,6 +196933,7 @@ var ts; function hoistFunctionDeclaration(func) { ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(func, 1048576 /* CustomPrologue */); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -191259,6 +196941,20 @@ var ts; lexicalEnvironmentFunctionDeclarations.push(func); } } + /** + * Adds an initialization statement to the top of the lexical environment. + */ + function addInitializationStatement(node) { + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); + ts.setEmitFlags(node, 1048576 /* CustomPrologue */); + if (!lexicalEnvironmentStatements) { + lexicalEnvironmentStatements = [node]; + } + else { + lexicalEnvironmentStatements.push(node); + } + } /** * Starts a new lexical environment. Any existing hoisted variable or function declarations * are pushed onto a stack, and the related storage variables are reset. @@ -191273,9 +196969,13 @@ var ts; // transformation. lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations; lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations; + lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements; + lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags; lexicalEnvironmentStackOffset++; lexicalEnvironmentVariableDeclarations = undefined; lexicalEnvironmentFunctionDeclarations = undefined; + lexicalEnvironmentStatements = undefined; + lexicalEnvironmentFlags = 0 /* None */; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { @@ -191300,7 +197000,9 @@ var ts; ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; - if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { + if (lexicalEnvironmentVariableDeclarations || + lexicalEnvironmentFunctionDeclarations || + lexicalEnvironmentStatements) { if (lexicalEnvironmentFunctionDeclarations) { statements = __spreadArrays(lexicalEnvironmentFunctionDeclarations); } @@ -191315,21 +197017,47 @@ var ts; statements.push(statement); } } + if (lexicalEnvironmentStatements) { + if (!statements) { + statements = __spreadArrays(lexicalEnvironmentStatements); + } + else { + statements = __spreadArrays(statements, lexicalEnvironmentStatements); + } + } } // Restore the previous lexical environment. lexicalEnvironmentStackOffset--; lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset]; lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset]; + lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset]; + lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset]; if (lexicalEnvironmentStackOffset === 0) { lexicalEnvironmentVariableDeclarationsStack = []; lexicalEnvironmentFunctionDeclarationsStack = []; + lexicalEnvironmentStatementsStack = []; + lexicalEnvironmentFlagsStack = []; } return statements; } + function setLexicalEnvironmentFlags(flags, value) { + lexicalEnvironmentFlags = value ? + lexicalEnvironmentFlags | flags : + lexicalEnvironmentFlags & ~flags; + } + function getLexicalEnvironmentFlags() { + return lexicalEnvironmentFlags; + } function requestEmitHelper(helper) { ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); + if (helper.dependencies) { + for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) { + var h = _a[_i]; + requestEmitHelper(h); + } + } emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { @@ -191493,7 +197221,7 @@ var ts; } ts.getOutputExtension = getOutputExtension; function rootDirOfOptions(configFile) { - return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.assertDefined(configFile.options.configFilePath)); + return configFile.options.rootDir || ts.getDirectoryPath(ts.Debug.checkDefined(configFile.options.configFilePath)); } function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir) { return outputDir ? @@ -191515,7 +197243,7 @@ var ts; ts.fileExtensionIs(inputFileName, ".tsx" /* Tsx */) && configFile.options.jsx === 1 /* Preserve */ ? ".jsx" /* Jsx */ : ".js" /* Js */); - return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.assertDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? + return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 /* EqualTo */ ? outputFileName : undefined; } @@ -191590,7 +197318,7 @@ var ts; function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { var jsFilePath = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false).jsFilePath; - return ts.Debug.assertDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); + return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output"); } for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) { var inputFileName = _b[_a]; @@ -191878,7 +197606,7 @@ var ts; var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText); return "data:application/json;base64," + base64SourceMapText; } - var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.assertDefined(sourceMapFilePath))); + var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath))); if (mapOptions.mapRoot) { var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot); if (sourceFile) { @@ -191953,6 +197681,7 @@ var ts; getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, getDeclarationStatementsForSourceFile: ts.notImplemented, + isImportRequiredByAugmentation: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { @@ -191962,7 +197691,7 @@ var ts; sourceFile.statements = ts.createNodeArray(); return sourceFile; }); - var jsBundle = ts.Debug.assertDefined(bundle.js); + var jsBundle = ts.Debug.checkDefined(bundle.js); ts.forEach(jsBundle.sources && jsBundle.sources.prologues, function (prologueInfo) { var sourceFile = sourceFiles[prologueInfo.file]; sourceFile.text = prologueInfo.text; @@ -191979,10 +197708,10 @@ var ts; /*@internal*/ function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) { var _a = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath; - var buildInfoText = host.readFile(ts.Debug.assertDefined(buildInfoPath)); + var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath)); if (!buildInfoText) return buildInfoPath; - var jsFileText = host.readFile(ts.Debug.assertDefined(jsFilePath)); + var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath)); if (!jsFileText) return jsFilePath; var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath); @@ -192019,6 +197748,7 @@ var ts; getLibFileFromReference: ts.notImplemented, isSourceFileFromExternalLibrary: ts.returnFalse, getResolvedProjectReferenceToRedirect: ts.returnUndefined, + getProjectReferenceRedirect: ts.returnUndefined, isSourceOfProjectReferenceRedirect: ts.returnFalse, writeFile: function (name, text, writeByteOrderMark) { switch (name) { @@ -192058,7 +197788,6 @@ var ts; isEmitBlocked: ts.returnFalse, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { return host.fileExists(f); }, - directoryExists: host.directoryExists && (function (f) { return host.directoryExists(f); }), useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: ts.returnUndefined, getSourceFileFromReference: ts.returnUndefined, @@ -192093,12 +197822,13 @@ var ts; var tempFlags; // TempFlags for the current name generation scope. var reservedNamesStack; // Stack of TempFlags reserved in enclosing name generation scopes. var reservedNames; // TempFlags to reserve in nested name generation scopes. + var preserveSourceNewlines = printerOptions.preserveSourceNewlines; // Can be overridden inside nodes with the `IgnoreSourceNewlines` emit flag. var writer; var ownWriter; // Reusable `EmitTextWriter` for basic printing. var write = writeBase; var isOwnFileEmit; var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined; - var relativeToBuildInfo = bundleFileInfo ? ts.Debug.assertDefined(printerOptions.relativeToBuildInfo) : undefined; + var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined; var recordInternalSection = printerOptions.recordInternalSection; var sourceFileTextPos = 0; var sourceFileTextKind = "text" /* Text */; @@ -192375,14 +198105,19 @@ var ts; function pipelineEmit(emitHint, node) { var savedLastNode = lastNode; var savedLastSubstitution = lastSubstitution; + var savedPreserveSourceNewlines = preserveSourceNewlines; lastNode = node; lastSubstitution = undefined; + if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728 /* IgnoreSourceNewlines */)) { + preserveSourceNewlines = false; + } var pipelinePhase = getPipelinePhase(0 /* Notification */, emitHint, node); pipelinePhase(emitHint, node); ts.Debug.assert(lastNode === node); var substitute = lastSubstitution; lastNode = savedLastNode; lastSubstitution = savedLastSubstitution; + preserveSourceNewlines = savedPreserveSourceNewlines; return substitute || node; } function getPipelinePhase(phase, emitHint, node) { @@ -192692,27 +198427,28 @@ var ts; case 284 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 316 /* JSDocParameterTag */: - case 322 /* JSDocPropertyTag */: + case 317 /* JSDocParameterTag */: + case 323 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 317 /* JSDocReturnTag */: - case 319 /* JSDocTypeTag */: - case 318 /* JSDocThisTag */: - case 315 /* JSDocEnumTag */: + case 318 /* JSDocReturnTag */: + case 320 /* JSDocTypeTag */: + case 319 /* JSDocThisTag */: + case 316 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); + case 308 /* JSDocImplementsTag */: case 307 /* JSDocAugmentsTag */: - return emitJSDocAugmentsTag(node); - case 320 /* JSDocTemplateTag */: + return emitJSDocHeritageTag(node); + case 321 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 321 /* JSDocTypedefTag */: + case 322 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 314 /* JSDocCallbackTag */: + case 315 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); case 305 /* JSDocSignature */: return emitJSDocSignature(node); case 304 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 309 /* JSDocClassTag */: + case 310 /* JSDocClassTag */: case 306 /* JSDocTag */: return emitJSDocSimpleTag(node); case 303 /* JSDocComment */: @@ -192814,9 +198550,9 @@ var ts; case 270 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 325 /* PartiallyEmittedExpression */: + case 326 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 326 /* CommaListExpression */: + case 327 /* CommaListExpression */: return emitCommaList(node); } } @@ -193367,10 +199103,10 @@ var ts; } function emitPropertyAccessExpression(node) { var expression = ts.cast(emitExpression(node.expression), ts.isExpression); - var token = ts.getDotOrQuestionDotToken(node); - var indentBeforeDot = needsIndentation(node, node.expression, token); - var indentAfterDot = needsIndentation(node, token, node.name); - increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); + var token = node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token); + var linesAfterDot = getLinesBetweenNodes(node, token, node.name); + writeLinesAndIndent(linesBeforeDot, /*writeSpaceIfNotIndenting*/ false); var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && mayNeedDotDotForPropertyAccess(expression) && !writer.hasTrailingComment() && @@ -193378,10 +199114,15 @@ var ts; if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); - increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); + if (node.questionDotToken) { + emit(token); + } + else { + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); + } + writeLinesAndIndent(linesAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); - decreaseIndentIf(indentBeforeDot, indentAfterDot); + decreaseIndentIf(linesBeforeDot, linesAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal @@ -193436,7 +199177,10 @@ var ts; } function emitParenthesizedExpression(node) { var openParenPos = emitTokenWithComment(20 /* OpenParenToken */, node.pos, writePunctuation, node); + var indented = writeLineSeparatorsAndIndentBefore(node.expression, node); emitExpression(node.expression); + writeLineSeparatorsAfter(node.expression, node); + decreaseIndentIf(indented); emitTokenWithComment(21 /* CloseParenToken */, node.expression ? node.expression.end : openParenPos, writePunctuation, node); } function emitFunctionExpression(node) { @@ -193528,20 +199272,20 @@ var ts; } case 1 /* EmitRight */: { var isCommaOperator = node.operatorToken.kind !== 27 /* CommaToken */; - var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); - var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); - increaseIndentIf(indentBeforeOperator, isCommaOperator); + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); + writeLinesAndIndent(linesBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); writeTokenNode(node.operatorToken, node.operatorToken.kind === 97 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts - increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); + writeLinesAndIndent(linesAfterOperator, /*writeSpaceIfNotIndenting*/ true); maybePipelineEmitExpression(node.right); break; } case 2 /* FinishEmit */: { - var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); - var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); - decreaseIndentIf(indentBeforeOperator, indentAfterOperator); + var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken); + var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right); + decreaseIndentIf(linesBeforeOperator, linesAfterOperator); stackIndex--; break; } @@ -193577,21 +199321,21 @@ var ts; } } function emitConditionalExpression(node) { - var indentBeforeQuestion = needsIndentation(node, node.condition, node.questionToken); - var indentAfterQuestion = needsIndentation(node, node.questionToken, node.whenTrue); - var indentBeforeColon = needsIndentation(node, node.whenTrue, node.colonToken); - var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); + var linesBeforeQuestion = getLinesBetweenNodes(node, node.condition, node.questionToken); + var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue); + var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken); + var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse); emitExpression(node.condition); - increaseIndentIf(indentBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); + writeLinesAndIndent(linesBeforeQuestion, /*writeSpaceIfNotIndenting*/ true); emit(node.questionToken); - increaseIndentIf(indentAfterQuestion, /*writeSpaceIfNotIndenting*/ true); + writeLinesAndIndent(linesAfterQuestion, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenTrue); - decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); - increaseIndentIf(indentBeforeColon, /*writeSpaceIfNotIndenting*/ true); + decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion); + writeLinesAndIndent(linesBeforeColon, /*writeSpaceIfNotIndenting*/ true); emit(node.colonToken); - increaseIndentIf(indentAfterColon, /*writeSpaceIfNotIndenting*/ true); + writeLinesAndIndent(linesAfterColon, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.whenFalse); - decreaseIndentIf(indentBeforeColon, indentAfterColon); + decreaseIndentIf(linesBeforeColon, linesAfterColon); } function emitTemplateExpression(node) { emit(node.head); @@ -193932,14 +199676,14 @@ var ts; if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) { return false; } - if (shouldWriteLeadingLineTerminator(body, body.statements, 2 /* PreserveLines */) - || shouldWriteClosingLineTerminator(body, body.statements, 2 /* PreserveLines */)) { + if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */) + || getClosingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)) { return false; } var previousStatement; for (var _a = 0, _b = body.statements; _a < _b.length; _a++) { var statement = _b[_a]; - if (shouldWriteSeparatingLineTerminator(previousStatement, statement, 2 /* PreserveLines */)) { + if (getSeparatingLineTerminatorCount(previousStatement, statement, 2 /* PreserveLines */) > 0) { return false; } previousStatement = statement; @@ -194232,12 +199976,15 @@ var ts; function emitJsxOpeningElementOrFragment(node) { writePunctuation("<"); if (ts.isJsxOpeningElement(node)) { + var indented = writeLineSeparatorsAndIndentBefore(node.tagName, node); emitJsxTagName(node.tagName); emitTypeArguments(node, node.typeArguments); if (node.attributes.properties && node.attributes.properties.length > 0) { writeSpace(); } emit(node.attributes); + writeLineSeparatorsAfter(node.attributes, node); + decreaseIndentIf(indented); } writePunctuation(">"); } @@ -194387,7 +200134,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 319 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 320 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -194403,7 +200150,7 @@ var ts; emitJSDocTypeExpression(tag.typeExpression); emitJSDocComment(tag.comment); } - function emitJSDocAugmentsTag(tag) { + function emitJSDocHeritageTag(tag) { emitJSDocTagName(tag.tagName); writeSpace(); writePunctuation("{"); @@ -194574,8 +200321,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_21 = types; _d < types_21.length; _d++) { - var directive = types_21[_d]; + for (var _d = 0, types_22 = types; _d < types_22.length; _d++) { + var directive = types_22[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -194802,7 +200549,7 @@ var ts; } } function emitDecorators(parentNode, decorators) { - emitList(parentNode, decorators, 49153 /* Decorators */); + emitList(parentNode, decorators, 2146305 /* Decorators */); } function emitTypeArguments(parentNode, typeArguments) { emitList(parentNode, typeArguments, 53776 /* TypeArguments */); @@ -194901,7 +200648,7 @@ var ts; } if (isEmpty) { // Write a line terminator if the parent node was multi-line - if (format & 1 /* MultiLine */) { + if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) { writeLine(); } else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) { @@ -194912,8 +200659,9 @@ var ts; // Write the opening line terminator or leading whitespace. var mayEmitInterveningComments = (format & 262144 /* NoInterveningComments */) === 0; var shouldEmitInterveningComments = mayEmitInterveningComments; - if (shouldWriteLeadingLineTerminator(parentNode, children, format)) { // TODO: GH#18217 - writeLine(); + var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); // TODO: GH#18217 + if (leadingLineTerminatorCount) { + writeLine(leadingLineTerminatorCount); shouldEmitInterveningComments = false; } else if (format & 256 /* SpaceBetweenBraces */) { @@ -194948,14 +200696,15 @@ var ts; writeDelimiter(format); recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write either a line terminator or whitespace to separate the elements. - if (shouldWriteSeparatingLineTerminator(previousSibling, child, format)) { + var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format); + if (separatingLineTerminatorCount > 0) { // If a synthesized node in a single-line list starts on a new // line, we should increase the indent. if ((format & (3 /* LinesMask */ | 128 /* Indented */)) === 0 /* SingleLine */) { increaseIndent(); shouldDecreaseIndentAfterEmit = true; } - writeLine(); + writeLine(separatingLineTerminatorCount); shouldEmitInterveningComments = false; } else if (previousSibling && format & 512 /* SpaceBetweenSiblings */) { @@ -195000,10 +200749,11 @@ var ts; } recordBundleFileInternalSectionEnd(previousSourceFileTextKind); // Write the closing line terminator or closing whitespace. - if (shouldWriteClosingLineTerminator(parentNode, children, format)) { - writeLine(); + var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format); + if (closingLineTerminatorCount) { + writeLine(closingLineTerminatorCount); } - else if (format & 256 /* SpaceBetweenBraces */) { + else if (format & (2097152 /* SpaceAfterList */ | 256 /* SpaceBetweenBraces */)) { writeSpace(); } } @@ -195055,8 +200805,11 @@ var ts; function writeProperty(s) { writer.writeProperty(s); } - function writeLine() { - writer.writeLine(); + function writeLine(count) { + if (count === void 0) { count = 1; } + for (var i = 0; i < count; i++) { + writer.writeLine(i > 0); + } } function increaseIndent() { writer.increaseIndent(); @@ -195103,10 +200856,10 @@ var ts; } } } - function increaseIndentIf(value, writeSpaceIfNotIndenting) { - if (value) { + function writeLinesAndIndent(lineCount, writeSpaceIfNotIndenting) { + if (lineCount) { increaseIndent(); - writeLine(); + writeLine(lineCount); } else if (writeSpaceIfNotIndenting) { writeSpace(); @@ -195124,69 +200877,113 @@ var ts; decreaseIndent(); } } - function shouldWriteLeadingLineTerminator(parentNode, children, format) { - if (format & 1 /* MultiLine */) { - return true; - } - if (format & 2 /* PreserveLines */) { + function getLeadingLineTerminatorCount(parentNode, children, format) { + if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { if (format & 65536 /* PreferNewLine */) { - return true; + return 1; } - var firstChild = children[0]; - if (firstChild === undefined) { - return !ts.rangeIsOnSingleLine(parentNode, currentSourceFile); + var firstChild_1 = children[0]; + if (firstChild_1 === undefined) { + return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - else if (ts.positionIsSynthesized(parentNode.pos) || ts.nodeIsSynthesized(firstChild)) { - return synthesizedNodeStartsOnNewLine(firstChild, format); + if (firstChild_1.kind === 11 /* JsxText */) { + // JsxText will be written with its leading whitespace, so don't add more manually. + return 0; } - else { - return !ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild, currentSourceFile); + if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(firstChild_1) && (!firstChild_1.parent || firstChild_1.parent === parentNode)) { + if (preserveSourceNewlines) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); }); + } + return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1; + } + if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) { + return 1; } } - else { - return false; - } + return format & 1 /* MultiLine */ ? 1 : 0; } - function shouldWriteSeparatingLineTerminator(previousNode, nextNode, format) { - if (format & 1 /* MultiLine */) { - return true; - } - else if (format & 2 /* PreserveLines */) { + function getSeparatingLineTerminatorCount(previousNode, nextNode, format) { + if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { if (previousNode === undefined || nextNode === undefined) { - return false; + return 0; } - else if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format); + if (nextNode.kind === 11 /* JsxText */) { + // JsxText will be written with its leading whitespace, so don't add more manually. + return 0; } - else { - return !ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile); + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) { + if (preserveSourceNewlines) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { + return 1; } } - else { - return ts.getStartsOnNewLine(nextNode); + else if (ts.getStartsOnNewLine(nextNode)) { + return 1; } + return format & 1 /* MultiLine */ ? 1 : 0; } - function shouldWriteClosingLineTerminator(parentNode, children, format) { - if (format & 1 /* MultiLine */) { - return (format & 131072 /* NoTrailingNewLine */) === 0; - } - else if (format & 2 /* PreserveLines */) { + function getClosingLineTerminatorCount(parentNode, children, format) { + if (format & 2 /* PreserveLines */ || preserveSourceNewlines) { if (format & 65536 /* PreferNewLine */) { - return true; + return 1; } - var lastChild = ts.lastOrUndefined(children); - if (lastChild === undefined) { - return !ts.rangeIsOnSingleLine(parentNode, currentSourceFile); + var lastChild_1 = ts.lastOrUndefined(children); + if (lastChild_1 === undefined) { + return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } - else if (ts.positionIsSynthesized(parentNode.pos) || ts.nodeIsSynthesized(lastChild)) { - return synthesizedNodeStartsOnNewLine(lastChild, format); + if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild_1) && (!lastChild_1.parent || lastChild_1.parent === parentNode)) { + if (preserveSourceNewlines) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(lastChild_1.end, parentNode.end, currentSourceFile, includeComments); }); + } + return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild_1, currentSourceFile) ? 0 : 1; } - else { - return !ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild, currentSourceFile); + if (synthesizedNodeStartsOnNewLine(lastChild_1, format)) { + return 1; } } - else { - return false; + if (format & 1 /* MultiLine */ && !(format & 131072 /* NoTrailingNewLine */)) { + return 1; + } + return 0; + } + function getEffectiveLines(getLineDifference) { + // If 'preserveSourceNewlines' is disabled, we should never call this function + // because it could be more expensive than alternative approximations. + ts.Debug.assert(!!preserveSourceNewlines); + // We start by measuring the line difference from a position to its adjacent comments, + // so that this is counted as a one-line difference, not two: + // + // node1; + // // NODE2 COMMENT + // node2; + var lines = getLineDifference(/*includeComments*/ true); + if (lines === 0) { + // However, if the line difference considering comments was 0, we might have this: + // + // node1; // NODE2 COMMENT + // node2; + // + // in which case we should be ignoring node2's comment, so this too is counted as + // a one-line difference, not zero. + return getLineDifference(/*includeComments*/ false); + } + return lines; + } + function writeLineSeparatorsAndIndentBefore(node, parent) { + var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0 /* None */); + if (leadingNewlines) { + writeLinesAndIndent(leadingNewlines, /*writeLinesIfNotIndenting*/ false); + } + return !!leadingNewlines; + } + function writeLineSeparatorsAfter(node, parent) { + var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0 /* None */); + if (trailingNewlines) { + writeLine(trailingNewlines); } } function synthesizedNodeStartsOnNewLine(node, format) { @@ -195199,21 +200996,24 @@ var ts; } return (format & 65536 /* PreferNewLine */) !== 0; } - function needsIndentation(parent, node1, node2) { + function getLinesBetweenNodes(parent, node1, node2) { if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { - return false; + return 0; } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); // Always use a newline for synthesized code if the synthesizer desires it. if (ts.getStartsOnNewLine(node2)) { - return true; + return 1; + } + if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) { + if (preserveSourceNewlines) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); }); + } + return ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1; } - return !ts.nodeIsSynthesized(parent) - && !ts.nodeIsSynthesized(node1) - && !ts.nodeIsSynthesized(node2) - && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); + return 0; } function isEmptyBlock(block) { return block.statements.length === 0 @@ -195622,7 +201422,7 @@ var ts; hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 324 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 325 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -195905,7 +201705,7 @@ var ts; else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 324 /* NotEmittedStatement */ + if (node.kind !== 325 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -195918,7 +201718,7 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 324 /* NotEmittedStatement */ + if (node.kind !== 325 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); @@ -196378,7 +202178,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } return ts.forEachAncestorDirectory(searchPath, function (ancestor) { @@ -196703,12 +202502,6 @@ var ts; return formatStyle + text + resetEscapeSequence; } ts.formatColorAndReset = formatColorAndReset; - function padLeft(s, length) { - while (s.length < length) { - s = " " + s; - } - return s; - } function formatCodeSpan(file, start, length, indent, squiggleColor, host) { var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character; @@ -196724,7 +202517,7 @@ var ts; // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, // so we'll skip ahead to the second-to-last line. if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - context += indent + formatColorAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); + context += indent + formatColorAndReset(ts.padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); i = lastLine - 1; } var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); @@ -196733,10 +202526,10 @@ var ts; lineContent = lineContent.replace(/\s+$/g, ""); // trim from end lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. - context += indent + formatColorAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; + context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; context += lineContent + host.getNewLine(); // Output the gutter and the error span for the line using tildes. - context += indent + formatColorAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; + context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; context += squiggleColor; if (i === firstLine) { // If we're on the last line, then limit it to the last character of the last line. @@ -196788,11 +202581,11 @@ var ts; if (diagnostic.relatedInformation) { output += host.getNewLine(); for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) { - var _c = _b[_a], file = _c.file, start = _c.start, length_7 = _c.length, messageText = _c.messageText; + var _c = _b[_a], file = _c.file, start = _c.start, length_8 = _c.length, messageText = _c.messageText; if (file) { output += host.getNewLine(); output += halfIndent + formatLocation(file, start, host); // TODO: GH#18217 - output += formatCodeSpan(file, start, length_7, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 + output += formatCodeSpan(file, start, length_8, indent, ForegroundColorEscapeSequences.Cyan, host); // TODO: GH#18217 } output += host.getNewLine(); output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine()); @@ -196895,7 +202688,7 @@ var ts; hasInvalidatedResolution(sourceFile.path); } function sourceFileVersionUptoDate(sourceFile) { - return sourceFile.version === getSourceVersion(sourceFile.resolvedPath); + return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName); } function projectReferenceUptoDate(oldRef, newRef, index) { if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) { @@ -196954,6 +202747,7 @@ var ts; }; } function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { + var _a; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; @@ -197000,10 +202794,10 @@ var ts; var hasEmitBlockingDiagnostics = ts.createMap(); var _compilerOptionsObjectLiteralSyntax; var moduleResolutionCache; - var resolveModuleNamesWorker; + var actualResolveModuleNamesWorker; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; if (host.resolveModuleNames) { - resolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.assertEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { + actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) { // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName. if (!resolved || resolved.extension !== undefined) { return resolved; @@ -197016,15 +202810,15 @@ var ts; else { moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options); var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; }; // TODO: GH#18217 - resolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; + actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); }; } - var resolveTypeReferenceDirectiveNamesWorker; + var actualResolveTypeReferenceDirectiveNamesWorker; if (host.resolveTypeReferenceDirectives) { - resolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.assertEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; + actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); }; } else { var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; }; // TODO: GH#18217 - resolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.assertEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; + actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); }; } // Map from a stringified PackageId to the source file with that id. // Only one source file may have a given packageId. Others become redirects (see createRedirectSourceFile). @@ -197050,7 +202844,16 @@ var ts; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; var mapFromToProjectReferenceRedirectSource; - var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); + var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) && + !options.disableSourceOfProjectReferenceRedirect; + var _b = updateHostForUseSourceOfProjectReferenceRedirect({ + compilerHost: host, + useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect, + toPath: toPath, + getResolvedProjectReferences: getResolvedProjectReferences, + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }), onProgramCreateComplete = _b.onProgramCreateComplete, fileExists = _b.fileExists; var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. @@ -197063,12 +202866,6 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } - if (host.setResolvedProjectReferenceCallbacks) { - host.setResolvedProjectReferenceCallbacks({ - getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, - forEachResolvedProjectReference: forEachResolvedProjectReference - }); - } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; @@ -197077,8 +202874,8 @@ var ts; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; if (useSourceOfProjectReferenceRedirect) { if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); } } @@ -197088,8 +202885,8 @@ var ts; processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); } else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { - var fileName = _d[_c]; + for (var _e = 0, _f = parsedRef.commandLine.fileNames; _e < _f.length; _e++) { + var fileName = _f[_e]; if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && !ts.fileExtensionIs(fileName, ".json" /* Json */)) { processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); } @@ -197141,8 +202938,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { - var oldSourceFile = oldSourceFiles_1[_e]; + for (var _g = 0, oldSourceFiles_1 = oldSourceFiles; _g < oldSourceFiles_1.length; _g++) { + var oldSourceFile = oldSourceFiles_1[_g]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -197185,6 +202982,7 @@ var ts; getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); }, getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); }, getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); }, + getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); }, getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); }, getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, @@ -197206,12 +203004,29 @@ var ts; forEachResolvedProjectReference: forEachResolvedProjectReference, isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, emitBuildInfo: emitBuildInfo, - getProbableSymlinks: getProbableSymlinks + fileExists: fileExists, + getProbableSymlinks: getProbableSymlinks, + useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, }; + onProgramCreateComplete(); verifyCompilerOptions(); ts.performance.mark("afterProgram"); ts.performance.measure("Program", "beforeProgram", "afterProgram"); return program; + function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference) { + ts.performance.mark("beforeResolveModule"); + var result = actualResolveModuleNamesWorker(moduleNames, containingFile, reusedNames, redirectedReference); + ts.performance.mark("afterResolveModule"); + ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule"); + return result; + } + function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference) { + ts.performance.mark("beforeResolveTypeReference"); + var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile, redirectedReference); + ts.performance.mark("afterResolveTypeReference"); + ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference"); + return result; + } function compareDefaultLibFiles(a, b) { return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b)); } @@ -197285,13 +203100,13 @@ var ts; // which per above occurred during the current program creation. // Since we assume the filesystem does not change during program creation, // it is safe to reuse resolutions from the earlier call. - var result_8 = []; + var result_11 = []; for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) { var moduleName = moduleNames_1[_i]; var resolvedModule = file.resolvedModules.get(moduleName); - result_8.push(resolvedModule); + result_11.push(resolvedModule); } - return result_8; + return result_11; } // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules @@ -197439,12 +203254,6 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); - if (host.setResolvedProjectReferenceCallbacks) { - host.setResolvedProjectReferenceCallbacks({ - getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, - forEachResolvedProjectReference: forEachResolvedProjectReference - }); - } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -197639,11 +203448,26 @@ var ts; return oldProgram.structureIsReused = 2 /* Completely */; } function getEmitHost(writeFileCallback) { - return __assign(__assign({ getPrependNodes: getPrependNodes, - getCanonicalFileName: getCanonicalFileName, getCommonSourceDirectory: program.getCommonSourceDirectory, getCompilerOptions: program.getCompilerOptions, getCurrentDirectory: function () { return currentDirectory; }, getNewLine: function () { return host.getNewLine(); }, getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + return { + getPrependNodes: getPrependNodes, + getCanonicalFileName: getCanonicalFileName, + getCommonSourceDirectory: program.getCommonSourceDirectory, + getCompilerOptions: program.getCompilerOptions, + getCurrentDirectory: function () { return currentDirectory; }, + getNewLine: function () { return host.getNewLine(); }, + getSourceFile: program.getSourceFile, + getSourceFileByPath: program.getSourceFileByPath, + getSourceFiles: program.getSourceFiles, + getLibFileFromReference: program.getLibFileFromReference, + isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProjectReferenceRedirect: getProjectReferenceRedirect, isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, - getProbableSymlinks: getProbableSymlinks, writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), isEmitBlocked: isEmitBlocked, readFile: function (f) { return host.readFile(f); }, fileExists: function (f) { + getProbableSymlinks: getProbableSymlinks, + writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }), + isEmitBlocked: isEmitBlocked, + readFile: function (f) { return host.readFile(f); }, + fileExists: function (f) { // Use local caches var path = toPath(f); if (getSourceFileByPath(path)) @@ -197652,7 +203476,12 @@ var ts; return false; // Before falling back to the host return host.fileExists(f); - } }, (host.directoryExists ? { directoryExists: function (f) { return host.directoryExists(f); } } : {})), { useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, redirectTargetsMap: redirectTargetsMap }); + }, + useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); }, + getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); }, + getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); }, + redirectTargetsMap: redirectTargetsMap, + }; } function emitBuildInfo(writeFileCallback) { ts.Debug.assert(!options.out && !options.outFile); @@ -197768,19 +203597,19 @@ var ts; } var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - var diagnostics; - for (var _i = 0, _a = [fileProcessingDiagnosticsInFile, programDiagnosticsInFile]; _i < _a.length; _i++) { - var diags = _a[_i]; - if (diags) { - for (var _b = 0, diags_4 = diags; _b < diags_4.length; _b++) { - var diag = diags_4[_b]; - if (shouldReportDiagnostic(diag)) { - diagnostics = ts.append(diagnostics, diag); - } - } - } + return getMergedProgramDiagnostics(sourceFile, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + } + function getMergedProgramDiagnostics(sourceFile) { + var _a; + var allDiagnostics = []; + for (var _i = 1; _i < arguments.length; _i++) { + allDiagnostics[_i - 1] = arguments[_i]; } - return diagnostics || ts.emptyArray; + var flatDiagnostics = ts.flatten(allDiagnostics); + if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { + return flatDiagnostics; + } + return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics).diagnostics; } function getDeclarationDiagnostics(sourceFile, cancellationToken) { var options = program.getCompilerOptions(); @@ -197844,57 +203673,74 @@ var ts; sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; - var diagnostics; - for (var _i = 0, _a = [bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined]; _i < _a.length; _i++) { - var diags = _a[_i]; - if (diags) { - for (var _b = 0, diags_5 = diags; _b < diags_5.length; _b++) { - var diag = diags_5[_b]; - if (shouldReportDiagnostic(diag)) { - diagnostics = ts.append(diagnostics, diag); - } - } - } - } - return diagnostics || ts.emptyArray; + return getMergedBindAndCheckDiagnostics(sourceFile, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined); }); } + function getMergedBindAndCheckDiagnostics(sourceFile) { + var _a; + var allDiagnostics = []; + for (var _i = 1; _i < arguments.length; _i++) { + allDiagnostics[_i - 1] = arguments[_i]; + } + var flatDiagnostics = ts.flatten(allDiagnostics); + if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) { + return flatDiagnostics; + } + var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives; + for (var _c = 0, _d = directives.getUnusedExpectations(); _c < _d.length; _c++) { + var errorExpectation = _d[_c]; + diagnostics.push(ts.createDiagnosticForRange(sourceFile, errorExpectation.range, ts.Diagnostics.Unused_ts_expect_error_directive)); + } + return diagnostics; + } + /** + * Creates a map of comment directives along with the diagnostics immediately preceded by one of them. + * Comments that match to any of those diagnostics are marked as used. + */ + function getDiagnosticsWithPrecedingDirectives(sourceFile, commentDirectives, flatDiagnostics) { + // Diagnostics are only reported if there is no comment directive preceding them + // This will modify the directives map by marking "used" ones with a corresponding diagnostic + var directives = ts.createCommentDirectivesMap(sourceFile, commentDirectives); + var diagnostics = flatDiagnostics.filter(function (diagnostic) { return markPrecedingCommentDirectiveLine(diagnostic, directives) === -1; }); + return { diagnostics: diagnostics, directives: directives }; + } function getSuggestionDiagnostics(sourceFile, cancellationToken) { return runWithCancellationToken(function () { return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken); }); } /** - * Skip errors if previous line start with '// @ts-ignore' comment, not counting non-empty non-comment lines + * @returns The line index marked as preceding the diagnostic, or -1 if none was. */ - function shouldReportDiagnostic(diagnostic) { + function markPrecedingCommentDirectiveLine(diagnostic, directives) { var file = diagnostic.file, start = diagnostic.start; - if (file) { - var lineStarts = ts.getLineStarts(file); - var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; // TODO: GH#18217 - while (line > 0) { - var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); - var result = ignoreDiagnosticCommentRegEx.exec(previousLineText); - if (!result) { - // non-empty line - return true; - } - if (result[3]) { - // @ts-ignore - return false; - } - line--; + if (!file) { + return -1; + } + // Start out with the line just before the text + var lineStarts = ts.getLineStarts(file); + var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line - 1; // TODO: GH#18217 + while (line >= 0) { + // As soon as that line is known to have a comment directive, use that + if (directives.markUsed(line)) { + return line; + } + // Stop searching if the line is not empty and not a comment + var lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim(); + if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) { + return -1; } + line--; } - return true; + return -1; } function getJSSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; - var parent = sourceFile; - walk(sourceFile); + walk(sourceFile, sourceFile); + ts.forEachChildRecursively(sourceFile, walk, walkArray); return diagnostics; - function walk(node) { + function walk(node, parent) { // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { @@ -197903,7 +203749,7 @@ var ts; case 161 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); - return; + return "skip"; } // falls through case 160 /* MethodSignature */: @@ -197917,70 +203763,66 @@ var ts; // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; } } switch (node.kind) { case 255 /* ImportClause */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node.parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type")); - return; + return "skip"; } break; case 260 /* ExportDeclaration */: if (node.isTypeOnly) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type")); - return; + return "skip"; } break; case 253 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; case 259 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; } break; case 279 /* HeritageClause */: var heritageClause = node; if (heritageClause.token === 113 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; } break; case 246 /* InterfaceDeclaration */: var interfaceKeyword = ts.tokenToString(114 /* InterfaceKeyword */); - ts.Debug.assertDefined(interfaceKeyword); + ts.Debug.assertIsDefined(interfaceKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword)); - return; + return "skip"; case 249 /* ModuleDeclaration */: var moduleKeyword = node.flags & 16 /* Namespace */ ? ts.tokenToString(136 /* NamespaceKeyword */) : ts.tokenToString(135 /* ModuleKeyword */); - ts.Debug.assertDefined(moduleKeyword); + ts.Debug.assertIsDefined(moduleKeyword); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword)); - return; + return "skip"; case 247 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; case 248 /* EnumDeclaration */: - var enumKeyword = ts.Debug.assertDefined(ts.tokenToString(88 /* EnumKeyword */)); + var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(88 /* EnumKeyword */)); diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword)); - return; + return "skip"; case 218 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; case 217 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; case 199 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } - var prevParent = parent; - parent = node; - ts.forEachChild(node, walk, walkArray); - parent = prevParent; } - function walkArray(nodes) { + function walkArray(nodes, parent) { if (parent.decorators === nodes && !options.experimentalDecorators) { diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } @@ -197997,13 +203839,14 @@ var ts; // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; } // falls through case 225 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(parent.modifiers, parent.kind === 225 /* VariableStatement */); + checkModifiers(parent.modifiers, parent.kind === 225 /* VariableStatement */); + return "skip"; } break; case 159 /* PropertyDeclaration */: @@ -198015,14 +203858,14 @@ var ts; diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind))); } } - return; + return "skip"; } break; case 156 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; } break; case 196 /* CallExpression */: @@ -198034,14 +203877,10 @@ var ts; // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files)); - return; + return "skip"; } break; } - for (var _b = 0, nodes_6 = nodes; _b < nodes_6.length; _b++) { - var node = nodes_6[_b]; - walk(node); - } } function checkModifiers(modifiers, isConstValid) { for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { @@ -198304,7 +204143,7 @@ var ts; } var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); }); if (fail && !sourceFileWithAddedExtension) - fail(ts.Diagnostics.File_0_not_found, fileName + ".ts" /* Ts */); + fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'"); return sourceFileWithAddedExtension; } } @@ -198836,7 +204675,7 @@ var ts; projectReferenceRedirects.set(sourceFilePath, false); return undefined; } - sourceFile = ts.Debug.assertDefined(commandLine.options.configFile); + sourceFile = ts.Debug.checkDefined(commandLine.options.configFile); ts.Debug.assert(!sourceFile.path || sourceFile.path === sourceFilePath); addFileToFilesByName(sourceFile, sourceFilePath, /*redirectedPath*/ undefined); } @@ -199100,7 +204939,7 @@ var ts; for (var _i = 2; _i < arguments.length; _i++) { args[_i - 2] = arguments[_i]; } - var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var refFile = ts.Debug.checkDefined(getSourceFileByPath(refPathToReportErrorOn.file)); var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; var pos, end; switch (kind) { @@ -199299,6 +205138,156 @@ var ts; } } ts.createProgram = createProgram; + function updateHostForUseSourceOfProjectReferenceRedirect(host) { + var mapOfDeclarationDirectories; + var symlinkedDirectories; + var symlinkedFiles; + var originalFileExists = host.compilerHost.fileExists; + var originalDirectoryExists = host.compilerHost.directoryExists; + var originalGetDirectories = host.compilerHost.getDirectories; + var originalRealpath = host.compilerHost.realpath; + if (!host.useSourceOfProjectReferenceRedirect) + return { onProgramCreateComplete: ts.noop, fileExists: fileExists }; + host.compilerHost.fileExists = fileExists; + if (originalDirectoryExists) { + // This implementation of directoryExists checks if the directory being requested is + // directory of .d.ts file for the referenced Project. + // If it is it returns true irrespective of whether that directory exists on host + host.compilerHost.directoryExists = function (path) { + if (originalDirectoryExists.call(host.compilerHost, path)) { + handleDirectoryCouldBeSymlink(path); + return true; + } + if (!host.getResolvedProjectReferences()) + return false; + if (!mapOfDeclarationDirectories) { + mapOfDeclarationDirectories = ts.createMap(); + host.forEachResolvedProjectReference(function (ref) { + if (!ref) + return; + var out = ref.commandLine.options.outFile || ref.commandLine.options.out; + if (out) { + mapOfDeclarationDirectories.set(ts.getDirectoryPath(host.toPath(out)), true); + } + else { + // Set declaration's in different locations only, if they are next to source the directory present doesnt change + var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir; + if (declarationDir) { + mapOfDeclarationDirectories.set(host.toPath(declarationDir), true); + } + } + }); + } + return fileOrDirectoryExistsUsingSource(path, /*isFile*/ false); + }; + } + if (originalGetDirectories) { + // Call getDirectories only if directory actually present on the host + // This is needed to ensure that we arent getting directories that we fake about presence for + host.compilerHost.getDirectories = function (path) { + return !host.getResolvedProjectReferences() || (originalDirectoryExists && originalDirectoryExists.call(host.compilerHost, path)) ? + originalGetDirectories.call(host.compilerHost, path) : + []; + }; + } + // This is something we keep for life time of the host + if (originalRealpath) { + host.compilerHost.realpath = function (s) { + return (symlinkedFiles === null || symlinkedFiles === void 0 ? void 0 : symlinkedFiles.get(host.toPath(s))) || + originalRealpath.call(host.compilerHost, s); + }; + } + return { onProgramCreateComplete: onProgramCreateComplete, fileExists: fileExists }; + function onProgramCreateComplete() { + host.compilerHost.fileExists = originalFileExists; + host.compilerHost.directoryExists = originalDirectoryExists; + host.compilerHost.getDirectories = originalGetDirectories; + // DO not revert realpath as it could be used later + } + // This implementation of fileExists checks if the file being requested is + // .d.ts file for the referenced Project. + // If it is it returns true irrespective of whether that file exists on host + function fileExists(file) { + if (originalFileExists.call(host.compilerHost, file)) + return true; + if (!host.getResolvedProjectReferences()) + return false; + if (!ts.isDeclarationFileName(file)) + return false; + // Project references go to source file instead of .d.ts file + return fileOrDirectoryExistsUsingSource(file, /*isFile*/ true); + } + function fileExistsIfProjectReferenceDts(file) { + var source = host.getSourceOfProjectReferenceRedirect(file); + return source !== undefined ? + ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true : + undefined; + } + function directoryExistsIfProjectReferenceDeclDir(dir) { + var dirPath = host.toPath(dir); + var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + return ts.forEachKey(mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || + // Any parent directory of declaration dir + ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) || + // Any directory inside declaration dir + ts.startsWith(dirPath, declDirPath + "/"); }); + } + function handleDirectoryCouldBeSymlink(directory) { + if (!host.getResolvedProjectReferences()) + return; + // Because we already watch node_modules, handle symlinks in there + if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart)) + return; + if (!symlinkedDirectories) + symlinkedDirectories = ts.createMap(); + var directoryPath = ts.ensureTrailingDirectorySeparator(host.toPath(directory)); + if (symlinkedDirectories.has(directoryPath)) + return; + var real = ts.normalizePath(originalRealpath.call(host.compilerHost, directory)); + var realPath; + if (real === directory || + (realPath = ts.ensureTrailingDirectorySeparator(host.toPath(real))) === directoryPath) { + // not symlinked + symlinkedDirectories.set(directoryPath, false); + return; + } + symlinkedDirectories.set(directoryPath, { + real: ts.ensureTrailingDirectorySeparator(real), + realPath: realPath + }); + } + function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) { + var fileOrDirectoryExistsUsingSource = isFile ? + function (file) { return fileExistsIfProjectReferenceDts(file); } : + function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); }; + // Check current directory or file + var result = fileOrDirectoryExistsUsingSource(fileOrDirectory); + if (result !== undefined) + return result; + if (!symlinkedDirectories) + return false; + var fileOrDirectoryPath = host.toPath(fileOrDirectory); + if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart)) + return false; + if (isFile && symlinkedFiles && symlinkedFiles.has(fileOrDirectoryPath)) + return true; + // If it contains node_modules check if its one of the symlinked path we know of + return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) { + var directoryPath = _a[0], symlinkedDirectory = _a[1]; + if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath)) + return undefined; + var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath)); + if (isFile && result) { + if (!symlinkedFiles) + symlinkedFiles = ts.createMap(); + // Store the real path for the file' + var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory()); + symlinkedFiles.set(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + } + return result; + }) || false; + } + } /*@internal*/ function handleNoEmitOptions(program, sourceFile, cancellationToken) { var options = program.getCompilerOptions(); @@ -199325,7 +205314,7 @@ var ts; return { fileExists: function (f) { return directoryStructureHost.fileExists(f); }, readDirectory: function (root, extensions, excludes, includes, depth) { - ts.Debug.assertDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'"); + ts.Debug.assertIsDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'"); return directoryStructureHost.readDirectory(root, extensions, excludes, includes, depth); }, readFile: function (f) { return directoryStructureHost.readFile(f); }, @@ -199413,8 +205402,8 @@ var ts; (function (ts) { function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); - return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; + var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit; + return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); } @@ -199543,7 +205532,7 @@ var ts; // Create the reference map, and set the file infos for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - var version_1 = ts.Debug.assertDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set"); + var version_1 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set"); var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined; if (referencedMap) { var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName); @@ -199558,7 +205547,7 @@ var ts; } } } - fileInfos.set(sourceFile.resolvedPath, { version: version_1, signature: oldInfo && oldInfo.signature }); + fileInfos.set(sourceFile.resolvedPath, { version: version_1, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) }); } return { fileInfos: fileInfos, @@ -199622,12 +205611,14 @@ var ts; * This should be called whenever it is safe to commit the state of the builder */ function updateSignaturesFromCache(state, signatureCache) { - signatureCache.forEach(function (signature, path) { - state.fileInfos.get(path).signature = signature; - state.hasCalledUpdateShapeSignature.set(path, true); - }); + signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); }); } BuilderState.updateSignaturesFromCache = updateSignaturesFromCache; + function updateSignatureOfFile(state, signature, path) { + state.fileInfos.get(path).signature = signature; + state.hasCalledUpdateShapeSignature.set(path, true); + } + BuilderState.updateSignatureOfFile = updateSignatureOfFile; /** * Returns if the shape of the signature has changed since last emit */ @@ -199806,7 +205797,8 @@ var ts; return state.allFilesExcludingDefaultLibraryFile; } var result; - addSourceFile(firstSourceFile); + if (firstSourceFile) + addSourceFile(firstSourceFile); for (var _i = 0, _a = programOfThisState.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; if (sourceFile !== firstSourceFile) { @@ -199821,6 +205813,7 @@ var ts; } } } + BuilderState.getAllFilesExcludingDefaultLibraryFile = getAllFilesExcludingDefaultLibraryFile; /** * When program emits non modular code, gets the files affected by the sourceFile whose shape has changed */ @@ -199919,6 +205912,7 @@ var ts; state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; + state.seenAffectedFiles = ts.createMap(); } } // Update changed files and copy semantic diagnostics if we can @@ -199961,11 +205955,16 @@ var ts; } } }); - if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { + // If the global file is removed, add all files as changed + if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) { + ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, /*firstSourceFile*/ undefined) + .forEach(function (file) { return state.changedFilesSet.set(file.resolvedPath, true); }); + } + else if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1 /* Full */); }); - ts.Debug.assert(state.seenAffectedFiles === undefined); - state.seenAffectedFiles = ts.createMap(); + ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); + state.seenAffectedFiles = state.seenAffectedFiles || ts.createMap(); } state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit; return state; @@ -200070,7 +206069,7 @@ var ts; } // With --out or --outFile all outputs go into single file // so operations are performed directly on program, return program - var program = ts.Debug.assertDefined(state.program); + var program = ts.Debug.checkDefined(state.program); var compilerOptions = program.getCompilerOptions(); if (compilerOptions.outFile || compilerOptions.out) { ts.Debug.assert(!state.semanticDiagnosticsPerFile); @@ -200095,10 +206094,10 @@ var ts; if (affectedFilesPendingEmit) { var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { - var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); + var affectedFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); if (affectedFile) { var seenKind = seenEmittedFiles.get(affectedFile.resolvedPath); - var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath)); + var emitKind = ts.Debug.checkDefined(ts.Debug.checkDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath)); if (seenKind === undefined || seenKind < emitKind) { // emit this file state.affectedFilesPendingEmitIndex = i; @@ -200122,7 +206121,7 @@ var ts; if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) { if (!state.cleanedDiagnosticsOfLibFiles) { state.cleanedDiagnosticsOfLibFiles = true; - var program_1 = ts.Debug.assertDefined(state.program); + var program_1 = ts.Debug.checkDefined(state.program); var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && @@ -200143,14 +206142,14 @@ var ts; function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) { removeSemanticDiagnosticsOf(state, path); if (!state.changedFilesSet.has(path)) { - var program = ts.Debug.assertDefined(state.program); + var program = ts.Debug.checkDefined(state.program); var sourceFile = program.getSourceFileByPath(path); if (sourceFile) { // Even though the js emit doesnt change and we are already handling dts emit and semantic diagnostics // we need to update the signature to reflect correctness of the signature(which is output d.ts emit) of this file // This ensures that we dont later during incremental builds considering wrong signature. // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build - ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); + ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); @@ -200172,8 +206171,8 @@ var ts; return !state.semanticDiagnosticsFromOldState.size; } function isChangedSignagure(state, path) { - var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); - var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.checkDefined(state.fileInfos.get(path)).signature; return newSignature !== oldSignagure; } /** @@ -200199,7 +206198,7 @@ var ts; seenFileNamesMap.set(currentPath, true); var result = fn(state, currentPath); if (result && isChangedSignagure(state, currentPath)) { - var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath); queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); } } @@ -200312,7 +206311,7 @@ var ts; * bindAndCheckDiagnostics (from cache) and program diagnostics */ function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) { - return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.assertDefined(state.program).getProgramDiagnostics(sourceFile)); + return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile)); } /** * Gets the binder and checker diagnostics either from cache if present, or otherwise from program and caches it @@ -200328,7 +206327,7 @@ var ts; } } // Diagnostics werent cached, get them from program, and cache the result - var diagnostics = ts.Debug.assertDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken); + var diagnostics = ts.Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken); if (state.semanticDiagnosticsPerFile) { state.semanticDiagnosticsPerFile.set(path, diagnostics); } @@ -200340,49 +206339,54 @@ var ts; function getProgramBuildInfo(state, getCanonicalFileName) { if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; - var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); + var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory(); var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); - fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature }; + fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope }; }); var result = { fileInfos: fileInfos, options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath) }; if (state.referencedMap) { - var referencedMap_1 = {}; - state.referencedMap.forEach(function (value, key) { - referencedMap_1[relativeToBuildInfo(key)] = ts.arrayFrom(value.keys(), relativeToBuildInfo); - }); - result.referencedMap = referencedMap_1; + var referencedMap = {}; + for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { + var key = _a[_i]; + referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); + } + result.referencedMap = referencedMap; } if (state.exportedModulesMap) { - var exportedModulesMap_1 = {}; - state.exportedModulesMap.forEach(function (value, key) { + var exportedModulesMap = {}; + for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) { + var key = _c[_b]; var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key); // Not in temporary cache, use existing value if (newValue === undefined) - exportedModulesMap_1[relativeToBuildInfo(key)] = ts.arrayFrom(value.keys(), relativeToBuildInfo); + exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); // Value in cache and has updated value map, use that else if (newValue) - exportedModulesMap_1[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo); - }); - result.exportedModulesMap = exportedModulesMap_1; + exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive); + } + result.exportedModulesMap = exportedModulesMap; } if (state.semanticDiagnosticsPerFile) { - var semanticDiagnosticsPerFile_1 = []; - // Currently not recording actual errors since those mean no emit for tsc --build - state.semanticDiagnosticsPerFile.forEach(function (value, key) { return semanticDiagnosticsPerFile_1.push(value.length ? - [ - relativeToBuildInfo(key), - state.hasReusableDiagnostic ? - value : - convertToReusableDiagnostics(value, relativeToBuildInfo) - ] : - relativeToBuildInfo(key)); }); - result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile_1; + var semanticDiagnosticsPerFile = []; + for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) { + var key = _e[_d]; + var value = state.semanticDiagnosticsPerFile.get(key); + semanticDiagnosticsPerFile.push(value.length ? + [ + relativeToBuildInfo(key), + state.hasReusableDiagnostic ? + value : + convertToReusableDiagnostics(value, relativeToBuildInfo) + ] : + relativeToBuildInfo(key)); + } + result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile; } return result; function relativeToBuildInfoEnsuringAbsolutePath(path) { @@ -200506,10 +206510,10 @@ var ts; backupState = cloneBuilderProgramState(state); }; builderProgram.restoreState = function () { - state = ts.Debug.assertDefined(backupState); + state = ts.Debug.checkDefined(backupState); backupState = undefined; }; - builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.assertDefined(state.program), sourceFile); }; + builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); }; builderProgram.getSemanticDiagnostics = getSemanticDiagnostics; builderProgram.emit = emit; builderProgram.releaseProgram = function () { @@ -200543,7 +206547,7 @@ var ts; if (state.emittedBuildInfo) { return undefined; } - var affected_1 = ts.Debug.assertDefined(state.program); + var affected_1 = ts.Debug.checkDefined(state.program); return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file @@ -200555,7 +206559,7 @@ var ts; isPendingEmitFile = true; } else { - var program = ts.Debug.assertDefined(state.program); + var program = ts.Debug.checkDefined(state.program); if (state.programEmitComplete) return undefined; affected = program; @@ -200564,7 +206568,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); + ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -200604,7 +206608,7 @@ var ts; }; } } - return ts.Debug.assertDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); + return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); } /** * Return the semantic diagnostics for the next affected file or undefined if iteration is complete @@ -200644,11 +206648,11 @@ var ts; */ function getSemanticDiagnostics(sourceFile, cancellationToken) { assertSourceFileOkWithoutNextAffectedCall(state, sourceFile); - var compilerOptions = ts.Debug.assertDefined(state.program).getCompilerOptions(); + var compilerOptions = ts.Debug.checkDefined(state.program).getCompilerOptions(); if (compilerOptions.outFile || compilerOptions.out) { ts.Debug.assert(!state.semanticDiagnosticsPerFile); // We dont need to cache the diagnostics just return them from program - return ts.Debug.assertDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken); + return ts.Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken); } if (sourceFile) { return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken); @@ -200659,7 +206663,7 @@ var ts; while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; - for (var _i = 0, _a = ts.Debug.assertDefined(state.program).getSourceFiles(); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.Debug.checkDefined(state.program).getSourceFiles(); _i < _a.length; _i++) { var sourceFile_1 = _a[_i]; diagnostics = ts.addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile_1, cancellationToken)); } @@ -200767,7 +206771,7 @@ var ts; close: ts.noop, }; function getProgram() { - return ts.Debug.assertDefined(state.program); + return ts.Debug.checkDefined(state.program); } } ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram; @@ -200845,13 +206849,13 @@ var ts; return true; } ts.canWatchDirectory = canWatchDirectory; - ts.maxNumberOfFilesToIterateForInvalidation = 256; function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) { var filesWithChangedSetOfUnresolvedImports; var filesWithInvalidatedResolutions; var filesWithInvalidatedNonRelativeUnresolvedImports; - var allFilesHaveInvalidatedResolution = false; var nonRelativeExternalModuleResolutions = ts.createMultiMap(); + var resolutionsWithFailedLookups = []; + var resolvedFileToResolution = ts.createMultiMap(); var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); }); // TODO: GH#18217 var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost(); // The resolvedModuleNames and resolvedTypeReferenceDirectives are the cache of resolutions per file. @@ -200915,7 +206919,8 @@ var ts; closeTypeRootsWatch(); resolvedModuleNames.clear(); resolvedTypeReferenceDirectives.clear(); - allFilesHaveInvalidatedResolution = false; + resolvedFileToResolution.clear(); + resolutionsWithFailedLookups.length = 0; // perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update // (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution) clearPerDirectoryResolutions(); @@ -200937,7 +206942,7 @@ var ts; return !!value && !!value.length; } function createHasInvalidatedResolution(forceAllFilesAsInvalidated) { - if (allFilesHaveInvalidatedResolution || forceAllFilesAsInvalidated) { + if (forceAllFilesAsInvalidated) { // Any file asked would have invalidated resolution filesWithInvalidatedResolutions = undefined; return ts.returnTrue; @@ -200955,7 +206960,6 @@ var ts; nonRelativeExternalModuleResolutions.clear(); } function finishCachingPerDirectoryResolution() { - allFilesHaveInvalidatedResolution = false; filesWithInvalidatedNonRelativeUnresolvedImports = undefined; clearPerDirectoryResolutions(); directoryWatchesOfFailedLookups.forEach(function (watcher, path) { @@ -200966,6 +206970,7 @@ var ts; }); } function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) { + var _a; var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference); // return result immediately only if global cache support is not enabled or if it is .ts, .tsx or .d.ts if (!resolutionHost.getGlobalCache) { @@ -200976,15 +206981,20 @@ var ts; if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) { // create different collection of failed lookup locations for second pass // if it will fail and we've already found something during the first pass - we don't want to pollute its results - var _a = ts.loadModuleFromGlobalCache(ts.Debug.assertDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations; + var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations; if (resolvedModule) { - return { resolvedModule: resolvedModule, failedLookupLocations: ts.addRange(primaryResult.failedLookupLocations, failedLookupLocations) }; + // Modify existing resolution so its saved in the directory cache as well + primaryResult.resolvedModule = resolvedModule; + (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations); + return primaryResult; } } // Default return the result from the first pass return primaryResult; } - function resolveNamesWithLocalCache(names, containingFile, redirectedReference, cache, perDirectoryCacheWithRedirects, loader, getResolutionWithResolvedFileName, shouldRetryResolution, reusedNames, logChanges) { + function resolveNamesWithLocalCache(_a) { + var _b; + var names = _a.names, containingFile = _a.containingFile, redirectedReference = _a.redirectedReference, cache = _a.cache, perDirectoryCacheWithRedirects = _a.perDirectoryCacheWithRedirects, loader = _a.loader, getResolutionWithResolvedFileName = _a.getResolutionWithResolvedFileName, shouldRetryResolution = _a.shouldRetryResolution, reusedNames = _a.reusedNames, logChanges = _a.logChanges; var path = resolutionHost.toPath(containingFile); var resolutionsInFile = cache.get(path) || cache.set(path, ts.createMap()).get(path); var dirPath = ts.getDirectoryPath(path); @@ -201009,7 +207019,7 @@ var ts; var resolution = resolutionsInFile.get(name); // Resolution is valid if it is present and not invalidated if (!seenNamesInFile.has(name) && - allFilesHaveInvalidatedResolution || unmatchedRedirects || !resolution || resolution.isInvalidated || + unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) { var existingResolution = resolution; @@ -201018,13 +207028,13 @@ var ts; resolution = resolutionInDirectory; } else { - resolution = loader(name, containingFile, compilerOptions, resolutionHost, redirectedReference); + resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference); perDirectoryResolution.set(name, resolution); } resolutionsInFile.set(name, resolution); - watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution); + watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName); if (existingResolution) { - stopWatchFailedLookupLocationOfResolution(existingResolution); + stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName); } if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) { filesWithChangedSetOfUnresolvedImports.push(path); @@ -201039,7 +207049,7 @@ var ts; // Stop watching and remove the unused name resolutionsInFile.forEach(function (resolution, name) { if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) { - stopWatchFailedLookupLocationOfResolution(resolution); + stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName); resolutionsInFile.delete(name); } }); @@ -201063,21 +207073,35 @@ var ts; } } function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) { - return resolveNamesWithLocalCache(typeDirectiveNames, containingFile, redirectedReference, resolvedTypeReferenceDirectives, perDirectoryResolvedTypeReferenceDirectives, ts.resolveTypeReferenceDirective, getResolvedTypeReferenceDirective, - /*shouldRetryResolution*/ function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, - /*reusedNames*/ undefined, /*logChanges*/ false); + return resolveNamesWithLocalCache({ + names: typeDirectiveNames, + containingFile: containingFile, + redirectedReference: redirectedReference, + cache: resolvedTypeReferenceDirectives, + perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives, + loader: ts.resolveTypeReferenceDirective, + getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective, + shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; }, + }); } function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) { - return resolveNamesWithLocalCache(moduleNames, containingFile, redirectedReference, resolvedModuleNames, perDirectoryResolvedModuleNames, resolveModuleName, getResolvedModule, - /*shouldRetryResolution*/ function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, reusedNames, logChangesWhenResolvingModule); + return resolveNamesWithLocalCache({ + names: moduleNames, + containingFile: containingFile, + redirectedReference: redirectedReference, + cache: resolvedModuleNames, + perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames, + loader: resolveModuleName, + getResolutionWithResolvedFileName: getResolvedModule, + shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); }, + reusedNames: reusedNames, + logChanges: logChangesWhenResolvingModule + }); } function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) { var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile)); return cache && cache.get(moduleName); } - function isNodeModulesDirectory(dirPath) { - return ts.endsWith(dirPath, "/node_modules"); - } function isNodeModulesAtTypesDirectory(dirPath) { return ts.endsWith(dirPath, "/node_modules/@types"); } @@ -201113,7 +207137,7 @@ var ts; dirPath = ts.getDirectoryPath(dirPath); } // If the directory is node_modules use it to watch, always watch it recursively - if (isNodeModulesDirectory(dirPath)) { + if (ts.isNodeModulesDirectory(dirPath)) { return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined; } var nonRecursive = true; @@ -201137,26 +207161,33 @@ var ts; function isPathWithDefaultFailedLookupExtension(path) { return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions); } - function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution) { - // No need to set the resolution refCount - if (resolution.failedLookupLocations && resolution.failedLookupLocations.length) { - if (resolution.refCount) { - resolution.refCount++; + function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) { + if (resolution.refCount) { + resolution.refCount++; + ts.Debug.assertDefined(resolution.files); + } + else { + resolution.refCount = 1; + ts.Debug.assert(resolution.files === undefined); + if (ts.isExternalModuleNameRelative(name)) { + watchFailedLookupLocationOfResolution(resolution); } else { - resolution.refCount = 1; - if (ts.isExternalModuleNameRelative(name)) { - watchFailedLookupLocationOfResolution(resolution); - } - else { - nonRelativeExternalModuleResolutions.add(name, resolution); - } + nonRelativeExternalModuleResolutions.add(name, resolution); + } + var resolved = getResolutionWithResolvedFileName(resolution); + if (resolved && resolved.resolvedFileName) { + resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution); } } + (resolution.files || (resolution.files = [])).push(filePath); } function watchFailedLookupLocationOfResolution(resolution) { ts.Debug.assert(!!resolution.refCount); var failedLookupLocations = resolution.failedLookupLocations; + if (!failedLookupLocations.length) + return; + resolutionsWithFailedLookups.push(resolution); var setAtRoot = false; for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) { var failedLookupLocation = failedLookupLocations_1[_i]; @@ -201184,14 +207215,11 @@ var ts; setDirectoryWatcher(rootDir, rootPath, /*nonRecursive*/ true); // TODO: GH#18217 } } - function setRefCountToUndefined(resolution) { - resolution.refCount = undefined; - } function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) { var program = resolutionHost.getCurrentProgram(); - var updateResolution = program && program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name) ? - setRefCountToUndefined : watchFailedLookupLocationOfResolution; - resolutions.forEach(updateResolution); + if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) { + resolutions.forEach(watchFailedLookupLocationOfResolution); + } } function setDirectoryWatcher(dir, dirPath, nonRecursive) { var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath); @@ -201203,14 +207231,20 @@ var ts; directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive }); } } - function stopWatchFailedLookupLocationOfResolution(resolution) { - if (!resolution.refCount) { - return; - } + function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) { + ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath); resolution.refCount--; if (resolution.refCount) { return; } + var resolved = getResolutionWithResolvedFileName(resolution); + if (resolved && resolved.resolvedFileName) { + resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution); + } + if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) { + // If not watching failed lookups, it wont be there in resolutionsWithFailedLookups + return; + } var failedLookupLocations = resolution.failedLookupLocations; var removeAtRoot = false; for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) { @@ -201253,16 +207287,16 @@ var ts; // Since the file existence changed, update the sourceFiles cache cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); } - if (!allFilesHaveInvalidatedResolution && invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { + if (invalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath)) { resolutionHost.onInvalidatedResolution(); } }, nonRecursive ? 0 /* None */ : 1 /* Recursive */); } - function removeResolutionsOfFileFromCache(cache, filePath) { + function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) { // Deleted file, stop watching failed lookups for all the resolutions in the file var resolutions = cache.get(filePath); if (resolutions) { - resolutions.forEach(stopWatchFailedLookupLocationOfResolution); + resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); }); cache.delete(filePath); } } @@ -201283,57 +207317,26 @@ var ts; resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); }); } function removeResolutionsOfFile(filePath) { - removeResolutionsOfFileFromCache(resolvedModuleNames, filePath); - removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath); - } - function invalidateResolutionCache(cache, isInvalidatedResolution, getResolutionWithResolvedFileName) { - var seen = ts.createMap(); - cache.forEach(function (resolutions, containingFilePath) { - var dirPath = ts.getDirectoryPath(containingFilePath); - var seenInDir = seen.get(dirPath); - if (!seenInDir) { - seenInDir = ts.createMap(); - seen.set(dirPath, seenInDir); - } - resolutions.forEach(function (resolution, name) { - if (seenInDir.has(name)) { - return; - } - seenInDir.set(name, true); - if (!resolution.isInvalidated && isInvalidatedResolution(resolution, getResolutionWithResolvedFileName)) { - // Mark the file as needing re-evaluation of module resolution instead of using it blindly. - resolution.isInvalidated = true; - (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); - // When its a file with inferred types resolution, invalidate type reference directive resolution - if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { - resolutionHost.onChangedAutomaticTypeDirectiveNames(); - } - } - }); - }); - } - function hasReachedResolutionIterationLimit() { - var maxSize = resolutionHost.maxNumberOfFilesToIterateForInvalidation || ts.maxNumberOfFilesToIterateForInvalidation; - return resolvedModuleNames.size > maxSize || resolvedTypeReferenceDirectives.size > maxSize; - } - function invalidateResolutions(isInvalidatedResolution) { - // If more than maxNumberOfFilesToIterateForInvalidation present, - // just invalidated all files and recalculate the resolutions for files instead - if (hasReachedResolutionIterationLimit()) { - allFilesHaveInvalidatedResolution = true; - return; + removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule); + removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective); + } + function invalidateResolution(resolution) { + resolution.isInvalidated = true; + var changedInAutoTypeReferenced = false; + for (var _i = 0, _a = ts.Debug.assertDefined(resolution.files); _i < _a.length; _i++) { + var containingFilePath = _a[_i]; + (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + changedInAutoTypeReferenced = changedInAutoTypeReferenced || containingFilePath.endsWith(ts.inferredTypesContainingFile); + } + if (changedInAutoTypeReferenced) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); } - invalidateResolutionCache(resolvedModuleNames, isInvalidatedResolution, getResolvedModule); - invalidateResolutionCache(resolvedTypeReferenceDirectives, isInvalidatedResolution, getResolvedTypeReferenceDirective); } function invalidateResolutionOfFile(filePath) { removeResolutionsOfFile(filePath); - invalidateResolutions( // Resolution is invalidated if the resulting file name is same as the deleted file path - function (resolution, getResolutionWithResolvedFileName) { - var result = getResolutionWithResolvedFileName(resolution); - return !!result && resolutionHost.toPath(result.resolvedFileName) === filePath; // TODO: GH#18217 - }); + ts.forEach(resolvedFileToResolution.get(filePath), invalidateResolution); } function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) { ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined); @@ -201359,8 +207362,8 @@ var ts; // Some file or directory in the watching directory is created // Return early if it does not have any of the watching extension or not the custom failed lookup path var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath); - if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || isNodeModulesDirectory(fileOrDirectoryPath) || - isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || isNodeModulesDirectory(dirOfFileOrDirectory)) { + if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) || + isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) { // Invalidate any resolution from this directory isChangedFailedLookupLocation = function (location) { var locationPath = resolutionHost.toPath(location); @@ -201379,20 +207382,21 @@ var ts; isChangedFailedLookupLocation = function (location) { return resolutionHost.toPath(location) === fileOrDirectoryPath; }; } } - var hasChangedFailedLookupLocation = function (resolution) { return ts.some(resolution.failedLookupLocations, isChangedFailedLookupLocation); }; - var invalidatedFilesCount = filesWithInvalidatedResolutions && filesWithInvalidatedResolutions.size; - invalidateResolutions( + var invalidated = false; // Resolution is invalidated if the resulting file name is same as the deleted file path - hasChangedFailedLookupLocation); - return allFilesHaveInvalidatedResolution || filesWithInvalidatedResolutions && filesWithInvalidatedResolutions.size !== invalidatedFilesCount; + for (var _i = 0, resolutionsWithFailedLookups_1 = resolutionsWithFailedLookups; _i < resolutionsWithFailedLookups_1.length; _i++) { + var resolution = resolutionsWithFailedLookups_1[_i]; + if (resolution.failedLookupLocations.some(isChangedFailedLookupLocation)) { + invalidateResolution(resolution); + invalidated = true; + } + } + return invalidated; } function closeTypeRootsWatch() { ts.clearMap(typeRootsWatches, ts.closeFileWatcher); } function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) { - if (allFilesHaveInvalidatedResolution) { - return undefined; - } if (isInDirectoryPath(rootPath, typeRootPath)) { return rootPath; } @@ -201500,39 +207504,39 @@ var ts; ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } - function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { - var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferencesForUpdate(compilerOptions, oldImportSpecifier)); + function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) { + var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier)); if (res === oldImportSpecifier) return undefined; return res; } moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier; // Note: importingSourceFile is just for usesJsExtensionOnImports - function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, files, preferences, redirectTargetsMap) { + function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) { if (preferences === void 0) { preferences = {}; } - return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); + return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; - function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) { var info = getInfo(importingSourceFileName, host); - var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); } moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; - function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { + function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) { var info = getInfo(importingSourceFileName, host); - var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } /** Returns an import for each symlink and for the realpath. */ - function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { + function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, userPreferences) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) return [ambient]; var info = getInfo(importingSourceFile.path, host); var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol)); - var modulePaths = getAllModulePaths(files, importingSourceFile.path, moduleSourceFile.originalFileName, info.getCanonicalFileName, host, redirectTargetsMap); + var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host); var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile); var global = ts.mapDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }); return global.length ? global : modulePaths.map(function (moduleFileName) { return getLocalModuleSpecifier(moduleFileName, info, compilerOptions, preferences); }); @@ -201591,45 +207595,67 @@ var ts; function comparePathsByNumberOfDirectorySeparators(a, b) { return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } - /** - * Looks for existing imports that use symlinks to this module. - * Symlinks will be returned first so they are preferred over the real path. - */ - function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { - var redirects = redirectTargetsMap.get(importedFileName); - var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; - var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; + function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) { + var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + var cwd = host.getCurrentDirectory(); + var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined; + var redirects = host.redirectTargetsMap.get(ts.toPath(importedFileName, cwd, getCanonicalFileName)) || ts.emptyArray; + var importedFileNames = __spreadArrays((referenceRedirect ? [referenceRedirect] : ts.emptyArray), [importedFileName], redirects); var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); + if (!preferSymlinks) { + var result_12 = ts.forEach(targets, cb); + if (result_12) + return result_12; + } var links = host.getProbableSymlinks - ? host.getProbableSymlinks(files) - : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); - var result = []; + ? host.getProbableSymlinks(host.getSourceFiles()) + : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd); var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; - links.forEach(function (resolved, path) { + var result = ts.forEachEntry(links, function (resolved, path) { if (ts.startsWithDirectory(importingFileName, resolved, getCanonicalFileName)) { - return; // Don't want to a package to globally import from itself + return undefined; // Don't want to a package to globally import from itself } var target = ts.find(targets, function (t) { return compareStrings(t.slice(0, resolved.length + 1), resolved + "/") === 0 /* EqualTo */; }); if (target === undefined) - return; + return undefined; var relative = ts.getRelativePathFromDirectory(resolved, target, getCanonicalFileName); var option = ts.resolvePath(path, relative); if (!host.fileExists || host.fileExists(option)) { - result.push(option); + var result_13 = cb(option); + if (result_13) + return result_13; } }); - result.push.apply(result, targets); - if (result.length < 2) - return result; + return result || + (preferSymlinks ? ts.forEach(targets, cb) : undefined); + } + moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule; + /** + * Looks for existing imports that use symlinks to this module. + * Symlinks will be returned first so they are preferred over the real path. + */ + function getAllModulePaths(importingFileName, importedFileName, host) { + var cwd = host.getCurrentDirectory(); + var getCanonicalFileName = ts.hostGetCanonicalFileName(host); + var allFileNames = ts.createMap(); + var importedFileFromNodeModules = false; + forEachFileNameOfModule(importingFileName, importedFileName, host, + /*preferSymlinks*/ true, function (path) { + // dont return value, so we collect everything + allFileNames.set(path, getCanonicalFileName(path)); + importedFileFromNodeModules = importedFileFromNodeModules || ts.pathContainsNodeModules(path); + }); // Sort by paths closest to importing file Name directory - var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); var sortedPaths = []; - var _loop_18 = function (directory) { + var _loop_20 = function (directory) { var directoryStart = ts.ensureTrailingDirectorySeparator(directory); var pathsInDirectory; allFileNames.forEach(function (canonicalFileName, fileName) { if (ts.startsWith(canonicalFileName, directoryStart)) { - (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + // If the importedFile is from node modules, use only paths in node_modules folder as option + if (!importedFileFromNodeModules || ts.pathContainsNodeModules(fileName)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + } allFileNames.delete(fileName); } }); @@ -201647,9 +207673,9 @@ var ts; }; var out_directory_1; for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) { - var state_7 = _loop_18(directory); + var state_8 = _loop_20(directory); directory = out_directory_1; - if (state_7 === "break") + if (state_8 === "break") break; } if (allFileNames.size) { @@ -201709,27 +207735,28 @@ var ts; if (!parts) { return undefined; } - var packageJsonContent; - var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); + // Simplify the full file path to something that can be resolved by Node. + var moduleSpecifier = moduleFileName; if (!packageNameOnly) { - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + var packageRootIndex = parts.packageRootIndex; + var moduleFileNameForExtensionless = void 0; + while (true) { + // If the module could be imported by a directory name, use that directory's name + var _b = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _b.moduleFileToTry, packageRootPath = _b.packageRootPath; + if (packageRootPath) { + moduleSpecifier = packageRootPath; + break; + } + if (!moduleFileNameForExtensionless) + moduleFileNameForExtensionless = moduleFileToTry; + // try with next level of directory + packageRootIndex = moduleFileName.indexOf(ts.directorySeparator, packageRootIndex + 1); + if (packageRootIndex === -1) { + moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless); + break; } } } - // Simplify the full file path to something that can be resolved by Node. - // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. @@ -201742,17 +207769,34 @@ var ts; var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName); // For classic resolution, only allow importing from node_modules/@types, not other node_modules return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName; - function getDirectoryOrExtensionlessFileName(path) { - // If the file is the main module, it can be imported by the package name - if (packageJsonContent) { + function tryDirectoryWithPackageJson(packageRootIndex) { + var packageRootPath = moduleFileName.substring(0, packageRootIndex); + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + var moduleFileToTry = moduleFileName; + if (host.fileExists(packageJsonPath)) { + var packageJsonContent = JSON.parse(host.readFile(packageJsonPath)); + var versionPaths = packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(packageRootPath.length + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths); + } + } + // If the file is the main module, it can be imported by the package name var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main; if (ts.isString(mainFileRelative)) { var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName); - if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(path))) { - return packageRootPath; + if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) { + return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry }; } } } + return { moduleFileToTry: moduleFileToTry }; + } + function getExtensionlessFileName(path) { // We still have a file name - remove the extension var fullModulePathWithoutExtension = ts.removeFileExtension(path); // If the file is /index, it can be imported by its directory name @@ -202157,10 +208201,6 @@ var ts; */ function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); - var host = system; - // TODO: `host` is unused! - // eslint-disable-next-line no-unused-expressions - host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -202177,7 +208217,6 @@ var ts; trace: function (s) { return system.write(s + system.newLine); }, createDirectory: function (path) { return system.createDirectory(path); }, writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); }, - onCachedDirectoryStructureHostCreate: function (cacheHost) { return host = cacheHost || system; }, createHash: ts.maybeBind(system, system.createHash), createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram }; @@ -202208,20 +208247,23 @@ var ts; /** * Creates the watch compiler host from system for config file in watch mode */ - function createWatchCompilerHostOfConfigFile(configFileName, optionsToExtend, watchOptionsToExtend, system, createProgram, reportDiagnostic, reportWatchStatus) { + function createWatchCompilerHostOfConfigFile(_a) { + var configFileName = _a.configFileName, optionsToExtend = _a.optionsToExtend, watchOptionsToExtend = _a.watchOptionsToExtend, extraFileExtensions = _a.extraFileExtensions, system = _a.system, createProgram = _a.createProgram, reportDiagnostic = _a.reportDiagnostic, reportWatchStatus = _a.reportWatchStatus; var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system); var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus); host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); }; host.configFileName = configFileName; host.optionsToExtend = optionsToExtend; host.watchOptionsToExtend = watchOptionsToExtend; + host.extraFileExtensions = extraFileExtensions; return host; } ts.createWatchCompilerHostOfConfigFile = createWatchCompilerHostOfConfigFile; /** * Creates the watch compiler host from system for compiling root files and options in watch mode */ - function createWatchCompilerHostOfFilesAndCompilerOptions(rootFiles, options, watchOptions, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferences) { + function createWatchCompilerHostOfFilesAndCompilerOptions(_a) { + var rootFiles = _a.rootFiles, options = _a.options, watchOptions = _a.watchOptions, projectReferences = _a.projectReferences, system = _a.system, createProgram = _a.createProgram, reportDiagnostic = _a.reportDiagnostic, reportWatchStatus = _a.reportWatchStatus; var host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus); host.rootFiles = rootFiles; host.options = options; @@ -202277,12 +208319,30 @@ var ts; return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences); } ts.createIncrementalProgram = createIncrementalProgram; - function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptions) { + function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptionsOrExtraFileExtensions) { if (ts.isArray(rootFilesOrConfigFileName)) { - return ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFilesOrConfigFileName, options, watchOptions, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend); // TODO: GH#18217 + return ts.createWatchCompilerHostOfFilesAndCompilerOptions({ + rootFiles: rootFilesOrConfigFileName, + options: options, + watchOptions: watchOptionsOrExtraFileExtensions, + projectReferences: projectReferencesOrWatchOptionsToExtend, + system: system, + createProgram: createProgram, + reportDiagnostic: reportDiagnostic, + reportWatchStatus: reportWatchStatus, + }); } else { - return ts.createWatchCompilerHostOfConfigFile(rootFilesOrConfigFileName, options, projectReferencesOrWatchOptionsToExtend, system, createProgram, reportDiagnostic, reportWatchStatus); + return ts.createWatchCompilerHostOfConfigFile({ + configFileName: rootFilesOrConfigFileName, + optionsToExtend: options, + watchOptionsToExtend: projectReferencesOrWatchOptionsToExtend, + extraFileExtensions: watchOptionsOrExtraFileExtensions, + system: system, + createProgram: createProgram, + reportDiagnostic: reportDiagnostic, + reportWatchStatus: reportWatchStatus, + }); } } ts.createWatchCompilerHost = createWatchCompilerHost; @@ -202298,16 +208358,13 @@ var ts; var hasChangedAutomaticTypeDirectiveNames = false; // True if the automatic type directives have changed var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var currentDirectory = host.getCurrentDirectory(); - var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, createProgram = host.createProgram; + var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, extraFileExtensions = host.extraFileExtensions, createProgram = host.createProgram; var rootFileNames = host.rootFiles, compilerOptions = host.options, watchOptions = host.watchOptions, projectReferences = host.projectReferences; var configFileSpecs; var configFileParsingDiagnostics; var canConfigFileJsonReportNoInputFiles = false; var hasChangedConfigFileParsingErrors = false; var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames); - if (cachedDirectoryStructureHost && host.onCachedDirectoryStructureHostCreate) { - host.onCachedDirectoryStructureHostCreate(cachedDirectoryStructureHost); - } var directoryStructureHost = cachedDirectoryStructureHost || host; var parseConfigFileHost = ts.parseConfigHostFromCompilerHostLike(host, directoryStructureHost); // From tsc we want to get already parsed result and hence check for rootFileNames @@ -202348,6 +208405,7 @@ var ts; // Members for ResolutionCacheHost compilerHost.toPath = toPath; compilerHost.getCompilationSettings = function () { return compilerOptions; }; + compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect); compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); }; compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(host, dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); }; compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; }; @@ -202357,7 +208415,6 @@ var ts; scheduleProgramUpdate(); }; compilerHost.fileIsOpen = ts.returnFalse; - compilerHost.maxNumberOfFilesToIterateForInvalidation = host.maxNumberOfFilesToIterateForInvalidation; compilerHost.getCurrentProgram = getCurrentProgram; compilerHost.writeLog = writeLog; // Cache for the module resolution @@ -202390,8 +208447,8 @@ var ts; // Update the wild card directory watch watchConfigFileWildCardDirectories(); return configFileName ? - { getCurrentProgram: getCurrentBuilderProgram, getProgram: synchronizeProgram, close: close } : - { getCurrentProgram: getCurrentBuilderProgram, getProgram: synchronizeProgram, updateRootFileNames: updateRootFileNames, close: close }; + { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } : + { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close }; function close() { resolutionCache.clear(); ts.clearMap(sourceFilesCache, function (value) { @@ -202439,7 +208496,7 @@ var ts; else { createNewProgram(hasInvalidatedResolution); } - if (host.afterProgramCreate) { + if (host.afterProgramCreate && program !== builderProgram) { host.afterProgramCreate(builderProgram); } return builderProgram; @@ -202455,6 +208512,7 @@ var ts; resolutionCache.startCachingPerDirectoryResolution(); compilerHost.hasInvalidatedResolution = hasInvalidatedResolution; compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames; + hasChangedAutomaticTypeDirectiveNames = false; builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences); resolutionCache.finishCachingPerDirectoryResolution(); // Update watches @@ -202499,7 +208557,7 @@ var ts; // If file is missing on host from cache, we can definitely say file doesnt exist // otherwise we need to ensure from the disk if (isFileMissingOnHost(sourceFilesCache.get(path))) { - return true; + return false; } return directoryStructureHost.fileExists(fileName); } @@ -202596,16 +208654,19 @@ var ts; host.clearTimeout(timerToUpdateProgram); } writeLog("Scheduling update"); - timerToUpdateProgram = host.setTimeout(updateProgram, 250); + timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250); } function scheduleProgramReload() { ts.Debug.assert(!!configFileName); reloadLevel = ts.ConfigFileProgramReloadLevel.Full; scheduleProgramUpdate(); } - function updateProgram() { + function updateProgramWithWatchStatus() { timerToUpdateProgram = undefined; reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); + updateProgram(); + } + function updateProgram() { switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: ts.perfLogger.logStartUpdateProgram("PartialConfigReload"); @@ -202621,6 +208682,7 @@ var ts; break; } ts.perfLogger.logStopUpdateProgram("Done"); + return getCurrentBuilderProgram(); } function reloadFileNamesFromConfigFile() { writeLog("Reloading new file names and options"); @@ -202645,7 +208707,7 @@ var ts; watchConfigFileWildCardDirectories(); } function parseConfigFile() { - setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend)); // TODO: GH#18217 + setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, /*extendedConfigCache*/ undefined, watchOptionsToExtend, extraFileExtensions)); // TODO: GH#18217 } function setConfigFileParsingResult(configFileParseResult) { rootFileNames = configFileParseResult.fileNames; @@ -202885,7 +208947,7 @@ var ts; if (!compilerHost.resolveModuleNames) { var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; }; compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) { - return ts.loadWithLocalCache(ts.Debug.assertEachDefined(moduleNames), containingFile, redirectedReference, loader_3); + return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3); }; } var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchFilePath = _a.watchFilePath, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog; @@ -203295,14 +209357,14 @@ var ts; } } function getSyntaxDiagnostics(cancellationToken) { - ts.Debug.assertDefined(program); + ts.Debug.assertIsDefined(program); handleDiagnostics(__spreadArrays(program.getConfigFileParsingDiagnostics(), program.getOptionsDiagnostics(cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSyntacticDiagnostics(/*sourceFile*/ undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic"); } function getSemanticDiagnostics(cancellationToken) { - handleDiagnostics(ts.Debug.assertDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); + handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic"); } function emit(writeFileCallback, cancellationToken, customTransformers) { - ts.Debug.assertDefined(program); + ts.Debug.assertIsDefined(program); ts.Debug.assert(step === Step.Emit); // Before emitting lets backup state, so we can revert it back if there are declaration errors to handle emit and declaration errors correctly program.backupState(); @@ -203436,11 +209498,11 @@ var ts; emitBundle(writeFile, customTransformers); break; case Step.BuildInvalidatedProjectOfBundle: - ts.Debug.assertDefined(invalidatedProjectOfBundle).done(cancellationToken); + ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken); step = Step.Done; break; case Step.QueueReferencingProjects: - queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.assertDefined(buildResult)); + queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.checkDefined(buildResult)); step++; break; // Should never be done @@ -204695,6 +210757,7 @@ var ts; placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, semicolons: SemicolonPreference.Ignore, + trimTrailingWhitespace: true }; } ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; @@ -204949,7 +211012,7 @@ var ts; case 247 /* TypeAliasDeclaration */: case 173 /* TypeLiteral */: return 2 /* Type */; - case 321 /* JSDocTypedefTag */: + case 322 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; case 284 /* EnumMember */: @@ -204985,7 +211048,11 @@ var ts; if (node.kind === 290 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 259 /* ExportAssignment */ || node.parent.kind === 265 /* ExternalModuleReference */) { + else if (node.parent.kind === 259 /* ExportAssignment */ + || node.parent.kind === 265 /* ExternalModuleReference */ + || node.parent.kind === 258 /* ImportSpecifier */ + || node.parent.kind === 255 /* ImportClause */ + || ts.isImportEqualsDeclaration(node.parent) && node === node.parent.name) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -205266,8 +211333,8 @@ var ts; return "class" /* classElement */; case 246 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; case 247 /* TypeAliasDeclaration */: - case 314 /* JSDocCallbackTag */: - case 321 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 322 /* JSDocTypedefTag */: return "type" /* typeElement */; case 248 /* EnumDeclaration */: return "enum" /* enumElement */; case 242 /* VariableDeclaration */: @@ -206181,7 +212248,7 @@ var ts; function getPossibleGenericSignatures(called, typeArgumentCount, checker) { var type = checker.getTypeAtLocation(called); if (ts.isOptionalChain(called.parent)) { - type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true); + type = removeOptionality(type, ts.isOptionalChainRoot(called.parent), /*isOptionalChain*/ true); } var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; }); @@ -206404,10 +212471,28 @@ var ts; var range = isInComment(sourceFile, position, /*tokenAtPosition*/ undefined); return !!range && shouldBeReference === tripleSlashDirectivePrefixRegex.test(sourceFile.text.substring(range.pos, range.end)); } + function getReplacementSpanForContextToken(contextToken) { + if (!contextToken) + return undefined; + switch (contextToken.kind) { + case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: + return createTextSpanFromStringLiteralLikeContent(contextToken); + default: + return createTextSpanFromNode(contextToken); + } + } + ts.getReplacementSpanForContextToken = getReplacementSpanForContextToken; function createTextSpanFromNode(node, sourceFile, endNode) { return ts.createTextSpanFromBounds(node.getStart(sourceFile), (endNode || node).getEnd()); } ts.createTextSpanFromNode = createTextSpanFromNode; + function createTextSpanFromStringLiteralLikeContent(node) { + if (node.isUnterminated) + return undefined; + return ts.createTextSpanFromBounds(node.getStart() + 1, node.getEnd() - 1); + } + ts.createTextSpanFromStringLiteralLikeContent = createTextSpanFromStringLiteralLikeContent; function createTextRangeFromNode(node, sourceFile) { return ts.createRange(node.getStart(sourceFile), node.end); } @@ -206492,6 +212577,10 @@ var ts; : ts.isPrivateIdentifier(name) ? ts.idText(name) : ts.getTextOfIdentifierOrLiteral(name); } ts.getNameFromPropertyName = getNameFromPropertyName; + function programContainsModules(program) { + return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!(s.externalModuleIndicator || s.commonJsModuleIndicator); }); + } + ts.programContainsModules = programContainsModules; function programContainsEs6Modules(program) { return program.getSourceFiles().some(function (s) { return !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator; }); } @@ -206500,14 +212589,27 @@ var ts; return !!compilerOptions.module || compilerOptions.target >= 2 /* ES2015 */ || !!compilerOptions.noEmit; } ts.compilerOptionsIndicateEs6Modules = compilerOptionsIndicateEs6Modules; - function hostUsesCaseSensitiveFileNames(host) { - return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false; + function createModuleSpecifierResolutionHost(program, host) { + // Mix in `getProbableSymlinks` from Program when host doesn't have it + // in order for non-Project hosts to have a symlinks cache. + return { + fileExists: function (fileName) { return program.fileExists(fileName); }, + getCurrentDirectory: function () { return host.getCurrentDirectory(); }, + readFile: ts.maybeBind(host, host.readFile), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || (function () { return program.getProbableSymlinks(); }), + getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), + getSourceFiles: function () { return program.getSourceFiles(); }, + redirectTargetsMap: program.redirectTargetsMap, + getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); }, + isSourceOfProjectReferenceRedirect: function (fileName) { return program.isSourceOfProjectReferenceRedirect(fileName); }, + }; } - ts.hostUsesCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames; - function hostGetCanonicalFileName(host) { - return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host)); + ts.createModuleSpecifierResolutionHost = createModuleSpecifierResolutionHost; + function getModuleSpecifierResolverHost(program, host) { + return __assign(__assign({}, createModuleSpecifierResolutionHost(program, host)), { getCommonSourceDirectory: function () { return program.getCommonSourceDirectory(); } }); } - ts.hostGetCanonicalFileName = hostGetCanonicalFileName; + ts.getModuleSpecifierResolverHost = getModuleSpecifierResolverHost; function makeImportIfNecessary(defaultImport, namedImports, moduleSpecifier, quotePreference) { return defaultImport || namedImports && namedImports.length ? makeImport(defaultImport, namedImports, moduleSpecifier, quotePreference) : undefined; } @@ -206628,16 +212730,26 @@ var ts; return node.modifiers && ts.find(node.modifiers, function (m) { return m.kind === kind; }); } ts.findModifier = findModifier; - function insertImport(changes, sourceFile, importDecl, blankLineBetween) { - var lastImportDeclaration = ts.findLast(sourceFile.statements, ts.isAnyImportSyntax); + function insertImports(changes, sourceFile, imports, blankLineBetween) { + var decl = ts.isArray(imports) ? imports[0] : imports; + var importKindPredicate = decl.kind === 225 /* VariableStatement */ ? ts.isRequireVariableDeclarationStatement : ts.isAnyImportSyntax; + var lastImportDeclaration = ts.findLast(sourceFile.statements, function (statement) { return importKindPredicate(statement); }); if (lastImportDeclaration) { - changes.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl); + if (ts.isArray(imports)) { + changes.insertNodesAfter(sourceFile, lastImportDeclaration, imports); + } + else { + changes.insertNodeAfter(sourceFile, lastImportDeclaration, imports); + } + } + else if (ts.isArray(imports)) { + changes.insertNodesAtTopOfFile(sourceFile, imports, blankLineBetween); } else { - changes.insertNodeAtTopOfFile(sourceFile, importDecl, blankLineBetween); + changes.insertNodeAtTopOfFile(sourceFile, imports, blankLineBetween); } } - ts.insertImport = insertImport; + ts.insertImports = insertImports; function getTypeKeywordOfTypeOnlyImport(importClause, sourceFile) { ts.Debug.assert(importClause.isTypeOnly); return ts.cast(importClause.getChildAt(0, sourceFile), isTypeKeywordToken); @@ -206853,8 +212965,8 @@ var ts; * The default is CRLF. */ function getNewLineOrDefaultFromHost(host, formatSettings) { - return (formatSettings && formatSettings.newLineCharacter) || - (host.getNewLine && host.getNewLine()) || + var _a; + return (formatSettings === null || formatSettings === void 0 ? void 0 : formatSettings.newLineCharacter) || ((_a = host.getNewLine) === null || _a === void 0 ? void 0 : _a.call(host)) || carriageReturnLineFeed; } ts.getNewLineOrDefaultFromHost = getNewLineOrDefaultFromHost; @@ -206971,14 +213083,14 @@ var ts; var symbol = checker.getSymbolAtLocation(node.name); var renameInfo = symbol && renameMap.get(String(ts.getSymbolId(symbol))); if (renameInfo && renameInfo.text !== (node.name || node.propertyName).getText()) { - clone = ts.createBindingElement(node.dotDotDotToken, node.propertyName || node.name, renameInfo, node.initializer); + clone = ts.setOriginalNode(ts.createBindingElement(node.dotDotDotToken, node.propertyName || node.name, renameInfo, node.initializer), node); } } else if (renameMap && checker && ts.isIdentifier(node)) { var symbol = checker.getSymbolAtLocation(node); var renameInfo = symbol && renameMap.get(String(ts.getSymbolId(symbol))); if (renameInfo) { - clone = ts.createIdentifier(renameInfo.text); + clone = ts.setOriginalNode(ts.createIdentifier(renameInfo.text), node); } } if (!clone) { @@ -207042,6 +213154,27 @@ var ts; addEmitFlagsRecursively(node, 1024 /* NoTrailingComments */, ts.getLastChild); } ts.suppressTrailingTrivia = suppressTrailingTrivia; + function copyComments(sourceNode, targetNode) { + var sourceFile = sourceNode.getSourceFile(); + var text = sourceFile.text; + if (hasLeadingLineBreak(sourceNode, text)) { + copyLeadingComments(sourceNode, targetNode, sourceFile); + } + else { + copyTrailingAsLeadingComments(sourceNode, targetNode, sourceFile); + } + copyTrailingComments(sourceNode, targetNode, sourceFile); + } + ts.copyComments = copyComments; + function hasLeadingLineBreak(node, text) { + var start = node.getFullStart(); + var end = node.getStart(); + for (var i = start; i < end; i++) { + if (text.charCodeAt(i) === 10 /* lineFeed */) + return true; + } + return false; + } function addEmitFlagsRecursively(node, flag, getChild) { ts.addEmitFlags(node, flag); var child = getChild(node); @@ -207135,6 +213268,11 @@ var ts; idx = change.indexOf('"' + name); return idx === -1 ? -1 : idx + 1; } + /* @internal */ + function needsParentheses(expression) { + return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); + } + ts.needsParentheses = needsParentheses; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { @@ -207154,9 +213292,6 @@ var ts; } ts.getContextualTypeFromParent = getContextualTypeFromParent; function quote(text, preferences) { - if (/^\d+$/.test(text)) { - return text; - } // Editors can pass in undefined or empty string - we want to infer the preference in those cases. var quotePreference = preferences.quotePreference || "auto"; var quoted = JSON.stringify(text); @@ -207204,6 +213339,7 @@ var ts; return checker.getTypeAtLocation(caseClause.parent.parent.expression); } ts.getSwitchedType = getSwitchedType; + ts.ANONYMOUS = "anonymous function"; function getTypeNodeIfAccessible(type, enclosingScope, program, host) { var checker = program.getTypeChecker(); var typeIsAccessible = true; @@ -207215,14 +213351,7 @@ var ts; reportInaccessibleThisError: notAccessible, reportPrivateInBaseOfClassExpression: notAccessible, reportInaccessibleUniqueSymbolError: notAccessible, - moduleResolverHost: { - readFile: host.readFile, - fileExists: host.fileExists, - directoryExists: host.directoryExists, - getSourceFiles: program.getSourceFiles, - getCurrentDirectory: program.getCurrentDirectory, - getCommonSourceDirectory: program.getCommonSourceDirectory, - } + moduleResolverHost: getModuleSpecifierResolverHost(program, host) }); return typeIsAccessible ? res : undefined; } @@ -207543,6 +213672,63 @@ var ts; return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray; } ts.firstOrOnly = firstOrOnly; + function getNameForExportedSymbol(symbol, scriptTarget) { + if (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */) { + // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. + return ts.firstDefined(symbol.declarations, function (d) { return ts.isExportAssignment(d) && ts.isIdentifier(d.expression) ? d.expression.text : undefined; }) + || ts.codefix.moduleSymbolToValidIdentifier(ts.Debug.checkDefined(symbol.parent), scriptTarget); + } + return symbol.name; + } + ts.getNameForExportedSymbol = getNameForExportedSymbol; + /** + * Useful to check whether a string contains another string at a specific index + * without allocating another string or traversing the entire contents of the outer string. + * + * This function is useful in place of either of the following: + * + * ```ts + * // Allocates + * haystack.substr(startIndex, needle.length) === needle + * + * // Full traversal + * haystack.indexOf(needle, startIndex) === startIndex + * ``` + * + * @param haystack The string that potentially contains `needle`. + * @param needle The string whose content might sit within `haystack`. + * @param startIndex The index within `haystack` to start searching for `needle`. + */ + function stringContainsAt(haystack, needle, startIndex) { + var needleLength = needle.length; + if (needleLength + startIndex > haystack.length) { + return false; + } + for (var i = 0; i < needleLength; i++) { + if (needle.charCodeAt(i) !== haystack.charCodeAt(i + startIndex)) + return false; + } + return true; + } + ts.stringContainsAt = stringContainsAt; + function startsWithUnderscore(name) { + return name.charCodeAt(0) === 95 /* _ */; + } + ts.startsWithUnderscore = startsWithUnderscore; + function isGlobalDeclaration(declaration) { + return !isNonGlobalDeclaration(declaration); + } + ts.isGlobalDeclaration = isGlobalDeclaration; + function isNonGlobalDeclaration(declaration) { + var sourceFile = declaration.getSourceFile(); + // If the file is not a module, the declaration is global + if (!sourceFile.externalModuleIndicator && !sourceFile.commonJsModuleIndicator) { + return false; + } + // If the file is a module written in TypeScript, it still might be in a `declare global` augmentation + return ts.isInJSFile(declaration) || !ts.findAncestor(declaration, ts.isGlobalScopeAugmentation); + } + ts.isNonGlobalDeclaration = isNonGlobalDeclaration; // #endregion })(ts || (ts = {})); var ts; @@ -207673,7 +213859,7 @@ var ts; if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); if (lastTemplateStackToken === 15 /* TemplateHead */) { - token = scanner.reScanTemplateToken(); + token = scanner.reScanTemplateToken(/* isTaggedTemplate */ false); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. if (token === 17 /* TemplateTail */) { templateStack.pop(); @@ -208204,18 +214390,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 316 /* JSDocParameterTag */: + case 317 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 320 /* JSDocTemplateTag */: + case 321 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 319 /* JSDocTypeTag */: + case 320 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 317 /* JSDocReturnTag */: + case 318 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -208519,11 +214705,11 @@ var ts; if (!contextToken || !ts.isStringLiteralLike(contextToken)) return undefined; var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host); - return convertStringLiteralCompletions(entries, sourceFile, checker, log, preferences); + return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, preferences); } } StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions; - function convertStringLiteralCompletions(completion, sourceFile, checker, log, preferences) { + function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, preferences) { if (completion === undefined) { return undefined; } @@ -208532,11 +214718,17 @@ var ts; return convertPathCompletions(completion.paths); case 1 /* Properties */: { var entries = []; - Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary + Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences); // Target will not be used, so arbitrary return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, entries: entries }; } case 2 /* Types */: { - var entries = completion.types.map(function (type) { return ({ name: type.value, kindModifiers: "" /* none */, kind: "string" /* string */, sortText: "0" }); }); + var entries = completion.types.map(function (type) { return ({ + name: type.value, + kindModifiers: "" /* none */, + kind: "string" /* string */, + sortText: "0", + replacementSpan: ts.getReplacementSpanForContextToken(contextToken) + }); }); return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: completion.isNewIdentifier, entries: entries }; } default: @@ -208703,7 +214895,9 @@ var ts; function stringLiteralCompletionsFromProperties(type) { return type && { kind: 1 /* Properties */, - symbols: type.getApparentProperties().filter(function (prop) { return !ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration); }), + symbols: type.getApparentProperties().filter(function (prop) { + return !ts.isPrivateIdentifierPropertyDeclaration(ts.isTransientSymbol(prop) && prop.syntheticOrigin ? prop.syntheticOrigin.valueDeclaration : prop.valueDeclaration); + }), hasIndexSignature: ts.hasIndexSignature(type) }; } @@ -209135,6 +215329,22 @@ var ts; SortText["AutoImportSuggestions"] = "5"; SortText["JavascriptIdentifiers"] = "6"; })(SortText = Completions.SortText || (Completions.SortText = {})); + /** + * Special values for `CompletionInfo['source']` used to disambiguate + * completion items with the same `name`. (Each completion item must + * have a unique name/source combination, because those two fields + * comprise `CompletionEntryIdentifier` in `getCompletionEntryDetails`. + * + * When the completion item is an auto-import suggestion, the source + * is the module specifier of the suggestion. To avoid collisions, + * the values here should not be a module specifier we would ever + * generate for an auto-import. + */ + var CompletionSource; + (function (CompletionSource) { + /** Completions that require `this.` insertion text */ + CompletionSource["ThisProperty"] = "ThisProperty/"; + })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {})); var SymbolOriginInfoKind; (function (SymbolOriginInfoKind) { SymbolOriginInfoKind[SymbolOriginInfoKind["ThisType"] = 1] = "ThisType"; @@ -209152,7 +215362,7 @@ var ts; return !!(origin.kind & 2 /* SymbolMember */); } function originIsExport(origin) { - return !!(origin.kind & 4 /* Export */); + return !!(origin && origin.kind & 4 /* Export */); } function originIsPromise(origin) { return !!(origin.kind & 8 /* Promise */); @@ -209282,14 +215492,16 @@ var ts; } var entries = []; if (isUncheckedFile(sourceFile, compilerOptions)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); // TODO: GH#18217 } else { if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { return undefined; } - getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); + getCompletionEntriesFromSymbols(symbols, entries, + /* contextToken */ undefined, location, sourceFile, typeChecker, compilerOptions.target, log, completionKind, preferences, propertyAccessToConvert, completionData.isJsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap); } if (keywordFilters !== 0 /* None */) { var entryNames = ts.arrayToSet(entries, function (e) { return e.name; }); @@ -209302,7 +215514,7 @@ var ts; } for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) { var literal = literals_1[_b]; - entries.push(createCompletionEntryForLiteral(literal)); + entries.push(createCompletionEntryForLiteral(literal, preferences)); } return { isGlobalCompletion: isInSnippetScope, isMemberCompletion: isMemberCompletionKind(completionKind), isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; } @@ -209326,7 +215538,8 @@ var ts; return; } var realName = ts.unescapeLeadingUnderscores(name); - if (ts.addToSeen(uniqueNames, realName) && ts.isIdentifierText(realName, target)) { + if (!uniqueNames.has(realName) && ts.isIdentifierText(realName, target)) { + uniqueNames.add(realName); entries.push({ name: realName, kind: "warning" /* warning */, @@ -209337,26 +215550,27 @@ var ts; } }); } - var completionNameForLiteral = function (literal) { - return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : JSON.stringify(literal); - }; - function createCompletionEntryForLiteral(literal) { - return { name: completionNameForLiteral(literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; + function completionNameForLiteral(literal, preferences) { + return typeof literal === "object" ? ts.pseudoBigIntToString(literal) + "n" : + ts.isString(literal) ? ts.quote(literal, preferences) : JSON.stringify(literal); } - function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { + function createCompletionEntryForLiteral(literal, preferences) { + return { name: completionNameForLiteral(literal, preferences), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority }; + } + function createCompletionEntry(symbol, sortText, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; - var replacementSpan; + var replacementSpan = ts.getReplacementSpanForContextToken(contextToken); var insertQuestionDot = origin && originIsNullableMember(origin); var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; if (origin && originIsThisType(origin)) { insertText = needsConvertPropertyAccess - ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]" + ? "this" + (insertQuestionDot ? "?." : "") + "[" + quotePropertyName(name, preferences) + "]" : "this" + (insertQuestionDot ? "?." : ".") + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { - insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name; + insertText = useBraces ? needsConvertPropertyAccess ? "[" + quotePropertyName(name, preferences) + "]" : "[" + name + "]" : name; if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { insertText = "?." + insertText; } @@ -209411,43 +215625,59 @@ var ts; replacementSpan: replacementSpan, }; } + function quotePropertyName(name, preferences) { + if (/^\d+$/.test(name)) { + return name; + } + return ts.quote(name, preferences); + } function isRecommendedCompletionMatch(localSymbol, recommendedCompletion, checker) { return localSymbol === recommendedCompletion || !!(localSymbol.flags & 1048576 /* ExportValue */) && checker.getExportSymbolOfSymbol(localSymbol) === recommendedCompletion; } function getSourceFromOrigin(origin) { - return origin && originIsExport(origin) ? ts.stripQuotes(origin.moduleSymbol.name) : undefined; + if (originIsExport(origin)) { + return ts.stripQuotes(origin.moduleSymbol.name); + } + if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) { + return CompletionSource.ThisProperty; + } } - function getCompletionEntriesFromSymbols(symbols, entries, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) { + function getCompletionEntriesFromSymbols(symbols, entries, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap) { var start = ts.timestamp(); // Tracks unique names. - // We don't set this for global variables or completions from external module exports, because we can have multiple of those. - // Based on the order we add things we will always see locals first, then globals, then module exports. + // Value is set to false for global variables or completions from external module exports, because we can have multiple of those; + // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports. // So adding a completion for a local will prevent us from adding completions for external module exports sharing the same name. var uniques = ts.createMap(); for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) { var symbol = symbols_1[_i]; var origin = symbolToOriginInfoMap ? symbolToOriginInfoMap[ts.getSymbolId(symbol)] : undefined; - var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind); + var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected); if (!info) { continue; } var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess; - if (uniques.has(name)) { + if (uniques.get(name)) { continue; } - var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences); + var entry = createCompletionEntry(symbol, symbolToSortTextMap && symbolToSortTextMap[ts.getSymbolId(symbol)] || SortText.LocationPriority, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences); if (!entry) { continue; } - // Latter case tests whether this is a global variable. - if (!origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }))) { // TODO: GH#18217 - uniques.set(name, true); - } + /** True for locals; false for globals, module exports from other files, `this.` completions. */ + var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); })); + uniques.set(name, shouldShadowLaterSymbols); entries.push(entry); } log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (ts.timestamp() - start)); - return uniques; + // Prevent consumers of this map from having to worry about + // the boolean value. Externally, it should be seen as the + // set of all names. + return { + has: function (name) { return uniques.has(name); }, + add: function (name) { return uniques.set(name, true); }, + }; } Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols; function getLabelCompletionAtPosition(node) { @@ -209480,7 +215710,7 @@ var ts; } return entries; } - function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) { + function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences) { var compilerOptions = program.getCompilerOptions(); var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { @@ -209490,7 +215720,7 @@ var ts; return { type: "request", request: completionData }; } var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation; - var literal = ts.find(literals, function (l) { return completionNameForLiteral(l) === entryId.name; }); + var literal = ts.find(literals, function (l) { return completionNameForLiteral(l, preferences) === entryId.name; }); if (literal !== undefined) return { type: "literal", literal: literal }; // Find the symbol with the matching entry name. @@ -209499,20 +215729,12 @@ var ts; // completion entry. return ts.firstDefined(symbols, function (symbol) { var origin = symbolToOriginInfoMap[ts.getSymbolId(symbol)]; - var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind); + var info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target, origin, completionKind, completionData.isJsxIdentifierExpected); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source ? { type: "symbol", symbol: symbol, location: location, symbolToOriginInfoMap: symbolToOriginInfoMap, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation } : undefined; }) || { type: "none" }; } - function getSymbolName(symbol, origin, target) { - return origin && originIsExport(origin) && ((origin.isDefaultExport && symbol.escapedName === "default" /* Default */) || - (symbol.escapedName === "export=" /* ExportEquals */)) - // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase. - ? ts.firstDefined(symbol.declarations, function (d) { return ts.isExportAssignment(d) && ts.isIdentifier(d.expression) ? d.expression.text : undefined; }) - || ts.codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) - : symbol.name; - } function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) { var typeChecker = program.getTypeChecker(); var compilerOptions = program.getCompilerOptions(); @@ -209522,7 +215744,7 @@ var ts; return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); } // Compute all the completion symbols again. - var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); + var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences); switch (symbolCompletion.type) { case "request": { var request = symbolCompletion.request; @@ -209544,7 +215766,7 @@ var ts; } case "literal": { var literal = symbolCompletion.literal; - return createSimpleDetails(completionNameForLiteral(literal), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); + return createSimpleDetails(completionNameForLiteral(literal, preferences), "string" /* string */, typeof literal === "string" ? ts.SymbolDisplayPartKind.stringLiteral : ts.SymbolDisplayPartKind.numericLiteral); } case "none": // Didn't find a symbol with this name. See if we can find a keyword instead. @@ -209575,11 +215797,11 @@ var ts; } var moduleSymbol = symbolOriginInfo.moduleSymbol; var exportedSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker)); - var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; + var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } - function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) { - var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); + function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host, preferences) { + var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host, preferences); return completion.type === "symbol" ? completion.symbol : undefined; } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; @@ -209704,7 +215926,7 @@ var ts; currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 322 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 323 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -209744,6 +215966,7 @@ var ts; var isRightOfOpenTag = false; var isStartingCloseTag = false; var isJsxInitializer = false; + var isJsxIdentifierExpected = false; var location = ts.getTouchingPropertyName(sourceFile, position); if (contextToken) { // Bail out if this is a known invalid completion location @@ -209822,6 +216045,7 @@ var ts; case 267 /* JsxSelfClosingElement */: case 266 /* JsxElement */: case 268 /* JsxOpeningElement */: + isJsxIdentifierExpected = true; if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; @@ -209833,6 +216057,7 @@ var ts; isJsxInitializer = true; break; case 75 /* Identifier */: + isJsxIdentifierExpected = true; // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && @@ -209859,7 +216084,8 @@ var ts; getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { - var tagSymbols = ts.Debug.assertEachDefined(typeChecker.getJsxIntrinsicTagNamesAt(location), "getJsxIntrinsicTagNames() should all be defined"); + var tagSymbols = typeChecker.getJsxIntrinsicTagNamesAt(location); + ts.Debug.assertEachIsDefined(tagSymbols, "getJsxIntrinsicTagNames() should all be defined"); tryGetGlobalSymbols(); symbols = tagSymbols.concat(symbols); completionKind = 3 /* MemberLike */; @@ -209902,15 +216128,16 @@ var ts; isJsxInitializer: isJsxInitializer, insideJsDocTagTypeExpression: insideJsDocTagTypeExpression, symbolToSortTextMap: symbolToSortTextMap, - isTypeOnlyLocation: isTypeOnly + isTypeOnlyLocation: isTypeOnly, + isJsxIdentifierExpected: isJsxIdentifierExpected, }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 316 /* JSDocParameterTag */: - case 322 /* JSDocPropertyTag */: - case 317 /* JSDocReturnTag */: - case 319 /* JSDocTypeTag */: - case 321 /* JSDocTypedefTag */: + case 317 /* JSDocParameterTag */: + case 323 /* JSDocPropertyTag */: + case 318 /* JSDocReturnTag */: + case 320 /* JSDocTypeTag */: + case 322 /* JSDocTypedefTag */: return true; default: return false; @@ -209935,7 +216162,8 @@ var ts; symbol = ts.skipAlias(symbol, typeChecker); if (symbol.flags & (1536 /* Module */ | 384 /* Enum */)) { // Extract module or enum members - var exportedSymbols = ts.Debug.assertEachDefined(typeChecker.getExportsOfModule(symbol), "getExportsOfModule() should all be defined"); + var exportedSymbols = typeChecker.getExportsOfModule(symbol); + ts.Debug.assertEachIsDefined(exportedSymbols, "getExportsOfModule() should all be defined"); var isValidValueAccess_1 = function (symbol) { return typeChecker.isValidPropertyAccess(isImportType ? node : (node.parent), symbol.name); }; var isValidTypeAccess_1 = function (symbol) { return symbolCanBeReferencedAtTypeLocation(symbol); }; var isValidAccess = isNamespaceName @@ -210078,6 +216306,7 @@ var ts; function tryGetGlobalSymbols() { var result = tryGetObjectLikeCompletionSymbols() || tryGetImportOrExportClauseCompletionSymbols() + || tryGetLocalNamedExportCompletionSymbols() || tryGetConstructorCompletion() || tryGetClassLikeCompletionSymbols() || tryGetJsxCompletionSymbols() @@ -210147,7 +216376,8 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; isInSnippetScope = isSnippetScope(scopeNode); var symbolMeanings = (isTypeOnly ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */; - symbols = ts.Debug.assertEachDefined(typeChecker.getSymbolsInScope(scopeNode, symbolMeanings), "getSymbolsInScope() should all be defined"); + symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); + ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined"); for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) { var symbol = symbols_2[_i]; if (!typeChecker.isArgumentsSymbol(symbol) && @@ -210158,7 +216388,7 @@ var ts; // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 290 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); - if (thisType) { + if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; @@ -210192,20 +216422,17 @@ var ts; filterGlobalCompletion(symbols); } function shouldOfferImportCompletions() { - // If not already a module, must have modules enabled and not currently be in a commonjs module. (TODO: import completions for commonjs) + // If not already a module, must have modules enabled. if (!preferences.includeCompletionsForModuleExports) return false; // If already using ES6 modules, OK to continue using them. - if (sourceFile.externalModuleIndicator) + if (sourceFile.externalModuleIndicator || sourceFile.commonJsModuleIndicator) return true; - // If already using commonjs, don't introduce ES6. - if (sourceFile.commonJsModuleIndicator) - return false; // If module transpilation is enabled or we're targeting es6 or above, or not emitting, OK. if (ts.compilerOptionsIndicateEs6Modules(program.getCompilerOptions())) return true; // If some file is using ES6 modules, assume that it's OK to add more. - return ts.programContainsEs6Modules(program); + return ts.programContainsModules(program); } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { @@ -210348,6 +216575,7 @@ var ts; var startTime = ts.timestamp(); log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); var seenResolvedModules = ts.createMap(); + var seenExports = ts.createMap(); /** Bucket B */ var aliasesToAlreadyIncludedSymbols = ts.createMap(); /** Bucket C */ @@ -210368,17 +216596,20 @@ var ts; } // Don't add another completion for `export =` of a symbol that's already global. // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - if (resolvedModuleSymbol !== moduleSymbol && - ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator && !ts.findAncestor(d, ts.isGlobalScopeAugmentation); })) { + if (resolvedModuleSymbol !== moduleSymbol && ts.every(resolvedModuleSymbol.declarations, ts.isNonGlobalDeclaration)) { pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true); } - for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { + for (var _i = 0, _a = typeChecker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; + var symbolId = ts.getSymbolId(symbol).toString(); + // `getExportsAndPropertiesOfModule` can include duplicates + if (!ts.addToSeen(seenExports, symbolId)) { + continue; + } // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { continue; } - var symbolId = ts.getSymbolId(symbol).toString(); // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). @@ -210428,7 +216659,7 @@ var ts; var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; results.push({ symbol: symbol, - symbolName: getSymbolName(symbol, origin, target), + symbolName: ts.getNameForExportedSymbol(symbol, target), origin: origin, skipFilter: skipFilter, }); @@ -210617,7 +216848,7 @@ var ts; } if (typeMembers && typeMembers.length > 0) { // Add filtered items to the completion list - symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); + symbols = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)); } setSortTextToOptionalMember(); return 1 /* Success */; @@ -210634,8 +216865,6 @@ var ts; * export { | }; * * Relevant symbols are stored in the captured 'symbols' variable. - * - * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols() { // `import { |` or `import { a as 0, | }` @@ -210643,9 +216872,10 @@ var ts; ? ts.tryCast(contextToken.parent, ts.isNamedImportsOrExports) : undefined; if (!namedImportsOrExports) return 0 /* Continue */; - // cursor is in an import clause - // try to show exported member for imported module + // try to show exported member for imported/re-exported module var moduleSpecifier = (namedImportsOrExports.kind === 257 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + if (!moduleSpecifier) + return namedImportsOrExports.kind === 257 /* NamedImports */ ? 2 /* Fail */ : 0 /* Continue */; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -210656,6 +216886,35 @@ var ts; symbols = exports.filter(function (e) { return e.escapedName !== "default" /* Default */ && !existing.get(e.escapedName); }); return 1 /* Success */; } + /** + * Adds local declarations for completions in named exports: + * + * export { | }; + * + * Does not check for the absence of a module specifier (`export {} from "./other"`) + * because `tryGetImportOrExportClauseCompletionSymbols` runs first and handles that, + * preventing this function from running. + */ + function tryGetLocalNamedExportCompletionSymbols() { + var _a; + var namedExports = contextToken && (contextToken.kind === 18 /* OpenBraceToken */ || contextToken.kind === 27 /* CommaToken */) + ? ts.tryCast(contextToken.parent, ts.isNamedExports) + : undefined; + if (!namedExports) { + return 0 /* Continue */; + } + var localsContainer = ts.findAncestor(namedExports, ts.or(ts.isSourceFile, ts.isModuleDeclaration)); + completionKind = 5 /* None */; + isNewIdentifierLocation = false; + (_a = localsContainer.locals) === null || _a === void 0 ? void 0 : _a.forEach(function (symbol, name) { + var _a, _b; + symbols.push(symbol); + if ((_b = (_a = localsContainer.symbol) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has(name)) { + symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.OptionalMember; + } + }); + return 1 /* Success */; + } /** * Aggregates relevant symbols for completion in class declaration * Relevant symbols are stored in the captured 'symbols' variable. @@ -210884,7 +217143,6 @@ var ts; case 96 /* ImportKeyword */: case 115 /* LetKeyword */: case 81 /* ConstKeyword */: - case 121 /* YieldKeyword */: case 145 /* TypeKeyword */: // type htm| return true; case 41 /* AsteriskToken */: @@ -210921,7 +217179,6 @@ var ts; case 119 /* PublicKeyword */: case 120 /* StaticKeyword */: case 109 /* VarKeyword */: - case 121 /* YieldKeyword */: return true; case 126 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); @@ -211008,7 +217265,7 @@ var ts; }); } } - // Set SortText to OptionalMember if it is an optinoal member + // Set SortText to OptionalMember if it is an optional member function setSortTextToOptionalMember() { symbols.forEach(function (m) { if (m.flags & 16777216 /* Optional */) { @@ -211064,7 +217321,8 @@ var ts; return baseSymbols.filter(function (propertySymbol) { return !existingMemberNames.has(propertySymbol.escapedName) && !!propertySymbol.declarations && - !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */); + !(ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 8 /* Private */) && + !ts.isPrivateIdentifierPropertyDeclaration(propertySymbol.valueDeclaration); }); } /** @@ -211097,8 +217355,8 @@ var ts; return node.getStart(sourceFile) <= position && position <= node.getEnd(); } } - function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind) { - var name = getSymbolName(symbol, origin, target); + function getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, jsxIdentifierExpected) { + var name = originIsExport(origin) ? ts.getNameForExportedSymbol(symbol, target) : symbol.name; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) @@ -211108,7 +217366,7 @@ var ts; return undefined; } var validNameResult = { name: name, needsConvertPropertyAccess: false }; - if (ts.isIdentifierText(name, target) || symbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { + if (ts.isIdentifierText(name, target, jsxIdentifierExpected ? 1 /* JSX */ : 0 /* Standard */) || symbol.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) { return validNameResult; } switch (kind) { @@ -211273,8 +217531,8 @@ var ts; */ function getPropertiesForCompletion(type, checker) { return type.isUnion() - ? ts.Debug.assertEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") - : ts.Debug.assertEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); + ? ts.Debug.checkEachDefined(checker.getAllPossiblePropertiesOfTypes(type.types), "getAllPossiblePropertiesOfTypes() should all be defined") + : ts.Debug.checkEachDefined(type.getApparentProperties(), "getApparentProperties() should all be defined"); } /** * Returns the immediate owning class declaration of a context token, @@ -211283,7 +217541,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 323 /* SyntaxList */: + case 324 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -211291,10 +217549,16 @@ var ts; return cls; } break; - case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } + case 75 /* Identifier */: { + // class c { public prop = c| } + if (ts.isPropertyDeclaration(location.parent) && location.parent.initializer === location) { + return undefined; + } + // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return ts.findAncestor(location, ts.isObjectTypeDeclaration); } + } } if (!contextToken) return undefined; @@ -211362,6 +217626,24 @@ var ts; } } } + /** Determines if a type is exactly the same type resolved by the global 'self', 'global', or 'globalThis'. */ + function isProbablyGlobalType(type, sourceFile, checker) { + // The type of `self` and `window` is the same in lib.dom.d.ts, but `window` does not exist in + // lib.webworker.d.ts, so checking against `self` is also a check against `window` when it exists. + var selfSymbol = checker.resolveName("self", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + if (selfSymbol && checker.getTypeOfSymbolAtLocation(selfSymbol, sourceFile) === type) { + return true; + } + var globalSymbol = checker.resolveName("global", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + if (globalSymbol && checker.getTypeOfSymbolAtLocation(globalSymbol, sourceFile) === type) { + return true; + } + var globalThisSymbol = checker.resolveName("globalThis", /*location*/ undefined, 111551 /* Value */, /*excludeGlobals*/ false); + if (globalThisSymbol && checker.getTypeOfSymbolAtLocation(globalThisSymbol, sourceFile) === type) { + return true; + } + return false; + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -211902,7 +218184,7 @@ var ts; return releaseDocumentWithKey(path, key); } function releaseDocumentWithKey(path, key) { - var bucket = ts.Debug.assertDefined(buckets.get(key)); + var bucket = ts.Debug.checkDefined(buckets.get(key)); var entry = bucket.get(path); entry.languageServiceRefCount--; ts.Debug.assert(entry.languageServiceRefCount >= 0); @@ -212368,7 +218650,7 @@ var ts; } function getExportAssignmentExport(ex) { // Get the symbol for the `export =` node; its parent is the module it's the export of. - var exportingModuleSymbol = ts.Debug.assertDefined(ex.symbol.parent, "Expected export symbol to have a parent"); + var exportingModuleSymbol = ts.Debug.checkDefined(ex.symbol.parent, "Expected export symbol to have a parent"); var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; } @@ -212384,11 +218666,7 @@ var ts; default: return undefined; } - var sym = useLhsSymbol ? checker.getSymbolAtLocation(ts.cast(node.left, ts.isPropertyAccessExpression).name) : symbol; - // Better detection for GH#20803 - if (sym && !(checker.getMergedSymbol(sym.parent).flags & 1536 /* Module */)) { - ts.Debug.fail("Special property assignment kind does not have a module as its parent. Assignment is " + ts.Debug.formatSymbol(sym) + ", parent is " + ts.Debug.formatSymbol(sym.parent)); - } + var sym = useLhsSymbol ? checker.getSymbolAtLocation(ts.getNameOfAccessExpression(ts.cast(node.left, ts.isAccessExpression))) : symbol; return sym && exportInfo(sym, kind); } } @@ -212426,17 +218704,17 @@ var ts; FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; function getExportEqualsLocalSymbol(importedSymbol, checker) { if (importedSymbol.flags & 2097152 /* Alias */) { - return ts.Debug.assertDefined(checker.getImmediateAliasedSymbol(importedSymbol)); + return ts.Debug.checkDefined(checker.getImmediateAliasedSymbol(importedSymbol)); } var decl = importedSymbol.valueDeclaration; if (ts.isExportAssignment(decl)) { // `export = class {}` - return ts.Debug.assertDefined(decl.expression.symbol); + return ts.Debug.checkDefined(decl.expression.symbol); } else if (ts.isBinaryExpression(decl)) { // `module.exports = class {}` - return ts.Debug.assertDefined(decl.right.symbol); + return ts.Debug.checkDefined(decl.right.symbol); } else if (ts.isSourceFile(decl)) { // json module - return ts.Debug.assertDefined(decl.symbol); + return ts.Debug.checkDefined(decl.symbol); } return ts.Debug.fail(); } @@ -212693,7 +218971,29 @@ var ts; FindAllReferences.findReferencedSymbols = findReferencedSymbols; function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) { var node = ts.getTouchingPropertyName(sourceFile, position); - var referenceEntries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); + var referenceEntries; + var entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position); + if (node.parent.kind === 194 /* PropertyAccessExpression */ + || node.parent.kind === 191 /* BindingElement */ + || node.parent.kind === 195 /* ElementAccessExpression */ + || node.kind === 102 /* SuperKeyword */) { + referenceEntries = entries && __spreadArrays(entries); + } + else { + var queue = entries && __spreadArrays(entries); + var seenNodes = ts.createMap(); + while (queue && queue.length) { + var entry = queue.shift(); + if (!ts.addToSeen(seenNodes, ts.getNodeId(entry.node))) { + continue; + } + referenceEntries = ts.append(referenceEntries, entry); + var entries_1 = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, entry.node, entry.node.pos); + if (entries_1) { + queue.push.apply(queue, entries_1); + } + } + } var checker = program.getTypeChecker(); return ts.map(referenceEntries, function (entry) { return toImplementationLocation(entry, checker); }); } @@ -212934,8 +219234,8 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 246 /* InterfaceDeclaration */: - case 314 /* JSDocCallbackTag */: - case 321 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 322 /* JSDocTypedefTag */: case 273 /* JsxAttribute */: case 249 /* ModuleDeclaration */: case 252 /* NamespaceExportDeclaration */: @@ -212961,8 +219261,8 @@ var ts; return !!decl.initializer || ts.isCatchClause(decl.parent); case 160 /* MethodSignature */: case 158 /* PropertySignature */: - case 322 /* JSDocPropertyTag */: - case 316 /* JSDocParameterTag */: + case 323 /* JSDocPropertyTag */: + case 317 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -213119,20 +219419,22 @@ var ts; }; } }); - for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - switch (decl.kind) { - case 290 /* SourceFile */: - // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) - break; - case 249 /* ModuleDeclaration */: - if (sourceFilesSet.has(decl.getSourceFile().fileName)) { - references.push(nodeEntry(decl.name)); - } - break; - default: - // This may be merged with something. - ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + if (symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + switch (decl.kind) { + case 290 /* SourceFile */: + // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) + break; + case 249 /* ModuleDeclaration */: + if (sourceFilesSet.has(decl.getSourceFile().fileName)) { + references.push(nodeEntry(decl.name)); + } + break; + default: + // This may be merged with something. + ts.Debug.assert(!!(symbol.flags & 33554432 /* Transient */), "Expected a module symbol to be declared by a SourceFile or ModuleDeclaration."); + } } } var exported = symbol.exports.get("export=" /* ExportEquals */); @@ -213143,7 +219445,7 @@ var ts; if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : - ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 89 /* ExportKeyword */, sourceFile)) : + ts.isExportAssignment(decl) ? ts.Debug.checkDefined(ts.findChildOfKind(decl, 89 /* ExportKeyword */, sourceFile)) : ts.getNameOfDeclaration(decl) || decl; references.push(nodeEntry(node)); } @@ -213206,7 +219508,7 @@ var ts; } else if (node && node.kind === 84 /* DefaultKeyword */) { addReference(node, symbol, state); - searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); + searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.checkDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } else { var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: node ? populateSearchSymbolSet(symbol, node, checker, options.use === 2 /* Rename */, !!options.providePrefixAndSuffixTextForRename, !!options.implementations) : [symbol] }); @@ -213440,6 +219742,8 @@ var ts; } // Go to the symbol we imported from and find references for it. function searchForImportedSymbol(symbol, state) { + if (!symbol.declarations) + return; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var exportingFile = declaration.getSourceFile(); @@ -213525,17 +219829,19 @@ var ts; return exposedByParent ? scope.getSourceFile() : scope; // TODO: GH#18217 } /** Used as a quick check for whether a symbol is used at all in a file (besides its definition). */ - function isSymbolReferencedInFile(definition, checker, sourceFile) { - return eachSymbolReferenceInFile(definition, checker, sourceFile, function () { return true; }) || false; + function isSymbolReferencedInFile(definition, checker, sourceFile, searchContainer) { + if (searchContainer === void 0) { searchContainer = sourceFile; } + return eachSymbolReferenceInFile(definition, checker, sourceFile, function () { return true; }, searchContainer) || false; } Core.isSymbolReferencedInFile = isSymbolReferencedInFile; - function eachSymbolReferenceInFile(definition, checker, sourceFile, cb) { + function eachSymbolReferenceInFile(definition, checker, sourceFile, cb, searchContainer) { + if (searchContainer === void 0) { searchContainer = sourceFile; } var symbol = ts.isParameterPropertyDeclaration(definition.parent, definition.parent.parent) ? ts.first(checker.getSymbolsOfParameterPropertyDeclaration(definition.parent, definition.text)) : checker.getSymbolAtLocation(definition); if (!symbol) return undefined; - for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _i < _a.length; _i++) { + for (var _i = 0, _a = getPossibleSymbolReferenceNodes(sourceFile, symbol.name, searchContainer); _i < _a.length; _i++) { var token = _a[_i]; if (!ts.isIdentifier(token) || token === definition || token.escapedText !== definition.escapedText) continue; @@ -213553,7 +219859,7 @@ var ts; function eachSignatureCall(signature, sourceFiles, checker, cb) { if (!signature.name || !ts.isIdentifier(signature.name)) return; - var symbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(signature.name)); + var symbol = ts.Debug.checkDefined(checker.getSymbolAtLocation(signature.name)); for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { var sourceFile = sourceFiles_3[_i]; for (var _a = 0, _b = getPossibleSymbolReferenceNodes(sourceFile, symbol.name); _a < _b.length; _a++) { @@ -213740,7 +220046,7 @@ var ts; addRef(); } if (addReferencesHere && state.options.use !== 2 /* Rename */ && state.markSeenReExportRHS(name)) { - addReference(name, ts.Debug.assertDefined(exportSpecifier.symbol), state); + addReference(name, ts.Debug.checkDefined(exportSpecifier.symbol), state); } } else { @@ -213753,7 +220059,7 @@ var ts; var isDefaultExport = referenceLocation.originalKeywordKind === 84 /* DefaultKeyword */ || exportSpecifier.name.originalKeywordKind === 84 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; - var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol); + var exportSymbol = ts.Debug.checkDefined(exportSpecifier.symbol); var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); if (exportInfo) { searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); @@ -213875,7 +220181,7 @@ var ts; */ function findOwnConstructorReferences(classSymbol, sourceFile, addNode) { var constructorSymbol = getClassConstructorSymbol(classSymbol); - if (constructorSymbol) { + if (constructorSymbol && constructorSymbol.declarations) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; var ctrKeyword = ts.findChildOfKind(decl, 129 /* ConstructorKeyword */, sourceFile); @@ -213905,7 +220211,7 @@ var ts; /** Find references to `super` in the constructor of an extending class. */ function findSuperConstructorAccesses(classDeclaration, addNode) { var constructor = getClassConstructorSymbol(classDeclaration.symbol); - if (!constructor) { + if (!(constructor && constructor.declarations)) { return; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { @@ -214030,7 +220336,7 @@ var ts; } // Set the key so that we don't infinitely recurse cachedResults.set(key, false); - var inherits = symbol.declarations.some(function (declaration) { + var inherits = !!symbol.declarations && symbol.declarations.some(function (declaration) { return ts.getAllSuperTypeNodes(declaration).some(function (typeReference) { var type = checker.getTypeAtLocation(typeReference); return !!type && !!type.symbol && explicitlyInheritsFrom(type.symbol, parent, cachedResults, checker); @@ -214415,7 +220721,7 @@ var ts; return node.name; if (isConstNamedExpression(node)) return node.parent.name; - return ts.Debug.assertDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); + return ts.Debug.checkDefined(node.modifiers && ts.find(node.modifiers, isDefaultModifier)); } function isDefaultModifier(node) { return node.kind === 84 /* DefaultKeyword */; @@ -214437,7 +220743,7 @@ var ts; } } var declName = isConstNamedExpression(node) ? node.parent.name : - ts.Debug.assertDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); + ts.Debug.checkDefined(ts.getNameOfDeclaration(node), "Expected call hierarchy item to have a name"); var text = ts.isIdentifier(declName) ? ts.idText(declName) : ts.isStringOrNumericLiteralLike(declName) ? declName.text : ts.isComputedPropertyName(declName) ? @@ -214844,8 +221150,8 @@ var ts; var includes = ts.mapDefined(property.initializer.elements, function (e) { return ts.isStringLiteral(e) ? e.text : undefined; }); var matchers = ts.getFileMatcherPatterns(configDir, /*excludes*/ [], includes, useCaseSensitiveFileNames, currentDirectory); // If there isn't some include for this, add a new one. - if (ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) && - !ts.getRegexFromPattern(ts.Debug.assertDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { + if (ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(oldFileOrDirPath) && + !ts.getRegexFromPattern(ts.Debug.checkDefined(matchers.includeFilePattern), useCaseSensitiveFileNames).test(newFileOrDirPath)) { changeTracker.insertNodeAfter(configFile, ts.last(property.initializer.elements), ts.createStringLiteral(relativePath(newFileOrDirPath))); } } @@ -214924,7 +221230,7 @@ var ts; : getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew); // Need an update if the imported file moved, or the importing file moved and was using a relative path. return toImport !== undefined && (toImport.updated || (importingSourceFileMoved && ts.pathIsRelative(importLiteral.text))) - ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), newImportFromPath, toImport.newFileName, host, allFiles, program.redirectTargetsMap, importLiteral.text) + ? ts.moduleSpecifiers.updateModuleSpecifier(program.getCompilerOptions(), newImportFromPath, toImport.newFileName, ts.createModuleSpecifierResolutionHost(program, host), importLiteral.text) : undefined; }); }; @@ -215249,7 +221555,7 @@ var ts; function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 129 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & (16 /* Function */ | 3 /* Variable */)) && (ts.isNewExpressionTarget(node) || node.kind === 129 /* ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -215442,11 +221748,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 316 /* JSDocParameterTag */: - case 322 /* JSDocPropertyTag */: + case 317 /* JSDocParameterTag */: + case 323 /* JSDocPropertyTag */: return [declaration]; - case 314 /* JSDocCallbackTag */: - case 321 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 322 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -215467,16 +221773,18 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { + case 308 /* JSDocImplementsTag */: + return withNode(tag.class); case 307 /* JSDocAugmentsTag */: return withNode(tag.class); - case 320 /* JSDocTemplateTag */: + case 321 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 319 /* JSDocTypeTag */: + case 320 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 321 /* JSDocTypedefTag */: - case 314 /* JSDocCallbackTag */: - case 322 /* JSDocPropertyTag */: - case 316 /* JSDocParameterTag */: + case 322 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: + case 323 /* JSDocPropertyTag */: + case 317 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -215676,6 +221984,8 @@ var ts; // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. return commentOwner.parent.kind === 249 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 226 /* ExpressionStatement */: + return getCommentOwnerInfoWorker(commentOwner.expression); case 209 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { @@ -215684,6 +221994,11 @@ var ts; var parameters_2 = ts.isFunctionLike(be.right) ? be.right.parameters : ts.emptyArray; return { commentOwner: commentOwner, parameters: parameters_2 }; } + case 159 /* PropertyDeclaration */: + var init = commentOwner.initializer; + if (init && (ts.isFunctionExpression(init) || ts.isArrowFunction(init))) { + return { commentOwner: commentOwner, parameters: init.parameters }; + } } } /** @@ -216507,8 +222822,8 @@ var ts; case 249 /* ModuleDeclaration */: case 290 /* SourceFile */: case 247 /* TypeAliasDeclaration */: - case 321 /* JSDocTypedefTag */: - case 314 /* JSDocCallbackTag */: + case 322 /* JSDocTypedefTag */: + case 315 /* JSDocCallbackTag */: return true; case 202 /* ArrowFunction */: case 244 /* FunctionDeclaration */: @@ -216745,7 +223060,7 @@ var ts; } // Delete any subsequent imports. for (var i = 1; i < oldImportDecls.length; i++) { - changeTracker.delete(sourceFile, oldImportDecls[i]); + changeTracker.deleteNode(sourceFile, oldImportDecls[i]); } } } @@ -216881,7 +223196,9 @@ var ts; : namedImports.length === 0 ? ts.createNamedImports(sortedImportSpecifiers) : ts.updateNamedImports(namedImports[0].importClause.namedBindings, sortedImportSpecifiers); // TODO: GH#18217 - // Type-only imports are not allowed to combine + // Type-only imports are not allowed to mix default, namespace, and named imports in any combination. + // We could rewrite a default import as a named import (`import { default as name }`), but we currently + // choose not to as a stylistic preference. if (isTypeOnly && newDefaultImport && newNamedImports) { coalescedImports.push(updateImportDeclarationAndClause(importDecl, newDefaultImport, /*namedBindings*/ undefined)); coalescedImports.push(updateImportDeclarationAndClause((_a = namedImports[0]) !== null && _a !== void 0 ? _a : importDecl, /*name*/ undefined, newNamedImports)); @@ -217212,7 +223529,11 @@ var ts; case 246 /* InterfaceDeclaration */: case 248 /* EnumDeclaration */: case 251 /* CaseBlock */: + case 173 /* TypeLiteral */: return spanForNode(n); + case 277 /* CaseClause */: + case 278 /* DefaultClause */: + return spanForNodeArray(n.statements); case 193 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); case 192 /* ArrayLiteralExpression */: @@ -217267,6 +223588,9 @@ var ts; var closeToken = ts.findChildOfKind(n, close, sourceFile); return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart); } + function spanForNodeArray(nodeArray) { + return nodeArray.length ? createOutliningSpan(ts.createTextSpanFromRange(nodeArray), "code" /* Code */) : undefined; + } } function functionSpan(node, body, sourceFile) { var openToken = ts.isNodeArrayMultiLine(node.parameters, sourceFile) @@ -217833,7 +224157,7 @@ var ts; token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { // import("mod"); recordModuleName(); return true; @@ -217845,6 +224169,18 @@ var ts; return true; } else { + if (token === 145 /* TypeKeyword */) { + var skipTypeKeyword = ts.scanner.lookAhead(function () { + var token = ts.scanner.scan(); + return token !== 149 /* FromKeyword */ && (token === 41 /* AsteriskToken */ || + token === 18 /* OpenBraceToken */ || + token === 75 /* Identifier */ || + ts.isKeyword(token)); + }); + if (skipTypeKeyword) { + token = nextToken(); + } + } if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); if (token === 149 /* FromKeyword */) { @@ -217915,6 +224251,16 @@ var ts; if (token === 89 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); + if (token === 145 /* TypeKeyword */) { + var skipTypeKeyword = ts.scanner.lookAhead(function () { + var token = ts.scanner.scan(); + return token === 41 /* AsteriskToken */ || + token === 18 /* OpenBraceToken */; + }); + if (skipTypeKeyword) { + token = nextToken(); + } + } if (token === 18 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses @@ -217946,6 +224292,16 @@ var ts; } else if (token === 96 /* ImportKeyword */) { token = nextToken(); + if (token === 145 /* TypeKeyword */) { + var skipTypeKeyword = ts.scanner.lookAhead(function () { + var token = ts.scanner.scan(); + return token === 75 /* Identifier */ || + ts.isKeyword(token); + }); + if (skipTypeKeyword) { + token = nextToken(); + } + } if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); if (token === 62 /* EqualsToken */) { @@ -217959,13 +224315,15 @@ var ts; } return false; } - function tryConsumeRequireCall(skipCurrentToken) { + function tryConsumeRequireCall(skipCurrentToken, allowTemplateLiterals) { + if (allowTemplateLiterals === void 0) { allowTemplateLiterals = false; } var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); if (token === 139 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* StringLiteral */ || + allowTemplateLiterals && token === 14 /* NoSubstitutionTemplateLiteral */) { // require("mod"); recordModuleName(); } @@ -217982,7 +224340,7 @@ var ts; return true; } token = nextToken(); - if (token === 10 /* StringLiteral */) { + if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); if (token === 27 /* CommaToken */) { @@ -218002,7 +224360,7 @@ var ts; // scan until ']' or EOF while (token !== 23 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names - if (token === 10 /* StringLiteral */) { + if (token === 10 /* StringLiteral */ || token === 14 /* NoSubstitutionTemplateLiteral */) { recordModuleName(); } token = nextToken(); @@ -218037,7 +224395,8 @@ var ts; if (tryConsumeDeclare() || tryConsumeImport() || tryConsumeExport() || - (detectJavaScriptImports && (tryConsumeRequireCall(/*skipCurrentToken*/ false) || tryConsumeDefine()))) { + (detectJavaScriptImports && (tryConsumeRequireCall(/*skipCurrentToken*/ false, /*allowTemplateLiterals*/ true) || + tryConsumeDefine()))) { continue; } else { @@ -218113,7 +224472,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 84 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 84 /* DefaultKeyword */ && symbol.parent && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { @@ -218327,7 +224686,7 @@ var ts; // few keystrokes. if (ts.isMappedTypeNode(node)) { var _a = node.getChildren(), openBraceToken = _a[0], children = _a.slice(1); - var closeBraceToken = ts.Debug.assertDefined(children.pop()); + var closeBraceToken = ts.Debug.checkDefined(children.pop()); ts.Debug.assertEqual(openBraceToken.kind, 18 /* OpenBraceToken */); ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` @@ -218446,7 +224805,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(323 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(324 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -218977,7 +225336,7 @@ var ts; var printer = ts.createPrinter({ removeComments: true }); var typeParameterParts = ts.mapToDisplayParts(function (writer) { if (candidateSignature.typeParameters && candidateSignature.typeParameters.length) { - var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration); })); + var args = ts.createNodeArray(candidateSignature.typeParameters.map(function (p) { return checker.typeParameterToDeclaration(p, enclosingDeclaration, signatureHelpNodeBuilderFlags); })); printer.writeList(53776 /* TypeParameters */, args, sourceFile, writer); } }); @@ -218994,7 +225353,7 @@ var ts; } function createSignatureHelpParameterForTypeParameter(typeParameter, checker, enclosingDeclaration, sourceFile, printer) { var displayParts = ts.mapToDisplayParts(function (writer) { - var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration); + var param = checker.typeParameterToDeclaration(typeParameter, enclosingDeclaration, signatureHelpNodeBuilderFlags); printer.writeNode(4 /* Unspecified */, param, sourceFile, writer); }); return { name: typeParameter.symbol.name, documentation: typeParameter.symbol.getDocumentationComment(checker), displayParts: displayParts, isOptional: false }; @@ -219189,23 +225548,8 @@ var ts; return diags.sort(function (d1, d2) { return d1.start - d2.start; }); function check(node) { if (isJsFile) { - switch (node.kind) { - case 201 /* FunctionExpression */: - var decl = ts.getDeclarationOfExpando(node); - if (decl) { - var symbol_1 = decl.symbol; - if (symbol_1 && (symbol_1.exports && symbol_1.exports.size || symbol_1.members && symbol_1.members.size)) { - diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); - break; - } - } - // falls through if no diagnostic was created - case 244 /* FunctionDeclaration */: - var symbol = node.symbol; - if (symbol.members && (symbol.members.size > 0)) { - diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); - } - break; + if (canBeConvertedToClass(node)) { + diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); } } else { @@ -219312,7 +225656,18 @@ var ts; } ts.isFixablePromiseHandler = isFixablePromiseHandler; function isPromiseHandler(node) { - return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") || ts.hasPropertyAccessExpressionWithName(node, "catch")); + return ts.isCallExpression(node) && (ts.hasPropertyAccessExpressionWithName(node, "then") && hasSupportedNumberOfArguments(node) || + ts.hasPropertyAccessExpressionWithName(node, "catch")); + } + function hasSupportedNumberOfArguments(node) { + if (node.arguments.length > 2) + return false; + if (node.arguments.length < 2) + return true; + return ts.some(node.arguments, function (arg) { + return arg.kind === 100 /* NullKeyword */ || + ts.isIdentifier(arg) && arg.text === "undefined"; + }); } // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { @@ -219332,12 +225687,28 @@ var ts; function getKeyFromNode(exp) { return exp.pos.toString() + ":" + exp.end.toString(); } + function canBeConvertedToClass(node) { + var _a, _b, _c, _d; + if (node.kind === 201 /* FunctionExpression */) { + if (ts.isVariableDeclaration(node.parent) && ((_a = node.symbol.members) === null || _a === void 0 ? void 0 : _a.size)) { + return true; + } + var decl = ts.getDeclarationOfExpando(node); + var symbol = decl === null || decl === void 0 ? void 0 : decl.symbol; + return !!(symbol && (((_b = symbol.exports) === null || _b === void 0 ? void 0 : _b.size) || ((_c = symbol.members) === null || _c === void 0 ? void 0 : _c.size))); + } + if (node.kind === 244 /* FunctionDeclaration */) { + return !!((_d = node.symbol.members) === null || _d === void 0 ? void 0 : _d.size); + } + return false; + } })(ts || (ts = {})); /* @internal */ var ts; (function (ts) { var SymbolDisplay; (function (SymbolDisplay) { + var symbolDisplayNodeBuilderFlags = 8192 /* OmitParameterModifiers */ | 70221824 /* IgnoreErrors */ | 16384 /* UseAliasDefinedOutsideCurrentScope */; // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); @@ -219782,7 +226153,7 @@ var ts; // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { - var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration); + var param = typeChecker.typeParameterToDeclaration(type, enclosingDeclaration, symbolDisplayNodeBuilderFlags); getPrinter().writeNode(4 /* Unspecified */, param, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); @@ -219924,7 +226295,7 @@ var ts; } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { - var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration); + var params = typeChecker.symbolToTypeParameterDeclarations(symbol, enclosingDeclaration, symbolDisplayNodeBuilderFlags); getPrinter().writeList(53776 /* TypeParameters */, params, ts.getSourceFileOfNode(ts.getParseTreeNode(enclosingDeclaration)), writer); }); ts.addRange(displayParts, typeParameterParts); @@ -220098,11 +226469,11 @@ var ts; this.options = options; } FormattingContext.prototype.updateContext = function (currentRange, currentTokenParent, nextRange, nextTokenParent, commonParent) { - this.currentTokenSpan = ts.Debug.assertDefined(currentRange); - this.currentTokenParent = ts.Debug.assertDefined(currentTokenParent); - this.nextTokenSpan = ts.Debug.assertDefined(nextRange); - this.nextTokenParent = ts.Debug.assertDefined(nextTokenParent); - this.contextNode = ts.Debug.assertDefined(commonParent); + this.currentTokenSpan = ts.Debug.checkDefined(currentRange); + this.currentTokenParent = ts.Debug.checkDefined(currentTokenParent); + this.nextTokenSpan = ts.Debug.checkDefined(nextRange); + this.nextTokenParent = ts.Debug.checkDefined(nextTokenParent); + this.contextNode = ts.Debug.checkDefined(commonParent); // drop cached results this.contextNodeAllOnSameLine = undefined; this.nextNodeAllOnSameLine = undefined; @@ -220353,7 +226724,7 @@ var ts; case 3 /* RescanTemplateToken */: if (token === 19 /* CloseBraceToken */) { lastScanAction = 3 /* RescanTemplateToken */; - return scanner.reScanTemplateToken(); + return scanner.reScanTemplateToken(/* isTaggedTemplate */ false); } break; case 4 /* RescanJsxIdentifier */: @@ -220545,7 +226916,7 @@ var ts; rule("SpaceAfterVoidOperator", 110 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await rule("SpaceBetweenAsyncAndOpenParen", 126 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 126 /* AsyncKeyword */, 94 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 126 /* AsyncKeyword */, [94 /* FunctionKeyword */, 75 /* Identifier */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements @@ -220628,7 +226999,7 @@ var ts; // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses rule("SpaceAfterConstructor", 129 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("NoSpaceAfterConstructor", 129 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket, isNextTokenNotCloseParen], 4 /* InsertSpace */), rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions rule("SpaceAfterAnonymousFunctionKeyword", [94 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), @@ -220655,6 +227026,9 @@ var ts; rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + // Insert a space after opening and before closing empty brace brackets + rule("SpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces")], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingEmptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing template string braces rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), @@ -220977,6 +227351,9 @@ var ts; function isNextTokenNotCloseBracket(context) { return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } + function isNextTokenNotCloseParen(context) { + return context.nextTokenSpan.kind !== 21 /* CloseParenToken */; + } function isArrowFunctionContext(context) { return context.contextNode.kind === 202 /* ArrowFunction */; } @@ -221153,8 +227530,8 @@ var ts; (function (ts) { var formatting; (function (formatting) { - function getFormatContext(options) { - return { options: options, getRules: getRulesMap() }; + function getFormatContext(options, host) { + return { options: options, getRules: getRulesMap(), host: host }; } formatting.getFormatContext = getFormatContext; var rulesMapCache; @@ -221567,7 +227944,7 @@ var ts; return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) { - var options = _a.options, getRules = _a.getRules; + var options = _a.options, getRules = _a.getRules, host = _a.host; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); var previousRange; @@ -221589,7 +227966,9 @@ var ts; var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { indentTriviaItems(leadingTrivia, initialIndentation, /*indentNextTokenOrTrivia*/ false, function (item) { return processRange(item, sourceFile.getLineAndCharacterOfPosition(item.pos), enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); }); - trimTrailingWhitespacesForRemainingRange(); + if (options.trimTrailingWhitespace !== false) { + trimTrailingWhitespacesForRemainingRange(); + } } } return edits; @@ -221706,8 +228085,8 @@ var ts; }, getIndentation: function () { return indentation; }, getDelta: getDelta, - recomputeIndentation: function (lineAdded) { - if (node.parent && formatting.SmartIndenter.shouldIndentChildNode(options, node.parent, node, sourceFile)) { + recomputeIndentation: function (lineAdded, parent) { + if (formatting.SmartIndenter.shouldIndentChildNode(options, parent, node, sourceFile)) { indentation += lineAdded ? options.indentSize : -options.indentSize; delta = formatting.SmartIndenter.shouldIndentChildNode(options, node) ? options.indentSize : 0; } @@ -221908,8 +228287,11 @@ var ts; if (listEndToken !== 0 /* Unknown */ && formattingScanner.isOnToken()) { var tokenInfo = formattingScanner.readTokenInfo(parent); if (tokenInfo.token.kind === 27 /* CommaToken */ && ts.isCallLikeExpression(parent)) { - formattingScanner.advance(); - tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; + var commaTokenLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line; + if (startLine !== commaTokenLine) { + formattingScanner.advance(); + tokenInfo = formattingScanner.isOnToken() ? formattingScanner.readTokenInfo(parent) : undefined; + } } // consume the list end token only if it is still belong to the parent // there might be the case when current token matches end token but does not considered as one @@ -222026,7 +228408,7 @@ var ts; function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); var rules = getRules(formattingContext); - var trimTrailingWhitespaces = false; + var trimTrailingWhitespaces = formattingContext.options.trimTrailingWhitespace !== false; var lineAction = 0 /* None */; if (rules) { // Apply rules in reverse order so that higher priority rules (which are first in the array) @@ -222038,7 +228420,7 @@ var ts; // Handle the case where the next line is moved to be the end of this line. // In this case we don't indent the next line in the next pass. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false, contextNode); } break; case 1 /* LineAdded */: @@ -222046,18 +228428,18 @@ var ts; // In this case we indent token2 in the next pass but we set // sameLineIndent flag to notify the indenter that the indentation is within the line. if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true, contextNode); } break; default: ts.Debug.assert(lineAction === 0 /* None */); } // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + trimTrailingWhitespaces = trimTrailingWhitespaces && !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; }); } else { - trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */; + trimTrailingWhitespaces = trimTrailingWhitespaces && currentItem.kind !== 1 /* EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -222232,7 +228614,7 @@ var ts; // edit should not be applied if we have one line feed between elements var lineDelta = currentStartLine - previousStartLine; if (lineDelta !== 1) { - recordReplace(previousRange.end, currentRange.pos - previousRange.end, options.newLineCharacter); + recordReplace(previousRange.end, currentRange.pos - previousRange.end, ts.getNewLineOrDefaultFromHost(host, options)); return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; } break; @@ -222704,7 +229086,7 @@ var ts; case 214 /* ClassExpression */: case 246 /* InterfaceDeclaration */: case 247 /* TypeAliasDeclaration */: - case 320 /* JSDocTemplateTag */: + case 321 /* JSDocTemplateTag */: return getList(node.typeParameters); case 197 /* NewExpression */: case 196 /* CallExpression */: @@ -222966,6 +229348,15 @@ var ts; * include all trivia between the node and the previous token */ LeadingTriviaOption[LeadingTriviaOption["IncludeAll"] = 1] = "IncludeAll"; + /** + * Include attached JSDoc comments + */ + LeadingTriviaOption[LeadingTriviaOption["JSDoc"] = 2] = "JSDoc"; + /** + * Only delete trivia on the same line as getStart(). + * Used to avoid deleting leading comments + */ + LeadingTriviaOption[LeadingTriviaOption["StartLine"] = 3] = "StartLine"; })(LeadingTriviaOption = textChanges_3.LeadingTriviaOption || (textChanges_3.LeadingTriviaOption = {})); var TrailingTriviaOption; (function (TrailingTriviaOption) { @@ -223008,6 +229399,15 @@ var ts; if (leadingTriviaOption === LeadingTriviaOption.Exclude) { return node.getStart(sourceFile); } + if (leadingTriviaOption === LeadingTriviaOption.StartLine) { + return ts.getLineStartPositionForPosition(node.getStart(sourceFile), sourceFile); + } + if (leadingTriviaOption === LeadingTriviaOption.JSDoc) { + var JSDocComments = ts.getJSDocCommentRanges(node, sourceFile.text); + if (JSDocComments === null || JSDocComments === void 0 ? void 0 : JSDocComments.length) { + return ts.getLineStartPositionForPosition(JSDocComments[0].pos, sourceFile); + } + } var fullStart = node.getFullStart(); var start = node.getStart(sourceFile); if (fullStart === start) { @@ -223097,6 +229497,10 @@ var ts; ChangeTracker.prototype.delete = function (sourceFile, node) { this.deletedNodes.push({ sourceFile: sourceFile, node: node }); }; + ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { + if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; } + this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options)); + }; ChangeTracker.prototype.deleteModifier = function (sourceFile, modifier) { this.deleteRange(sourceFile, { pos: modifier.getStart(sourceFile), end: ts.skipTrivia(sourceFile.text, modifier.end, /*stopAfterLineBreak*/ true) }); }; @@ -223156,15 +229560,36 @@ var ts; this.replaceRangeWithNodes(sourceFile, ts.createRange(pos), newNodes, options); }; ChangeTracker.prototype.insertNodeAtTopOfFile = function (sourceFile, newNode, blankLineBetween) { + this.insertAtTopOfFile(sourceFile, newNode, blankLineBetween); + }; + ChangeTracker.prototype.insertNodesAtTopOfFile = function (sourceFile, newNodes, blankLineBetween) { + this.insertAtTopOfFile(sourceFile, newNodes, blankLineBetween); + }; + ChangeTracker.prototype.insertAtTopOfFile = function (sourceFile, insert, blankLineBetween) { var pos = getInsertionPositionAtSourceFileTop(sourceFile); - this.insertNodeAt(sourceFile, pos, newNode, { + var options = { prefix: pos === 0 ? undefined : this.newLineCharacter, suffix: (ts.isLineBreak(sourceFile.text.charCodeAt(pos)) ? "" : this.newLineCharacter) + (blankLineBetween ? this.newLineCharacter : ""), - }); + }; + if (ts.isArray(insert)) { + this.insertNodesAt(sourceFile, pos, insert, options); + } + else { + this.insertNodeAt(sourceFile, pos, insert, options); + } + }; + ChangeTracker.prototype.insertFirstParameter = function (sourceFile, parameters, newParam) { + var p0 = ts.firstOrUndefined(parameters); + if (p0) { + this.insertNodeBefore(sourceFile, p0, newParam); + } + else { + this.insertNodeAt(sourceFile, parameters.pos, newParam); + } }; ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, blankLineBetween) { if (blankLineBetween === void 0) { blankLineBetween = false; } - this.insertNodeAt(sourceFile, getAdjustedStartPosition(sourceFile, before, {}), newNode, this.getOptionsForInsertNodeBefore(before, blankLineBetween)); + this.insertNodeAt(sourceFile, getAdjustedStartPosition(sourceFile, before, {}), newNode, this.getOptionsForInsertNodeBefore(before, newNode, blankLineBetween)); }; ChangeTracker.prototype.insertModifierBefore = function (sourceFile, modifier, before) { var pos = before.getStart(sourceFile); @@ -223214,6 +229639,7 @@ var ts; }; /** Prefer this over replacing a node with another that has a type annotation, as it avoids reformatting the other parts of the node. */ ChangeTracker.prototype.tryInsertTypeAnnotation = function (sourceFile, node, type) { + var _a; var endNode; if (ts.isFunctionLike(node)) { endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); @@ -223225,7 +229651,7 @@ var ts; } } else { - endNode = node.kind !== 242 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = (_a = (node.kind === 242 /* VariableDeclaration */ ? node.exclamationToken : node.questionToken)) !== null && _a !== void 0 ? _a : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); return true; @@ -223240,7 +229666,7 @@ var ts; var start = (ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) || ts.first(node.parameters)).getStart(sourceFile); this.insertNodesAt(sourceFile, start, typeParameters, { prefix: "<", suffix: ">" }); }; - ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, doubleNewlines) { + ChangeTracker.prototype.getOptionsForInsertNodeBefore = function (before, inserted, doubleNewlines) { if (ts.isStatement(before) || ts.isClassElement(before)) { return { suffix: doubleNewlines ? this.newLineCharacter + this.newLineCharacter : this.newLineCharacter }; } @@ -223248,7 +229674,7 @@ var ts; return { suffix: ", " }; } else if (ts.isParameter(before)) { - return {}; + return ts.isParameter(inserted) ? { suffix: ", " } : {}; } else if (ts.isStringLiteral(before) && ts.isImportDeclaration(before.parent) || ts.isNamedImports(before)) { return { suffix: ", " }; @@ -223630,7 +230056,7 @@ var ts; var changesToText; (function (changesToText) { function getTextChangesFromChanges(changes, newLineCharacter, formatContext, validate) { - return ts.group(changes, function (c) { return c.sourceFile.path; }).map(function (changesInFile) { + return ts.mapDefined(ts.group(changes, function (c) { return c.sourceFile.path; }), function (changesInFile) { var sourceFile = changesInFile[0].sourceFile; // order changes by start position // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa. @@ -223644,10 +230070,16 @@ var ts; for (var i = 0; i < normalized.length - 1; i++) { _loop_10(i); } - var textChanges = normalized.map(function (c) { - return ts.createTextChange(ts.createTextSpanFromRange(c.range), computeNewText(c, sourceFile, newLineCharacter, formatContext, validate)); + var textChanges = ts.mapDefined(normalized, function (c) { + var span = ts.createTextSpanFromRange(c.range); + var newText = computeNewText(c, sourceFile, newLineCharacter, formatContext, validate); + // Filter out redundant changes. + if (span.length === newText.length && ts.stringContainsAt(sourceFile.text, newText, span.start)) { + return undefined; + } + return ts.createTextChange(span, newText); }); - return { fileName: sourceFile.fileName, textChanges: textChanges }; + return textChanges.length > 0 ? { fileName: sourceFile.fileName, textChanges: textChanges } : undefined; }); } changesToText.getTextChangesFromChanges = getTextChangesFromChanges; @@ -223678,7 +230110,9 @@ var ts; : format(change.node); // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); - return (options.prefix || "") + noIndent + (options.suffix || ""); + return (options.prefix || "") + noIndent + + ((!options.suffix || ts.endsWith(noIndent, options.suffix)) + ? "" : options.suffix); } function getFormatCodeSettingsForWriting(_a, sourceFile) { var options = _a.options; @@ -223707,7 +230141,7 @@ var ts; function getNonformattedText(node, sourceFile, newLineCharacter) { var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, preserveSourceNewlines: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -223828,8 +230262,8 @@ var ts; writer.writeSymbol(s, sym); setLastNonTriviaPosition(s, /*force*/ false); } - function writeLine() { - writer.writeLine(); + function writeLine(force) { + writer.writeLine(force); } function increaseIndent() { writer.increaseIndent(); @@ -224006,10 +230440,10 @@ var ts; break; } case 254 /* ImportDeclaration */: - var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isImportDeclaration); - deleteNode(changes, sourceFile, node, - // For first import, leave header comment in place - isFirstImport ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); + case 253 /* ImportEqualsDeclaration */: + var isFirstImport = sourceFile.imports.length && node === ts.first(sourceFile.imports).parent || node === ts.find(sourceFile.statements, ts.isAnyImportSyntax); + // For first import, leave header comment in place, otherwise only delete JSDoc comments + deleteNode(changes, sourceFile, node, { leadingTriviaOption: isFirstImport ? LeadingTriviaOption.Exclude : ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; case 191 /* BindingElement */: var pattern = node.parent; @@ -224039,15 +230473,25 @@ var ts; case 256 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; + case 26 /* SemicolonToken */: + deleteNode(changes, sourceFile, node, { trailingTriviaOption: TrailingTriviaOption.Exclude }); + break; + case 94 /* FunctionKeyword */: + deleteNode(changes, sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.Exclude }); + break; + case 245 /* ClassDeclaration */: + case 244 /* FunctionDeclaration */: + deleteNode(changes, sourceFile, node, { leadingTriviaOption: ts.hasJSDocNodes(node) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); + break; default: if (ts.isImportClause(node.parent) && node.parent.name === node) { deleteDefaultImport(changes, sourceFile, node.parent); } - else if (ts.isCallLikeExpression(node.parent)) { + else if (ts.isCallExpression(node.parent) && ts.contains(node.parent.arguments, node)) { deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } else { - deleteNode(changes, sourceFile, node, node.kind === 26 /* SemicolonToken */ ? { trailingTriviaOption: TrailingTriviaOption.Exclude } : undefined); + deleteNode(changes, sourceFile, node); } } } @@ -224076,7 +230520,7 @@ var ts; // Delete named imports while preserving the default import // import d|, * as ns| from './file' // import d|, { a }| from './file' - var previousToken = ts.Debug.assertDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1)); + var previousToken = ts.Debug.checkDefined(ts.getTokenAtPosition(sourceFile, node.pos - 1)); changes.deleteRange(sourceFile, { pos: previousToken.getStart(sourceFile), end: node.end }); } else { @@ -224108,7 +230552,7 @@ var ts; deleteNode(changes, sourceFile, parent); break; case 225 /* VariableStatement */: - deleteNode(changes, sourceFile, gp); + deleteNode(changes, sourceFile, gp, { leadingTriviaOption: ts.hasJSDocNodes(gp) ? LeadingTriviaOption.JSDoc : LeadingTriviaOption.StartLine }); break; default: ts.Debug.assertNever(gp); @@ -224125,7 +230569,7 @@ var ts; } textChanges_3.deleteNode = deleteNode; function deleteNodeInList(changes, deletedNodesInLists, sourceFile, node) { - var containingList = ts.Debug.assertDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile)); + var containingList = ts.Debug.checkDefined(ts.formatting.SmartIndenter.getContainingList(node, sourceFile)); var index = ts.indexOfNode(containingList, node); ts.Debug.assert(index !== -1); if (containingList.length === 1) { @@ -224236,7 +230680,7 @@ var ts; codefix.eachDiagnostic = eachDiagnostic; function getDiagnostics(_a) { var program = _a.program, sourceFile = _a.sourceFile, cancellationToken = _a.cancellationToken; - return program.getSemanticDiagnostics(sourceFile, cancellationToken).concat(ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken)); + return __spreadArrays(program.getSemanticDiagnostics(sourceFile, cancellationToken), program.getSyntacticDiagnostics(sourceFile, cancellationToken), ts.computeSuggestionDiagnostics(sourceFile, program, cancellationToken)); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -224284,7 +230728,7 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); + var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(148 /* UnknownKeyword */)) : ts.createTypeAssertion(ts.createKeywordTypeNode(148 /* UnknownKeyword */), assertion.expression); @@ -224316,6 +230760,87 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addMissingAsync"; + var errorCodes = [ + ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code, + ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code, + ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code + ]; + codefix.registerCodeFix({ + fixIds: [fixId], + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, errorCode = context.errorCode, cancellationToken = context.cancellationToken, program = context.program, span = context.span; + var diagnostic = ts.find(program.getDiagnosticsProducingTypeChecker().getDiagnostics(sourceFile, cancellationToken), getIsMatchingAsyncError(span, errorCode)); + var directSpan = diagnostic && diagnostic.relatedInformation && ts.find(diagnostic.relatedInformation, function (r) { return r.code === ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async.code; }); + var decl = getFixableErrorSpanDeclaration(sourceFile, directSpan); + if (!decl) { + return; + } + var trackChanges = function (cb) { return ts.textChanges.ChangeTracker.with(context, cb); }; + return [getFix(context, decl, trackChanges)]; + }, + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile; + var fixedDeclarations = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { + var span = diagnostic.relatedInformation && ts.find(diagnostic.relatedInformation, function (r) { return r.code === ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async.code; }); + var decl = getFixableErrorSpanDeclaration(sourceFile, span); + if (!decl) { + return; + } + var trackChanges = function (cb) { return (cb(t), []); }; + return getFix(context, decl, trackChanges, fixedDeclarations); + }); + }, + }); + function getFix(context, decl, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, context.sourceFile, decl, fixedDeclarations); }); + return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers); + } + function makeChange(changeTracker, sourceFile, insertionSite, fixedDeclarations) { + if (fixedDeclarations) { + if (fixedDeclarations.has(ts.getNodeId(insertionSite).toString())) { + return; + } + } + fixedDeclarations === null || fixedDeclarations === void 0 ? void 0 : fixedDeclarations.set(ts.getNodeId(insertionSite).toString(), true); + var cloneWithModifier = ts.getSynthesizedDeepClone(insertionSite, /*includeTrivia*/ true); + cloneWithModifier.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(ts.getModifierFlags(insertionSite) | 256 /* Async */)); + cloneWithModifier.modifierFlagsCache = 0; + changeTracker.replaceNode(sourceFile, insertionSite, cloneWithModifier); + } + function getFixableErrorSpanDeclaration(sourceFile, span) { + if (!span) + return undefined; + var token = ts.getTokenAtPosition(sourceFile, span.start); + // Checker has already done work to determine that async might be possible, and has attached + // related info to the node, so start by finding the signature that exactly matches up + // with the diagnostic range. + var decl = ts.findAncestor(token, function (node) { + if (node.getStart(sourceFile) < span.start || node.getEnd() > ts.textSpanEnd(span)) { + return "quit"; + } + return (ts.isArrowFunction(node) || ts.isMethodDeclaration(node) || ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node)) && ts.textSpansEqual(span, ts.createTextSpanFromNode(node, sourceFile)); + }); + return decl; + } + function getIsMatchingAsyncError(span, errorCode) { + return function (_a) { + var start = _a.start, length = _a.length, relatedInformation = _a.relatedInformation, code = _a.code; + return ts.isNumber(start) && ts.isNumber(length) && ts.textSpansEqual({ start: start, length: length }, span) && + code === errorCode && + !!relatedInformation && + ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async.code; }); + }; + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -224500,7 +231025,7 @@ var ts; reference; var diagnostic = ts.find(diagnostics, function (diagnostic) { return diagnostic.start === errorNode.getStart(sourceFile) && - diagnostic.start + diagnostic.length === errorNode.getEnd(); + (diagnostic.start + diagnostic.length) === errorNode.getEnd(); }); return diagnostic && ts.contains(errorCodes, diagnostic.code) || // A Promise is usually not correct in a binary expression (it’s not valid @@ -224834,7 +231359,7 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + var jsdocType = ts.Debug.checkDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } @@ -224933,989 +231458,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - var codefix; - (function (codefix) { - var fixId = "inferFromUsage"; - var errorCodes = [ - // Variable declarations - ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, - // Variable uses - ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, - // Parameter declarations - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, - // Get Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, - ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, - // Set Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, - // Property declarations - ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, - //// Suggestions - // Variable declarations - ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code, - // Variable uses - ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, - // Parameter declarations - ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, - ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code, - // Get Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code, - ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code, - // Set Accessor declarations - ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code, - // Property declarations - ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, - // Function expressions and declarations - ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code, - ]; - codefix.registerCodeFix({ - errorCodes: errorCodes, - getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; - var token = ts.getTokenAtPosition(sourceFile, start); - var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, formatContext, preferences); }); - var name = declaration && ts.getNameOfDeclaration(declaration); - return !name || changes.length === 0 ? undefined - : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; - }, - fixIds: [fixId], - getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; - var markSeen = ts.nodeSeenTracker(); - return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, formatContext, preferences); - }); - }, - }); - function getDiagnostic(errorCode, token) { - switch (errorCode) { - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: - return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: - return ts.Diagnostics.Infer_parameter_types_from_usage; - case ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code: - return ts.Diagnostics.Infer_this_type_of_0_from_usage; - default: - return ts.Diagnostics.Infer_type_of_0_from_usage; - } - } - /** Map suggestion code to error code */ - function mapSuggestionDiagnostic(errorCode) { - switch (errorCode) { - case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code: - return ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code; - case ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: - return ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code; - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: - return ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code; - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: - return ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code; - case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code: - return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code; - case ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code: - return ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code; - case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code: - return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code; - case ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: - return ts.Diagnostics.Member_0_implicitly_has_an_1_type.code; - } - return errorCode; - } - function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, formatContext, preferences) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 104 /* ThisKeyword */) { - return undefined; - } - var parent = token.parent; - errorCode = mapSuggestionDiagnostic(errorCode); - switch (errorCode) { - // Variable and Property declarations - case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: - case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: - if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location - annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken, formatContext, preferences); - return parent; - } - if (ts.isPropertyAccessExpression(parent)) { - var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); - var typeNode = ts.getTypeNodeIfAccessible(type, parent, program, host); - if (typeNode) { - // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags - var typeTag = ts.createJSDocTypeTag(ts.createJSDocTypeExpression(typeNode), /*comment*/ ""); - addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); - } - return parent; - } - return undefined; - case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { - var symbol = program.getTypeChecker().getSymbolAtLocation(token); - if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { - annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken, formatContext, preferences); - return symbol.valueDeclaration; - } - return undefined; - } - } - var containingFunction = ts.getContainingFunction(token); - if (containingFunction === undefined) { - return undefined; - } - switch (errorCode) { - // Parameter declarations - case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); - return containingFunction; - } - // falls through - case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: - if (markSeen(containingFunction)) { - var param = ts.cast(parent, ts.isParameter); - annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken, formatContext, preferences); - return param; - } - return undefined; - // Get Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: - case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: - if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { - annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host, formatContext, preferences); - return containingFunction; - } - return undefined; - // Set Accessor declarations - case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: - if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); - return containingFunction; - } - return undefined; - // Function 'this' - case ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code: - if (ts.textChanges.isThisTypeAnnotatable(containingFunction) && markSeen(containingFunction)) { - annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken); - return containingFunction; - } - return undefined; - default: - return ts.Debug.fail(String(errorCode)); - } - } - function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken, formatContext, preferences) { - if (ts.isIdentifier(declaration.name)) { - annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host, formatContext, preferences); - } - } - function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken, formatContext, preferences) { - if (!ts.isIdentifier(parameterDeclaration.name)) { - return; - } - var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); - if (ts.isInJSFile(containingFunction)) { - annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); - } - else { - var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); - if (needParens) - changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.createToken(20 /* OpenParenToken */)); - for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { - var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; - if (declaration && !declaration.type && !declaration.initializer) { - annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences); - } - } - if (needParens) - changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.createToken(21 /* CloseParenToken */)); - } - } - function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); - if (!references || !references.length) { - return; - } - var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); - var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); - if (!typeNode) { - return; - } - if (ts.isInJSFile(containingFunction)) { - annotateJSDocThis(changes, sourceFile, containingFunction, typeNode); - } - else { - changes.tryInsertThisTypeAnnotation(sourceFile, containingFunction, typeNode); - } - } - function annotateJSDocThis(changes, sourceFile, containingFunction, typeNode) { - addJSDocTags(changes, sourceFile, containingFunction, [ - ts.createJSDocThisTag(ts.createJSDocTypeExpression(typeNode)), - ]); - } - function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken, formatContext, preferences) { - var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); - if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { - var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); - if (type === program.getTypeChecker().getAnyType()) { - type = inferTypeForVariableFromUsage(param.name, program, cancellationToken); - } - if (ts.isInJSFile(setAccessorDeclaration)) { - annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); - } - else { - annotate(changes, sourceFile, param, type, program, host, formatContext, preferences); - } - } - } - function annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences) { - var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); - if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 158 /* PropertySignature */) { - var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; - if (!parent) { - return; - } - var typeExpression = ts.createJSDocTypeExpression(typeNode); - var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); - addJSDocTags(changes, sourceFile, parent, [typeTag]); - } - else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences)) { - changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); - } - } - } - function tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences) { - var _a; - if (ts.isLiteralImportTypeNode(typeNode) && typeNode.qualifier && type.symbol) { - // Replace 'import("./a").SomeType' with 'SomeType' and an actual import if possible - var moduleSymbol = (_a = ts.find(type.symbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) === null || _a === void 0 ? void 0 : _a.getSourceFile().symbol; - // Symbol for the left-most thing after the dot - if (moduleSymbol) { - var symbol = ts.getFirstIdentifier(typeNode.qualifier).symbol; - var action = codefix.getImportCompletionAction(symbol, moduleSymbol, sourceFile, symbol.name, host, program, formatContext, declaration.pos, preferences); - if (action.codeAction.changes.length && changes.tryInsertTypeAnnotation(sourceFile, declaration, ts.createTypeReferenceNode(typeNode.qualifier, typeNode.typeArguments))) { - for (var _i = 0, _b = action.codeAction.changes; _i < _b.length; _i++) { - var change = _b[_i]; - var file = sourceFile.fileName === change.fileName ? sourceFile : ts.Debug.assertDefined(program.getSourceFile(change.fileName)); - changes.pushRaw(file, change); - } - return true; - } - } - } - return false; - } - function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { - var signature = parameterInferences.length && parameterInferences[0].declaration.parent; - if (!signature) { - return; - } - var paramTags = ts.mapDefined(parameterInferences, function (inference) { - var param = inference.declaration; - // only infer parameters that have (1) no type and (2) an accessible inferred type - if (param.initializer || ts.getJSDocType(param) || !ts.isIdentifier(param.name)) - return; - var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); - var name = ts.getSynthesizedClone(param.name); - ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); - return typeNode && ts.createJSDocParamTag(name, !!inference.isOptional, ts.createJSDocTypeExpression(typeNode), ""); - }); - addJSDocTags(changes, sourceFile, signature, paramTags); - } - function addJSDocTags(changes, sourceFile, parent, newTags) { - var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); - var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); - var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { - var merged = tryMergeJsdocTags(tag, newTag); - if (merged) - oldTags[i] = merged; - return !!merged; - }); }); - var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); - var jsDocNode = parent.kind === 202 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; - jsDocNode.jsDoc = parent.jsDoc; - jsDocNode.jsDocCache = parent.jsDocCache; - changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); - } - function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 159 /* PropertyDeclaration */) { - return signature.parent; - } - return signature.parent.parent; - } - function tryMergeJsdocTags(oldTag, newTag) { - if (oldTag.kind !== newTag.kind) { - return undefined; - } - switch (oldTag.kind) { - case 316 /* JSDocParameterTag */: { - var oldParam = oldTag; - var newParam = newTag; - return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText - ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) - : undefined; - } - case 317 /* JSDocReturnTag */: - return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); - } - } - function getReferences(token, program, cancellationToken) { - // Position shouldn't matter since token is not a SourceFile. - return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { - return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; - }); - } - function inferTypeForVariableFromUsage(token, program, cancellationToken) { - var references = getReferences(token, program, cancellationToken); - return inferTypeFromReferences(program, references, cancellationToken).single(); - } - function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { - var references = getFunctionReferences(func, sourceFile, program, cancellationToken); - return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || - func.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() - }); }); - } - function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { - var searchToken; - switch (containingFunction.kind) { - case 162 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 129 /* ConstructorKeyword */, sourceFile); - break; - case 202 /* ArrowFunction */: - case 201 /* FunctionExpression */: - var parent = containingFunction.parent; - searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? - parent.name : - containingFunction.name; - break; - case 244 /* FunctionDeclaration */: - case 161 /* MethodDeclaration */: - searchToken = containingFunction.name; - break; - } - if (!searchToken) { - return undefined; - } - return getReferences(searchToken, program, cancellationToken); - } - function inferTypeFromReferences(program, references, cancellationToken) { - var checker = program.getTypeChecker(); - var builtinConstructors = { - string: function () { return checker.getStringType(); }, - number: function () { return checker.getNumberType(); }, - Array: function (t) { return checker.createArrayType(t); }, - Promise: function (t) { return checker.createPromiseType(t); }, - }; - var builtins = [ - checker.getStringType(), - checker.getNumberType(), - checker.createArrayType(checker.getAnyType()), - checker.createPromiseType(checker.getAnyType()), - ]; - return { - single: single, - parameters: parameters, - thisParameter: thisParameter, - }; - function createEmptyUsage() { - return { - isNumber: undefined, - isString: undefined, - isNumberOrString: undefined, - candidateTypes: undefined, - properties: undefined, - calls: undefined, - constructs: undefined, - numberIndex: undefined, - stringIndex: undefined, - candidateThisTypes: undefined, - inferredTypes: undefined, - }; - } - function combineUsages(usages) { - var combinedProperties = ts.createUnderscoreEscapedMap(); - for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { - var u = usages_1[_i]; - if (u.properties) { - u.properties.forEach(function (p, name) { - if (!combinedProperties.has(name)) { - combinedProperties.set(name, []); - } - combinedProperties.get(name).push(p); - }); - } - } - var properties = ts.createUnderscoreEscapedMap(); - combinedProperties.forEach(function (ps, name) { - properties.set(name, combineUsages(ps)); - }); - return { - isNumber: usages.some(function (u) { return u.isNumber; }), - isString: usages.some(function (u) { return u.isString; }), - isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), - candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), - properties: properties, - calls: ts.flatMap(usages, function (u) { return u.calls; }), - constructs: ts.flatMap(usages, function (u) { return u.constructs; }), - numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), - stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), - candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), - inferredTypes: undefined, - }; - } - function single() { - return combineTypes(inferTypesFromReferencesSingle(references)); - } - function parameters(declaration) { - if (references.length === 0 || !declaration.parameters) { - return undefined; - } - var usage = createEmptyUsage(); - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - calculateUsageOfNode(reference, usage); - } - var calls = __spreadArrays(usage.constructs || [], usage.calls || []); - return declaration.parameters.map(function (parameter, parameterIndex) { - var types = []; - var isRest = ts.isRestParameter(parameter); - var isOptional = false; - for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { - var call = calls_1[_i]; - if (call.argumentTypes.length <= parameterIndex) { - isOptional = ts.isInJSFile(declaration); - types.push(checker.getUndefinedType()); - } - else if (isRest) { - for (var i = parameterIndex; i < call.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); - } - } - else { - types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); - } - } - if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); - types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); - } - var type = combineTypes(types); - return { - type: isRest ? checker.createArrayType(type) : type, - isOptional: isOptional && !isRest, - declaration: parameter - }; - }); - } - function thisParameter() { - var usage = createEmptyUsage(); - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; - cancellationToken.throwIfCancellationRequested(); - calculateUsageOfNode(reference, usage); - } - return combineTypes(usage.candidateThisTypes || ts.emptyArray); - } - function inferTypesFromReferencesSingle(references) { - var usage = createEmptyUsage(); - for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { - var reference = references_4[_i]; - cancellationToken.throwIfCancellationRequested(); - calculateUsageOfNode(reference, usage); - } - return inferTypes(usage); - } - function calculateUsageOfNode(node, usage) { - while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { - node = node.parent; - } - switch (node.parent.kind) { - case 226 /* ExpressionStatement */: - addCandidateType(usage, checker.getVoidType()); - break; - case 208 /* PostfixUnaryExpression */: - usage.isNumber = true; - break; - case 207 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpression(node.parent, usage); - break; - case 209 /* BinaryExpression */: - inferTypeFromBinaryExpression(node, node.parent, usage); - break; - case 277 /* CaseClause */: - case 278 /* DefaultClause */: - inferTypeFromSwitchStatementLabel(node.parent, usage); - break; - case 196 /* CallExpression */: - case 197 /* NewExpression */: - if (node.parent.expression === node) { - inferTypeFromCallExpression(node.parent, usage); - } - else { - inferTypeFromContextualType(node, usage); - } - break; - case 194 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpression(node.parent, usage); - break; - case 195 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpression(node.parent, node, usage); - break; - case 281 /* PropertyAssignment */: - case 282 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, usage); - break; - case 159 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, usage); - break; - case 242 /* VariableDeclaration */: { - var _a = node.parent, name = _a.name, initializer = _a.initializer; - if (node === name) { - if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. - addCandidateType(usage, checker.getTypeAtLocation(initializer)); - } - break; - } - } - // falls through - default: - return inferTypeFromContextualType(node, usage); - } - } - function inferTypeFromContextualType(node, usage) { - if (ts.isExpressionNode(node)) { - addCandidateType(usage, checker.getContextualType(node)); - } - } - function inferTypeFromPrefixUnaryExpression(node, usage) { - switch (node.operator) { - case 45 /* PlusPlusToken */: - case 46 /* MinusMinusToken */: - case 40 /* MinusToken */: - case 54 /* TildeToken */: - usage.isNumber = true; - break; - case 39 /* PlusToken */: - usage.isNumberOrString = true; - break; - // case SyntaxKind.ExclamationToken: - // no inferences here; - } - } - function inferTypeFromBinaryExpression(node, parent, usage) { - switch (parent.operatorToken.kind) { - // ExponentiationOperator - case 42 /* AsteriskAsteriskToken */: - // MultiplicativeOperator - // falls through - case 41 /* AsteriskToken */: - case 43 /* SlashToken */: - case 44 /* PercentToken */: - // ShiftOperator - // falls through - case 47 /* LessThanLessThanToken */: - case 48 /* GreaterThanGreaterThanToken */: - case 49 /* GreaterThanGreaterThanGreaterThanToken */: - // BitwiseOperator - // falls through - case 50 /* AmpersandToken */: - case 51 /* BarToken */: - case 52 /* CaretToken */: - // CompoundAssignmentOperator - // falls through - case 64 /* MinusEqualsToken */: - case 66 /* AsteriskAsteriskEqualsToken */: - case 65 /* AsteriskEqualsToken */: - case 67 /* SlashEqualsToken */: - case 68 /* PercentEqualsToken */: - case 72 /* AmpersandEqualsToken */: - case 73 /* BarEqualsToken */: - case 74 /* CaretEqualsToken */: - case 69 /* LessThanLessThanEqualsToken */: - case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* GreaterThanGreaterThanEqualsToken */: - // AdditiveOperator - // falls through - case 40 /* MinusToken */: - // RelationalOperator - // falls through - case 29 /* LessThanToken */: - case 32 /* LessThanEqualsToken */: - case 31 /* GreaterThanToken */: - case 33 /* GreaterThanEqualsToken */: - var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usage, operandType); - } - else { - usage.isNumber = true; - } - break; - case 63 /* PlusEqualsToken */: - case 39 /* PlusToken */: - var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); - if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usage, otherOperandType); - } - else if (otherOperandType.flags & 296 /* NumberLike */) { - usage.isNumber = true; - } - else if (otherOperandType.flags & 132 /* StringLike */) { - usage.isString = true; - } - else if (otherOperandType.flags & 1 /* Any */) { - // do nothing, maybe we'll learn something elsewhere - } - else { - usage.isNumberOrString = true; - } - break; - // AssignmentOperators - case 62 /* EqualsToken */: - case 34 /* EqualsEqualsToken */: - case 36 /* EqualsEqualsEqualsToken */: - case 37 /* ExclamationEqualsEqualsToken */: - case 35 /* ExclamationEqualsToken */: - addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); - break; - case 97 /* InKeyword */: - if (node === parent.left) { - usage.isString = true; - } - break; - // LogicalOperator Or NullishCoalescing - case 56 /* BarBarToken */: - case 60 /* QuestionQuestionToken */: - if (node === parent.left && - (node.parent.parent.kind === 242 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { - // var x = x || {}; - // TODO: use getFalsyflagsOfType - addCandidateType(usage, checker.getTypeAtLocation(parent.right)); - } - break; - case 55 /* AmpersandAmpersandToken */: - case 27 /* CommaToken */: - case 98 /* InstanceOfKeyword */: - // nothing to infer here - break; - } - } - function inferTypeFromSwitchStatementLabel(parent, usage) { - addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); - } - function inferTypeFromCallExpression(parent, usage) { - var call = { - argumentTypes: [], - return_: createEmptyUsage() - }; - if (parent.arguments) { - for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { - var argument = _a[_i]; - call.argumentTypes.push(checker.getTypeAtLocation(argument)); - } - } - calculateUsageOfNode(parent, call.return_); - if (parent.kind === 196 /* CallExpression */) { - (usage.calls || (usage.calls = [])).push(call); - } - else { - (usage.constructs || (usage.constructs = [])).push(call); - } - } - function inferTypeFromPropertyAccessExpression(parent, usage) { - var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usage.properties) { - usage.properties = ts.createUnderscoreEscapedMap(); - } - var propertyUsage = usage.properties.get(name) || createEmptyUsage(); - calculateUsageOfNode(parent, propertyUsage); - usage.properties.set(name, propertyUsage); - } - function inferTypeFromPropertyElementExpression(parent, node, usage) { - if (node === parent.argumentExpression) { - usage.isNumberOrString = true; - return; - } - else { - var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsage = createEmptyUsage(); - calculateUsageOfNode(parent, indexUsage); - if (indexType.flags & 296 /* NumberLike */) { - usage.numberIndex = indexUsage; - } - else { - usage.stringIndex = indexUsage; - } - } - } - function inferTypeFromPropertyAssignment(assignment, usage) { - var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? - assignment.parent.parent : - assignment.parent; - addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); - } - function inferTypeFromPropertyDeclaration(declaration, usage) { - addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); - } - function removeLowPriorityInferences(inferences, priorities) { - var toRemove = []; - for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { - var i = inferences_1[_i]; - for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { - var _b = priorities_1[_a], high = _b.high, low = _b.low; - if (high(i)) { - ts.Debug.assert(!low(i), "Priority can't have both low and high"); - toRemove.push(low); - } - } - } - return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); - } - function combineFromUsage(usage) { - return combineTypes(inferTypes(usage)); - } - function combineTypes(inferences) { - if (!inferences.length) - return checker.getAnyType(); - // 1. string or number individually override string | number - // 2. non-any, non-void overrides any or void - // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types - var stringNumber = checker.getUnionType([checker.getStringType(), checker.getNumberType()]); - var priorities = [ - { - high: function (t) { return t === checker.getStringType() || t === checker.getNumberType(); }, - low: function (t) { return t === stringNumber; } - }, - { - high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, - low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } - }, - { - high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, - low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } - } - ]; - var good = removeLowPriorityInferences(inferences, priorities); - var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); - if (anons.length) { - good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(combineAnonymousTypes(anons)); - } - return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); - } - function combineAnonymousTypes(anons) { - if (anons.length === 1) { - return anons[0]; - } - var calls = []; - var constructs = []; - var stringIndices = []; - var numberIndices = []; - var stringIndexReadonly = false; - var numberIndexReadonly = false; - var props = ts.createMultiMap(); - for (var _i = 0, anons_1 = anons; _i < anons_1.length; _i++) { - var anon = anons_1[_i]; - for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { - var p = _b[_a]; - props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); - } - calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); - constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); - if (anon.stringIndexInfo) { - stringIndices.push(anon.stringIndexInfo.type); - stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly; - } - if (anon.numberIndexInfo) { - numberIndices.push(anon.numberIndexInfo.type); - numberIndexReadonly = numberIndexReadonly || anon.numberIndexInfo.isReadonly; - } - } - var members = ts.mapEntries(props, function (name, types) { - var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; - var s = checker.createSymbol(4 /* Property */ | isOptional, name); - s.type = checker.getUnionType(types); - return [name, s]; - }); - return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); - } - function inferTypes(usage) { - var types = []; - if (usage.isNumber) { - types.push(checker.getNumberType()); - } - if (usage.isString) { - types.push(checker.getStringType()); - } - if (usage.isNumberOrString) { - types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); - } - if (usage.numberIndex) { - types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); - } - if (usage.properties && usage.properties.size - || usage.calls && usage.calls.length - || usage.constructs && usage.constructs.length - || usage.stringIndex) { - types.push(inferStructuralType(usage)); - } - types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); - types.push.apply(types, inferNamedTypesFromProperties(usage)); - return types; - } - function inferStructuralType(usage) { - var members = ts.createUnderscoreEscapedMap(); - if (usage.properties) { - usage.properties.forEach(function (u, name) { - var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = combineFromUsage(u); - members.set(name, symbol); - }); - } - var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; - var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; - var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); - return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 - } - function inferNamedTypesFromProperties(usage) { - if (!usage.properties || !usage.properties.size) - return []; - var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); - if (0 < types.length && types.length < 3) { - return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); - } - return []; - } - function allPropertiesAreAssignableToUsage(type, usage) { - if (!usage.properties) - return false; - return !ts.forEachEntry(usage.properties, function (propUsage, name) { - var source = checker.getTypeOfPropertyOfType(type, name); - if (!source) { - return true; - } - if (propUsage.calls) { - var sigs = checker.getSignaturesOfType(source, 0 /* Call */); - return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); - } - else { - return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); - } - }); - } - /** - * inference is limited to - * 1. generic types with a single parameter - * 2. inference to/from calls with a single signature - */ - function inferInstantiationFromUsage(type, usage) { - if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { - return type; - } - var generic = type.target; - var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); - if (!singleTypeParameter) - return type; - var types = []; - usage.properties.forEach(function (propUsage, name) { - var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); - ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); - types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); - }); - return builtinConstructors[type.symbol.escapedName](combineTypes(types)); - } - function inferTypeParameters(genericType, usageType, typeParameter) { - if (genericType === typeParameter) { - return [usageType]; - } - else if (genericType.flags & 3145728 /* UnionOrIntersection */) { - return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); - } - else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { - // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference - var genericArgs = checker.getTypeArguments(genericType); - var usageArgs = checker.getTypeArguments(usageType); - var types = []; - if (genericArgs && usageArgs) { - for (var i = 0; i < genericArgs.length; i++) { - if (usageArgs[i]) { - types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); - } - } - } - return types; - } - var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); - var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); - if (genericSigs.length === 1 && usageSigs.length === 1) { - return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); - } - return []; - } - function inferFromSignatures(genericSig, usageSig, typeParameter) { - var types = []; - for (var i = 0; i < genericSig.parameters.length; i++) { - var genericParam = genericSig.parameters[i]; - var usageParam = usageSig.parameters[i]; - var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); - if (!usageParam) { - break; - } - var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); - var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); - if (elementType) { - genericParamType = elementType; - } - var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); - types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); - } - var genericReturn = checker.getReturnTypeOfSignature(genericSig); - var usageReturn = checker.getReturnTypeOfSignature(usageSig); - types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); - return types; - } - function getFunctionFromCalls(calls) { - return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - } - function getSignatureFromCalls(calls) { - var parameters = []; - var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); - var _loop_12 = function (i) { - var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); - if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { - symbol.flags |= 16777216 /* Optional */; - } - parameters.push(symbol); - }; - for (var i = 0; i < length; i++) { - _loop_12(i); - } - var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); - // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); - } - function addCandidateType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (usage.candidateTypes || (usage.candidateTypes = [])).push(type); - } - } - function addCandidateThisType(usage, type) { - if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); - } - } - } - })(codefix = ts.codefix || (ts.codefix = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var codefix; (function (codefix) { @@ -225960,7 +231502,10 @@ var ts; if (!newClassDeclaration) { return undefined; } - ts.copyLeadingComments(ctorDeclaration, newClassDeclaration, sourceFile); + // Deleting a declaration only deletes JSDoc style comments, so only copy those to the new node. + if (ts.hasJSDocNodes(ctorDeclaration)) { + ts.copyLeadingComments(ctorDeclaration, newClassDeclaration, sourceFile); + } // Because the preceding node could be touched, we need to insert nodes before delete nodes. changes.insertNodeAfter(sourceFile, precedingNode, newClassDeclaration); function createClassElementsFromSymbol(symbol) { @@ -226121,27 +231666,21 @@ var ts; return; } var synthNamesMap = ts.createMap(); - var originalTypeMap = ts.createMap(); - var allVarNames = []; var isInJavascript = ts.isInJSFile(functionToConvert); var setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker); - var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context, setOfExpressionsToReturn, originalTypeMap, allVarNames); - var constIdentifiers = getConstIdentifiers(synthNamesMap); + var functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context.sourceFile); var returnStatements = functionToConvertRenamed.body && ts.isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : ts.emptyArray; - var transformer = { checker: checker, synthNamesMap: synthNamesMap, allVarNames: allVarNames, setOfExpressionsToReturn: setOfExpressionsToReturn, constIdentifiers: constIdentifiers, originalTypeMap: originalTypeMap, isInJSFile: isInJavascript }; + var transformer = { checker: checker, synthNamesMap: synthNamesMap, setOfExpressionsToReturn: setOfExpressionsToReturn, isInJSFile: isInJavascript }; if (!returnStatements.length) { return; } // add the async keyword changes.insertLastModifierBefore(sourceFile, 126 /* AsyncKeyword */, functionToConvert); - function startTransformation(node, nodeToReplace) { - var newNodes = transformExpression(node, transformer, node); - changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); - } - var _loop_13 = function (statement) { - ts.forEachChild(statement, function visit(node) { + var _loop_12 = function (returnStatement) { + ts.forEachChild(returnStatement, function visit(node) { if (ts.isCallExpression(node)) { - startTransformation(node, statement); + var newNodes = transformExpression(node, transformer); + changes.replaceNodeWithNodes(sourceFile, returnStatement, newNodes); } else if (!ts.isFunctionLike(node)) { ts.forEachChild(node, visit); @@ -226149,8 +231688,8 @@ var ts; }); }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { - var statement = returnStatements_1[_i]; - _loop_13(statement); + var returnStatement = returnStatements_1[_i]; + _loop_12(returnStatement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -226161,16 +231700,6 @@ var ts; }); return res; } - // Returns the identifiers that are never reassigned in the refactor - function getConstIdentifiers(synthNamesMap) { - var constIdentifiers = []; - synthNamesMap.forEach(function (val) { - if (val.numberOfAssignmentsOriginal === 0) { - constIdentifiers.push(val.identifier); - } - }); - return constIdentifiers; - } /* Finds all of the expressions of promise type that should not be saved in a variable during the refactor */ @@ -226180,16 +231709,16 @@ var ts; } var setOfExpressionsToReturn = ts.createMap(); ts.forEachChild(func.body, function visit(node) { - if (isPromiseReturningExpression(node, checker, "then")) { + if (isPromiseReturningCallExpression(node, checker, "then")) { setOfExpressionsToReturn.set(ts.getNodeId(node).toString(), true); ts.forEach(node.arguments, visit); } - else if (isPromiseReturningExpression(node, checker, "catch")) { + else if (isPromiseReturningCallExpression(node, checker, "catch")) { setOfExpressionsToReturn.set(ts.getNodeId(node).toString(), true); // if .catch() is the last call in the chain, move leftward in the chain until we hit something else that should be returned ts.forEachChild(node, visit); } - else if (isPromiseReturningExpression(node, checker)) { + else if (isPromiseTypedExpression(node, checker)) { setOfExpressionsToReturn.set(ts.getNodeId(node).toString(), true); // don't recurse here, since we won't refactor any children or arguments of the expression } @@ -226199,16 +231728,18 @@ var ts; }); return setOfExpressionsToReturn; } - /* - Returns true if node is a promise returning expression - If name is not undefined, node is a promise returning call of name - */ - function isPromiseReturningExpression(node, checker, name) { - var isNodeExpression = name ? ts.isCallExpression(node) : ts.isExpression(node); - var isExpressionOfName = isNodeExpression && (!name || ts.hasPropertyAccessExpressionWithName(node, name)); + function isPromiseReturningCallExpression(node, checker, name) { + if (!ts.isCallExpression(node)) + return false; + var isExpressionOfName = ts.hasPropertyAccessExpressionWithName(node, name); var nodeType = isExpressionOfName && checker.getTypeAtLocation(node); return !!(nodeType && checker.getPromisedTypeOfPromise(nodeType)); } + function isPromiseTypedExpression(node, checker) { + if (!ts.isExpression(node)) + return false; + return !!checker.getPromisedTypeOfPromise(checker.getTypeAtLocation(node)); + } function declaredInFile(symbol, sourceFile) { return symbol.valueDeclaration && symbol.valueDeclaration.getSourceFile() === sourceFile; } @@ -226217,31 +231748,34 @@ var ts; This function collects all existing identifier names and names of identifiers that will be created in the refactor. It then checks for any collisions and renames them through getSynthesizedDeepClone */ - function renameCollidingVarNames(nodeToRename, checker, synthNamesMap, context, setOfAllExpressionsToReturn, originalType, allVarNames) { + function renameCollidingVarNames(nodeToRename, checker, synthNamesMap, sourceFile) { var identsToRenameMap = ts.createMap(); // key is the symbol id - var collidingSymbolMap = ts.createMap(); + var collidingSymbolMap = ts.createMultiMap(); ts.forEachChild(nodeToRename, function visit(node) { if (!ts.isIdentifier(node)) { ts.forEachChild(node, visit); return; } var symbol = checker.getSymbolAtLocation(node); - var isDefinedInFile = symbol && declaredInFile(symbol, context.sourceFile); + var isDefinedInFile = symbol && declaredInFile(symbol, sourceFile); if (symbol && isDefinedInFile) { var type = checker.getTypeAtLocation(node); + // Note - the choice of the last call signature is arbitrary var lastCallSignature = getLastCallSignature(type, checker); var symbolIdString = ts.getSymbolId(symbol).toString(); - // if the identifier refers to a function we want to add the new synthesized variable for the declaration (ex. blob in let blob = res(arg)) - // Note - the choice of the last call signature is arbitrary + // If the identifier refers to a function, we want to add the new synthesized variable for the declaration. Example: + // fetch('...').then(response => { ... }) + // will eventually become + // const response = await fetch('...') + // so we push an entry for 'response'. if (lastCallSignature && !ts.isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) { var firstParameter = ts.firstOrUndefined(lastCallSignature.parameters); var ident = firstParameter && ts.isParameter(firstParameter.valueDeclaration) && ts.tryCast(firstParameter.valueDeclaration.name, ts.isIdentifier) || ts.createOptimisticUniqueName("result"); var synthName = getNewNameIfConflict(ident, collidingSymbolMap); synthNamesMap.set(symbolIdString, synthName); - allVarNames.push({ identifier: synthName.identifier, symbol: symbol }); - addNameToFrequencyMap(collidingSymbolMap, ident.text, symbol); + collidingSymbolMap.add(ident.text, symbol); } - // we only care about identifiers that are parameters, declarations, or binding elements (don't care about other uses) + // We only care about identifiers that are parameters, variable declarations, or binding elements else if (node.parent && (ts.isParameter(node.parent) || ts.isVariableDeclaration(node.parent) || ts.isBindingElement(node.parent))) { var originalName = node.text; var collidingSymbols = collidingSymbolMap.get(originalName); @@ -226250,96 +231784,60 @@ var ts; var newName = getNewNameIfConflict(node, collidingSymbolMap); identsToRenameMap.set(symbolIdString, newName.identifier); synthNamesMap.set(symbolIdString, newName); - allVarNames.push({ identifier: newName.identifier, symbol: symbol }); - addNameToFrequencyMap(collidingSymbolMap, originalName, symbol); + collidingSymbolMap.add(originalName, symbol); } else { var identifier = ts.getSynthesizedDeepClone(node); - identsToRenameMap.set(symbolIdString, identifier); - synthNamesMap.set(symbolIdString, createSynthIdentifier(identifier, [], allVarNames.filter(function (elem) { return elem.identifier.text === node.text; }).length /*, numberOfAssignmentsSynthesized: 0*/)); - if ((ts.isParameter(node.parent) && isExpressionOrCallOnTypePromise(node.parent.parent)) || ts.isVariableDeclaration(node.parent)) { - allVarNames.push({ identifier: identifier, symbol: symbol }); - addNameToFrequencyMap(collidingSymbolMap, originalName, symbol); - } + synthNamesMap.set(symbolIdString, createSynthIdentifier(identifier)); + collidingSymbolMap.add(originalName, symbol); } } } }); - return ts.getSynthesizedDeepCloneWithRenames(nodeToRename, /*includeTrivia*/ true, identsToRenameMap, checker, deepCloneCallback); - function isExpressionOrCallOnTypePromise(child) { - var node = child.parent; - if (ts.isCallExpression(node) || ts.isIdentifier(node) && !setOfAllExpressionsToReturn.get(ts.getNodeId(node).toString())) { - var nodeType = checker.getTypeAtLocation(node); - var isPromise = nodeType && checker.getPromisedTypeOfPromise(nodeType); - return !!isPromise; - } - return false; - } - function deepCloneCallback(node, clone) { - if (ts.isIdentifier(node)) { - var symbol = checker.getSymbolAtLocation(node); - var symboldIdString = symbol && ts.getSymbolId(symbol).toString(); - var renameInfo = symbol && synthNamesMap.get(symboldIdString); - if (renameInfo) { - var type = checker.getTypeAtLocation(node); - originalType.set(ts.getNodeId(clone).toString(), type); - } - } - var val = setOfAllExpressionsToReturn.get(ts.getNodeId(node).toString()); - if (val !== undefined) { - setOfAllExpressionsToReturn.delete(ts.getNodeId(node).toString()); - setOfAllExpressionsToReturn.set(ts.getNodeId(clone).toString(), val); - } - } - } - function addNameToFrequencyMap(renamedVarNameFrequencyMap, originalName, symbol) { - if (renamedVarNameFrequencyMap.has(originalName)) { - renamedVarNameFrequencyMap.get(originalName).push(symbol); - } - else { - renamedVarNameFrequencyMap.set(originalName, [symbol]); - } + return ts.getSynthesizedDeepCloneWithRenames(nodeToRename, /*includeTrivia*/ true, identsToRenameMap, checker); } function getNewNameIfConflict(name, originalNames) { var numVarsSameName = (originalNames.get(name.text) || ts.emptyArray).length; - var numberOfAssignmentsOriginal = 0; var identifier = numVarsSameName === 0 ? name : ts.createIdentifier(name.text + "_" + numVarsSameName); - return createSynthIdentifier(identifier, [], numberOfAssignmentsOriginal); + return createSynthIdentifier(identifier); } - // dispatch function to recursively build the refactoring - // should be kept up to date with isFixablePromiseHandler in suggestionDiagnostics.ts - function transformExpression(node, transformer, outermostParent, prevArgName) { - if (!node) { - return ts.emptyArray; - } - var originalType = ts.isIdentifier(node) && transformer.originalTypeMap.get(ts.getNodeId(node).toString()); - var nodeType = originalType || transformer.checker.getTypeAtLocation(node); - if (ts.isCallExpression(node) && ts.hasPropertyAccessExpressionWithName(node, "then") && nodeType && !!transformer.checker.getPromisedTypeOfPromise(nodeType)) { - return transformThen(node, transformer, outermostParent, prevArgName); - } - else if (ts.isCallExpression(node) && ts.hasPropertyAccessExpressionWithName(node, "catch") && nodeType && !!transformer.checker.getPromisedTypeOfPromise(nodeType)) { + function silentFail() { + codeActionSucceeded = false; + return ts.emptyArray; + } + // dispatch function to recursively build the refactoring + // should be kept up to date with isFixablePromiseHandler in suggestionDiagnostics.ts + function transformExpression(node, transformer, prevArgName) { + if (isPromiseReturningCallExpression(node, transformer.checker, "then")) { + if (node.arguments.length === 0) + return silentFail(); + return transformThen(node, transformer, prevArgName); + } + if (isPromiseReturningCallExpression(node, transformer.checker, "catch")) { + if (node.arguments.length === 0) + return silentFail(); return transformCatch(node, transformer, prevArgName); } - else if (ts.isPropertyAccessExpression(node)) { - return transformExpression(node.expression, transformer, outermostParent, prevArgName); + if (ts.isPropertyAccessExpression(node)) { + return transformExpression(node.expression, transformer, prevArgName); } - else if (nodeType && transformer.checker.getPromisedTypeOfPromise(nodeType)) { - return transformPromiseCall(node, transformer, prevArgName); + var nodeType = transformer.checker.getTypeAtLocation(node); + if (nodeType && transformer.checker.getPromisedTypeOfPromise(nodeType)) { + ts.Debug.assertNode(node.original.parent, ts.isPropertyAccessExpression); + return transformPromiseExpressionOfPropertyAccess(node, transformer, prevArgName); } - codeActionSucceeded = false; - return ts.emptyArray; + return silentFail(); } function transformCatch(node, transformer, prevArgName) { var func = node.arguments[0]; var argName = getArgBindingName(func, transformer); - var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(node).toString()); var possibleNameForVarDecl; /* If there is another call in the chain after the .catch() we are transforming, we will need to save the result of both paths (try block and catch block) To do this, we will need to synthesize a variable that we were not aware of while we were adding identifiers to the synthNamesMap We will use the prevArgName and then update the synthNamesMap with a new variable name for the next transformation step */ - if (prevArgName && !shouldReturn) { + if (prevArgName && !shouldReturn(node, transformer)) { if (isSynthIdentifier(prevArgName)) { possibleNameForVarDecl = prevArgName; transformer.synthNamesMap.forEach(function (val, key) { @@ -226352,13 +231850,12 @@ var ts; else { possibleNameForVarDecl = createSynthIdentifier(ts.createOptimisticUniqueName("result"), prevArgName.types); } - possibleNameForVarDecl.numberOfAssignmentsOriginal = 2; // Try block and catch block - // update the constIdentifiers list - if (transformer.constIdentifiers.some(function (elem) { return elem.text === possibleNameForVarDecl.identifier.text; })) { - transformer.constIdentifiers.push(createUniqueSynthName(possibleNameForVarDecl).identifier); - } + // We are about to write a 'let' variable declaration, but `transformExpression` for both + // the try block and catch block will assign to this name. Setting this flag indicates + // that future assignments should be written as `name = value` instead of `const name = value`. + possibleNameForVarDecl.hasBeenDeclared = true; } - var tryBlock = ts.createBlock(transformExpression(node.expression, transformer, node, possibleNameForVarDecl)); + var tryBlock = ts.createBlock(transformExpression(node.expression, transformer, possibleNameForVarDecl)); var transformationBody = getTransformationBody(func, possibleNameForVarDecl, argName, node, transformer); var catchArg = argName ? isSynthIdentifier(argName) ? argName.identifier.text : argName.bindingPattern : "e"; var catchVariableDeclaration = ts.createVariableDeclaration(catchArg); @@ -226368,11 +231865,11 @@ var ts; */ var varDeclList; var varDeclIdentifier; - if (possibleNameForVarDecl && !shouldReturn) { + if (possibleNameForVarDecl && !shouldReturn(node, transformer)) { varDeclIdentifier = ts.getSynthesizedDeepClone(possibleNameForVarDecl.identifier); var typeArray = possibleNameForVarDecl.types; var unionType = transformer.checker.getUnionType(typeArray, 2 /* Subtype */); - var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType); + var unionTypeNode = transformer.isInJSFile ? undefined : transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined); var varDecl = [ts.createVariableDeclaration(varDeclIdentifier, unionTypeNode)]; varDeclList = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList(varDecl, 1 /* Let */)); } @@ -226381,68 +231878,62 @@ var ts; && ts.createVariableStatement(/* modifiers */ undefined, ts.createVariableDeclarationList([ts.createVariableDeclaration(ts.getSynthesizedDeepCloneWithRenames(prevArgName.bindingPattern), /* type */ undefined, varDeclIdentifier)], 2 /* Const */)); return ts.compact([varDeclList, tryStatement, destructuredResult]); } - function getIdentifierTextsFromBindingName(bindingName) { - if (ts.isIdentifier(bindingName)) - return [bindingName.text]; - return ts.flatMap(bindingName.elements, function (element) { - if (ts.isOmittedExpression(element)) - return []; - return getIdentifierTextsFromBindingName(element.name); - }); - } function createUniqueSynthName(prevArgName) { var renamedPrevArg = ts.createOptimisticUniqueName(prevArgName.identifier.text); return createSynthIdentifier(renamedPrevArg); } - function transformThen(node, transformer, outermostParent, prevArgName) { - var _a = node.arguments, res = _a[0], rej = _a[1]; - if (!res) { - return transformExpression(node.expression, transformer, outermostParent); - } - var argNameRes = getArgBindingName(res, transformer); - var transformationBody = getTransformationBody(res, prevArgName, argNameRes, node, transformer); - if (rej) { - var argNameRej = getArgBindingName(rej, transformer); - var tryBlock = ts.createBlock(transformExpression(node.expression, transformer, node, argNameRes).concat(transformationBody)); - var transformationBody2 = getTransformationBody(rej, prevArgName, argNameRej, node, transformer); - var catchArg = argNameRej ? isSynthIdentifier(argNameRej) ? argNameRej.identifier.text : argNameRej.bindingPattern : "e"; + function transformThen(node, transformer, prevArgName) { + var _a = node.arguments, onFulfilled = _a[0], onRejected = _a[1]; + var onFulfilledArgumentName = getArgBindingName(onFulfilled, transformer); + var transformationBody = getTransformationBody(onFulfilled, prevArgName, onFulfilledArgumentName, node, transformer); + if (onRejected) { + var onRejectedArgumentName = getArgBindingName(onRejected, transformer); + var tryBlock = ts.createBlock(transformExpression(node.expression, transformer, onFulfilledArgumentName).concat(transformationBody)); + var transformationBody2 = getTransformationBody(onRejected, prevArgName, onRejectedArgumentName, node, transformer); + var catchArg = onRejectedArgumentName ? isSynthIdentifier(onRejectedArgumentName) ? onRejectedArgumentName.identifier.text : onRejectedArgumentName.bindingPattern : "e"; var catchVariableDeclaration = ts.createVariableDeclaration(catchArg); var catchClause = ts.createCatchClause(catchVariableDeclaration, ts.createBlock(transformationBody2)); return [ts.createTry(tryBlock, catchClause, /* finallyBlock */ undefined)]; } - return transformExpression(node.expression, transformer, node, argNameRes).concat(transformationBody); + return transformExpression(node.expression, transformer, onFulfilledArgumentName).concat(transformationBody); } - function getFlagOfBindingName(bindingName, constIdentifiers) { - var identifiers = getIdentifierTextsFromBindingName(getNode(bindingName)); - var inArr = constIdentifiers.some(function (elem) { return ts.contains(identifiers, elem.text); }); - return inArr ? 2 /* Const */ : 1 /* Let */; - } - function transformPromiseCall(node, transformer, prevArgName) { - var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(node).toString()); - // the identifier is empty when the handler (.then()) ignores the argument - In this situation we do not need to save the result of the promise returning call - var originalNodeParent = node.original ? node.original.parent : node.parent; - if (prevArgName && !shouldReturn && (!originalNodeParent || ts.isPropertyAccessExpression(originalNodeParent))) { - return createTransformedStatement(prevArgName, ts.createAwait(node), transformer); - } - else if (!prevArgName && !shouldReturn && (!originalNodeParent || ts.isPropertyAccessExpression(originalNodeParent))) { - return [ts.createStatement(ts.createAwait(node))]; + /** + * Transforms the 'x' part of `x.then(...)`, or the 'y()' part of `y().catch(...)`, where 'x' and 'y()' are Promises. + */ + function transformPromiseExpressionOfPropertyAccess(node, transformer, prevArgName) { + if (shouldReturn(node, transformer)) { + return [ts.createReturn(ts.getSynthesizedDeepClone(node))]; } - return [ts.createReturn(ts.getSynthesizedDeepClone(node))]; + return createVariableOrAssignmentOrExpressionStatement(prevArgName, ts.createAwait(node), /*typeAnnotation*/ undefined); } - function createTransformedStatement(prevArgName, rightHandSide, transformer) { - if (!prevArgName || isEmpty(prevArgName)) { + function createVariableOrAssignmentOrExpressionStatement(variableName, rightHandSide, typeAnnotation) { + if (!variableName || isEmptyBindingName(variableName)) { // if there's no argName to assign to, there still might be side effects - return [ts.createStatement(rightHandSide)]; + return [ts.createExpressionStatement(rightHandSide)]; } - if (isSynthIdentifier(prevArgName) && prevArgName.types.length < prevArgName.numberOfAssignmentsOriginal) { + if (isSynthIdentifier(variableName) && variableName.hasBeenDeclared) { // if the variable has already been declared, we don't need "let" or "const" - return [ts.createStatement(ts.createAssignment(ts.getSynthesizedDeepClone(prevArgName.identifier), rightHandSide))]; + return [ts.createExpressionStatement(ts.createAssignment(ts.getSynthesizedDeepClone(variableName.identifier), rightHandSide))]; + } + return [ + ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(ts.getSynthesizedDeepClone(getNode(variableName)), typeAnnotation, rightHandSide) + ], 2 /* Const */)) + ]; + } + function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) { + if (typeAnnotation && expressionToReturn) { + var name = ts.createOptimisticUniqueName("result"); + return __spreadArrays(createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation), [ + ts.createReturn(name) + ]); } - return [ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(ts.getSynthesizedDeepClone(getNode(prevArgName)), /*type*/ undefined, rightHandSide)], getFlagOfBindingName(prevArgName, transformer.constIdentifiers))))]; + return [ts.createReturn(expressionToReturn)]; } // should be kept up to date with isFixablePromiseArgument in suggestionDiagnostics.ts function getTransformationBody(func, prevArgName, argName, parent, transformer) { - var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); + var _a, _b, _c, _d; switch (func.kind) { case 100 /* NullKeyword */: // do not produce a transformed statement for a null argument @@ -226453,18 +231944,17 @@ var ts; break; } var synthCall = ts.createCall(ts.getSynthesizedDeepClone(func), /*typeArguments*/ undefined, isSynthIdentifier(argName) ? [argName.identifier] : []); - if (shouldReturn) { - return [ts.createReturn(synthCall)]; + if (shouldReturn(parent, transformer)) { + return maybeAnnotateAndReturn(synthCall, (_a = parent.typeArguments) === null || _a === void 0 ? void 0 : _a[0]); } - var type = transformer.originalTypeMap.get(ts.getNodeId(func).toString()) || transformer.checker.getTypeAtLocation(func); + var type = transformer.checker.getTypeAtLocation(func); var callSignatures = transformer.checker.getSignaturesOfType(type, 0 /* Call */); if (!callSignatures.length) { // if identifier in handler has no call signatures, it's invalid - codeActionSucceeded = false; - break; + return silentFail(); } var returnType = callSignatures[0].getReturnType(); - var varDeclOrAssignment = createTransformedStatement(prevArgName, ts.createAwait(synthCall), transformer); + var varDeclOrAssignment = createVariableOrAssignmentOrExpressionStatement(prevArgName, ts.createAwait(synthCall), (_b = parent.typeArguments) === null || _b === void 0 ? void 0 : _b[0]); if (prevArgName) { prevArgName.types.push(returnType); } @@ -226476,20 +231966,24 @@ var ts; if (ts.isBlock(funcBody)) { var refactoredStmts = []; var seenReturnStatement = false; - for (var _i = 0, _a = funcBody.statements; _i < _a.length; _i++) { - var statement = _a[_i]; + for (var _i = 0, _e = funcBody.statements; _i < _e.length; _i++) { + var statement = _e[_i]; if (ts.isReturnStatement(statement)) { seenReturnStatement = true; - } - if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { - refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); + if (ts.isReturnStatementWithFixablePromiseHandler(statement)) { + refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName)); + } + else { + refactoredStmts.push.apply(refactoredStmts, maybeAnnotateAndReturn(statement.expression, (_c = parent.typeArguments) === null || _c === void 0 ? void 0 : _c[0])); + } } else { refactoredStmts.push(statement); } } - return shouldReturn ? refactoredStmts.map(function (s) { return ts.getSynthesizedDeepClone(s); }) : - removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement); + return shouldReturn(parent, transformer) + ? refactoredStmts.map(function (s) { return ts.getSynthesizedDeepClone(s); }) + : removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement); } else { var innerRetStmts = ts.isFixablePromiseHandler(funcBody) ? [ts.createReturn(funcBody)] : ts.emptyArray; @@ -226501,22 +231995,21 @@ var ts; var returnType_1 = getLastCallSignature(type_1, transformer.checker).getReturnType(); var rightHandSide = ts.getSynthesizedDeepClone(funcBody); var possiblyAwaitedRightHandSide = !!transformer.checker.getPromisedTypeOfPromise(returnType_1) ? ts.createAwait(rightHandSide) : rightHandSide; - if (!shouldReturn) { - var transformedStatement = createTransformedStatement(prevArgName, possiblyAwaitedRightHandSide, transformer); + if (!shouldReturn(parent, transformer)) { + var transformedStatement = createVariableOrAssignmentOrExpressionStatement(prevArgName, possiblyAwaitedRightHandSide, /*typeAnnotation*/ undefined); if (prevArgName) { prevArgName.types.push(returnType_1); } return transformedStatement; } else { - return [ts.createReturn(possiblyAwaitedRightHandSide)]; + return maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, (_d = parent.typeArguments) === null || _d === void 0 ? void 0 : _d[0]); } } } default: // If no cases apply, we've found a transformation body we don't know how to handle, so the refactoring should no-op to avoid deleting code. - codeActionSucceeded = false; - break; + return silentFail(); } return ts.emptyArray; } @@ -226530,12 +232023,12 @@ var ts; var stmt = stmts_1[_i]; if (ts.isReturnStatement(stmt)) { if (stmt.expression) { - var possiblyAwaitedExpression = isPromiseReturningExpression(stmt.expression, transformer.checker) ? ts.createAwait(stmt.expression) : stmt.expression; + var possiblyAwaitedExpression = isPromiseTypedExpression(stmt.expression, transformer.checker) ? ts.createAwait(stmt.expression) : stmt.expression; if (prevArgName === undefined) { ret.push(ts.createExpressionStatement(possiblyAwaitedExpression)); } else { - ret.push(ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, possiblyAwaitedExpression)], getFlagOfBindingName(prevArgName, transformer.constIdentifiers))))); + ret.push(ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, possiblyAwaitedExpression)], 2 /* Const */)))); } } } @@ -226545,7 +232038,7 @@ var ts; } // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables if (!seenReturnStatement && prevArgName !== undefined) { - ret.push(ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, ts.createIdentifier("undefined"))], getFlagOfBindingName(prevArgName, transformer.constIdentifiers))))); + ret.push(ts.createVariableStatement(/*modifiers*/ undefined, (ts.createVariableDeclarationList([ts.createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, ts.createIdentifier("undefined"))], 2 /* Const */)))); } return ret; } @@ -226555,7 +232048,7 @@ var ts; var stmt = innerRetStmts_1[_i]; ts.forEachChild(stmt, function visit(node) { if (ts.isCallExpression(node)) { - var temp = transformExpression(node, transformer, node, prevArgName); + var temp = transformExpression(node, transformer, prevArgName); innerCbBody = innerCbBody.concat(temp); if (innerCbBody.length > 0) { return; @@ -226569,7 +232062,6 @@ var ts; return innerCbBody; } function getArgBindingName(funcNode, transformer) { - var numberOfAssignmentsOriginal = 0; var types = []; var name; if (ts.isFunctionLikeDeclaration(funcNode)) { @@ -226601,10 +232093,10 @@ var ts; var originalNode = getOriginalNode(identifier); var symbol = getSymbol(originalNode); if (!symbol) { - return createSynthIdentifier(identifier, types, numberOfAssignmentsOriginal); + return createSynthIdentifier(identifier, types); } var mapEntry = transformer.synthNamesMap.get(ts.getSymbolId(symbol).toString()); - return mapEntry || createSynthIdentifier(identifier, types, numberOfAssignmentsOriginal); + return mapEntry || createSynthIdentifier(identifier, types); } function getSymbol(node) { return node.symbol ? node.symbol : transformer.checker.getSymbolAtLocation(node); @@ -226613,22 +232105,21 @@ var ts; return node.original ? node.original : node; } } - function isEmpty(bindingName) { + function isEmptyBindingName(bindingName) { if (!bindingName) { return true; } if (isSynthIdentifier(bindingName)) { return !bindingName.identifier.text; } - return ts.every(bindingName.elements, isEmpty); + return ts.every(bindingName.elements, isEmptyBindingName); } function getNode(bindingName) { return isSynthIdentifier(bindingName) ? bindingName.identifier : bindingName.bindingPattern; } - function createSynthIdentifier(identifier, types, numberOfAssignmentsOriginal) { + function createSynthIdentifier(identifier, types) { if (types === void 0) { types = []; } - if (numberOfAssignmentsOriginal === void 0) { numberOfAssignmentsOriginal = 0; } - return { kind: 0 /* Identifier */, identifier: identifier, types: types, numberOfAssignmentsOriginal: numberOfAssignmentsOriginal }; + return { kind: 0 /* Identifier */, identifier: identifier, types: types, hasBeenDeclared: false }; } function createSynthBindingPattern(bindingPattern, elements, types) { if (elements === void 0) { elements = ts.emptyArray; } @@ -226641,6 +232132,9 @@ var ts; function isSynthBindingPattern(bindingName) { return bindingName.kind === 1 /* BindingPattern */; } + function shouldReturn(expression, transformer) { + return !!expression.original && transformer.setOfExpressionsToReturn.has(ts.getNodeId(expression.original).toString()); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -227175,6 +232669,54 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var errorCodes = [ts.Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_the_importsNotUsedAsValues_is_set_to_error.code]; + var fixId = "convertToTypeOnlyImport"; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { + var importDeclaration = getImportDeclarationForDiagnosticSpan(context.span, context.sourceFile); + fixSingleImportDeclaration(t, importDeclaration, context); + }); + if (changes.length) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_type_only_import, fixId, ts.Diagnostics.Convert_all_imports_not_used_as_a_value_to_type_only_imports)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var importDeclaration = getImportDeclarationForDiagnosticSpan(diag, context.sourceFile); + fixSingleImportDeclaration(changes, importDeclaration, context); + }); + } + }); + function getImportDeclarationForDiagnosticSpan(span, sourceFile) { + return ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start).parent, ts.isImportDeclaration); + } + function fixSingleImportDeclaration(changes, importDeclaration, context) { + if (!(importDeclaration === null || importDeclaration === void 0 ? void 0 : importDeclaration.importClause)) { + return; + } + var importClause = importDeclaration.importClause; + // `changes.insertModifierBefore` produces a range that might overlap further changes + changes.insertText(context.sourceFile, importDeclaration.getStart() + "import".length, " type"); + // `import type foo, { Bar }` is not allowed, so move `foo` to new declaration + if (importClause.name && importClause.namedBindings) { + changes.deleteNodeRangeExcludingEnd(context.sourceFile, importClause.name, importDeclaration.importClause.namedBindings); + changes.insertNodeBefore(context.sourceFile, importDeclaration, ts.updateImportDeclaration(importDeclaration, + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(importClause.name, + /*namedBindings*/ undefined, + /*isTypeOnly*/ true), importDeclaration.moduleSpecifier)); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -227188,7 +232730,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile, span = context.span; var classDeclaration = getClass(sourceFile, span.start); - return ts.mapDefined(ts.getClassImplementsHeritageClauseElements(classDeclaration), function (implementedTypeNode) { + return ts.mapDefined(ts.getEffectiveImplementsTypeNodes(classDeclaration), function (implementedTypeNode) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingDeclarations(context, implementedTypeNode, sourceFile, classDeclaration, t, context.preferences); }); return changes.length === 0 ? undefined : codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Implement_interface_0, implementedTypeNode.getText(sourceFile)], fixId, ts.Diagnostics.Implement_all_unimplemented_interfaces); }); @@ -227199,7 +232741,7 @@ var ts; return codefix.codeFixAll(context, errorCodes, function (changes, diag) { var classDeclaration = getClass(diag.file, diag.start); if (ts.addToSeen(seenClassDeclarations, ts.getNodeId(classDeclaration))) { - for (var _i = 0, _a = ts.getClassImplementsHeritageClauseElements(classDeclaration); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.getEffectiveImplementsTypeNodes(classDeclaration); _i < _a.length; _i++) { var implementedTypeNode = _a[_i]; addMissingDeclarations(context, implementedTypeNode, diag.file, classDeclaration, changes, context.preferences); } @@ -227208,7 +232750,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); + return ts.Debug.checkDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !symbol.valueDeclaration || !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -227229,7 +232771,9 @@ var ts; if (!classType.getStringIndexType()) { createMissingIndexSignatureDeclaration(implementedType, 0 /* String */); } - codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, context, preferences, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); + var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); + codefix.createMissingMemberNodes(classDeclaration, nonPrivateAndNotExistedInHeritageClauseMembers, context, preferences, importAdder, function (member) { return insertInterfaceMemberNode(sourceFile, classDeclaration, member); }); + importAdder.writeFixes(changeTracker); function createMissingIndexSignatureDeclaration(type, kind) { var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); if (indexInfoOfKind) { @@ -227285,90 +232829,120 @@ var ts; }, fixIds: [importFixId], getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, preferences = context.preferences; - // Namespace fixes don't conflict, so just build a list. - var addToNamespace = []; - var importType = []; - // Keys are import clause node IDs. - var addToExisting = ts.createMap(); - var newImports = ts.createMap(); - var lastModuleSpecifier; - codefix.eachDiagnostic(context, errorCodes, function (diag) { - var info = getFixesInfo(context, diag.code, diag.start); - if (!info || !info.fixes.length) - return; - var fixes = info.fixes, symbolName = info.symbolName; - var fix = ts.first(fixes); - switch (fix.kind) { - case 0 /* UseNamespace */: - addToNamespace.push(fix); - break; - case 1 /* ImportType */: - importType.push(fix); - break; - case 2 /* AddToExisting */: { - var importClause = fix.importClause, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport; - var key = String(ts.getNodeId(importClause)); - var entry = addToExisting.get(key); - if (!entry) { - addToExisting.set(key, entry = { importClause: importClause, defaultImport: undefined, namedImports: [], canUseTypeOnlyImport: canUseTypeOnlyImport }); - } - if (importKind === 0 /* Named */) { - ts.pushIfUnique(entry.namedImports, symbolName); - } - else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); - entry.defaultImport = symbolName; - } - break; + var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences, host = context.host; + var importAdder = createImportAdder(sourceFile, program, preferences, host); + codefix.eachDiagnostic(context, errorCodes, function (diag) { return importAdder.addImportFromDiagnostic(diag, context); }); + return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, importAdder.writeFixes)); + }, + }); + function createImportAdder(sourceFile, program, preferences, host) { + var compilerOptions = program.getCompilerOptions(); + // Namespace fixes don't conflict, so just build a list. + var addToNamespace = []; + var importType = []; + // Keys are import clause node IDs. + var addToExisting = ts.createMap(); + var newImports = ts.createMap(); + return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes }; + function addImportFromDiagnostic(diagnostic, context) { + var info = getFixesInfo(context, diagnostic.code, diagnostic.start); + if (!info || !info.fixes.length) + return; + addImport(info); + } + function addImportFromExportedSymbol(exportedSymbol, usageIsTypeOnly) { + var moduleSymbol = ts.Debug.checkDefined(exportedSymbol.parent); + var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions)); + var checker = program.getTypeChecker(); + var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker)); + var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, sourceFile, compilerOptions, checker, program.getSourceFiles()); + var preferTypeOnlyImport = !!usageIsTypeOnly && compilerOptions.importsNotUsedAsValues === 2 /* Error */; + var useRequire = shouldUseRequire(sourceFile, compilerOptions); + var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, preferTypeOnlyImport, useRequire, host, preferences); + addImport({ fixes: [fix], symbolName: symbolName }); + } + function addImport(info) { + var fixes = info.fixes, symbolName = info.symbolName; + var fix = ts.first(fixes); + switch (fix.kind) { + case 0 /* UseNamespace */: + addToNamespace.push(fix); + break; + case 1 /* ImportType */: + importType.push(fix); + break; + case 2 /* AddToExisting */: { + var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport; + var key = String(ts.getNodeId(importClauseOrBindingPattern)); + var entry = addToExisting.get(key); + if (!entry) { + addToExisting.set(key, entry = { importClauseOrBindingPattern: importClauseOrBindingPattern, defaultImport: undefined, namedImports: [], canUseTypeOnlyImport: canUseTypeOnlyImport }); } - case 3 /* AddNew */: { - var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind; - var entry = newImports.get(moduleSpecifier); - if (!entry) { - newImports.set(moduleSpecifier, entry = { defaultImport: undefined, namedImports: [], namespaceLikeImport: undefined }); - lastModuleSpecifier = moduleSpecifier; - } - switch (importKind) { - case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); - entry.defaultImport = symbolName; - break; - case 0 /* Named */: - ts.pushIfUnique(entry.namedImports, symbolName); - break; - case 3 /* Equals */: - case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); - entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; - break; - } - break; + if (importKind === 0 /* Named */) { + ts.pushIfUnique(entry.namedImports, symbolName); } - default: - ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + else { + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); + entry.defaultImport = symbolName; + } + break; } + case 3 /* AddNew */: { + var moduleSpecifier = fix.moduleSpecifier, importKind = fix.importKind, useRequire = fix.useRequire, typeOnly = fix.typeOnly; + var entry = newImports.get(moduleSpecifier); + if (!entry) { + newImports.set(moduleSpecifier, entry = { namedImports: [], namespaceLikeImport: undefined, typeOnly: typeOnly, useRequire: useRequire }); + } + else { + // An import clause can only be type-only if every import fix contributing to it can be type-only. + entry.typeOnly = entry.typeOnly && typeOnly; + } + switch (importKind) { + case 1 /* Default */: + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); + entry.defaultImport = symbolName; + break; + case 0 /* Named */: + ts.pushIfUnique(entry.namedImports || (entry.namedImports = []), symbolName); + break; + case 3 /* CommonJS */: + case 2 /* Namespace */: + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); + entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; + break; + } + break; + } + default: + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); + } + } + function writeFixes(changeTracker) { + var quotePreference = ts.getQuotePreference(sourceFile, preferences); + for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) { + var fix = addToNamespace_1[_i]; + addNamespaceQualifier(changeTracker, sourceFile, fix); + } + for (var _a = 0, importType_1 = importType; _a < importType_1.length; _a++) { + var fix = importType_1[_a]; + addImportType(changeTracker, sourceFile, fix, quotePreference); + } + addToExisting.forEach(function (_a) { + var importClauseOrBindingPattern = _a.importClauseOrBindingPattern, defaultImport = _a.defaultImport, namedImports = _a.namedImports, canUseTypeOnlyImport = _a.canUseTypeOnlyImport; + doAddExistingFix(changeTracker, sourceFile, importClauseOrBindingPattern, defaultImport, namedImports, canUseTypeOnlyImport); }); - return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { - var quotePreference = ts.getQuotePreference(sourceFile, preferences); - for (var _i = 0, addToNamespace_1 = addToNamespace; _i < addToNamespace_1.length; _i++) { - var fix = addToNamespace_1[_i]; - addNamespaceQualifier(changes, sourceFile, fix); - } - for (var _a = 0, importType_1 = importType; _a < importType_1.length; _a++) { - var fix = importType_1[_a]; - addImportType(changes, sourceFile, fix, quotePreference); - } - addToExisting.forEach(function (_a) { - var importClause = _a.importClause, defaultImport = _a.defaultImport, namedImports = _a.namedImports, canUseTypeOnlyImport = _a.canUseTypeOnlyImport; - doAddExistingFix(changes, sourceFile, importClause, defaultImport, namedImports, canUseTypeOnlyImport); - }); - newImports.forEach(function (imports, moduleSpecifier) { - addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, imports, /*blankLineBetween*/ lastModuleSpecifier === moduleSpecifier); - }); - })); - }, - }); + var newDeclarations; + newImports.forEach(function (_a, moduleSpecifier) { + var useRequire = _a.useRequire, imports = __rest(_a, ["useRequire"]); + var getDeclarations = useRequire ? getNewRequires : getNewImports; + newDeclarations = ts.combine(newDeclarations, getDeclarations(moduleSpecifier, quotePreference, imports)); + }); + if (newDeclarations) { + ts.insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true); + } + } + } + codefix.createImportAdder = createImportAdder; // Sorted with the preferred fix coming first. var ImportFixKind; (function (ImportFixKind) { @@ -227382,18 +232956,23 @@ var ts; ImportKind[ImportKind["Named"] = 0] = "Named"; ImportKind[ImportKind["Default"] = 1] = "Default"; ImportKind[ImportKind["Namespace"] = 2] = "Namespace"; - ImportKind[ImportKind["Equals"] = 3] = "Equals"; - ImportKind[ImportKind["ConstEquals"] = 4] = "ConstEquals"; + ImportKind[ImportKind["CommonJS"] = 3] = "CommonJS"; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { - var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); - // We sort the best codefixes first, so taking `first` is best for completions. - var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; - var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); + var compilerOptions = program.getCompilerOptions(); + var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, compilerOptions, program.getTypeChecker(), program.getSourceFiles()); + var useRequire = shouldUseRequire(sourceFile, compilerOptions); + var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && !ts.isSourceFileJS(sourceFile) && ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position)); + var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences)).moduleSpecifier; + var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences); return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; + function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, preferTypeOnlyImport, useRequire, host, preferences) { + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); + // We sort the best codefixes first, so taking `first` is best. + return ts.first(getFixForImport(exportInfos, symbolName, position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences)); + } function codeFixActionToCodeAction(_a) { var description = _a.description, changes = _a.changes, commands = _a.commands; return { description: description, changes: changes, commands: commands }; @@ -227409,7 +232988,7 @@ var ts; if (defaultInfo && defaultInfo.name === symbolName && ts.skipAlias(defaultInfo.symbol, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: defaultInfo.kind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker) }); } - for (var _i = 0, _a = checker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { + for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) { var exported = _a[_i]; if (exported.name === symbolName && ts.skipAlias(exported, checker) === exportedSymbol) { result.push({ moduleSymbol: moduleSymbol, importKind: 0 /* Named */, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exported, checker) }); @@ -227426,13 +233005,13 @@ var ts; } function getFixForImport(exportInfos, symbolName, /** undefined only for missing JSX namespace */ - position, program, sourceFile, host, preferences) { + position, preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences) { var checker = program.getTypeChecker(); var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile); }); var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker); var addToExisting = tryAddToExistingImport(existingImports, position !== undefined && isTypeOnlyPosition(sourceFile, position)); // Don't bother providing an action to add a new import if we can add to an existing one. - var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences); + var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences); return __spreadArrays((useNamespace ? [useNamespace] : ts.emptyArray), addImport); } function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) { @@ -227450,58 +233029,91 @@ var ts; // and it is up to the user to decide which one fits best. return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration; - var namespace = getNamespaceImportName(declaration); - if (namespace) { - var moduleSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(namespace)); + var namespacePrefix = getNamespaceLikeImportText(declaration); + if (namespacePrefix) { + var moduleSymbol = getTargetModuleFromNamespaceLikeImport(declaration, checker); if (moduleSymbol && moduleSymbol.exports.has(ts.escapeLeadingUnderscores(symbolName))) { - return { kind: 0 /* UseNamespace */, namespacePrefix: namespace.text, position: position }; + return { kind: 0 /* UseNamespace */, namespacePrefix: namespacePrefix, position: position }; } } }); } + function getTargetModuleFromNamespaceLikeImport(declaration, checker) { + var _a; + switch (declaration.kind) { + case 242 /* VariableDeclaration */: + return checker.resolveExternalModuleName(declaration.initializer.arguments[0]); + case 253 /* ImportEqualsDeclaration */: + return checker.getAliasedSymbol(declaration.symbol); + case 254 /* ImportDeclaration */: + var namespaceImport = ts.tryCast((_a = declaration.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings, ts.isNamespaceImport); + return namespaceImport && checker.getAliasedSymbol(namespaceImport.symbol); + default: + return ts.Debug.assertNever(declaration); + } + } + function getNamespaceLikeImportText(declaration) { + var _a, _b, _c; + switch (declaration.kind) { + case 242 /* VariableDeclaration */: + return (_a = ts.tryCast(declaration.name, ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text; + case 253 /* ImportEqualsDeclaration */: + return declaration.name.text; + case 254 /* ImportDeclaration */: + return (_c = ts.tryCast((_b = declaration.importClause) === null || _b === void 0 ? void 0 : _b.namedBindings, ts.isNamespaceImport)) === null || _c === void 0 ? void 0 : _c.name.text; + default: + return ts.Debug.assertNever(declaration); + } + } function tryAddToExistingImport(existingImports, canUseTypeOnlyImport) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 254 /* ImportDeclaration */) + if (declaration.kind === 253 /* ImportEqualsDeclaration */) return undefined; + if (declaration.kind === 242 /* VariableDeclaration */) { + return (importKind === 0 /* Named */ || importKind === 1 /* Default */) && declaration.name.kind === 189 /* ObjectBindingPattern */ + ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: declaration.name, importKind: importKind, moduleSpecifier: declaration.initializer.arguments[0].text, canUseTypeOnlyImport: false } + : undefined; + } var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 257 /* NamedImports */) - ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind, canUseTypeOnlyImport: canUseTypeOnlyImport } + ? { kind: 2 /* AddToExisting */, importClauseOrBindingPattern: importClause, importKind: importKind, moduleSpecifier: declaration.moduleSpecifier.getText(), canUseTypeOnlyImport: canUseTypeOnlyImport } : undefined; }); } - function getNamespaceImportName(declaration) { - if (declaration.kind === 254 /* ImportDeclaration */) { - var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 256 /* NamespaceImport */ ? namedBindings.name : undefined; - } - else { - return declaration.name; - } - } function getExistingImportDeclarations(_a, checker, sourceFile) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 254 /* ImportDeclaration */ || i.kind === 253 /* ImportEqualsDeclaration */) - && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind, exportedSymbolIsTypeOnly: exportedSymbolIsTypeOnly } : undefined; + if (ts.isRequireVariableDeclaration(i.parent, /*requireStringLiteralLikeArgument*/ true)) { + return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind } : undefined; + } + if (i.kind === 254 /* ImportDeclaration */ || i.kind === 253 /* ImportEqualsDeclaration */) { + return checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; + } }); } - function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) { + function shouldUseRequire(sourceFile, compilerOptions) { + return ts.isSourceFileJS(sourceFile) + && !sourceFile.externalModuleIndicator + && (!!sourceFile.commonJsModuleIndicator || ts.getEmitModuleKind(compilerOptions) < ts.ModuleKind.ES2015); + } + function getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); + var compilerOptions = program.getCompilerOptions(); var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; - return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) + return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, compilerOptions, sourceFile, ts.createModuleSpecifierResolutionHost(program, host), preferences) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. return exportedSymbolIsTypeOnly && isJs - ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } - : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.checkDefined(position, "position should be defined") } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, useRequire: useRequire, typeOnly: preferTypeOnlyImport }; }); }); // Sort by presence in package.json, then shortest paths first @@ -227517,19 +233129,18 @@ var ts; return a.moduleSpecifier.length - b.moduleSpecifier.length; }); } - function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { - var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); - return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences); + function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, preferTypeOnlyImport, useRequire, host, preferences) { + var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, preferTypeOnlyImport, useRequire); }); + return existingDeclaration ? [existingDeclaration] : getNewImportInfos(program, sourceFile, position, preferTypeOnlyImport, useRequire, exportInfos, host, preferences); } - function newImportInfoFromExistingSpecifier(_a) { + function newImportInfoFromExistingSpecifier(_a, preferTypeOnlyImport, useRequire) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 254 /* ImportDeclaration */ - ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 265 /* ExternalModuleReference */ - ? declaration.moduleReference.expression - : undefined; - return expression && ts.isStringLiteral(expression) - ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } + var moduleSpecifier = declaration.kind === 254 /* ImportDeclaration */ ? declaration.moduleSpecifier : + declaration.kind === 242 /* VariableDeclaration */ ? declaration.initializer.arguments[0] : + declaration.moduleReference.kind === 265 /* ExternalModuleReference */ ? declaration.moduleReference.expression : + undefined; + return moduleSpecifier && ts.isStringLiteral(moduleSpecifier) + ? { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier.text, importKind: importKind, typeOnly: preferTypeOnlyImport, useRequire: useRequire } : undefined; } function getFixesInfo(context, errorCode, pos) { @@ -227548,7 +233159,8 @@ var ts; var symbol = checker.getAliasedSymbol(umdSymbol); var symbolName = umdSymbol.name; var exportInfos = [{ moduleSymbol: symbol, importKind: getUmdImportKind(sourceFile, program.getCompilerOptions()), exportedSymbolIsTypeOnly: false }]; - var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, program, sourceFile, host, preferences); + var useRequire = shouldUseRequire(sourceFile, program.getCompilerOptions()); + var fixes = getFixForImport(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*preferTypeOnlyImport*/ false, useRequire, program, sourceFile, host, preferences); return { fixes: fixes, symbolName: symbolName }; } function getUmdSymbol(token, checker) { @@ -227574,9 +233186,9 @@ var ts; case ts.ModuleKind.CommonJS: case ts.ModuleKind.UMD: if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 4 /* ConstEquals */; + return ts.isExternalModule(importingFile) ? 2 /* Namespace */ : 3 /* CommonJS */; } - return 3 /* Equals */; + return 3 /* CommonJS */; case ts.ModuleKind.System: case ts.ModuleKind.ES2015: case ts.ModuleKind.ES2020: @@ -227599,10 +233211,13 @@ var ts; : symbolToken.text; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); + var compilerOptions = program.getCompilerOptions(); + var preferTypeOnlyImport = compilerOptions.importsNotUsedAsValues === 2 /* Error */ && ts.isValidTypeOnlyAliasUseSite(symbolToken); + var useRequire = shouldUseRequire(sourceFile, compilerOptions); var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host); var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; - return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); + return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), preferTypeOnlyImport, useRequire, program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } @@ -227653,7 +233268,7 @@ var ts; // 2. 'import =' will not work in JavaScript, so the decision is between a default // and const/require. if (ts.isInJSFile(importingFile)) { - return ts.isExternalModule(importingFile) ? 1 /* Default */ : 4 /* ConstEquals */; + return ts.isExternalModule(importingFile) ? 1 /* Default */ : 3 /* CommonJS */; } // 3. At this point the most correct choice is probably 'import =', but people // really hate that, so look to see if the importing file has any precedent @@ -227661,12 +233276,12 @@ var ts; for (var _i = 0, _a = importingFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; if (ts.isImportEqualsDeclaration(statement)) { - return 3 /* Equals */; + return 3 /* CommonJS */; } } // 4. We have no precedent to go on, so just use a default import if // allowSyntheticDefaultImports/esModuleInterop is enabled. - return allowSyntheticDefaults ? 1 /* Default */ : 3 /* Equals */; + return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */; } function getDefaultExportInfoWorker(defaultExport, moduleSymbol, checker, compilerOptions) { var localSymbol = ts.getLocalSymbolForExportDefault(defaultExport); @@ -227677,7 +233292,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.checkDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -227714,16 +233329,18 @@ var ts; addImportType(changes, sourceFile, fix, quotePreference); return [ts.Diagnostics.Change_0_to_1, symbolName, getImportTypePrefix(fix.moduleSpecifier, quotePreference) + symbolName]; case 2 /* AddToExisting */: { - var importClause = fix.importClause, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport; - doAddExistingFix(changes, sourceFile, importClause, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray, canUseTypeOnlyImport); - var moduleSpecifierWithoutQuotes = ts.stripQuotes(importClause.parent.moduleSpecifier.getText()); + var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, canUseTypeOnlyImport = fix.canUseTypeOnlyImport, moduleSpecifier = fix.moduleSpecifier; + doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? symbolName : undefined, importKind === 0 /* Named */ ? [symbolName] : ts.emptyArray, canUseTypeOnlyImport); + var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier); return [importKind === 1 /* Default */ ? ts.Diagnostics.Add_default_import_0_to_existing_import_declaration_from_1 : ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, symbolName, moduleSpecifierWithoutQuotes]; // you too! } case 3 /* AddNew */: { - var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier; - addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, importKind === 1 /* Default */ ? { defaultImport: symbolName, namedImports: ts.emptyArray, namespaceLikeImport: undefined } - : importKind === 0 /* Named */ ? { defaultImport: undefined, namedImports: [symbolName], namespaceLikeImport: undefined } - : { defaultImport: undefined, namedImports: ts.emptyArray, namespaceLikeImport: { importKind: importKind, name: symbolName } }, /*blankLineBetween*/ true); + var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, typeOnly = fix.typeOnly, useRequire = fix.useRequire; + var getDeclarations = useRequire ? getNewRequires : getNewImports; + var importsCollection = importKind === 1 /* Default */ ? { defaultImport: symbolName, typeOnly: typeOnly } : + importKind === 0 /* Named */ ? { namedImports: [symbolName], typeOnly: typeOnly } : + { namespaceLikeImport: { importKind: importKind, name: symbolName }, typeOnly: typeOnly }; + ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, importsCollection), /*blankLineBetween*/ true); return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: @@ -227731,6 +233348,16 @@ var ts; } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, canUseTypeOnlyImport) { + if (clause.kind === 189 /* ObjectBindingPattern */) { + if (defaultImport) { + addElementToBindingPattern(clause, defaultImport, "default"); + } + for (var _i = 0, namedImports_1 = namedImports; _i < namedImports_1.length; _i++) { + var specifier = namedImports_1[_i]; + addElementToBindingPattern(clause, specifier, /*propertyName*/ undefined); + } + return; + } var convertTypeOnlyToRegular = !canUseTypeOnlyImport && clause.isTypeOnly; if (defaultImport) { ts.Debug.assert(!clause.name, "Cannot add a default import to an import clause that already has one"); @@ -227739,19 +233366,19 @@ var ts; if (namedImports.length) { var specifiers = namedImports.map(function (name) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); }); if (clause.namedBindings && ts.cast(clause.namedBindings, ts.isNamedImports).elements.length) { - for (var _i = 0, specifiers_1 = specifiers; _i < specifiers_1.length; _i++) { - var spec = specifiers_1[_i]; + for (var _a = 0, specifiers_1 = specifiers; _a < specifiers_1.length; _a++) { + var spec = specifiers_1[_a]; changes.insertNodeInListAfter(sourceFile, ts.last(ts.cast(clause.namedBindings, ts.isNamedImports).elements), spec); } } else { if (specifiers.length) { - var namedImports_1 = ts.createNamedImports(specifiers); + var namedImports_2 = ts.createNamedImports(specifiers); if (clause.namedBindings) { - changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); + changes.replaceNode(sourceFile, clause.namedBindings, namedImports_2); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Import clause must have either named imports or a default import"), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.checkDefined(clause.name, "Import clause must have either named imports or a default import"), namedImports_2); } } } @@ -227759,6 +233386,15 @@ var ts; if (convertTypeOnlyToRegular) { changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(clause, sourceFile)); } + function addElementToBindingPattern(bindingPattern, name, propertyName) { + var element = ts.createBindingElement(/*dotDotDotToken*/ undefined, propertyName, name); + if (bindingPattern.elements.length) { + changes.insertNodeInListAfter(sourceFile, ts.last(bindingPattern.elements), element); + } + else { + changes.replaceNode(sourceFile, bindingPattern, ts.createObjectBindingPattern([element])); + } + } } function addNamespaceQualifier(changes, sourceFile, _a) { var namespacePrefix = _a.namespacePrefix, position = _a.position; @@ -227772,21 +233408,51 @@ var ts; var quote = ts.getQuoteFromPreference(quotePreference); return "import(" + quote + moduleSpecifier + quote + ")."; } - function addNewImports(changes, sourceFile, moduleSpecifier, quotePreference, _a, blankLineBetween) { - var defaultImport = _a.defaultImport, namedImports = _a.namedImports, namespaceLikeImport = _a.namespaceLikeImport; + function getNewImports(moduleSpecifier, quotePreference, imports) { + var _a, _b; var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); - if (defaultImport !== undefined || namedImports.length) { - ts.insertImport(changes, sourceFile, ts.makeImport(defaultImport === undefined ? undefined : ts.createIdentifier(defaultImport), namedImports.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference), /*blankLineBetween*/ blankLineBetween); + var statements; + if (imports.defaultImport !== undefined || ((_a = imports.namedImports) === null || _a === void 0 ? void 0 : _a.length)) { + statements = ts.combine(statements, ts.makeImport(imports.defaultImport === undefined ? undefined : ts.createIdentifier(imports.defaultImport), (_b = imports.namedImports) === null || _b === void 0 ? void 0 : _b.map(function (n) { return ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(n)); }), moduleSpecifier, quotePreference, imports.typeOnly)); } + var namespaceLikeImport = imports.namespaceLikeImport, typeOnly = imports.typeOnly; if (namespaceLikeImport) { - ts.insertImport(changes, sourceFile, namespaceLikeImport.importKind === 3 /* Equals */ ? ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) : - namespaceLikeImport.importKind === 4 /* ConstEquals */ ? createConstEqualsRequireDeclaration(namespaceLikeImport.name, quotedModuleSpecifier) : - ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name))), quotedModuleSpecifier), /*blankLineBetween*/ blankLineBetween); + var declaration = namespaceLikeImport.importKind === 3 /* CommonJS */ + ? ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(namespaceLikeImport.name), ts.createExternalModuleReference(quotedModuleSpecifier)) + : ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause( + /*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(namespaceLikeImport.name)), typeOnly), quotedModuleSpecifier); + statements = ts.combine(statements, declaration); } + return ts.Debug.checkDefined(statements); + } + function getNewRequires(moduleSpecifier, quotePreference, imports) { + var _a, _b; + var quotedModuleSpecifier = ts.makeStringLiteral(moduleSpecifier, quotePreference); + var statements; + // const { default: foo, bar, etc } = require('./mod'); + if (imports.defaultImport || ((_a = imports.namedImports) === null || _a === void 0 ? void 0 : _a.length)) { + var bindingElements = ((_b = imports.namedImports) === null || _b === void 0 ? void 0 : _b.map(function (name) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name); })) || []; + if (imports.defaultImport) { + bindingElements.unshift(ts.createBindingElement(/*dotDotDotToken*/ undefined, "default", imports.defaultImport)); + } + var declaration = createConstEqualsRequireDeclaration(ts.createObjectBindingPattern(bindingElements), quotedModuleSpecifier); + statements = ts.combine(statements, declaration); + } + // const foo = require('./mod'); + if (imports.namespaceLikeImport) { + var declaration = createConstEqualsRequireDeclaration(imports.namespaceLikeImport.name, quotedModuleSpecifier); + statements = ts.combine(statements, declaration); + } + return ts.Debug.checkDefined(statements); } function createConstEqualsRequireDeclaration(name, quotedModuleSpecifier) { - return ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.createIdentifier(name), + return ts.createVariableStatement( + /*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(typeof name === "string" ? ts.createIdentifier(name) : name, /*type*/ undefined, ts.createCall(ts.createIdentifier("require"), /*typeArguments*/ undefined, [quotedModuleSpecifier])) ], 2 /* Const */)); } @@ -227796,12 +233462,11 @@ var ts; } function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) { var filteredCount = 0; - var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host); - var allSourceFiles = program.getSourceFiles(); - var globalTypingsCache = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); - forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) { + var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); + var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host, moduleSpecifierResolutionHost); + forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, sourceFile) { if (sourceFile === undefined) { - if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) { + if (!packageJson || packageJson.allowsImportingAmbientModule(module)) { cb(module); } else if (packageJson) { @@ -227810,8 +233475,8 @@ var ts; } else if (sourceFile && sourceFile !== from && - isImportablePath(from.fileName, sourceFile.fileName, ts.hostGetCanonicalFileName(host), globalTypingsCache)) { - if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) { + isImportableFile(program, from, sourceFile, moduleSpecifierResolutionHost)) { + if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile)) { cb(module); } else if (packageJson) { @@ -227836,6 +233501,19 @@ var ts; } } } + function isImportableFile(program, from, to, moduleSpecifierResolutionHost) { + var _a; + var getCanonicalFileName = ts.hostGetCanonicalFileName(moduleSpecifierResolutionHost); + var globalTypingsCache = (_a = moduleSpecifierResolutionHost.getGlobalTypingsCacheLocation) === null || _a === void 0 ? void 0 : _a.call(moduleSpecifierResolutionHost); + return !!ts.moduleSpecifiers.forEachFileNameOfModule(from.fileName, to.fileName, moduleSpecifierResolutionHost, + /*preferSymlinks*/ false, function (toPath) { + var toFile = program.getSourceFile(toPath); + // Determine to import using toPath only if toPath is what we were looking at + // or there doesnt exist the file in the program by the symlink + return (toFile === to || !toFile) && + isImportablePath(from.fileName, toPath, getCanonicalFileName, globalTypingsCache); + }); + } /** * Don't include something from a `node_modules` that isn't actually reachable by a global import. * A relative import to node_modules is usually a bad idea. @@ -227879,22 +233557,12 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; - function createAutoImportFilter(fromFile, program, host) { + function createAutoImportFilter(fromFile, program, host, moduleSpecifierResolutionHost) { + if (moduleSpecifierResolutionHost === void 0) { moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host); } var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host); var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */; - // Mix in `getProbablySymlinks` from Program when host doesn't have it - // in order for non-Project hosts to have a symlinks cache. - var moduleSpecifierResolutionHost = { - directoryExists: ts.maybeBind(host, host.directoryExists), - fileExists: ts.maybeBind(host, host.fileExists), - getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), - readFile: ts.maybeBind(host, host.readFile), - useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), - getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks, - getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), - }; var usesNodeCoreModules; - return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier, moduleSpecifierResolutionHost: moduleSpecifierResolutionHost }; function moduleSpecifierIsCoveredByPackageJson(specifier) { var packageName = getNodeModuleRootSpecifier(specifier); for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { @@ -227905,12 +233573,12 @@ var ts; } return false; } - function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) { + function allowsImportingAmbientModule(moduleSymbol) { if (!packageJsons.length) { return true; } var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); - var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName); if (typeof declaringNodeModuleName === "undefined") { return true; } @@ -227921,11 +233589,11 @@ var ts; return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); } - function allowsImportingSourceFile(sourceFile, allSourceFiles) { + function allowsImportingSourceFile(sourceFile) { if (!packageJsons.length) { return true; } - var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles); + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName); if (!moduleSpecifier) { return true; } @@ -227960,11 +233628,11 @@ var ts; } return false; } - function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) { + function getNodeModulesPackageNameFromFileName(importedFileName) { if (!ts.stringContains(importedFileName, "node_modules")) { return undefined; } - var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap); + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost); if (!specifier) { return undefined; } @@ -227987,6 +233655,68 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixImplicitThis"; + var errorCodes = [ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, span = context.span; + var diagnostic; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { + diagnostic = doChange(t, sourceFile, span.start, program.getTypeChecker()); + }); + return diagnostic ? [codefix.createCodeFixAction(fixId, changes, diagnostic, fixId, ts.Diagnostics.Fix_all_implicit_this_errors)] : ts.emptyArray; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + doChange(changes, diag.file, diag.start, context.program.getTypeChecker()); + }); }, + }); + function doChange(changes, sourceFile, pos, checker) { + var token = ts.getTokenAtPosition(sourceFile, pos); + ts.Debug.assert(token.kind === 104 /* ThisKeyword */); + var fn = ts.getThisContainer(token, /*includeArrowFunctions*/ false); + if (!ts.isFunctionDeclaration(fn) && !ts.isFunctionExpression(fn)) + return undefined; + if (!ts.isSourceFile(ts.getThisContainer(fn, /*includeArrowFunctions*/ false))) { // 'this' is defined outside, convert to arrow function + var fnKeyword = ts.Debug.assertDefined(ts.findChildOfKind(fn, 94 /* FunctionKeyword */, sourceFile)); + var name = fn.name; + var body = ts.Debug.assertDefined(fn.body); // Should be defined because the function contained a 'this' expression + if (ts.isFunctionExpression(fn)) { + if (name && ts.FindAllReferences.Core.isSymbolReferencedInFile(name, checker, sourceFile, body)) { + // Function expression references itself. To fix we would have to extract it to a const. + return undefined; + } + // `function() {}` --> `() => {}` + changes.delete(sourceFile, fnKeyword); + if (name) { + changes.delete(sourceFile, name); + } + changes.insertText(sourceFile, body.pos, " =>"); + return [ts.Diagnostics.Convert_function_expression_0_to_arrow_function, name ? name.text : ts.ANONYMOUS]; + } + else { + // `function f() {}` => `const f = () => {}` + // `name` should be defined because we only do this in inner contexts, and name is only undefined for `export default function() {}`. + changes.replaceNode(sourceFile, fnKeyword, ts.createToken(81 /* ConstKeyword */)); + changes.insertText(sourceFile, name.end, " = "); + changes.insertText(sourceFile, body.pos, " =>"); + return [ts.Diagnostics.Convert_function_declaration_0_to_arrow_function, name.text]; + } + } + // No outer 'this', add a @class tag if in a JS constructor function + else if (ts.isSourceFileJS(sourceFile) && ts.isPropertyAccessExpression(token.parent) && ts.isAssignmentExpression(token.parent.parent)) { + codefix.addJSDocTags(changes, sourceFile, fn, [ts.createJSDocClassTag()]); + return ts.Diagnostics.Add_class_tag; + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -228023,19 +233753,19 @@ var ts; // this.speling = 1; // ^^^^^^^ var node = ts.getTokenAtPosition(sourceFile, pos); + var parent = node.parent; var checker = context.program.getTypeChecker(); var suggestedSymbol; - if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { + if (ts.isPropertyAccessExpression(parent) && parent.name === node) { ts.Debug.assert(ts.isIdentifierOrPrivateIdentifier(node), "Expected an identifier for spelling (property access)"); - var containingType = checker.getTypeAtLocation(node.parent.expression); - if (node.parent.flags & 32 /* OptionalChain */) { + var containingType = checker.getTypeAtLocation(parent.expression); + if (parent.flags & 32 /* OptionalChain */) { containingType = checker.getNonNullableType(containingType); } - var name = node; - suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(name, containingType); + suggestedSymbol = checker.getSuggestedSymbolForNonexistentProperty(node, containingType); } - else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)"); + else if (ts.isImportSpecifier(parent) && parent.name === node) { + ts.Debug.assertNode(node, ts.isIdentifier, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -228090,6 +233820,192 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "returnValueCorrect"; + var fixIdAddReturnStatement = "fixAddReturnStatement"; + var fixIdRemoveBlockBodyBrace = "fixRemoveBlockBodyBrace"; + var fixIdWrapTheBlockWithParen = "fixWrapTheBlockWithParen"; + var errorCodes = [ + ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code, + ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code, + ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code + ]; + var ProblemKind; + (function (ProblemKind) { + ProblemKind[ProblemKind["MissingReturnStatement"] = 0] = "MissingReturnStatement"; + ProblemKind[ProblemKind["MissingParentheses"] = 1] = "MissingParentheses"; + })(ProblemKind || (ProblemKind = {})); + codefix.registerCodeFix({ + errorCodes: errorCodes, + fixIds: [fixIdAddReturnStatement, fixIdRemoveBlockBodyBrace, fixIdWrapTheBlockWithParen], + getCodeActions: function (context) { + var program = context.program, sourceFile = context.sourceFile, start = context.span.start, errorCode = context.errorCode; + var info = getInfo(program.getTypeChecker(), sourceFile, start, errorCode); + if (!info) + return undefined; + if (info.kind === ProblemKind.MissingReturnStatement) { + return ts.append([getActionForfixAddReturnStatement(context, info.expression, info.statement)], ts.isArrowFunction(info.declaration) ? getActionForfixRemoveBlockBodyBrace(context, info.declaration, info.expression, info.commentSource) : undefined); + } + else { + return [getActionForfixWrapTheBlockWithParen(context, info.declaration, info.expression)]; + } + }, + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(context.program.getTypeChecker(), diag.file, diag.start, diag.code); + if (!info) + return undefined; + switch (context.fixId) { + case fixIdAddReturnStatement: + addReturnStatement(changes, diag.file, info.expression, info.statement); + break; + case fixIdRemoveBlockBodyBrace: + if (!ts.isArrowFunction(info.declaration)) + return undefined; + removeBlockBodyBrace(changes, diag.file, info.declaration, info.expression, info.commentSource, /* withParen */ false); + break; + case fixIdWrapTheBlockWithParen: + if (!ts.isArrowFunction(info.declaration)) + return undefined; + wrapBlockWithParen(changes, diag.file, info.declaration, info.expression); + break; + default: + ts.Debug.fail(JSON.stringify(context.fixId)); + } + }); }, + }); + function getFixInfo(checker, declaration, expectType, isFunctionType) { + if (!declaration.body || !ts.isBlock(declaration.body) || ts.length(declaration.body.statements) !== 1) + return undefined; + var firstStatement = ts.first(declaration.body.statements); + if (ts.isExpressionStatement(firstStatement) && checkFixedAssignableTo(checker, declaration, firstStatement.expression, expectType, isFunctionType)) { + return { + declaration: declaration, + kind: ProblemKind.MissingReturnStatement, + expression: firstStatement.expression, + statement: firstStatement, + commentSource: firstStatement.expression + }; + } + else if (ts.isLabeledStatement(firstStatement) && ts.isExpressionStatement(firstStatement.statement)) { + var node = ts.createObjectLiteral([ts.createPropertyAssignment(firstStatement.label, firstStatement.statement.expression)]); + if (checkFixedAssignableTo(checker, declaration, node, expectType, isFunctionType)) { + return ts.isArrowFunction(declaration) ? { + declaration: declaration, + kind: ProblemKind.MissingParentheses, + expression: node, + statement: firstStatement, + commentSource: firstStatement.statement.expression + } : { + declaration: declaration, + kind: ProblemKind.MissingReturnStatement, + expression: node, + statement: firstStatement, + commentSource: firstStatement.statement.expression + }; + } + } + else if (ts.isBlock(firstStatement) && ts.length(firstStatement.statements) === 1) { + var firstBlockStatement = ts.first(firstStatement.statements); + if (ts.isLabeledStatement(firstBlockStatement) && ts.isExpressionStatement(firstBlockStatement.statement)) { + var node = ts.createObjectLiteral([ts.createPropertyAssignment(firstBlockStatement.label, firstBlockStatement.statement.expression)]); + if (checkFixedAssignableTo(checker, declaration, node, expectType, isFunctionType)) { + return { + declaration: declaration, + kind: ProblemKind.MissingReturnStatement, + expression: node, + statement: firstStatement, + commentSource: firstBlockStatement + }; + } + } + } + return undefined; + } + function checkFixedAssignableTo(checker, declaration, expr, type, isFunctionType) { + return checker.isTypeAssignableTo(checker.getTypeAtLocation(isFunctionType ? ts.updateFunctionLikeBody(declaration, ts.createBlock([ts.createReturn(expr)])) : expr), type); + } + function getInfo(checker, sourceFile, position, errorCode) { + var node = ts.getTokenAtPosition(sourceFile, position); + if (!node.parent) + return undefined; + var declaration = ts.findAncestor(node.parent, ts.isFunctionLikeDeclaration); + switch (errorCode) { + case ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code: + if (!declaration || !declaration.body || !declaration.type || !ts.rangeContainsRange(declaration.type, node)) + return undefined; + return getFixInfo(checker, declaration, checker.getTypeFromTypeNode(declaration.type), /* isFunctionType */ false); + case ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code: + if (!declaration || !ts.isCallExpression(declaration.parent) || !declaration.body) + return undefined; + var pos = declaration.parent.arguments.indexOf(declaration); + var type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos); + if (!type) + return undefined; + return getFixInfo(checker, declaration, type, /* isFunctionType */ true); + case ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code: + if (!ts.isDeclarationName(node) || !ts.isVariableLike(node.parent) && !ts.isJsxAttribute(node.parent)) + return undefined; + var initializer = getVariableLikeInitializer(node.parent); + if (!initializer || !ts.isFunctionLikeDeclaration(initializer) || !initializer.body) + return undefined; + return getFixInfo(checker, initializer, checker.getTypeAtLocation(node.parent), /* isFunctionType */ true); + } + return undefined; + } + function getVariableLikeInitializer(declaration) { + switch (declaration.kind) { + case 242 /* VariableDeclaration */: + case 156 /* Parameter */: + case 191 /* BindingElement */: + case 159 /* PropertyDeclaration */: + case 281 /* PropertyAssignment */: + return declaration.initializer; + case 273 /* JsxAttribute */: + return declaration.initializer && (ts.isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined); + case 282 /* ShorthandPropertyAssignment */: + case 158 /* PropertySignature */: + case 284 /* EnumMember */: + case 323 /* JSDocPropertyTag */: + case 317 /* JSDocParameterTag */: + return undefined; + } + } + function addReturnStatement(changes, sourceFile, expression, statement) { + ts.suppressLeadingAndTrailingTrivia(expression); + var probablyNeedSemi = ts.probablyUsesSemicolons(sourceFile); + changes.replaceNode(sourceFile, statement, ts.createReturn(expression), { + leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude, + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Exclude, + suffix: probablyNeedSemi ? ";" : undefined + }); + } + function removeBlockBodyBrace(changes, sourceFile, declaration, expression, commentSource, withParen) { + var newBody = (withParen || ts.needsParentheses(expression)) ? ts.createParen(expression) : expression; + ts.suppressLeadingAndTrailingTrivia(commentSource); + ts.copyComments(commentSource, newBody); + changes.replaceNode(sourceFile, declaration.body, newBody); + } + function wrapBlockWithParen(changes, sourceFile, declaration, expression) { + changes.replaceNode(sourceFile, declaration.body, ts.createParen(expression)); + } + function getActionForfixAddReturnStatement(context, expression, statement) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addReturnStatement(t, context.sourceFile, expression, statement); }); + return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, ts.Diagnostics.Add_all_missing_return_statement); + } + function getActionForfixRemoveBlockBodyBrace(context, declaration, expression, commentSource) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return removeBlockBodyBrace(t, context.sourceFile, declaration, expression, commentSource, /* withParen */ false); }); + return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Remove_block_body_braces, fixIdRemoveBlockBodyBrace, ts.Diagnostics.Remove_all_incorrect_body_block_braces); + } + function getActionForfixWrapTheBlockWithParen(context, declaration, expression) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return wrapBlockWithParen(t, context.sourceFile, declaration, expression); }); + return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Wrap_the_following_body_with_parentheses_which_should_be_an_object_literal, fixIdWrapTheBlockWithParen, ts.Diagnostics.Wrap_all_object_literal_with_parentheses); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -228114,7 +234030,7 @@ var ts; return [codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_missing_enum_member_0, token_1.text], fixId, ts.Diagnostics.Add_all_missing_members)]; } var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; - var methodCodeAction = call && getActionForMethodDeclaration(context, declSourceFile, parentDeclaration, token, call, makeStatic, inJs, context.preferences); + var methodCodeAction = call && getActionForMethodDeclaration(context, declSourceFile, parentDeclaration, token, call, makeStatic, inJs); var addMember = inJs && !ts.isInterfaceDeclaration(parentDeclaration) ? ts.singleElementArray(getActionsForAddMissingMemberInJavascriptFile(context, declSourceFile, parentDeclaration, token, makeStatic)) : getActionsForAddMissingMemberInTypeScriptFile(context, declSourceFile, parentDeclaration, token, makeStatic); @@ -228122,7 +234038,7 @@ var ts; }, fixIds: [fixId], getAllCodeActions: function (context) { - var program = context.program, preferences = context.preferences; + var program = context.program; var checker = program.getTypeChecker(); var seen = ts.createMap(); var typeDeclToMembers = new ts.NodeMap(); @@ -228145,7 +234061,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_14 = function (info) { + var _loop_13 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -228158,7 +234074,7 @@ var ts; var parentDeclaration = info.parentDeclaration, declSourceFile = info.declSourceFile, inJs = info.inJs, makeStatic = info.makeStatic, token = info.token, call = info.call; // Always prefer to add a method declaration if possible. if (call && !ts.isPrivateIdentifier(token)) { - addMethodDeclaration(context, changes, declSourceFile, parentDeclaration, token, call, makeStatic, inJs, preferences); + addMethodDeclaration(context, changes, declSourceFile, parentDeclaration, token, call, makeStatic, inJs); } else { if (inJs && !ts.isInterfaceDeclaration(parentDeclaration)) { @@ -228166,13 +234082,13 @@ var ts; } else { var typeNode = getTypeNode(program.getTypeChecker(), parentDeclaration, token); - addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, makeStatic); + addPropertyDeclaration(changes, declSourceFile, parentDeclaration, token.text, typeNode, makeStatic ? 32 /* Static */ : 0); } } }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_14(info); + _loop_13(info); } }); })); @@ -228211,18 +234127,18 @@ var ts; var symbol = leftExpressionType.symbol; if (!symbol || !symbol.declarations) return undefined; - var isClass = ts.find(symbol.declarations, ts.isClassLike); + var classDeclaration = ts.find(symbol.declarations, ts.isClassLike); // Don't suggest adding private identifiers to anything other than a class. - if (!isClass && ts.isPrivateIdentifier(token)) { + if (!classDeclaration && ts.isPrivateIdentifier(token)) { return undefined; } // Prefer to change the class instead of the interface if they are merged - var classOrInterface = isClass || ts.find(symbol.declarations, ts.isInterfaceDeclaration); + var classOrInterface = classDeclaration || ts.find(symbol.declarations, ts.isInterfaceDeclaration); if (classOrInterface && !program.isSourceFileFromExternalLibrary(classOrInterface.getSourceFile())) { var makeStatic = (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol); - // Static private identifier properties are not supported yet. - if (makeStatic && ts.isPrivateIdentifier(token)) + if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(classOrInterface))) { return undefined; + } var declSourceFile = classOrInterface.getSourceFile(); var inJs = ts.isSourceFileJS(declSourceFile); var call = ts.tryCast(parent.parent, ts.isCallExpression); @@ -228282,8 +234198,15 @@ var ts; } function getActionsForAddMissingMemberInTypeScriptFile(context, declSourceFile, classDeclaration, token, makeStatic) { var typeNode = getTypeNode(context.program.getTypeChecker(), classDeclaration, token); - var addProp = createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, token.text, typeNode); - return makeStatic || ts.isPrivateIdentifier(token) ? [addProp] : [addProp, createAddIndexSignatureAction(context, declSourceFile, classDeclaration, token.text, typeNode)]; + var actions = [createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, token.text, typeNode, makeStatic ? 32 /* Static */ : 0)]; + if (makeStatic || ts.isPrivateIdentifier(token)) { + return actions; + } + if (ts.startsWithUnderscore(token.text)) { + actions.unshift(createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, token.text, typeNode, 8 /* Private */)); + } + actions.push(createAddIndexSignatureAction(context, declSourceFile, classDeclaration, token.text, typeNode)); + return actions; } function getTypeNode(checker, classDeclaration, token) { var typeNode; @@ -228291,22 +234214,25 @@ var ts; var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); - typeNode = checker.typeToTypeNode(widenedType, classDeclaration); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration, /*flags*/ undefined); } else { var contextualType = checker.getContextualType(token.parent); - typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; + typeNode = contextualType ? checker.typeToTypeNode(contextualType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined) : undefined; } return typeNode || ts.createKeywordTypeNode(125 /* AnyKeyword */); } - function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) { - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); }); - return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, tokenName], fixId, ts.Diagnostics.Add_all_missing_members); + function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags); }); + if (modifierFlags & 8 /* Private */) { + return codefix.createCodeFixActionWithoutFixAll(fixName, changes, [ts.Diagnostics.Declare_private_property_0, tokenName]); + } + return codefix.createCodeFixAction(fixName, changes, [modifierFlags & 32 /* Static */ ? ts.Diagnostics.Declare_static_property_0 : ts.Diagnostics.Declare_property_0, tokenName], fixId, ts.Diagnostics.Add_all_missing_members); } - function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { + function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, modifierFlags) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(120 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ modifierFlags ? ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -228344,16 +234270,17 @@ var ts; // No fixId here because code-fix-all currently only works on adding individual named properties. return codefix.createCodeFixActionWithoutFixAll(fixName, changes, [ts.Diagnostics.Add_index_signature_for_property_0, tokenName]); } - function getActionForMethodDeclaration(context, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences) { + function getActionForMethodDeclaration(context, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs) { // Private methods are not implemented yet. if (ts.isPrivateIdentifier(token)) { return undefined; } - var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs, preferences); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMethodDeclaration(context, t, declSourceFile, classDeclaration, token, callExpression, makeStatic, inJs); }); return codefix.createCodeFixAction(fixName, changes, [makeStatic ? ts.Diagnostics.Declare_static_method_0 : ts.Diagnostics.Declare_method_0, token.text], fixId, ts.Diagnostics.Add_all_missing_members); } - function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { - var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); + function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs) { + var importAdder = codefix.createImportAdder(declSourceFile, context.program, context.preferences, context.host); + var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, typeDecl, importAdder); var containingMethodDeclaration = ts.getAncestor(callExpression, 161 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); @@ -228361,6 +234288,7 @@ var ts; else { changeTracker.insertNodeAtClassStart(declSourceFile, typeDecl, methodDeclaration); } + importAdder.writeFixes(changeTracker); } function addEnumMemberDeclaration(changes, checker, token, enumDeclaration) { /** @@ -228373,7 +234301,10 @@ var ts; return !!(type && type.flags & 132 /* StringLike */); }); var enumMember = ts.createEnumMember(token, hasStringInitializer ? ts.createStringLiteral(token.text) : undefined); - changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember)))); + changes.replaceNode(enumDeclaration.getSourceFile(), enumDeclaration, ts.updateEnumDeclaration(enumDeclaration, enumDeclaration.decorators, enumDeclaration.modifiers, enumDeclaration.name, ts.concatenate(enumDeclaration.members, ts.singleElementArray(enumMember))), { + leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll, + trailingTriviaOption: ts.textChanges.TrailingTriviaOption.Exclude + }); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -228418,7 +234349,7 @@ var ts; (function (codefix) { var fixName = "fixCannotFindModule"; var fixIdInstallTypesPackage = "installTypesPackage"; - var errorCodeCannotFindModule = ts.Diagnostics.Cannot_find_module_0.code; + var errorCodeCannotFindModule = ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations.code; var errorCodes = [ errorCodeCannotFindModule, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type.code, @@ -228513,7 +234444,9 @@ var ts; // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. var abstractAndNonPrivateExtendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType).filter(symbolPointsToNonPrivateAndAbstractMember); - codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, context, preferences, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); + var importAdder = codefix.createImportAdder(sourceFile, context.program, preferences, context.host); + codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, context, preferences, importAdder, function (member) { return changeTracker.insertNodeAtClassStart(sourceFile, classDeclaration, member); }); + importAdder.writeFixes(changeTracker); } function symbolPointsToNonPrivateAndAbstractMember(symbol) { // See `codeFixClassExtendAbstractProtectedProperty.ts` in https://github.com/Microsoft/TypeScript/pull/11547/files @@ -228601,7 +234534,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 129 /* ConstructorKeyword */, "token should be at the constructor keyword"); + ts.Debug.assert(ts.isConstructorDeclaration(token.parent), "token should be at the constructor declaration"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -228821,6 +234754,51 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixIdExpression = "fixInvalidJsxCharacters_expression"; + var fixIdHtmlEntity = "fixInvalidJsxCharacters_htmlEntity"; + var errorCodes = [ + ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt.code, + ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace.code + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + fixIds: [fixIdExpression, fixIdHtmlEntity], + getCodeActions: function (context) { + var sourceFile = context.sourceFile, preferences = context.preferences, span = context.span; + var changeToExpression = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, preferences, sourceFile, span.start, /* useHtmlEntity */ false); }); + var changeToHtmlEntity = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, preferences, sourceFile, span.start, /* useHtmlEntity */ true); }); + return [ + codefix.createCodeFixAction(fixIdExpression, changeToExpression, ts.Diagnostics.Wrap_invalid_character_in_an_expression_container, fixIdExpression, ts.Diagnostics.Wrap_all_invalid_characters_in_an_expression_container), + codefix.createCodeFixAction(fixIdHtmlEntity, changeToHtmlEntity, ts.Diagnostics.Convert_invalid_character_to_its_html_entity_code, fixIdHtmlEntity, ts.Diagnostics.Convert_all_invalid_characters_to_HTML_entity_code) + ]; + }, + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diagnostic) { return doChange(changes, context.preferences, diagnostic.file, diagnostic.start, context.fixId === fixIdHtmlEntity); }); + } + }); + var htmlEntity = { + ">": ">", + "}": "}", + }; + function isValidCharacter(character) { + return ts.hasProperty(htmlEntity, character); + } + function doChange(changes, preferences, sourceFile, start, useHtmlEntity) { + var character = sourceFile.getText()[start]; + // sanity check + if (!isValidCharacter(character)) { + return; + } + var replacement = useHtmlEntity ? htmlEntity[character] : "{" + ts.quote(character, preferences) + "}"; + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 1 }, replacement); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -228935,7 +234913,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); + changes.delete(sourceFile, ts.Debug.checkDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { @@ -228970,6 +234948,13 @@ var ts; } if (ts.isIdentifier(token) && canPrefix(token)) { changes.replaceNode(sourceFile, token, ts.createIdentifier("_" + token.text)); + if (ts.isParameter(token.parent)) { + ts.getJSDocParameterTags(token.parent).forEach(function (tag) { + if (ts.isIdentifier(tag.name)) { + changes.replaceNode(sourceFile, tag.name, ts.createIdentifier("_" + tag.name.text)); + } + }); + } } } function canPrefix(token) { @@ -229115,7 +235100,7 @@ var ts; } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); + var lastStatement = ts.Debug.checkDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -229207,7 +235192,7 @@ var ts; } }); function doChange(changes, sourceFile, oldTypeNode, newType, checker) { - changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode)); // TODO: GH#18217 + changes.replaceNode(sourceFile, oldTypeNode, checker.typeToTypeNode(newType, /*enclosingDeclaration*/ oldTypeNode, /*flags*/ undefined)); // TODO: GH#18217 } function getInfo(sourceFile, pos, checker) { var decl = ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), isTypeContainer); @@ -229243,6 +235228,51 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixMissingCallParentheses"; + var errorCodes = [ + ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + fixIds: [fixId], + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span; + var callName = getCallName(sourceFile, span.start); + if (!callName) + return; + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, context.sourceFile, callName); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_missing_call_parentheses, fixId, ts.Diagnostics.Add_all_missing_call_parentheses)]; + }, + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var callName = getCallName(diag.file, diag.start); + if (callName) + doChange(changes, diag.file, callName); + }); } + }); + function doChange(changes, sourceFile, name) { + changes.replaceNodeWithText(sourceFile, name, name.text + "()"); + } + function getCallName(sourceFile, start) { + var token = ts.getTokenAtPosition(sourceFile, start); + if (ts.isPropertyAccessExpression(token.parent)) { + var current = token.parent; + while (ts.isPropertyAccessExpression(current.parent)) { + current = current.parent; + } + return current.name; + } + if (ts.isIdentifier(token)) { + return token; + } + return undefined; + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -229322,6 +235352,986 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "inferFromUsage"; + var errorCodes = [ + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code, + ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type.code, + //// Suggestions + // Variable declarations + ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code, + // Variable uses + ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + // Parameter declarations + ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code, + // Get Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code, + ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code, + // Set Accessor declarations + ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code, + // Property declarations + ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code, + // Function expressions and declarations + ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host, preferences = context.preferences; + var token = ts.getTokenAtPosition(sourceFile, start); + var declaration; + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, preferences); }); + var name = declaration && ts.getNameOfDeclaration(declaration); + return !name || changes.length === 0 ? undefined + : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host, preferences = context.preferences; + var markSeen = ts.nodeSeenTracker(); + return codefix.codeFixAll(context, errorCodes, function (changes, err) { + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, preferences); + }); + }, + }); + function getDiagnostic(errorCode, token) { + switch (errorCode) { + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.isSetAccessorDeclaration(ts.getContainingFunction(token)) ? ts.Diagnostics.Infer_type_of_0_from_usage : ts.Diagnostics.Infer_parameter_types_from_usage; // TODO: GH#18217 + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Infer_parameter_types_from_usage; + case ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code: + return ts.Diagnostics.Infer_this_type_of_0_from_usage; + default: + return ts.Diagnostics.Infer_type_of_0_from_usage; + } + } + /** Map suggestion code to error code */ + function mapSuggestionDiagnostic(errorCode) { + switch (errorCode) { + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code; + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_get_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code; + case ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code; + case ts.Diagnostics.Property_0_implicitly_has_type_any_but_a_better_type_for_its_set_accessor_may_be_inferred_from_usage.code: + return ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code; + case ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage.code: + return ts.Diagnostics.Member_0_implicitly_has_an_1_type.code; + } + return errorCode; + } + function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, preferences) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 104 /* ThisKeyword */) { + return undefined; + } + var parent = token.parent; + var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host); + errorCode = mapSuggestionDiagnostic(errorCode); + switch (errorCode) { + // Variable and Property declarations + case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: + case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: + if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location + annotateVariableDeclaration(changes, importAdder, sourceFile, parent, program, host, cancellationToken); + importAdder.writeFixes(changes); + return parent; + } + if (ts.isPropertyAccessExpression(parent)) { + var type = inferTypeForVariableFromUsage(parent.name, program, cancellationToken); + var typeNode = ts.getTypeNodeIfAccessible(type, parent, program, host); + if (typeNode) { + // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags + var typeTag = ts.createJSDocTypeTag(ts.createJSDocTypeExpression(typeNode), /*comment*/ ""); + addJSDocTags(changes, sourceFile, ts.cast(parent.parent.parent, ts.isExpressionStatement), [typeTag]); + } + importAdder.writeFixes(changes); + return parent; + } + return undefined; + case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { + var symbol = program.getTypeChecker().getSymbolAtLocation(token); + if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { + annotateVariableDeclaration(changes, importAdder, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); + importAdder.writeFixes(changes); + return symbol.valueDeclaration; + } + return undefined; + } + } + var containingFunction = ts.getContainingFunction(token); + if (containingFunction === undefined) { + return undefined; + } + var declaration; + switch (errorCode) { + // Parameter declarations + case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, importAdder, sourceFile, containingFunction, program, host, cancellationToken); + declaration = containingFunction; + break; + } + // falls through + case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: + if (markSeen(containingFunction)) { + var param = ts.cast(parent, ts.isParameter); + annotateParameters(changes, importAdder, sourceFile, param, containingFunction, program, host, cancellationToken); + declaration = param; + } + break; + // Get Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: + case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: + if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { + annotate(changes, importAdder, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); + declaration = containingFunction; + } + break; + // Set Accessor declarations + case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: + if (ts.isSetAccessorDeclaration(containingFunction)) { + annotateSetAccessor(changes, importAdder, sourceFile, containingFunction, program, host, cancellationToken); + declaration = containingFunction; + } + break; + // Function 'this' + case ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation.code: + if (ts.textChanges.isThisTypeAnnotatable(containingFunction) && markSeen(containingFunction)) { + annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken); + declaration = containingFunction; + } + break; + default: + return ts.Debug.fail(String(errorCode)); + } + importAdder.writeFixes(changes); + return declaration; + } + function annotateVariableDeclaration(changes, importAdder, sourceFile, declaration, program, host, cancellationToken) { + if (ts.isIdentifier(declaration.name)) { + annotate(changes, importAdder, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); + } + } + function annotateParameters(changes, importAdder, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { + if (!ts.isIdentifier(parameterDeclaration.name)) { + return; + } + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); + if (ts.isInJSFile(containingFunction)) { + annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); + } + else { + var needParens = ts.isArrowFunction(containingFunction) && !ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile); + if (needParens) + changes.insertNodeBefore(sourceFile, ts.first(containingFunction.parameters), ts.createToken(20 /* OpenParenToken */)); + for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { + var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; + if (declaration && !declaration.type && !declaration.initializer) { + annotate(changes, importAdder, sourceFile, declaration, type, program, host); + } + } + if (needParens) + changes.insertNodeAfter(sourceFile, ts.last(containingFunction.parameters), ts.createToken(21 /* CloseParenToken */)); + } + } + function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { + return; + } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); + var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); + if (!typeNode) { + return; + } + if (ts.isInJSFile(containingFunction)) { + annotateJSDocThis(changes, sourceFile, containingFunction, typeNode); + } + else { + changes.tryInsertThisTypeAnnotation(sourceFile, containingFunction, typeNode); + } + } + function annotateJSDocThis(changes, sourceFile, containingFunction, typeNode) { + addJSDocTags(changes, sourceFile, containingFunction, [ + ts.createJSDocThisTag(ts.createJSDocTypeExpression(typeNode)), + ]); + } + function annotateSetAccessor(changes, importAdder, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { + var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); + if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { + var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); + if (type === program.getTypeChecker().getAnyType()) { + type = inferTypeForVariableFromUsage(param.name, program, cancellationToken); + } + if (ts.isInJSFile(setAccessorDeclaration)) { + annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); + } + else { + annotate(changes, importAdder, sourceFile, param, type, program, host); + } + } + } + function annotate(changes, importAdder, sourceFile, declaration, type, program, host) { + var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); + if (typeNode) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 158 /* PropertySignature */) { + var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; + if (!parent) { + return; + } + var typeExpression = ts.createJSDocTypeExpression(typeNode); + var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); + addJSDocTags(changes, sourceFile, parent, [typeTag]); + } + else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, type, sourceFile, changes, importAdder, ts.getEmitScriptTarget(program.getCompilerOptions()))) { + changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); + } + } + } + function tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, type, sourceFile, changes, importAdder, scriptTarget) { + var importableReference = codefix.tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget); + if (importableReference && changes.tryInsertTypeAnnotation(sourceFile, declaration, importableReference.typeReference)) { + ts.forEach(importableReference.symbols, function (s) { return importAdder.addImportFromExportedSymbol(s, /*usageIsTypeOnly*/ true); }); + return true; + } + return false; + } + function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { + var signature = parameterInferences.length && parameterInferences[0].declaration.parent; + if (!signature) { + return; + } + var paramTags = ts.mapDefined(parameterInferences, function (inference) { + var param = inference.declaration; + // only infer parameters that have (1) no type and (2) an accessible inferred type + if (param.initializer || ts.getJSDocType(param) || !ts.isIdentifier(param.name)) + return; + var typeNode = inference.type && ts.getTypeNodeIfAccessible(inference.type, param, program, host); + var name = ts.getSynthesizedClone(param.name); + ts.setEmitFlags(name, 1536 /* NoComments */ | 2048 /* NoNestedComments */); + return typeNode && ts.createJSDocParamTag(name, !!inference.isOptional, ts.createJSDocTypeExpression(typeNode), ""); + }); + addJSDocTags(changes, sourceFile, signature, paramTags); + } + function addJSDocTags(changes, sourceFile, parent, newTags) { + var comments = ts.mapDefined(parent.jsDoc, function (j) { return j.comment; }); + var oldTags = ts.flatMapToMutable(parent.jsDoc, function (j) { return j.tags; }); + var unmergedNewTags = newTags.filter(function (newTag) { return !oldTags || !oldTags.some(function (tag, i) { + var merged = tryMergeJsdocTags(tag, newTag); + if (merged) + oldTags[i] = merged; + return !!merged; + }); }); + var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); + var jsDocNode = parent.kind === 202 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + jsDocNode.jsDoc = parent.jsDoc; + jsDocNode.jsDocCache = parent.jsDocCache; + changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); + } + codefix.addJSDocTags = addJSDocTags; + function getJsDocNodeForArrowFunction(signature) { + if (signature.parent.kind === 159 /* PropertyDeclaration */) { + return signature.parent; + } + return signature.parent.parent; + } + function tryMergeJsdocTags(oldTag, newTag) { + if (oldTag.kind !== newTag.kind) { + return undefined; + } + switch (oldTag.kind) { + case 317 /* JSDocParameterTag */: { + var oldParam = oldTag; + var newParam = newTag; + return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText + ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) + : undefined; + } + case 318 /* JSDocReturnTag */: + return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); + } + } + function getReferences(token, program, cancellationToken) { + // Position shouldn't matter since token is not a SourceFile. + return ts.mapDefined(ts.FindAllReferences.getReferenceEntriesForNode(-1, token, program, program.getSourceFiles(), cancellationToken), function (entry) { + return entry.kind !== 0 /* Span */ ? ts.tryCast(entry.node, ts.isIdentifier) : undefined; + }); + } + function inferTypeForVariableFromUsage(token, program, cancellationToken) { + var references = getReferences(token, program, cancellationToken); + return inferTypeFromReferences(program, references, cancellationToken).single(); + } + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + } + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { + var searchToken; + switch (containingFunction.kind) { + case 162 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 129 /* ConstructorKeyword */, sourceFile); + break; + case 202 /* ArrowFunction */: + case 201 /* FunctionExpression */: + var parent = containingFunction.parent; + searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? + parent.name : + containingFunction.name; + break; + case 244 /* FunctionDeclaration */: + case 161 /* MethodDeclaration */: + searchToken = containingFunction.name; + break; + } + if (!searchToken) { + return undefined; + } + return getReferences(searchToken, program, cancellationToken); + } + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + var builtinConstructors = { + string: function () { return checker.getStringType(); }, + number: function () { return checker.getNumberType(); }, + Array: function (t) { return checker.createArrayType(t); }, + Promise: function (t) { return checker.createPromiseType(t); }, + }; + var builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function createEmptyUsage() { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + function combineUsages(usages) { + var combinedProperties = ts.createUnderscoreEscapedMap(); + for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { + var u = usages_1[_i]; + if (u.properties) { + u.properties.forEach(function (p, name) { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name).push(p); + }); + } + } + var properties = ts.createUnderscoreEscapedMap(); + combinedProperties.forEach(function (ps, name) { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(function (u) { return u.isNumber; }), + isString: usages.some(function (u) { return u.isString; }), + isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), + candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), + properties: properties, + calls: ts.flatMap(usages, function (u) { return u.calls; }), + constructs: ts.flatMap(usages, function (u) { return u.constructs; }), + numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), + stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), + candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), + inferredTypes: undefined, + }; + } + function single() { + return combineTypes(inferTypesFromReferencesSingle(references)); + } + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { + return undefined; + } + var usage = createEmptyUsage(); + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); + } + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); + return declaration.parameters.map(function (parameter, parameterIndex) { + var types = []; + var isRest = ts.isRestParameter(parameter); + var isOptional = false; + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.argumentTypes.length <= parameterIndex) { + isOptional = ts.isInJSFile(declaration); + types.push(checker.getUndefinedType()); + } + else if (isRest) { + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); + } + } + else { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); + } + } + if (ts.isIdentifier(parameter.name)) { + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); + types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); + } + var type = combineTypes(types); + return { + type: isRest ? checker.createArrayType(type) : type, + isOptional: isOptional && !isRest, + declaration: parameter + }; + }); + } + function thisParameter() { + var usage = createEmptyUsage(); + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); + } + return combineTypes(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = createEmptyUsage(); + for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { + var reference = references_4[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); + } + return inferTypes(usage); + } + function calculateUsageOfNode(node, usage) { + while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { + node = node.parent; + } + switch (node.parent.kind) { + case 226 /* ExpressionStatement */: + inferTypeFromExpressionStatement(node, usage); + break; + case 208 /* PostfixUnaryExpression */: + usage.isNumber = true; + break; + case 207 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); + break; + case 209 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); + break; + case 277 /* CaseClause */: + case 278 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); + break; + case 196 /* CallExpression */: + case 197 /* NewExpression */: + if (node.parent.expression === node) { + inferTypeFromCallExpression(node.parent, usage); + } + else { + inferTypeFromContextualType(node, usage); + } + break; + case 194 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); + break; + case 195 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); + break; + case 281 /* PropertyAssignment */: + case 282 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); + break; + case 159 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); + break; + case 242 /* VariableDeclaration */: { + var _a = node.parent, name = _a.name, initializer = _a.initializer; + if (node === name) { + if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. + addCandidateType(usage, checker.getTypeAtLocation(initializer)); + } + break; + } + } + // falls through + default: + return inferTypeFromContextualType(node, usage); + } + } + function inferTypeFromContextualType(node, usage) { + if (ts.isExpressionNode(node)) { + addCandidateType(usage, checker.getContextualType(node)); + } + } + function inferTypeFromExpressionStatement(node, usage) { + addCandidateType(usage, ts.isCallExpression(node) ? checker.getVoidType() : checker.getAnyType()); + } + function inferTypeFromPrefixUnaryExpression(node, usage) { + switch (node.operator) { + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + usage.isNumber = true; + break; + case 39 /* PlusToken */: + usage.isNumberOrString = true; + break; + // case SyntaxKind.ExclamationToken: + // no inferences here; + } + } + function inferTypeFromBinaryExpression(node, parent, usage) { + switch (parent.operatorToken.kind) { + // ExponentiationOperator + case 42 /* AsteriskAsteriskToken */: + // MultiplicativeOperator + // falls through + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: + // ShiftOperator + // falls through + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + // BitwiseOperator + // falls through + case 50 /* AmpersandToken */: + case 51 /* BarToken */: + case 52 /* CaretToken */: + // CompoundAssignmentOperator + // falls through + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 73 /* BarEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + // AdditiveOperator + // falls through + case 40 /* MinusToken */: + // RelationalOperator + // falls through + case 29 /* LessThanToken */: + case 32 /* LessThanEqualsToken */: + case 31 /* GreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: + var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (operandType.flags & 1056 /* EnumLike */) { + addCandidateType(usage, operandType); + } + else { + usage.isNumber = true; + } + break; + case 63 /* PlusEqualsToken */: + case 39 /* PlusToken */: + var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); + if (otherOperandType.flags & 1056 /* EnumLike */) { + addCandidateType(usage, otherOperandType); + } + else if (otherOperandType.flags & 296 /* NumberLike */) { + usage.isNumber = true; + } + else if (otherOperandType.flags & 132 /* StringLike */) { + usage.isString = true; + } + else if (otherOperandType.flags & 1 /* Any */) { + // do nothing, maybe we'll learn something elsewhere + } + else { + usage.isNumberOrString = true; + } + break; + // AssignmentOperators + case 62 /* EqualsToken */: + case 34 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + break; + case 97 /* InKeyword */: + if (node === parent.left) { + usage.isString = true; + } + break; + // LogicalOperator Or NullishCoalescing + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + if (node === parent.left && + (node.parent.parent.kind === 242 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + // var x = x || {}; + // TODO: use getFalsyflagsOfType + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); + } + break; + case 55 /* AmpersandAmpersandToken */: + case 27 /* CommaToken */: + case 98 /* InstanceOfKeyword */: + // nothing to infer here + break; + } + } + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); + } + function inferTypeFromCallExpression(parent, usage) { + var call = { + argumentTypes: [], + return_: createEmptyUsage() + }; + if (parent.arguments) { + for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { + var argument = _a[_i]; + call.argumentTypes.push(checker.getTypeAtLocation(argument)); + } + } + calculateUsageOfNode(parent, call.return_); + if (parent.kind === 196 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); + } + else { + (usage.constructs || (usage.constructs = [])).push(call); + } + } + function inferTypeFromPropertyAccessExpression(parent, usage) { + var name = ts.escapeLeadingUnderscores(parent.name.text); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); + } + var propertyUsage = usage.properties.get(name) || createEmptyUsage(); + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); + } + function inferTypeFromPropertyElementExpression(parent, node, usage) { + if (node === parent.argumentExpression) { + usage.isNumberOrString = true; + return; + } + else { + var indexType = checker.getTypeAtLocation(parent.argumentExpression); + var indexUsage = createEmptyUsage(); + calculateUsageOfNode(parent, indexUsage); + if (indexType.flags & 296 /* NumberLike */) { + usage.numberIndex = indexUsage; + } + else { + usage.stringIndex = indexUsage; + } + } + } + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); + } + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); + } + function removeLowPriorityInferences(inferences, priorities) { + var toRemove = []; + for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) { + var i = inferences_1[_i]; + for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { + var _b = priorities_1[_a], high = _b.high, low = _b.low; + if (high(i)) { + ts.Debug.assert(!low(i), "Priority can't have both low and high"); + toRemove.push(low); + } + } + } + return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); + } + function combineFromUsage(usage) { + return combineTypes(inferTypes(usage)); + } + function combineTypes(inferences) { + if (!inferences.length) + return checker.getAnyType(); + // 1. string or number individually override string | number + // 2. non-any, non-void overrides any or void + // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types + var stringNumber = checker.getUnionType([checker.getStringType(), checker.getNumberType()]); + var priorities = [ + { + high: function (t) { return t === checker.getStringType() || t === checker.getNumberType(); }, + low: function (t) { return t === stringNumber; } + }, + { + high: function (t) { return !(t.flags & (1 /* Any */ | 16384 /* Void */)); }, + low: function (t) { return !!(t.flags & (1 /* Any */ | 16384 /* Void */)); } + }, + { + high: function (t) { return !(t.flags & (98304 /* Nullable */ | 1 /* Any */ | 16384 /* Void */)) && !(ts.getObjectFlags(t) & 16 /* Anonymous */); }, + low: function (t) { return !!(ts.getObjectFlags(t) & 16 /* Anonymous */); } + } + ]; + var good = removeLowPriorityInferences(inferences, priorities); + var anons = good.filter(function (i) { return ts.getObjectFlags(i) & 16 /* Anonymous */; }); + if (anons.length) { + good = good.filter(function (i) { return !(ts.getObjectFlags(i) & 16 /* Anonymous */); }); + good.push(combineAnonymousTypes(anons)); + } + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); + } + function combineAnonymousTypes(anons) { + if (anons.length === 1) { + return anons[0]; + } + var calls = []; + var constructs = []; + var stringIndices = []; + var numberIndices = []; + var stringIndexReadonly = false; + var numberIndexReadonly = false; + var props = ts.createMultiMap(); + for (var _i = 0, anons_1 = anons; _i < anons_1.length; _i++) { + var anon = anons_1[_i]; + for (var _a = 0, _b = checker.getPropertiesOfType(anon); _a < _b.length; _a++) { + var p = _b[_a]; + props.add(p.name, checker.getTypeOfSymbolAtLocation(p, p.valueDeclaration)); + } + calls.push.apply(calls, checker.getSignaturesOfType(anon, 0 /* Call */)); + constructs.push.apply(constructs, checker.getSignaturesOfType(anon, 1 /* Construct */)); + if (anon.stringIndexInfo) { + stringIndices.push(anon.stringIndexInfo.type); + stringIndexReadonly = stringIndexReadonly || anon.stringIndexInfo.isReadonly; + } + if (anon.numberIndexInfo) { + numberIndices.push(anon.numberIndexInfo.type); + numberIndexReadonly = numberIndexReadonly || anon.numberIndexInfo.isReadonly; + } + } + var members = ts.mapEntries(props, function (name, types) { + var isOptional = types.length < anons.length ? 16777216 /* Optional */ : 0; + var s = checker.createSymbol(4 /* Property */ | isOptional, name); + s.type = checker.getUnionType(types); + return [name, s]; + }); + return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); + } + function inferTypes(usage) { + var _a, _b, _c; + var types = []; + if (usage.isNumber) { + types.push(checker.getNumberType()); + } + if (usage.isString) { + types.push(checker.getStringType()); + } + if (usage.isNumberOrString) { + types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); + } + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); + } + if (((_a = usage.properties) === null || _a === void 0 ? void 0 : _a.size) || ((_b = usage.calls) === null || _b === void 0 ? void 0 : _b.length) || ((_c = usage.constructs) === null || _c === void 0 ? void 0 : _c.length) || usage.stringIndex) { + types.push(inferStructuralType(usage)); + } + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + types.push.apply(types, inferNamedTypesFromProperties(usage)); + return types; + } + function inferStructuralType(usage) { + var members = ts.createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach(function (u, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); + } + var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); + } + function inferNamedTypesFromProperties(usage) { + if (!usage.properties || !usage.properties.size) + return []; + var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); + if (0 < types.length && types.length < 3) { + return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); + } + return []; + } + function allPropertiesAreAssignableToUsage(type, usage) { + if (!usage.properties) + return false; + return !ts.forEachEntry(usage.properties, function (propUsage, name) { + var source = checker.getTypeOfPropertyOfType(type, name); + if (!source) { + return true; + } + if (propUsage.calls) { + var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); + } + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type, usage) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + return type; + } + var generic = type.target; + var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) + return type; + var types = []; + usage.properties.forEach(function (propUsage, name) { + var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); + ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName](combineTypes(types)); + } + function inferTypeParameters(genericType, usageType, typeParameter) { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); + } + else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + var genericArgs = checker.getTypeArguments(genericType); + var usageArgs = checker.getTypeArguments(usageType); + var types = []; + if (genericArgs && usageArgs) { + for (var i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); + } + } + } + return types; + } + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); + } + return []; + } + function inferFromSignatures(genericSig, usageSig, typeParameter) { + var types = []; + for (var i = 0; i < genericSig.parameters.length; i++) { + var genericParam = genericSig.parameters[i]; + var usageParam = usageSig.parameters[i]; + var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); + } + var genericReturn = checker.getReturnTypeOfSignature(genericSig); + var usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; + } + function getFunctionFromCalls(calls) { + return checker.createAnonymousType(/*symbol*/ undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + function getSignatureFromCalls(calls) { + var parameters = []; + var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); + var _loop_14 = function (i) { + var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); + symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); + if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { + symbol.flags |= 16777216 /* Optional */; + } + parameters.push(symbol); + }; + for (var i = 0; i < length; i++) { + _loop_14(i); + } + var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); + // TODO: GH#18217 + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); + } + function addCandidateType(usage, type) { + if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); + } + } + function addCandidateThisType(usage, type) { + if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); + } + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -229338,12 +236348,13 @@ var ts; if (!ts.isInJSFile(sourceFile) || !ts.isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) { return undefined; } + var newLineCharacter = sourceFile.checkJsDirective ? "" : ts.getNewLineOrDefaultFromHost(host, formatContext.options); var fixes = [ // fixId unnecessary because adding `// @ts-nocheck` even once will ignore every error in the file. codefix.createCodeFixActionWithoutFixAll(fixName, [codefix.createFileTextChanges(sourceFile.fileName, [ ts.createTextChange(sourceFile.checkJsDirective ? ts.createTextSpanFromBounds(sourceFile.checkJsDirective.pos, sourceFile.checkJsDirective.end) - : ts.createTextSpan(0, 0), "// @ts-nocheck" + ts.getNewLineOrDefaultFromHost(host, formatContext.options)), + : ts.createTextSpan(0, 0), "// @ts-nocheck" + newLineCharacter), ])], ts.Diagnostics.Disable_checking_for_this_file), ]; if (ts.textChanges.isValidLocationToAddComment(sourceFile, span.start)) { @@ -229379,45 +236390,36 @@ var ts; * Finds members of the resolved type that are missing in the class pointed to by class decl * and generates source code for the missing members. * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. + * @param importAdder If provided, type annotations will use identifier type references instead of ImportTypeNodes, and the missing imports will be added to the importAdder. * @returns Empty string iff there are no member insertions. */ - function createMissingMemberNodes(classDeclaration, possiblyMissingSymbols, context, preferences, out) { + function createMissingMemberNodes(classDeclaration, possiblyMissingSymbols, context, preferences, importAdder, addClassElement) { var classMembers = classDeclaration.symbol.members; for (var _i = 0, possiblyMissingSymbols_1 = possiblyMissingSymbols; _i < possiblyMissingSymbols_1.length; _i++) { var symbol = possiblyMissingSymbols_1[_i]; if (!classMembers.has(symbol.escapedName)) { - addNewNodeForMemberSymbol(symbol, classDeclaration, context, preferences, out); + addNewNodeForMemberSymbol(symbol, classDeclaration, context, preferences, importAdder, addClassElement); } } } codefix.createMissingMemberNodes = createMissingMemberNodes; - function getModuleSpecifierResolverHost(context) { - return { - directoryExists: context.host.directoryExists ? function (d) { return context.host.directoryExists(d); } : undefined, - fileExists: context.host.fileExists ? function (f) { return context.host.fileExists(f); } : undefined, - getCurrentDirectory: context.host.getCurrentDirectory ? function () { return context.host.getCurrentDirectory(); } : undefined, - readFile: context.host.readFile ? function (f) { return context.host.readFile(f); } : undefined, - useCaseSensitiveFileNames: context.host.useCaseSensitiveFileNames ? function () { return context.host.useCaseSensitiveFileNames(); } : undefined, - getSourceFiles: function () { return context.program.getSourceFiles(); }, - getCommonSourceDirectory: function () { return context.program.getCommonSourceDirectory(); }, - }; - } function getNoopSymbolTrackerWithResolver(context) { return { trackSymbol: ts.noop, - moduleResolverHost: getModuleSpecifierResolverHost(context), + moduleResolverHost: ts.getModuleSpecifierResolverHost(context.program, context.host), }; } codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver; /** * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ - function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, context, preferences, out) { + function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, context, preferences, importAdder, addClassElement) { var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { return undefined; } var checker = context.program.getTypeChecker(); + var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions()); var declaration = declarations[0]; var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false); var visibilityModifier = createVisibilityModifier(ts.getModifierFlags(declaration)); @@ -229430,28 +236432,42 @@ var ts; case 159 /* PropertyDeclaration */: var flags = preferences.quotePreference === "single" ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined; var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, flags, getNoopSymbolTrackerWithResolver(context)); - out(ts.createProperty( + if (importAdder) { + var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget); + if (importableReference) { + typeNode = importableReference.typeReference; + importSymbols(importAdder, importableReference.symbols); + } + } + addClassElement(ts.createProperty( /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; case 163 /* GetAccessor */: case 164 /* SetAccessor */: { - var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); + var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var orderedAccessors = allAccessors.secondAccessor ? [allAccessors.firstAccessor, allAccessors.secondAccessor] : [allAccessors.firstAccessor]; + if (importAdder) { + var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode_1, type, scriptTarget); + if (importableReference) { + typeNode_1 = importableReference.typeReference; + importSymbols(importAdder, importableReference.symbols); + } + } for (var _i = 0, orderedAccessors_1 = orderedAccessors; _i < orderedAccessors_1.length; _i++) { var accessor = orderedAccessors_1[_i]; if (ts.isGetAccessorDeclaration(accessor)) { - out(ts.createGetAccessor( + addClassElement(ts.createGetAccessor( /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); } else { ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); var parameter = ts.getSetAccessorValueParameter(accessor); var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; - out(ts.createSetAccessor( + addClassElement(ts.createSetAccessor( /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(preferences))); } } @@ -229488,23 +236504,61 @@ var ts; } else { ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); - out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); + addClassElement(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); } } break; } function outputMethod(signature, modifiers, name, body) { - var method = signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body); + var method = signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder); if (method) - out(method); + addClassElement(method); } } - function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { + function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body, importAdder) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 161 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var checker = program.getTypeChecker(); + var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions()); + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 161 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } + if (importAdder) { + if (signatureDeclaration.typeParameters) { + ts.forEach(signatureDeclaration.typeParameters, function (typeParameterDecl, i) { + var typeParameter = signature.typeParameters[i]; + if (typeParameterDecl.constraint) { + var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeParameterDecl.constraint, typeParameter.constraint, scriptTarget); + if (importableReference) { + typeParameterDecl.constraint = importableReference.typeReference; + importSymbols(importAdder, importableReference.symbols); + } + } + if (typeParameterDecl.default) { + var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeParameterDecl.default, typeParameter.default, scriptTarget); + if (importableReference) { + typeParameterDecl.default = importableReference.typeReference; + importSymbols(importAdder, importableReference.symbols); + } + } + }); + } + ts.forEach(signatureDeclaration.parameters, function (parameterDecl, i) { + var parameter = signature.parameters[i]; + var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(parameterDecl.type, checker.getTypeAtLocation(parameter.valueDeclaration), scriptTarget); + if (importableReference) { + parameterDecl.type = importableReference.typeReference; + importSymbols(importAdder, importableReference.symbols); + } + }); + if (signatureDeclaration.type) { + var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(signatureDeclaration.type, signature.resolvedReturnType, scriptTarget); + if (importableReference) { + signatureDeclaration.type = importableReference.typeReference; + importSymbols(importAdder, importableReference.symbols); + } + } + } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; @@ -229512,14 +236566,14 @@ var ts; signatureDeclaration.body = body; return signatureDeclaration; } - function createMethodFromCallExpression(context, call, methodName, inJs, makeStatic, preferences, contextNode) { + function createMethodFromCallExpression(context, call, methodName, inJs, makeStatic, contextNode, importAdder) { var body = !ts.isInterfaceDeclaration(contextNode); var typeArguments = call.typeArguments, args = call.arguments, parent = call.parent; + var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions()); var checker = context.program.getTypeChecker(); var tracker = getNoopSymbolTrackerWithResolver(context); var types = ts.map(args, function (arg) { - // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" - return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); + return typeToAutoImportableTypeNode(checker, importAdder, checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, scriptTarget, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) && ts.isIdentifier(arg.name) ? arg.name.text : undefined; @@ -229535,9 +236589,21 @@ var ts; return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); }), /*parameters*/ createDummyParameters(args.length, names, types, /*minArgumentCount*/ undefined, inJs), - /*type*/ returnType, body ? createStubbedMethodBody(preferences) : undefined); + /*type*/ returnType, body ? createStubbedMethodBody(context.preferences) : undefined); } codefix.createMethodFromCallExpression = createMethodFromCallExpression; + function typeToAutoImportableTypeNode(checker, importAdder, type, contextNode, scriptTarget, flags, tracker) { + var typeNode = checker.typeToTypeNode(type, contextNode, flags, tracker); + if (typeNode && ts.isImportTypeNode(typeNode)) { + var importableReference = tryGetAutoImportableReferenceFromImportTypeNode(typeNode, type, scriptTarget); + if (importableReference) { + importSymbols(importAdder, importableReference.symbols); + return importableReference.typeReference; + } + } + return typeNode; + } + codefix.typeToAutoImportableTypeNode = typeToAutoImportableTypeNode; function createDummyParameters(argCount, names, types, minArgumentCount, inJs) { var parameters = []; for (var i = 0; i < argCount; i++) { @@ -229648,12 +236714,56 @@ var ts; return ts.find(obj.properties, function (p) { return ts.isPropertyAssignment(p) && !!p.name && ts.isStringLiteral(p.name) && p.name.text === name; }); } codefix.findJsonProperty = findJsonProperty; - })(codefix = ts.codefix || (ts.codefix = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; -(function (ts) { - var codefix; + /** + * Given an ImportTypeNode 'import("./a").SomeType>', + * returns an equivalent type reference node with any nested ImportTypeNodes also replaced + * with type references, and a list of symbols that must be imported to use the type reference. + */ + function tryGetAutoImportableReferenceFromImportTypeNode(importTypeNode, type, scriptTarget) { + if (importTypeNode && ts.isLiteralImportTypeNode(importTypeNode) && importTypeNode.qualifier && (!type || type.symbol)) { + // Symbol for the left-most thing after the dot + var firstIdentifier = ts.getFirstIdentifier(importTypeNode.qualifier); + var name = ts.getNameForExportedSymbol(firstIdentifier.symbol, scriptTarget); + var qualifier = name !== firstIdentifier.text + ? replaceFirstIdentifierOfEntityName(importTypeNode.qualifier, ts.createIdentifier(name)) + : importTypeNode.qualifier; + var symbols_4 = [firstIdentifier.symbol]; + var typeArguments_1 = []; + if (importTypeNode.typeArguments) { + importTypeNode.typeArguments.forEach(function (arg) { + var ref = tryGetAutoImportableReferenceFromImportTypeNode(arg, /*undefined*/ type, scriptTarget); + if (ref) { + symbols_4.push.apply(symbols_4, ref.symbols); + typeArguments_1.push(ref.typeReference); + } + else { + typeArguments_1.push(arg); + } + }); + } + return { + symbols: symbols_4, + typeReference: ts.createTypeReferenceNode(qualifier, typeArguments_1) + }; + } + } + codefix.tryGetAutoImportableReferenceFromImportTypeNode = tryGetAutoImportableReferenceFromImportTypeNode; + function replaceFirstIdentifierOfEntityName(name, newIdentifier) { + if (name.kind === 75 /* Identifier */) { + return newIdentifier; + } + return ts.createQualifiedName(replaceFirstIdentifierOfEntityName(name.left, newIdentifier), name.right); + } + function importSymbols(importAdder, symbols) { + symbols.forEach(function (s) { return importAdder.addImportFromExportedSymbol(s, /*usageIsTypeOnly*/ true); }); + } + codefix.importSymbols = importSymbols; + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; (function (codefix) { var fixName = "invalidImportSyntax"; function getCodeFixesForImportDeclaration(context, node) { @@ -230111,7 +237221,7 @@ var ts; if (!importDeclaration) { return; } - var importClause = ts.Debug.assertDefined(importDeclaration.importClause); + var importClause = ts.Debug.checkDefined(importDeclaration.importClause); changes.replaceNode(context.sourceFile, importDeclaration, ts.updateImportDeclaration(importDeclaration, importDeclaration.decorators, importDeclaration.modifiers, ts.updateImportClause(importClause, importClause.name, /*namedBindings*/ undefined, importClause.isTypeOnly), importDeclaration.moduleSpecifier)); changes.insertNodeAfter(context.sourceFile, importDeclaration, ts.createImportDeclaration( /*decorators*/ undefined, @@ -230155,6 +237265,46 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixExpectedComma"; + var expectedErrorCode = ts.Diagnostics._0_expected.code; + var errorCodes = [expectedErrorCode]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile; + var info = getInfo(sourceFile, context.span.start, context.errorCode); + if (!info) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, info); }); + return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Change_0_to_1, ";", ","], fixId, [ts.Diagnostics.Change_0_to_1, ";", ","])]; + }, + fixIds: [fixId], + getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var info = getInfo(diag.file, diag.start, diag.code); + if (info) + doChange(changes, context.sourceFile, info); + }); }, + }); + function getInfo(sourceFile, pos, _) { + var node = ts.getTokenAtPosition(sourceFile, pos); + return (node.kind === 26 /* SemicolonToken */ && + node.parent && + (ts.isObjectLiteralExpression(node.parent) || + ts.isArrayLiteralExpression(node.parent))) ? { node: node } : undefined; + } + function doChange(changes, sourceFile, _a) { + var node = _a.node; + var newNode = ts.createNode(27 /* CommaToken */); + changes.replaceNode(sourceFile, node, newNode); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -230172,7 +237322,7 @@ var ts; }, getEditsForAction: function (context, actionName) { ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.checkDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -230224,10 +237374,10 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 84 /* DefaultKeyword */), "Should find a default keyword in modifier list")); + changes.delete(exportingSourceFile, ts.Debug.checkDefined(ts.findModifier(exportNode, 84 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 89 /* ExportKeyword */), "Should find an export keyword in modifier list"); + var exportKeyword = ts.Debug.checkDefined(ts.findModifier(exportNode, 89 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { case 244 /* FunctionDeclaration */: case 245 /* ClassDeclaration */: @@ -230238,7 +237388,7 @@ var ts; // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.checkDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through @@ -230257,7 +237407,7 @@ var ts; function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); + var exportSymbol = ts.Debug.checkDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -230368,7 +237518,7 @@ var ts; }, getEditsForAction: function (context, actionName) { ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.checkDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -231055,7 +238205,7 @@ var ts; case 244 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" - : "anonymous function"; + : ts.ANONYMOUS; case 202 /* ArrowFunction */: return "arrow function"; case 161 /* MethodDeclaration */: @@ -231090,6 +238240,8 @@ var ts; function extractFunctionInScope(node, scope, _a, exposedVariableDeclarations, range, context) { var usagesInScope = _a.usages, typeParameterUsages = _a.typeParameterUsages, substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); + var scriptTarget = ts.getEmitScriptTarget(context.program.getCompilerOptions()); + var importAdder = ts.codefix.createImportAdder(context.file, context.program, context.preferences, context.host); // Make a unique name for the extracted function var file = scope.getSourceFile(); var functionNameText = ts.getUniqueName(ts.isClassLike(scope) ? "newMethod" : "newFunction", file); @@ -231105,7 +238257,7 @@ var ts; var type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node); // Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {" type = checker.getBaseTypeOfLiteralType(type); - typeNode = checker.typeToTypeNode(type, scope, 1 /* NoTruncation */); + typeNode = ts.codefix.typeToAutoImportableTypeNode(checker, importAdder, type, scope, scriptTarget, 1 /* NoTruncation */); } var paramDecl = ts.createParameter( /*decorators*/ undefined, @@ -231164,6 +238316,7 @@ var ts; else { changeTracker.insertNodeAtEndOfScope(context.file, scope, newFunction); } + importAdder.writeFixes(changeTracker); var newNodes = []; // replace range with function call var called = getCalledExpression(scope, range, functionNameText); @@ -231626,7 +238779,7 @@ var ts; return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); + return ts.Debug.checkDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -232071,7 +239224,7 @@ var ts; }, getEditsForAction: function (context, actionName) { var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); + var info = ts.Debug.checkDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { switch (actionName) { @@ -232102,7 +239255,7 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(ts.findAncestor(selection, ts.isStatement), "Should find a statement"); + var firstStatement = ts.Debug.checkDefined(ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; @@ -232184,7 +239337,7 @@ var ts; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); - changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.insertNodeBefore(file, firstStatement, ts.ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } function doInterfaceChange(changes, file, name, info) { @@ -232193,12 +239346,12 @@ var ts; /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters, /* heritageClauses */ undefined, typeElements); - changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.insertNodeBefore(file, firstStatement, ts.ignoreSourceNewlines(newTypeNode), /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } function doTypedefChange(changes, file, name, info) { var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; - var node = ts.createNode(321 /* JSDocTypedefTag */); + var node = ts.createNode(322 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -232206,7 +239359,7 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(320 /* JSDocTemplateTag */); + var template = ts.createNode(321 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); var parameter = ts.createNode(155 /* TypeParameter */); @@ -232252,6 +239405,7 @@ var ts; var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var isStatic = fieldInfo.isStatic, isReadonly = fieldInfo.isReadonly, fieldName = fieldInfo.fieldName, accessorName = fieldInfo.accessorName, originalName = fieldInfo.originalName, type = fieldInfo.type, container = fieldInfo.container, declaration = fieldInfo.declaration, renameAccessor = fieldInfo.renameAccessor; ts.suppressLeadingAndTrailingTrivia(fieldName); + ts.suppressLeadingAndTrailingTrivia(accessorName); ts.suppressLeadingAndTrailingTrivia(declaration); ts.suppressLeadingAndTrailingTrivia(container); var isInClassLike = ts.isClassLike(container); @@ -232303,9 +239457,6 @@ var ts; var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(120 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } - function startsWithUnderscore(name) { - return name.charCodeAt(0) === 95 /* _ */; - } function getConvertibleFieldAtPosition(context) { var file = context.file, startPosition = context.startPosition, endPosition = context.endPosition; var node = ts.getTokenAtPosition(file, startPosition); @@ -232316,7 +239467,7 @@ var ts; || !isConvertibleName(declaration.name) || (ts.getModifierFlags(declaration) | meaning) !== meaning) return undefined; var name = declaration.name.text; - var startWithUnderscore = startsWithUnderscore(name); + var startWithUnderscore = ts.startsWithUnderscore(name); var fieldName = createPropertyName(startWithUnderscore ? name : ts.getUniqueName("_" + name, file), declaration.name); var accessorName = createPropertyName(startWithUnderscore ? ts.getUniqueName(name.substring(1), file) : name, declaration.name); return { @@ -232410,7 +239561,7 @@ var ts; }, getEditsForAction: function (context, actionName) { ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); - var statements = ts.Debug.assertDefined(getStatementsToMove(context)); + var statements = ts.Debug.checkDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } @@ -232500,7 +239651,7 @@ var ts; var quotePreference = ts.getQuotePreference(oldFile, preferences); var importsFromNewFile = createOldFileImportsFromNewFile(usage.oldFileImportsFromNewFile, newModuleName, useEs6ModuleSyntax, quotePreference); if (importsFromNewFile) { - ts.insertImport(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true); + ts.insertImports(changes, oldFile, importsFromNewFile, /*blankLineBetween*/ true); } deleteUnusedOldImports(oldFile, toMove.all, changes, usage.unusedImportsFromOldFile, checker); deleteMovedStatements(oldFile, toMove.ranges, changes); @@ -232667,7 +239818,7 @@ var ts; return ts.flatMap(toMove, function (statement) { if (isTopLevelDeclarationStatement(statement) && !isExported(sourceFile, statement, useEs6Exports) && - forEachTopLevelDeclaration(statement, function (d) { return needExport.has(ts.Debug.assertDefined(d.symbol)); })) { + forEachTopLevelDeclaration(statement, function (d) { return needExport.has(ts.Debug.checkDefined(d.symbol)); })) { var exports = addExport(statement, useEs6Exports); if (exports) return exports; @@ -232804,7 +239955,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); + movedSymbols.add(ts.Debug.checkDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -232860,6 +240011,7 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 255 /* ImportClause */: + case 256 /* NamespaceImport */: return true; case 242 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); @@ -233149,19 +240301,20 @@ var ts; } else if (actionName === removeBracesActionName && returnStatement) { var actualExpression = expression || ts.createVoidZero(); - body = needsParentheses(actualExpression) ? ts.createParen(actualExpression) : actualExpression; + body = ts.needsParentheses(actualExpression) ? ts.createParen(actualExpression) : actualExpression; ts.suppressLeadingAndTrailingTrivia(body); + ts.copyTrailingAsLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); ts.copyLeadingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); + ts.copyTrailingComments(returnStatement, body, file, 3 /* MultiLineCommentTrivia */, /* hasTrailingNewLine */ false); } else { ts.Debug.fail("invalid action"); } - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return t.replaceNode(file, func.body, body); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { + t.replaceNode(file, func.body, body); + }); return { renameFilename: undefined, renameLocation: undefined, edits: edits }; } - function needsParentheses(expression) { - return ts.isBinaryExpression(expression) && expression.operatorToken.kind === 27 /* CommaToken */ || ts.isObjectLiteralExpression(expression); - } function getConvertibleArrowFunctionAtPosition(file, startPosition) { var node = ts.getTokenAtPosition(file, startPosition); var func = ts.getContainingFunction(node); @@ -233518,7 +240671,7 @@ var ts; ts.suppressLeadingAndTrailingTrivia(property.name); if (ts.isPropertyAssignment(property)) ts.suppressLeadingAndTrailingTrivia(property.initializer); - copyComments(arg, property); + ts.copyComments(arg, property); return property; }); if (hasRestParameter && functionArguments.length >= parameters.length) { @@ -233553,10 +240706,10 @@ var ts; /*dotDotDotToken*/ undefined, thisParameter.name, /*questionToken*/ undefined, thisParameter.type); ts.suppressLeadingAndTrailingTrivia(newThisParameter.name); - copyComments(thisParameter.name, newThisParameter.name); + ts.copyComments(thisParameter.name, newThisParameter.name); if (thisParameter.type) { ts.suppressLeadingAndTrailingTrivia(newThisParameter.type); - copyComments(thisParameter.type, newThisParameter.type); + ts.copyComments(thisParameter.type, newThisParameter.type); } return ts.createNodeArray([newThisParameter, objectParameter]); } @@ -233567,7 +240720,7 @@ var ts; /*propertyName*/ undefined, getParameterName(parameterDeclaration), ts.isRestParameter(parameterDeclaration) && isOptionalParameter(parameterDeclaration) ? ts.createArrayLiteral() : parameterDeclaration.initializer); ts.suppressLeadingAndTrailingTrivia(element); if (parameterDeclaration.initializer && element.initializer) { - copyComments(parameterDeclaration.initializer, element.initializer); + ts.copyComments(parameterDeclaration.initializer, element.initializer); } return element; } @@ -233585,9 +240738,9 @@ var ts; /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); ts.suppressLeadingAndTrailingTrivia(propertySignature); - copyComments(parameterDeclaration.name, propertySignature.name); + ts.copyComments(parameterDeclaration.name, propertySignature.name); if (parameterDeclaration.type && propertySignature.type) { - copyComments(parameterDeclaration.type, propertySignature.type); + ts.copyComments(parameterDeclaration.type, propertySignature.type); } return propertySignature; } @@ -233603,26 +240756,6 @@ var ts; return checker.isOptionalParameter(parameterDeclaration); } } - function copyComments(sourceNode, targetNode) { - var sourceFile = sourceNode.getSourceFile(); - var text = sourceFile.text; - if (hasLeadingLineBreak(sourceNode, text)) { - ts.copyLeadingComments(sourceNode, targetNode, sourceFile); - } - else { - ts.copyTrailingAsLeadingComments(sourceNode, targetNode, sourceFile); - } - ts.copyTrailingComments(sourceNode, targetNode, sourceFile); - } - function hasLeadingLineBreak(node, text) { - var start = node.getFullStart(); - var end = node.getStart(); - for (var i = start; i < end; i++) { - if (text.charCodeAt(i) === 10 /* lineFeed */) - return true; - } - return false; - } function getParameterName(paramDeclaration) { return ts.getTextOfIdentifierOrLiteral(paramDeclaration.name); } @@ -233634,7 +240767,7 @@ var ts; return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 84 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(classDeclaration, 84 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; case 214 /* ClassExpression */: var classExpression = constructorDeclaration.parent; @@ -233652,12 +240785,12 @@ var ts; return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 84 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.checkDefined(ts.findModifier(functionDeclaration, 84 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; case 161 /* MethodDeclaration */: return [functionDeclaration.name]; case 162 /* Constructor */: - var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 129 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + var ctrKeyword = ts.Debug.checkDefined(ts.findChildOfKind(functionDeclaration, 129 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); if (functionDeclaration.parent.kind === 214 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; @@ -233791,7 +240924,6 @@ var ts; indexes.push(index); index++; } - text = ts.escapeString(text); return [index, text, indexes]; } function nodesToTemplate(_a, file) { @@ -233916,7 +241048,7 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 294 /* FirstJSDocNode */ || kid.kind > 322 /* LastJSDocNode */; }); + var child = ts.find(children, function (kid) { return kid.kind < 294 /* FirstJSDocNode */ || kid.kind > 323 /* LastJSDocNode */; }); return child.kind < 153 /* FirstNode */ ? child : child.getFirstToken(sourceFile); @@ -233986,7 +241118,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(323 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(324 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -234070,7 +241202,7 @@ var ts; get: function () { return ts.symbolName(this); }, - enumerable: true, + enumerable: false, configurable: true }); SymbolObject.prototype.getEscapedName = function () { @@ -234117,7 +241249,7 @@ var ts; get: function () { return ts.idText(this); }, - enumerable: true, + enumerable: false, configurable: true }); return IdentifierObject; @@ -234132,7 +241264,7 @@ var ts; get: function () { return ts.idText(this); }, - enumerable: true, + enumerable: false, configurable: true }); return PrivateIdentifierObject; @@ -234225,7 +241357,7 @@ var ts; } return undefined; }, - enumerable: true, + enumerable: false, configurable: true }); return TypeObject; @@ -234599,10 +241731,6 @@ var ts; }); return names; }; - HostCache.prototype.getVersion = function (path) { - var file = this.getHostFileInformation(path); - return (file && file.version); // TODO: GH#18217 - }; HostCache.prototype.getScriptSnapshot = function (path) { var file = this.getHostFileInformation(path); return (file && file.scriptSnapshot); // TODO: GH#18217 @@ -234786,6 +241914,7 @@ var ts; return sourceFile; } function synchronizeHostData() { + var _a; ts.Debug.assert(!syntaxOnly); // perform fast check if host supports it if (host.getProjectVersion) { @@ -234809,7 +241938,7 @@ var ts; var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse; var projectReferences = hostCache.getProjectReferences(); // If the program is already up-to-date, we can reuse it - if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (path) { return hostCache.getVersion(path); }, fileExists, hasInvalidatedResolution, !!host.hasChangedAutomaticTypeDirectiveNames, projectReferences)) { + if (ts.isProgramUptoDate(program, rootFileNames, hostCache.compilationSettings(), function (_path, fileName) { return host.getScriptVersion(fileName); }, fileExists, hasInvalidatedResolution, !!host.hasChangedAutomaticTypeDirectiveNames, projectReferences)) { return; } // IMPORTANT - It is critical from this moment onward that we do not check @@ -234839,7 +241968,7 @@ var ts; return host.getDirectories ? host.getDirectories(path) : []; }, readDirectory: function (path, extensions, exclude, include, depth) { - ts.Debug.assertDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); + ts.Debug.checkDefined(host.readDirectory, "'LanguageServiceHost.readDirectory' must be implemented to correctly process 'projectReferences'"); return host.readDirectory(path, extensions, exclude, include, depth); }, onReleaseOldSourceFile: onReleaseOldSourceFile, @@ -234867,12 +241996,10 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }; } - if (host.setResolvedProjectReferenceCallbacks) { - compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); }; - } if (host.useSourceOfProjectReferenceRedirect) { compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); }; } + (_a = host.setCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host, compilerHost); var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -234958,7 +242085,7 @@ var ts; // We do not support the scenario where a host can modify a registered // file's script kind, i.e. in one project some file is treated as ".ts" // and in another as ".js" - ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind.", path); + ts.Debug.assertEqual(hostFileInformation.scriptKind, oldSourceFile.scriptKind, "Registered script kind should match new script kind."); return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind); } // We didn't already have the file. Fall through and acquire it from the registry. @@ -234981,8 +242108,10 @@ var ts; } function dispose() { if (program) { + // Use paths to ensure we are using correct key and paths as document registry could bre created with different current directory than host + var key_1 = documentRegistry.getKeyForCompilationSettings(program.getCompilerOptions()); ts.forEach(program.getSourceFiles(), function (f) { - return documentRegistry.releaseDocument(f.fileName, program.getCompilerOptions()); + return documentRegistry.releaseDocumentWithKey(f.resolvedPath, key_1); }); program = undefined; // TODO: GH#18217 } @@ -235028,12 +242157,13 @@ var ts; function getCompletionEntryDetails(fileName, position, name, formattingOptions, source, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions)), // TODO: GH#18217 + return ts.Completions.getCompletionEntryDetails(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, (formattingOptions && ts.formatting.getFormatContext(formattingOptions, host)), // TODO: GH#18217 preferences, cancellationToken); } - function getCompletionEntrySymbol(fileName, position, name, source) { + function getCompletionEntrySymbol(fileName, position, name, source, preferences) { + if (preferences === void 0) { preferences = ts.emptyOptions; } synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host); + return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host, preferences); } function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); @@ -235299,14 +242429,14 @@ var ts; } function getFormattingEditsForRange(fileName, start, end, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.formatting.formatSelection(start, end, sourceFile, ts.formatting.getFormatContext(toEditorSettings(options))); + return ts.formatting.formatSelection(start, end, sourceFile, ts.formatting.getFormatContext(toEditorSettings(options), host)); } function getFormattingEditsForDocument(fileName, options) { - return ts.formatting.formatDocument(syntaxTreeCache.getCurrentSourceFile(fileName), ts.formatting.getFormatContext(toEditorSettings(options))); + return ts.formatting.formatDocument(syntaxTreeCache.getCurrentSourceFile(fileName), ts.formatting.getFormatContext(toEditorSettings(options), host)); } function getFormattingEditsAfterKeystroke(fileName, position, key, options) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - var formatContext = ts.formatting.getFormatContext(toEditorSettings(options)); + var formatContext = ts.formatting.getFormatContext(toEditorSettings(options), host); if (!ts.isInComment(sourceFile, position)) { switch (key) { case "{": @@ -235326,7 +242456,7 @@ var ts; synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = ts.createTextSpanFromBounds(start, end); - var formatContext = ts.formatting.getFormatContext(formatOptions); + var formatContext = ts.formatting.getFormatContext(formatOptions, host); return ts.flatMap(ts.deduplicate(errorCodes, ts.equateValues, ts.compareValues), function (errorCode) { cancellationToken.throwIfCancellationRequested(); return ts.codefix.getFixes({ errorCode: errorCode, sourceFile: sourceFile, span: span, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); @@ -235337,7 +242467,7 @@ var ts; synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); - var formatContext = ts.formatting.getFormatContext(formatOptions); + var formatContext = ts.formatting.getFormatContext(formatOptions, host); return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences }); } function organizeImports(scope, formatOptions, preferences) { @@ -235345,12 +242475,12 @@ var ts; synchronizeHostData(); ts.Debug.assert(scope.type === "file"); var sourceFile = getValidSourceFile(scope.fileName); - var formatContext = ts.formatting.getFormatContext(formatOptions); + var formatContext = ts.formatting.getFormatContext(formatOptions, host); return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences); } function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) { if (preferences === void 0) { preferences = ts.emptyOptions; } - return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions), preferences, sourceMapper); + return ts.getEditsForFileRename(getProgram(), oldFilePath, newFilePath, host, ts.formatting.getFormatContext(formatOptions, host), preferences, sourceMapper); } function applyCodeActionCommand(fileName, actionOrFormatSettingsOrUndefined) { var action = typeof fileName === "string" ? actionOrFormatSettingsOrUndefined : fileName; @@ -235552,7 +242682,7 @@ var ts; endPosition: endPosition, program: getProgram(), host: host, - formatContext: ts.formatting.getFormatContext(formatOptions), + formatContext: ts.formatting.getFormatContext(formatOptions, host), cancellationToken: cancellationToken, preferences: preferences, }; @@ -235644,6 +242774,7 @@ var ts; getEditsForRefactor: getEditsForRefactor, toLineColumnOffset: sourceMapper.toLineColumnOffset, getSourceMapper: function () { return sourceMapper; }, + clearSourceMapperCache: function () { return sourceMapper.clearCache(); }, prepareCallHierarchy: prepareCallHierarchy, provideCallHierarchyIncomingCalls: provideCallHierarchyIncomingCalls, provideCallHierarchyOutgoingCalls: provideCallHierarchyOutgoingCalls @@ -236970,7 +244101,10 @@ var ts; /// Emit LanguageServiceShimObject.prototype.getEmitOutput = function (fileName) { var _this = this; - return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { return _this.languageService.getEmitOutput(fileName); }); + return this.forwardJSONCall("getEmitOutput('" + fileName + "')", function () { + var _a = _this.languageService.getEmitOutput(fileName), diagnostics = _a.diagnostics, rest = __rest(_a, ["diagnostics"]); + return __assign(__assign({}, rest), { diagnostics: _this.realizeDiagnostics(diagnostics) }); + }); }; LanguageServiceShimObject.prototype.getEmitOutputObject = function (fileName) { var _this = this; @@ -237257,7 +244391,7 @@ var isPlainObject = _interopDefault(__webpack_require__(696)); var nodeFetch = _interopDefault(__webpack_require__(454)); var requestError = __webpack_require__(463); -const VERSION = "5.4.2"; +const VERSION = "5.4.4"; function getBufferResponse(response) { return response.arrayBuffer(); @@ -238711,7 +245845,27 @@ module.exports = exports.default; /***/ }), /* 766 */, -/* 767 */, +/* 767 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) + +const inc = (version, release, options, identifier) => { + if (typeof (options) === 'string') { + identifier = options + options = undefined + } + + try { + return new SemVer(version, options).inc(release, identifier).version + } catch (er) { + return null + } +} +module.exports = inc + + +/***/ }), /* 768 */ /***/ (function(module) { @@ -238735,7 +245889,20 @@ module.exports = function (x) { /***/ }), /* 769 */, -/* 770 */, +/* 770 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(986) + +// Mostly just for testing and legacy API reasons +const toComparators = (range, options) => + new Range(range, options).set + .map(comp => comp.map(c => c.value).join(' ').trim().split(' ')) + +module.exports = toComparators + + +/***/ }), /* 771 */, /* 772 */, /* 773 */, @@ -238850,7 +246017,92 @@ module.exports.sync = sync; /***/ }), /* 775 */, -/* 776 */, +/* 776 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) +const Comparator = __webpack_require__(456) +const {ANY} = Comparator +const Range = __webpack_require__(635) +const satisfies = __webpack_require__(171) +const gt = __webpack_require__(738) +const lt = __webpack_require__(375) +const lte = __webpack_require__(546) +const gte = __webpack_require__(790) + +const outside = (version, range, hilo, options) => { + version = new SemVer(version, options) + range = new Range(range, options) + + let gtfn, ltefn, ltfn, comp, ecomp + switch (hilo) { + case '>': + gtfn = gt + ltefn = lte + ltfn = lt + comp = '>' + ecomp = '>=' + break + case '<': + gtfn = lt + ltefn = gte + ltfn = gt + comp = '<' + ecomp = '<=' + break + default: + throw new TypeError('Must provide a hilo val of "<" or ">"') + } + + // If it satisifes the range it is not outside + if (satisfies(version, range, options)) { + return false + } + + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. + + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] + + let high = null + let low = null + + comparators.forEach((comparator) => { + if (comparator.semver === ANY) { + comparator = new Comparator('>=0.0.0') + } + high = high || comparator + low = low || comparator + if (gtfn(comparator.semver, high.semver, options)) { + high = comparator + } else if (ltfn(comparator.semver, low.semver, options)) { + low = comparator + } + }) + + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } + + // If the lowest version comparator has an operator and our version + // is less than it then it isn't higher than the range + if ((!low.operator || low.operator === comp) && + ltefn(version, low.semver)) { + return false + } else if (low.operator === ecomp && ltfn(version, low.semver)) { + return false + } + } + return true +} + +module.exports = outside + + +/***/ }), /* 777 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -239502,7 +246754,7 @@ function () { * throw new Error('This plugin works only with PostCSS 6') * } */ - this.version = '7.0.29'; + this.version = '7.0.31'; /** * Plugins added to this processor. * @@ -239724,7 +246976,7 @@ var _default = Processor; exports.default = _default; module.exports = exports.default; -//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByb2Nlc3Nvci5lczYiXSwibmFtZXMiOlsiUHJvY2Vzc29yIiwicGx1Z2lucyIsInZlcnNpb24iLCJub3JtYWxpemUiLCJ1c2UiLCJwbHVnaW4iLCJjb25jYXQiLCJwcm9jZXNzIiwiY3NzIiwib3B0cyIsImxlbmd0aCIsInBhcnNlciIsInN0cmluZ2lmaWVyIiwiZW52IiwiTk9ERV9FTlYiLCJjb25zb2xlIiwid2FybiIsIkxhenlSZXN1bHQiLCJub3JtYWxpemVkIiwiaSIsInBvc3Rjc3MiLCJBcnJheSIsImlzQXJyYXkiLCJwdXNoIiwicGFyc2UiLCJzdHJpbmdpZnkiLCJFcnJvciJdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQTs7OztBQUVBOzs7Ozs7Ozs7SUFTTUEsUzs7O0FBQ0o7Ozs7QUFJQSxxQkFBYUMsT0FBYixFQUEyQjtBQUFBLFFBQWRBLE9BQWM7QUFBZEEsTUFBQUEsT0FBYyxHQUFKLEVBQUk7QUFBQTs7QUFDekI7Ozs7Ozs7Ozs7QUFVQSxTQUFLQyxPQUFMLEdBQWUsUUFBZjtBQUNBOzs7Ozs7Ozs7O0FBU0EsU0FBS0QsT0FBTCxHQUFlLEtBQUtFLFNBQUwsQ0FBZUYsT0FBZixDQUFmO0FBQ0Q7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O1NBNkJBRyxHLEdBQUEsYUFBS0MsTUFBTCxFQUFhO0FBQ1gsU0FBS0osT0FBTCxHQUFlLEtBQUtBLE9BQUwsQ0FBYUssTUFBYixDQUFvQixLQUFLSCxTQUFMLENBQWUsQ0FBQ0UsTUFBRCxDQUFmLENBQXBCLENBQWY7QUFDQSxXQUFPLElBQVA7QUFDRDtBQUVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7U0FzQkFFLE87Ozs7Ozs7Ozs7SUFBQSxVQUFTQyxHQUFULEVBQWNDLElBQWQsRUFBMEI7QUFBQSxRQUFaQSxJQUFZO0FBQVpBLE1BQUFBLElBQVksR0FBTCxFQUFLO0FBQUE7O0FBQ3hCLFFBQUksS0FBS1IsT0FBTCxDQUFhUyxNQUFiLEtBQXdCLENBQXhCLElBQTZCRCxJQUFJLENBQUNFLE1BQUwsS0FBZ0JGLElBQUksQ0FBQ0csV0FBdEQsRUFBbUU7QUFDakUsVUFBSUwsT0FBTyxDQUFDTSxHQUFSLENBQVlDLFFBQVosS0FBeUIsWUFBN0IsRUFBMkM7QUFDekMsWUFBSSxPQUFPQyxPQUFQLEtBQW1CLFdBQW5CLElBQWtDQSxPQUFPLENBQUNDLElBQTlDLEVBQW9EO0FBQ2xERCxVQUFBQSxPQUFPLENBQUNDLElBQVIsQ0FDRSwwREFDQSw4REFEQSxHQUVBLGtFQUhGO0FBS0Q7QUFDRjtBQUNGOztBQUNELFdBQU8sSUFBSUMsbUJBQUosQ0FBZSxJQUFmLEVBQXFCVCxHQUFyQixFQUEwQkMsSUFBMUIsQ0FBUDtBQUNELEc7O1NBRUROLFMsR0FBQSxtQkFBV0YsT0FBWCxFQUFvQjtBQUNsQixRQUFJaUIsVUFBVSxHQUFHLEVBQWpCOztBQUNBLHlCQUFjakIsT0FBZCxrSEFBdUI7QUFBQTs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBOztBQUFBLFVBQWRrQixDQUFjO0FBQ3JCLFVBQUlBLENBQUMsQ0FBQ0MsT0FBTixFQUFlRCxDQUFDLEdBQUdBLENBQUMsQ0FBQ0MsT0FBTjs7QUFFZixVQUFJLE9BQU9ELENBQVAsS0FBYSxRQUFiLElBQXlCRSxLQUFLLENBQUNDLE9BQU4sQ0FBY0gsQ0FBQyxDQUFDbEIsT0FBaEIsQ0FBN0IsRUFBdUQ7QUFDckRpQixRQUFBQSxVQUFVLEdBQUdBLFVBQVUsQ0FBQ1osTUFBWCxDQUFrQmEsQ0FBQyxDQUFDbEIsT0FBcEIsQ0FBYjtBQUNELE9BRkQsTUFFTyxJQUFJLE9BQU9rQixDQUFQLEtBQWEsVUFBakIsRUFBNkI7QUFDbENELFFBQUFBLFVBQVUsQ0FBQ0ssSUFBWCxDQUFnQkosQ0FBaEI7QUFDRCxPQUZNLE1BRUEsSUFBSSxPQUFPQSxDQUFQLEtBQWEsUUFBYixLQUEwQkEsQ0FBQyxDQUFDSyxLQUFGLElBQVdMLENBQUMsQ0FBQ00sU0FBdkMsQ0FBSixFQUF1RDtBQUM1RCxZQUFJbEIsT0FBTyxDQUFDTSxHQUFSLENBQVlDLFFBQVosS0FBeUIsWUFBN0IsRUFBMkM7QUFDekMsZ0JBQU0sSUFBSVksS0FBSixDQUNKLHFFQUNBLDJEQURBLEdBRUEsdUNBSEksQ0FBTjtBQUtEO0FBQ0YsT0FSTSxNQVFBO0FBQ0wsY0FBTSxJQUFJQSxLQUFKLENBQVVQLENBQUMsR0FBRywwQkFBZCxDQUFOO0FBQ0Q7QUFDRjs7QUFDRCxXQUFPRCxVQUFQO0FBQ0QsRzs7Ozs7ZUFHWWxCLFM7QUFFZjs7Ozs7OztBQU9BOzs7Ozs7Ozs7O0FBVUE7Ozs7Ozs7Ozs7QUFVQTs7Ozs7O0FBTUE7Ozs7O0FBS0E7Ozs7OztBQU1BOzs7OztBQUtBIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IExhenlSZXN1bHQgZnJvbSAnLi9sYXp5LXJlc3VsdCdcblxuLyoqXG4gKiBDb250YWlucyBwbHVnaW5zIHRvIHByb2Nlc3MgQ1NTLiBDcmVhdGUgb25lIGBQcm9jZXNzb3JgIGluc3RhbmNlLFxuICogaW5pdGlhbGl6ZSBpdHMgcGx1Z2lucywgYW5kIHRoZW4gdXNlIHRoYXQgaW5zdGFuY2Ugb24gbnVtZXJvdXMgQ1NTIGZpbGVzLlxuICpcbiAqIEBleGFtcGxlXG4gKiBjb25zdCBwcm9jZXNzb3IgPSBwb3N0Y3NzKFthdXRvcHJlZml4ZXIsIHByZWNzc10pXG4gKiBwcm9jZXNzb3IucHJvY2Vzcyhjc3MxKS50aGVuKHJlc3VsdCA9PiBjb25zb2xlLmxvZyhyZXN1bHQuY3NzKSlcbiAqIHByb2Nlc3Nvci5wcm9jZXNzKGNzczIpLnRoZW4ocmVzdWx0ID0+IGNvbnNvbGUubG9nKHJlc3VsdC5jc3MpKVxuICovXG5jbGFzcyBQcm9jZXNzb3Ige1xuICAvKipcbiAgICogQHBhcmFtIHtBcnJheS48UGx1Z2lufHBsdWdpbkZ1bmN0aW9uPnxQcm9jZXNzb3J9IHBsdWdpbnMgUG9zdENTUyBwbHVnaW5zLlxuICAgKiAgICAgICAgU2VlIHtAbGluayBQcm9jZXNzb3IjdXNlfSBmb3IgcGx1Z2luIGZvcm1hdC5cbiAgICovXG4gIGNvbnN0cnVjdG9yIChwbHVnaW5zID0gW10pIHtcbiAgICAvKipcbiAgICAgKiBDdXJyZW50IFBvc3RDU1MgdmVyc2lvbi5cbiAgICAgKlxuICAgICAqIEB0eXBlIHtzdHJpbmd9XG4gICAgICpcbiAgICAgKiBAZXhhbXBsZVxuICAgICAqIGlmIChyZXN1bHQucHJvY2Vzc29yLnZlcnNpb24uc3BsaXQoJy4nKVswXSAhPT0gJzYnKSB7XG4gICAgICogICB0aHJvdyBuZXcgRXJyb3IoJ1RoaXMgcGx1Z2luIHdvcmtzIG9ubHkgd2l0aCBQb3N0Q1NTIDYnKVxuICAgICAqIH1cbiAgICAgKi9cbiAgICB0aGlzLnZlcnNpb24gPSAnNy4wLjI5J1xuICAgIC8qKlxuICAgICAqIFBsdWdpbnMgYWRkZWQgdG8gdGhpcyBwcm9jZXNzb3IuXG4gICAgICpcbiAgICAgKiBAdHlwZSB7cGx1Z2luRnVuY3Rpb25bXX1cbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogY29uc3QgcHJvY2Vzc29yID0gcG9zdGNzcyhbYXV0b3ByZWZpeGVyLCBwcmVjc3NdKVxuICAgICAqIHByb2Nlc3Nvci5wbHVnaW5zLmxlbmd0aCAvLz0+IDJcbiAgICAgKi9cbiAgICB0aGlzLnBsdWdpbnMgPSB0aGlzLm5vcm1hbGl6ZShwbHVnaW5zKVxuICB9XG5cbiAgLyoqXG4gICAqIEFkZHMgYSBwbHVnaW4gdG8gYmUgdXNlZCBhcyBhIENTUyBwcm9jZXNzb3IuXG4gICAqXG4gICAqIFBvc3RDU1MgcGx1Z2luIGNhbiBiZSBpbiA0IGZvcm1hdHM6XG4gICAqICogQSBwbHVnaW4gY3JlYXRlZCBieSB7QGxpbmsgcG9zdGNzcy5wbHVnaW59IG1ldGhvZC5cbiAgICogKiBBIGZ1bmN0aW9uLiBQb3N0Q1NTIHdpbGwgcGFzcyB0aGUgZnVuY3Rpb24gYSBAe2xpbmsgUm9vdH1cbiAgICogICBhcyB0aGUgZmlyc3QgYXJndW1lbnQgYW5kIGN1cnJlbnQge0BsaW5rIFJlc3VsdH0gaW5zdGFuY2VcbiAgICogICBhcyB0aGUgc2Vjb25kLlxuICAgKiAqIEFuIG9iamVjdCB3aXRoIGEgYHBvc3Rjc3NgIG1ldGhvZC4gUG9zdENTUyB3aWxsIHVzZSB0aGF0IG1ldGhvZFxuICAgKiAgIGFzIGRlc2NyaWJlZCBpbiAjMi5cbiAgICogKiBBbm90aGVyIHtAbGluayBQcm9jZXNzb3J9IGluc3RhbmNlLiBQb3N0Q1NTIHdpbGwgY29weSBwbHVnaW5zXG4gICAqICAgZnJvbSB0aGF0IGluc3RhbmNlIGludG8gdGhpcyBvbmUuXG4gICAqXG4gICAqIFBsdWdpbnMgY2FuIGFsc28gYmUgYWRkZWQgYnkgcGFzc2luZyB0aGVtIGFzIGFyZ3VtZW50cyB3aGVuIGNyZWF0aW5nXG4gICAqIGEgYHBvc3Rjc3NgIGluc3RhbmNlIChzZWUgW2Bwb3N0Y3NzKHBsdWdpbnMpYF0pLlxuICAgKlxuICAgKiBBc3luY2hyb25vdXMgcGx1Z2lucyBzaG91bGQgcmV0dXJuIGEgYFByb21pc2VgIGluc3RhbmNlLlxuICAgKlxuICAgKiBAcGFyYW0ge1BsdWdpbnxwbHVnaW5GdW5jdGlvbnxQcm9jZXNzb3J9IHBsdWdpbiBQb3N0Q1NTIHBsdWdpblxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvciB7QGxpbmsgUHJvY2Vzc29yfVxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoIHBsdWdpbnMuXG4gICAqXG4gICAqIEBleGFtcGxlXG4gICAqIGNvbnN0IHByb2Nlc3NvciA9IHBvc3Rjc3MoKVxuICAgKiAgIC51c2UoYXV0b3ByZWZpeGVyKVxuICAgKiAgIC51c2UocHJlY3NzKVxuICAgKlxuICAgKiBAcmV0dXJuIHtQcm9jZXNzZXN9IEN1cnJlbnQgcHJvY2Vzc29yIHRvIG1ha2UgbWV0aG9kcyBjaGFpbi5cbiAgICovXG4gIHVzZSAocGx1Z2luKSB7XG4gICAgdGhpcy5wbHVnaW5zID0gdGhpcy5wbHVnaW5zLmNvbmNhdCh0aGlzLm5vcm1hbGl6ZShbcGx1Z2luXSkpXG4gICAgcmV0dXJuIHRoaXNcbiAgfVxuXG4gIC8qKlxuICAgKiBQYXJzZXMgc291cmNlIENTUyBhbmQgcmV0dXJucyBhIHtAbGluayBMYXp5UmVzdWx0fSBQcm9taXNlIHByb3h5LlxuICAgKiBCZWNhdXNlIHNvbWUgcGx1Z2lucyBjYW4gYmUgYXN5bmNocm9ub3VzIGl0IGRvZXNu4oCZdCBtYWtlXG4gICAqIGFueSB0cmFuc2Zvcm1hdGlvbnMuIFRyYW5zZm9ybWF0aW9ucyB3aWxsIGJlIGFwcGxpZWRcbiAgICogaW4gdGhlIHtAbGluayBMYXp5UmVzdWx0fSBtZXRob2RzLlxuICAgKlxuICAgKiBAcGFyYW0ge3N0cmluZ3x0b1N0cmluZ3xSZXN1bHR9IGNzcyBTdHJpbmcgd2l0aCBpbnB1dCBDU1Mgb3IgYW55IG9iamVjdFxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoIGEgYHRvU3RyaW5nKClgIG1ldGhvZCxcbiAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlrZSBhIEJ1ZmZlci4gT3B0aW9uYWxseSwgc2VuZFxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhIHtAbGluayBSZXN1bHR9IGluc3RhbmNlXG4gICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuZCB0aGUgcHJvY2Vzc29yIHdpbGwgdGFrZVxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGUge0BsaW5rIFJvb3R9IGZyb20gaXQuXG4gICAqIEBwYXJhbSB7cHJvY2Vzc09wdGlvbnN9IFtvcHRzXSAgICAgIE9wdGlvbnMuXG4gICAqXG4gICAqIEByZXR1cm4ge0xhenlSZXN1bHR9IFByb21pc2UgcHJveHkuXG4gICAqXG4gICAqIEBleGFtcGxlXG4gICAqIHByb2Nlc3Nvci5wcm9jZXNzKGNzcywgeyBmcm9tOiAnYS5jc3MnLCB0bzogJ2Eub3V0LmNzcycgfSlcbiAgICogICAudGhlbihyZXN1bHQgPT4ge1xuICAgKiAgICAgIGNvbnNvbGUubG9nKHJlc3VsdC5jc3MpXG4gICAqICAgfSlcbiAgICovXG4gIHByb2Nlc3MgKGNzcywgb3B0cyA9IHsgfSkge1xuICAgIGlmICh0aGlzLnBsdWdpbnMubGVuZ3RoID09PSAwICYmIG9wdHMucGFyc2VyID09PSBvcHRzLnN0cmluZ2lmaWVyKSB7XG4gICAgICBpZiAocHJvY2Vzcy5lbnYuTk9ERV9FTlYgIT09ICdwcm9kdWN0aW9uJykge1xuICAgICAgICBpZiAodHlwZW9mIGNvbnNvbGUgIT09ICd1bmRlZmluZWQnICYmIGNvbnNvbGUud2Fybikge1xuICAgICAgICAgIGNvbnNvbGUud2FybihcbiAgICAgICAgICAgICdZb3UgZGlkIG5vdCBzZXQgYW55IHBsdWdpbnMsIHBhcnNlciwgb3Igc3RyaW5naWZpZXIuICcgK1xuICAgICAgICAgICAgJ1JpZ2h0IG5vdywgUG9zdENTUyBkb2VzIG5vdGhpbmcuIFBpY2sgcGx1Z2lucyBmb3IgeW91ciBjYXNlICcgK1xuICAgICAgICAgICAgJ29uIGh0dHBzOi8vd3d3LnBvc3Rjc3MucGFydHMvIGFuZCB1c2UgdGhlbSBpbiBwb3N0Y3NzLmNvbmZpZy5qcy4nXG4gICAgICAgICAgKVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiBuZXcgTGF6eVJlc3VsdCh0aGlzLCBjc3MsIG9wdHMpXG4gIH1cblxuICBub3JtYWxpemUgKHBsdWdpbnMpIHtcbiAgICBsZXQgbm9ybWFsaXplZCA9IFtdXG4gICAgZm9yIChsZXQgaSBvZiBwbHVnaW5zKSB7XG4gICAgICBpZiAoaS5wb3N0Y3NzKSBpID0gaS5wb3N0Y3NzXG5cbiAgICAgIGlmICh0eXBlb2YgaSA9PT0gJ29iamVjdCcgJiYgQXJyYXkuaXNBcnJheShpLnBsdWdpbnMpKSB7XG4gICAgICAgIG5vcm1hbGl6ZWQgPSBub3JtYWxpemVkLmNvbmNhdChpLnBsdWdpbnMpXG4gICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIG5vcm1hbGl6ZWQucHVzaChpKVxuICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaSA9PT0gJ29iamVjdCcgJiYgKGkucGFyc2UgfHwgaS5zdHJpbmdpZnkpKSB7XG4gICAgICAgIGlmIChwcm9jZXNzLmVudi5OT0RFX0VOViAhPT0gJ3Byb2R1Y3Rpb24nKSB7XG4gICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxuICAgICAgICAgICAgJ1Bvc3RDU1Mgc3ludGF4ZXMgY2Fubm90IGJlIHVzZWQgYXMgcGx1Z2lucy4gSW5zdGVhZCwgcGxlYXNlIHVzZSAnICtcbiAgICAgICAgICAgICdvbmUgb2YgdGhlIHN5bnRheC9wYXJzZXIvc3RyaW5naWZpZXIgb3B0aW9ucyBhcyBvdXRsaW5lZCAnICtcbiAgICAgICAgICAgICdpbiB5b3VyIFBvc3RDU1MgcnVubmVyIGRvY3VtZW50YXRpb24uJ1xuICAgICAgICAgIClcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGkgKyAnIGlzIG5vdCBhIFBvc3RDU1MgcGx1Z2luJylcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIG5vcm1hbGl6ZWRcbiAgfVxufVxuXG5leHBvcnQgZGVmYXVsdCBQcm9jZXNzb3JcblxuLyoqXG4gKiBAY2FsbGJhY2sgYnVpbGRlclxuICogQHBhcmFtIHtzdHJpbmd9IHBhcnQgICAgICAgICAgUGFydCBvZiBnZW5lcmF0ZWQgQ1NTIGNvbm5lY3RlZCB0byB0aGlzIG5vZGUuXG4gKiBAcGFyYW0ge05vZGV9ICAgbm9kZSAgICAgICAgICBBU1Qgbm9kZS5cbiAqIEBwYXJhbSB7XCJzdGFydFwifFwiZW5kXCJ9IFt0eXBlXSBOb2Rl4oCZcyBwYXJ0IHR5cGUuXG4gKi9cblxuLyoqXG4gKiBAY2FsbGJhY2sgcGFyc2VyXG4gKlxuICogQHBhcmFtIHtzdHJpbmd8dG9TdHJpbmd9IGNzcyAgIFN0cmluZyB3aXRoIGlucHV0IENTUyBvciBhbnkgb2JqZWN0XG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2l0aCB0b1N0cmluZygpIG1ldGhvZCwgbGlrZSBhIEJ1ZmZlci5cbiAqIEBwYXJhbSB7cHJvY2Vzc09wdGlvbnN9IFtvcHRzXSBPcHRpb25zIHdpdGggb25seSBgZnJvbWAgYW5kIGBtYXBgIGtleXMuXG4gKlxuICogQHJldHVybiB7Um9vdH0gUG9zdENTUyBBU1RcbiAqL1xuXG4vKipcbiAqIEBjYWxsYmFjayBzdHJpbmdpZmllclxuICpcbiAqIEBwYXJhbSB7Tm9kZX0gbm9kZSAgICAgICBTdGFydCBub2RlIGZvciBzdHJpbmdpZmluZy4gVXN1YWxseSB7QGxpbmsgUm9vdH0uXG4gKiBAcGFyYW0ge2J1aWxkZXJ9IGJ1aWxkZXIgRnVuY3Rpb24gdG8gY29uY2F0ZW5hdGUgQ1NTIGZyb20gbm9kZeKAmXMgcGFydHNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICBvciBnZW5lcmF0ZSBzdHJpbmcgYW5kIHNvdXJjZSBtYXAuXG4gKlxuICogQHJldHVybiB7dm9pZH1cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHN5bnRheFxuICogQHByb3BlcnR5IHtwYXJzZXJ9IHBhcnNlICAgICAgICAgIEZ1bmN0aW9uIHRvIGdlbmVyYXRlIEFTVCBieSBzdHJpbmcuXG4gKiBAcHJvcGVydHkge3N0cmluZ2lmaWVyfSBzdHJpbmdpZnkgRnVuY3Rpb24gdG8gZ2VuZXJhdGUgc3RyaW5nIGJ5IEFTVC5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHRvU3RyaW5nXG4gKiBAcHJvcGVydHkge2Z1bmN0aW9ufSB0b1N0cmluZ1xuICovXG5cbi8qKlxuICogQGNhbGxiYWNrIHBsdWdpbkZ1bmN0aW9uXG4gKiBAcGFyYW0ge1Jvb3R9IHJvb3QgICAgIFBhcnNlZCBpbnB1dCBDU1MuXG4gKiBAcGFyYW0ge1Jlc3VsdH0gcmVzdWx0IFJlc3VsdCB0byBzZXQgd2FybmluZ3Mgb3IgY2hlY2sgb3RoZXIgcGx1Z2lucy5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IFBsdWdpblxuICogQHByb3BlcnR5IHtmdW5jdGlvbn0gcG9zdGNzcyBQb3N0Q1NTIHBsdWdpbiBmdW5jdGlvbi5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHByb2Nlc3NPcHRpb25zXG4gKiBAcHJvcGVydHkge3N0cmluZ30gZnJvbSAgICAgICAgICAgICBUaGUgcGF0aCBvZiB0aGUgQ1NTIHNvdXJjZSBmaWxlLlxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWW91IHNob3VsZCBhbHdheXMgc2V0IGBmcm9tYCxcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlY2F1c2UgaXQgaXMgdXNlZCBpbiBzb3VyY2UgbWFwXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZW5lcmF0aW9uIGFuZCBzeW50YXggZXJyb3IgbWVzc2FnZXMuXG4gKiBAcHJvcGVydHkge3N0cmluZ30gdG8gICAgICAgICAgICAgICBUaGUgcGF0aCB3aGVyZSB5b3XigJlsbCBwdXQgdGhlIG91dHB1dFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ1NTIGZpbGUuIFlvdSBzaG91bGQgYWx3YXlzIHNldCBgdG9gXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0byBnZW5lcmF0ZSBjb3JyZWN0IHNvdXJjZSBtYXBzLlxuICogQHByb3BlcnR5IHtwYXJzZXJ9IHBhcnNlciAgICAgICAgICAgRnVuY3Rpb24gdG8gZ2VuZXJhdGUgQVNUIGJ5IHN0cmluZy5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5naWZpZXJ9IHN0cmluZ2lmaWVyIENsYXNzIHRvIGdlbmVyYXRlIHN0cmluZyBieSBBU1QuXG4gKiBAcHJvcGVydHkge3N5bnRheH0gc3ludGF4ICAgICAgICAgICBPYmplY3Qgd2l0aCBgcGFyc2VgIGFuZCBgc3RyaW5naWZ5YC5cbiAqIEBwcm9wZXJ0eSB7b2JqZWN0fSBtYXAgICAgICAgICAgICAgIFNvdXJjZSBtYXAgb3B0aW9ucy5cbiAqIEBwcm9wZXJ0eSB7Ym9vbGVhbn0gbWFwLmlubGluZSAgICAgICAgICAgICAgICAgICAgRG9lcyBzb3VyY2UgbWFwIHNob3VsZFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZSBlbWJlZGRlZCBpbiB0aGUgb3V0cHV0XG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENTUyBhcyBhIGJhc2U2NC1lbmNvZGVkXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1lbnQuXG4gKiBAcHJvcGVydHkge3N0cmluZ3xvYmplY3R8ZmFsc2V8ZnVuY3Rpb259IG1hcC5wcmV2IFNvdXJjZSBtYXAgY29udGVudFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tIGEgcHJldmlvdXNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2luZyBzdGVwXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChmb3IgZXhhbXBsZSwgU2FzcykuXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBvc3RDU1Mgd2lsbCB0cnkgdG8gZmluZFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2aW91cyBtYXAgYXV0b21hdGljYWxseSxcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc28geW91IGNvdWxkIGRpc2FibGUgaXQgYnlcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYGZhbHNlYCB2YWx1ZS5cbiAqIEBwcm9wZXJ0eSB7Ym9vbGVhbn0gbWFwLnNvdXJjZXNDb250ZW50ICAgICAgICAgICAgRG9lcyBQb3N0Q1NTIHNob3VsZCBzZXRcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhlIG9yaWdpbiBjb250ZW50IHRvIG1hcC5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5nfGZhbHNlfSBtYXAuYW5ub3RhdGlvbiAgICAgICAgICAgRG9lcyBQb3N0Q1NTIHNob3VsZCBzZXRcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbiBjb21tZW50IHRvIG1hcC5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5nfSBtYXAuZnJvbSAgICAgICAgICAgICAgICAgICAgICAgT3ZlcnJpZGUgYGZyb21gIGluIG1hcOKAmXNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlc2AuXG4gKi9cbiJdLCJmaWxlIjoicHJvY2Vzc29yLmpzIn0= +//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInByb2Nlc3Nvci5lczYiXSwibmFtZXMiOlsiUHJvY2Vzc29yIiwicGx1Z2lucyIsInZlcnNpb24iLCJub3JtYWxpemUiLCJ1c2UiLCJwbHVnaW4iLCJjb25jYXQiLCJwcm9jZXNzIiwiY3NzIiwib3B0cyIsImxlbmd0aCIsInBhcnNlciIsInN0cmluZ2lmaWVyIiwiZW52IiwiTk9ERV9FTlYiLCJjb25zb2xlIiwid2FybiIsIkxhenlSZXN1bHQiLCJub3JtYWxpemVkIiwiaSIsInBvc3Rjc3MiLCJBcnJheSIsImlzQXJyYXkiLCJwdXNoIiwicGFyc2UiLCJzdHJpbmdpZnkiLCJFcnJvciJdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQTs7OztBQUVBOzs7Ozs7Ozs7SUFTTUEsUzs7O0FBQ0o7Ozs7QUFJQSxxQkFBYUMsT0FBYixFQUEyQjtBQUFBLFFBQWRBLE9BQWM7QUFBZEEsTUFBQUEsT0FBYyxHQUFKLEVBQUk7QUFBQTs7QUFDekI7Ozs7Ozs7Ozs7QUFVQSxTQUFLQyxPQUFMLEdBQWUsUUFBZjtBQUNBOzs7Ozs7Ozs7O0FBU0EsU0FBS0QsT0FBTCxHQUFlLEtBQUtFLFNBQUwsQ0FBZUYsT0FBZixDQUFmO0FBQ0Q7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O1NBNkJBRyxHLEdBQUEsYUFBS0MsTUFBTCxFQUFhO0FBQ1gsU0FBS0osT0FBTCxHQUFlLEtBQUtBLE9BQUwsQ0FBYUssTUFBYixDQUFvQixLQUFLSCxTQUFMLENBQWUsQ0FBQ0UsTUFBRCxDQUFmLENBQXBCLENBQWY7QUFDQSxXQUFPLElBQVA7QUFDRDtBQUVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7U0FzQkFFLE87Ozs7Ozs7Ozs7SUFBQSxVQUFTQyxHQUFULEVBQWNDLElBQWQsRUFBMEI7QUFBQSxRQUFaQSxJQUFZO0FBQVpBLE1BQUFBLElBQVksR0FBTCxFQUFLO0FBQUE7O0FBQ3hCLFFBQUksS0FBS1IsT0FBTCxDQUFhUyxNQUFiLEtBQXdCLENBQXhCLElBQTZCRCxJQUFJLENBQUNFLE1BQUwsS0FBZ0JGLElBQUksQ0FBQ0csV0FBdEQsRUFBbUU7QUFDakUsVUFBSUwsT0FBTyxDQUFDTSxHQUFSLENBQVlDLFFBQVosS0FBeUIsWUFBN0IsRUFBMkM7QUFDekMsWUFBSSxPQUFPQyxPQUFQLEtBQW1CLFdBQW5CLElBQWtDQSxPQUFPLENBQUNDLElBQTlDLEVBQW9EO0FBQ2xERCxVQUFBQSxPQUFPLENBQUNDLElBQVIsQ0FDRSwwREFDQSw4REFEQSxHQUVBLGtFQUhGO0FBS0Q7QUFDRjtBQUNGOztBQUNELFdBQU8sSUFBSUMsbUJBQUosQ0FBZSxJQUFmLEVBQXFCVCxHQUFyQixFQUEwQkMsSUFBMUIsQ0FBUDtBQUNELEc7O1NBRUROLFMsR0FBQSxtQkFBV0YsT0FBWCxFQUFvQjtBQUNsQixRQUFJaUIsVUFBVSxHQUFHLEVBQWpCOztBQUNBLHlCQUFjakIsT0FBZCxrSEFBdUI7QUFBQTs7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBOztBQUFBLFVBQWRrQixDQUFjO0FBQ3JCLFVBQUlBLENBQUMsQ0FBQ0MsT0FBTixFQUFlRCxDQUFDLEdBQUdBLENBQUMsQ0FBQ0MsT0FBTjs7QUFFZixVQUFJLE9BQU9ELENBQVAsS0FBYSxRQUFiLElBQXlCRSxLQUFLLENBQUNDLE9BQU4sQ0FBY0gsQ0FBQyxDQUFDbEIsT0FBaEIsQ0FBN0IsRUFBdUQ7QUFDckRpQixRQUFBQSxVQUFVLEdBQUdBLFVBQVUsQ0FBQ1osTUFBWCxDQUFrQmEsQ0FBQyxDQUFDbEIsT0FBcEIsQ0FBYjtBQUNELE9BRkQsTUFFTyxJQUFJLE9BQU9rQixDQUFQLEtBQWEsVUFBakIsRUFBNkI7QUFDbENELFFBQUFBLFVBQVUsQ0FBQ0ssSUFBWCxDQUFnQkosQ0FBaEI7QUFDRCxPQUZNLE1BRUEsSUFBSSxPQUFPQSxDQUFQLEtBQWEsUUFBYixLQUEwQkEsQ0FBQyxDQUFDSyxLQUFGLElBQVdMLENBQUMsQ0FBQ00sU0FBdkMsQ0FBSixFQUF1RDtBQUM1RCxZQUFJbEIsT0FBTyxDQUFDTSxHQUFSLENBQVlDLFFBQVosS0FBeUIsWUFBN0IsRUFBMkM7QUFDekMsZ0JBQU0sSUFBSVksS0FBSixDQUNKLHFFQUNBLDJEQURBLEdBRUEsdUNBSEksQ0FBTjtBQUtEO0FBQ0YsT0FSTSxNQVFBO0FBQ0wsY0FBTSxJQUFJQSxLQUFKLENBQVVQLENBQUMsR0FBRywwQkFBZCxDQUFOO0FBQ0Q7QUFDRjs7QUFDRCxXQUFPRCxVQUFQO0FBQ0QsRzs7Ozs7ZUFHWWxCLFM7QUFFZjs7Ozs7OztBQU9BOzs7Ozs7Ozs7O0FBVUE7Ozs7Ozs7Ozs7QUFVQTs7Ozs7O0FBTUE7Ozs7O0FBS0E7Ozs7OztBQU1BOzs7OztBQUtBIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IExhenlSZXN1bHQgZnJvbSAnLi9sYXp5LXJlc3VsdCdcblxuLyoqXG4gKiBDb250YWlucyBwbHVnaW5zIHRvIHByb2Nlc3MgQ1NTLiBDcmVhdGUgb25lIGBQcm9jZXNzb3JgIGluc3RhbmNlLFxuICogaW5pdGlhbGl6ZSBpdHMgcGx1Z2lucywgYW5kIHRoZW4gdXNlIHRoYXQgaW5zdGFuY2Ugb24gbnVtZXJvdXMgQ1NTIGZpbGVzLlxuICpcbiAqIEBleGFtcGxlXG4gKiBjb25zdCBwcm9jZXNzb3IgPSBwb3N0Y3NzKFthdXRvcHJlZml4ZXIsIHByZWNzc10pXG4gKiBwcm9jZXNzb3IucHJvY2Vzcyhjc3MxKS50aGVuKHJlc3VsdCA9PiBjb25zb2xlLmxvZyhyZXN1bHQuY3NzKSlcbiAqIHByb2Nlc3Nvci5wcm9jZXNzKGNzczIpLnRoZW4ocmVzdWx0ID0+IGNvbnNvbGUubG9nKHJlc3VsdC5jc3MpKVxuICovXG5jbGFzcyBQcm9jZXNzb3Ige1xuICAvKipcbiAgICogQHBhcmFtIHtBcnJheS48UGx1Z2lufHBsdWdpbkZ1bmN0aW9uPnxQcm9jZXNzb3J9IHBsdWdpbnMgUG9zdENTUyBwbHVnaW5zLlxuICAgKiAgICAgICAgU2VlIHtAbGluayBQcm9jZXNzb3IjdXNlfSBmb3IgcGx1Z2luIGZvcm1hdC5cbiAgICovXG4gIGNvbnN0cnVjdG9yIChwbHVnaW5zID0gW10pIHtcbiAgICAvKipcbiAgICAgKiBDdXJyZW50IFBvc3RDU1MgdmVyc2lvbi5cbiAgICAgKlxuICAgICAqIEB0eXBlIHtzdHJpbmd9XG4gICAgICpcbiAgICAgKiBAZXhhbXBsZVxuICAgICAqIGlmIChyZXN1bHQucHJvY2Vzc29yLnZlcnNpb24uc3BsaXQoJy4nKVswXSAhPT0gJzYnKSB7XG4gICAgICogICB0aHJvdyBuZXcgRXJyb3IoJ1RoaXMgcGx1Z2luIHdvcmtzIG9ubHkgd2l0aCBQb3N0Q1NTIDYnKVxuICAgICAqIH1cbiAgICAgKi9cbiAgICB0aGlzLnZlcnNpb24gPSAnNy4wLjMxJ1xuICAgIC8qKlxuICAgICAqIFBsdWdpbnMgYWRkZWQgdG8gdGhpcyBwcm9jZXNzb3IuXG4gICAgICpcbiAgICAgKiBAdHlwZSB7cGx1Z2luRnVuY3Rpb25bXX1cbiAgICAgKlxuICAgICAqIEBleGFtcGxlXG4gICAgICogY29uc3QgcHJvY2Vzc29yID0gcG9zdGNzcyhbYXV0b3ByZWZpeGVyLCBwcmVjc3NdKVxuICAgICAqIHByb2Nlc3Nvci5wbHVnaW5zLmxlbmd0aCAvLz0+IDJcbiAgICAgKi9cbiAgICB0aGlzLnBsdWdpbnMgPSB0aGlzLm5vcm1hbGl6ZShwbHVnaW5zKVxuICB9XG5cbiAgLyoqXG4gICAqIEFkZHMgYSBwbHVnaW4gdG8gYmUgdXNlZCBhcyBhIENTUyBwcm9jZXNzb3IuXG4gICAqXG4gICAqIFBvc3RDU1MgcGx1Z2luIGNhbiBiZSBpbiA0IGZvcm1hdHM6XG4gICAqICogQSBwbHVnaW4gY3JlYXRlZCBieSB7QGxpbmsgcG9zdGNzcy5wbHVnaW59IG1ldGhvZC5cbiAgICogKiBBIGZ1bmN0aW9uLiBQb3N0Q1NTIHdpbGwgcGFzcyB0aGUgZnVuY3Rpb24gYSBAe2xpbmsgUm9vdH1cbiAgICogICBhcyB0aGUgZmlyc3QgYXJndW1lbnQgYW5kIGN1cnJlbnQge0BsaW5rIFJlc3VsdH0gaW5zdGFuY2VcbiAgICogICBhcyB0aGUgc2Vjb25kLlxuICAgKiAqIEFuIG9iamVjdCB3aXRoIGEgYHBvc3Rjc3NgIG1ldGhvZC4gUG9zdENTUyB3aWxsIHVzZSB0aGF0IG1ldGhvZFxuICAgKiAgIGFzIGRlc2NyaWJlZCBpbiAjMi5cbiAgICogKiBBbm90aGVyIHtAbGluayBQcm9jZXNzb3J9IGluc3RhbmNlLiBQb3N0Q1NTIHdpbGwgY29weSBwbHVnaW5zXG4gICAqICAgZnJvbSB0aGF0IGluc3RhbmNlIGludG8gdGhpcyBvbmUuXG4gICAqXG4gICAqIFBsdWdpbnMgY2FuIGFsc28gYmUgYWRkZWQgYnkgcGFzc2luZyB0aGVtIGFzIGFyZ3VtZW50cyB3aGVuIGNyZWF0aW5nXG4gICAqIGEgYHBvc3Rjc3NgIGluc3RhbmNlIChzZWUgW2Bwb3N0Y3NzKHBsdWdpbnMpYF0pLlxuICAgKlxuICAgKiBBc3luY2hyb25vdXMgcGx1Z2lucyBzaG91bGQgcmV0dXJuIGEgYFByb21pc2VgIGluc3RhbmNlLlxuICAgKlxuICAgKiBAcGFyYW0ge1BsdWdpbnxwbHVnaW5GdW5jdGlvbnxQcm9jZXNzb3J9IHBsdWdpbiBQb3N0Q1NTIHBsdWdpblxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvciB7QGxpbmsgUHJvY2Vzc29yfVxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoIHBsdWdpbnMuXG4gICAqXG4gICAqIEBleGFtcGxlXG4gICAqIGNvbnN0IHByb2Nlc3NvciA9IHBvc3Rjc3MoKVxuICAgKiAgIC51c2UoYXV0b3ByZWZpeGVyKVxuICAgKiAgIC51c2UocHJlY3NzKVxuICAgKlxuICAgKiBAcmV0dXJuIHtQcm9jZXNzZXN9IEN1cnJlbnQgcHJvY2Vzc29yIHRvIG1ha2UgbWV0aG9kcyBjaGFpbi5cbiAgICovXG4gIHVzZSAocGx1Z2luKSB7XG4gICAgdGhpcy5wbHVnaW5zID0gdGhpcy5wbHVnaW5zLmNvbmNhdCh0aGlzLm5vcm1hbGl6ZShbcGx1Z2luXSkpXG4gICAgcmV0dXJuIHRoaXNcbiAgfVxuXG4gIC8qKlxuICAgKiBQYXJzZXMgc291cmNlIENTUyBhbmQgcmV0dXJucyBhIHtAbGluayBMYXp5UmVzdWx0fSBQcm9taXNlIHByb3h5LlxuICAgKiBCZWNhdXNlIHNvbWUgcGx1Z2lucyBjYW4gYmUgYXN5bmNocm9ub3VzIGl0IGRvZXNu4oCZdCBtYWtlXG4gICAqIGFueSB0cmFuc2Zvcm1hdGlvbnMuIFRyYW5zZm9ybWF0aW9ucyB3aWxsIGJlIGFwcGxpZWRcbiAgICogaW4gdGhlIHtAbGluayBMYXp5UmVzdWx0fSBtZXRob2RzLlxuICAgKlxuICAgKiBAcGFyYW0ge3N0cmluZ3x0b1N0cmluZ3xSZXN1bHR9IGNzcyBTdHJpbmcgd2l0aCBpbnB1dCBDU1Mgb3IgYW55IG9iamVjdFxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aXRoIGEgYHRvU3RyaW5nKClgIG1ldGhvZCxcbiAgICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbGlrZSBhIEJ1ZmZlci4gT3B0aW9uYWxseSwgc2VuZFxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBhIHtAbGluayBSZXN1bHR9IGluc3RhbmNlXG4gICAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFuZCB0aGUgcHJvY2Vzc29yIHdpbGwgdGFrZVxuICAgKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGUge0BsaW5rIFJvb3R9IGZyb20gaXQuXG4gICAqIEBwYXJhbSB7cHJvY2Vzc09wdGlvbnN9IFtvcHRzXSAgICAgIE9wdGlvbnMuXG4gICAqXG4gICAqIEByZXR1cm4ge0xhenlSZXN1bHR9IFByb21pc2UgcHJveHkuXG4gICAqXG4gICAqIEBleGFtcGxlXG4gICAqIHByb2Nlc3Nvci5wcm9jZXNzKGNzcywgeyBmcm9tOiAnYS5jc3MnLCB0bzogJ2Eub3V0LmNzcycgfSlcbiAgICogICAudGhlbihyZXN1bHQgPT4ge1xuICAgKiAgICAgIGNvbnNvbGUubG9nKHJlc3VsdC5jc3MpXG4gICAqICAgfSlcbiAgICovXG4gIHByb2Nlc3MgKGNzcywgb3B0cyA9IHsgfSkge1xuICAgIGlmICh0aGlzLnBsdWdpbnMubGVuZ3RoID09PSAwICYmIG9wdHMucGFyc2VyID09PSBvcHRzLnN0cmluZ2lmaWVyKSB7XG4gICAgICBpZiAocHJvY2Vzcy5lbnYuTk9ERV9FTlYgIT09ICdwcm9kdWN0aW9uJykge1xuICAgICAgICBpZiAodHlwZW9mIGNvbnNvbGUgIT09ICd1bmRlZmluZWQnICYmIGNvbnNvbGUud2Fybikge1xuICAgICAgICAgIGNvbnNvbGUud2FybihcbiAgICAgICAgICAgICdZb3UgZGlkIG5vdCBzZXQgYW55IHBsdWdpbnMsIHBhcnNlciwgb3Igc3RyaW5naWZpZXIuICcgK1xuICAgICAgICAgICAgJ1JpZ2h0IG5vdywgUG9zdENTUyBkb2VzIG5vdGhpbmcuIFBpY2sgcGx1Z2lucyBmb3IgeW91ciBjYXNlICcgK1xuICAgICAgICAgICAgJ29uIGh0dHBzOi8vd3d3LnBvc3Rjc3MucGFydHMvIGFuZCB1c2UgdGhlbSBpbiBwb3N0Y3NzLmNvbmZpZy5qcy4nXG4gICAgICAgICAgKVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiBuZXcgTGF6eVJlc3VsdCh0aGlzLCBjc3MsIG9wdHMpXG4gIH1cblxuICBub3JtYWxpemUgKHBsdWdpbnMpIHtcbiAgICBsZXQgbm9ybWFsaXplZCA9IFtdXG4gICAgZm9yIChsZXQgaSBvZiBwbHVnaW5zKSB7XG4gICAgICBpZiAoaS5wb3N0Y3NzKSBpID0gaS5wb3N0Y3NzXG5cbiAgICAgIGlmICh0eXBlb2YgaSA9PT0gJ29iamVjdCcgJiYgQXJyYXkuaXNBcnJheShpLnBsdWdpbnMpKSB7XG4gICAgICAgIG5vcm1hbGl6ZWQgPSBub3JtYWxpemVkLmNvbmNhdChpLnBsdWdpbnMpXG4gICAgICB9IGVsc2UgaWYgKHR5cGVvZiBpID09PSAnZnVuY3Rpb24nKSB7XG4gICAgICAgIG5vcm1hbGl6ZWQucHVzaChpKVxuICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaSA9PT0gJ29iamVjdCcgJiYgKGkucGFyc2UgfHwgaS5zdHJpbmdpZnkpKSB7XG4gICAgICAgIGlmIChwcm9jZXNzLmVudi5OT0RFX0VOViAhPT0gJ3Byb2R1Y3Rpb24nKSB7XG4gICAgICAgICAgdGhyb3cgbmV3IEVycm9yKFxuICAgICAgICAgICAgJ1Bvc3RDU1Mgc3ludGF4ZXMgY2Fubm90IGJlIHVzZWQgYXMgcGx1Z2lucy4gSW5zdGVhZCwgcGxlYXNlIHVzZSAnICtcbiAgICAgICAgICAgICdvbmUgb2YgdGhlIHN5bnRheC9wYXJzZXIvc3RyaW5naWZpZXIgb3B0aW9ucyBhcyBvdXRsaW5lZCAnICtcbiAgICAgICAgICAgICdpbiB5b3VyIFBvc3RDU1MgcnVubmVyIGRvY3VtZW50YXRpb24uJ1xuICAgICAgICAgIClcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGkgKyAnIGlzIG5vdCBhIFBvc3RDU1MgcGx1Z2luJylcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIG5vcm1hbGl6ZWRcbiAgfVxufVxuXG5leHBvcnQgZGVmYXVsdCBQcm9jZXNzb3JcblxuLyoqXG4gKiBAY2FsbGJhY2sgYnVpbGRlclxuICogQHBhcmFtIHtzdHJpbmd9IHBhcnQgICAgICAgICAgUGFydCBvZiBnZW5lcmF0ZWQgQ1NTIGNvbm5lY3RlZCB0byB0aGlzIG5vZGUuXG4gKiBAcGFyYW0ge05vZGV9ICAgbm9kZSAgICAgICAgICBBU1Qgbm9kZS5cbiAqIEBwYXJhbSB7XCJzdGFydFwifFwiZW5kXCJ9IFt0eXBlXSBOb2Rl4oCZcyBwYXJ0IHR5cGUuXG4gKi9cblxuLyoqXG4gKiBAY2FsbGJhY2sgcGFyc2VyXG4gKlxuICogQHBhcmFtIHtzdHJpbmd8dG9TdHJpbmd9IGNzcyAgIFN0cmluZyB3aXRoIGlucHV0IENTUyBvciBhbnkgb2JqZWN0XG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2l0aCB0b1N0cmluZygpIG1ldGhvZCwgbGlrZSBhIEJ1ZmZlci5cbiAqIEBwYXJhbSB7cHJvY2Vzc09wdGlvbnN9IFtvcHRzXSBPcHRpb25zIHdpdGggb25seSBgZnJvbWAgYW5kIGBtYXBgIGtleXMuXG4gKlxuICogQHJldHVybiB7Um9vdH0gUG9zdENTUyBBU1RcbiAqL1xuXG4vKipcbiAqIEBjYWxsYmFjayBzdHJpbmdpZmllclxuICpcbiAqIEBwYXJhbSB7Tm9kZX0gbm9kZSAgICAgICBTdGFydCBub2RlIGZvciBzdHJpbmdpZmluZy4gVXN1YWxseSB7QGxpbmsgUm9vdH0uXG4gKiBAcGFyYW0ge2J1aWxkZXJ9IGJ1aWxkZXIgRnVuY3Rpb24gdG8gY29uY2F0ZW5hdGUgQ1NTIGZyb20gbm9kZeKAmXMgcGFydHNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICBvciBnZW5lcmF0ZSBzdHJpbmcgYW5kIHNvdXJjZSBtYXAuXG4gKlxuICogQHJldHVybiB7dm9pZH1cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHN5bnRheFxuICogQHByb3BlcnR5IHtwYXJzZXJ9IHBhcnNlICAgICAgICAgIEZ1bmN0aW9uIHRvIGdlbmVyYXRlIEFTVCBieSBzdHJpbmcuXG4gKiBAcHJvcGVydHkge3N0cmluZ2lmaWVyfSBzdHJpbmdpZnkgRnVuY3Rpb24gdG8gZ2VuZXJhdGUgc3RyaW5nIGJ5IEFTVC5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHRvU3RyaW5nXG4gKiBAcHJvcGVydHkge2Z1bmN0aW9ufSB0b1N0cmluZ1xuICovXG5cbi8qKlxuICogQGNhbGxiYWNrIHBsdWdpbkZ1bmN0aW9uXG4gKiBAcGFyYW0ge1Jvb3R9IHJvb3QgICAgIFBhcnNlZCBpbnB1dCBDU1MuXG4gKiBAcGFyYW0ge1Jlc3VsdH0gcmVzdWx0IFJlc3VsdCB0byBzZXQgd2FybmluZ3Mgb3IgY2hlY2sgb3RoZXIgcGx1Z2lucy5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IFBsdWdpblxuICogQHByb3BlcnR5IHtmdW5jdGlvbn0gcG9zdGNzcyBQb3N0Q1NTIHBsdWdpbiBmdW5jdGlvbi5cbiAqL1xuXG4vKipcbiAqIEB0eXBlZGVmIHtvYmplY3R9IHByb2Nlc3NPcHRpb25zXG4gKiBAcHJvcGVydHkge3N0cmluZ30gZnJvbSAgICAgICAgICAgICBUaGUgcGF0aCBvZiB0aGUgQ1NTIHNvdXJjZSBmaWxlLlxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgWW91IHNob3VsZCBhbHdheXMgc2V0IGBmcm9tYCxcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlY2F1c2UgaXQgaXMgdXNlZCBpbiBzb3VyY2UgbWFwXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZW5lcmF0aW9uIGFuZCBzeW50YXggZXJyb3IgbWVzc2FnZXMuXG4gKiBAcHJvcGVydHkge3N0cmluZ30gdG8gICAgICAgICAgICAgICBUaGUgcGF0aCB3aGVyZSB5b3XigJlsbCBwdXQgdGhlIG91dHB1dFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ1NTIGZpbGUuIFlvdSBzaG91bGQgYWx3YXlzIHNldCBgdG9gXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0byBnZW5lcmF0ZSBjb3JyZWN0IHNvdXJjZSBtYXBzLlxuICogQHByb3BlcnR5IHtwYXJzZXJ9IHBhcnNlciAgICAgICAgICAgRnVuY3Rpb24gdG8gZ2VuZXJhdGUgQVNUIGJ5IHN0cmluZy5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5naWZpZXJ9IHN0cmluZ2lmaWVyIENsYXNzIHRvIGdlbmVyYXRlIHN0cmluZyBieSBBU1QuXG4gKiBAcHJvcGVydHkge3N5bnRheH0gc3ludGF4ICAgICAgICAgICBPYmplY3Qgd2l0aCBgcGFyc2VgIGFuZCBgc3RyaW5naWZ5YC5cbiAqIEBwcm9wZXJ0eSB7b2JqZWN0fSBtYXAgICAgICAgICAgICAgIFNvdXJjZSBtYXAgb3B0aW9ucy5cbiAqIEBwcm9wZXJ0eSB7Ym9vbGVhbn0gbWFwLmlubGluZSAgICAgICAgICAgICAgICAgICAgRG9lcyBzb3VyY2UgbWFwIHNob3VsZFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBiZSBlbWJlZGRlZCBpbiB0aGUgb3V0cHV0XG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENTUyBhcyBhIGJhc2U2NC1lbmNvZGVkXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbW1lbnQuXG4gKiBAcHJvcGVydHkge3N0cmluZ3xvYmplY3R8ZmFsc2V8ZnVuY3Rpb259IG1hcC5wcmV2IFNvdXJjZSBtYXAgY29udGVudFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmcm9tIGEgcHJldmlvdXNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc2luZyBzdGVwXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChmb3IgZXhhbXBsZSwgU2FzcykuXG4gKiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFBvc3RDU1Mgd2lsbCB0cnkgdG8gZmluZFxuICogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwcmV2aW91cyBtYXAgYXV0b21hdGljYWxseSxcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc28geW91IGNvdWxkIGRpc2FibGUgaXQgYnlcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYGZhbHNlYCB2YWx1ZS5cbiAqIEBwcm9wZXJ0eSB7Ym9vbGVhbn0gbWFwLnNvdXJjZXNDb250ZW50ICAgICAgICAgICAgRG9lcyBQb3N0Q1NTIHNob3VsZCBzZXRcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhlIG9yaWdpbiBjb250ZW50IHRvIG1hcC5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5nfGZhbHNlfSBtYXAuYW5ub3RhdGlvbiAgICAgICAgICAgRG9lcyBQb3N0Q1NTIHNob3VsZCBzZXRcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYW5ub3RhdGlvbiBjb21tZW50IHRvIG1hcC5cbiAqIEBwcm9wZXJ0eSB7c3RyaW5nfSBtYXAuZnJvbSAgICAgICAgICAgICAgICAgICAgICAgT3ZlcnJpZGUgYGZyb21gIGluIG1hcOKAmXNcbiAqICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlc2AuXG4gKi9cbiJdLCJmaWxlIjoicHJvY2Vzc29yLmpzIn0= /***/ }), @@ -239751,8 +247003,31 @@ module.exports = Comma; /***/ }), -/* 790 */, -/* 791 */, +/* 790 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(570) +const gte = (a, b, loose) => compare(a, b, loose) >= 0 +module.exports = gte + + +/***/ }), +/* 791 */ +/***/ (function(module) { + +module.exports = function (x, opts) { + /** + * This file is purposefully a passthrough. It's expected that third-party + * environments will override it at runtime in order to inject special logic + * into `resolve` (by manipulating the options). One such example is the PnP + * code path in Yarn. + */ + + return opts || {}; +}; + + +/***/ }), /* 792 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -239767,7 +247042,36 @@ module.exports = function getPolyfill() { /***/ }), -/* 793 */, +/* 793 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +/* + * Copyright (c) 2012 Mathieu Turcotte + * Licensed under the MIT license. + */ + +var util = __webpack_require__(669); + +function IllegalArgumentError(message) { + Error.call(this, message); + this.message = message; +} +util.inherits(IllegalArgumentError, Error); + +IllegalArgumentError.prototype.name = 'IllegalArgumentError'; + +function IllegalStateError(message) { + Error.call(this, message); + this.message = message; +} +util.inherits(IllegalStateError, Error); + +IllegalStateError.prototype.name = 'IllegalStateError'; + +module.exports.IllegalStateError = IllegalStateError; +module.exports.IllegalArgumentError = IllegalArgumentError; + +/***/ }), /* 794 */ /***/ (function(module, exports, __webpack_require__) { @@ -240611,15 +247915,57 @@ if (util && util.inspect && util.inspect.custom) { /* 801 */ /***/ (function(module, __unusedexports, __webpack_require__) { +const { version: nodeVersion } = __webpack_require__(956) + +const findUp = __webpack_require__(957) +const pathExists = __webpack_require__(757) const resolve = __webpack_require__(371) +const { lt: ltVersion } = __webpack_require__(94) + +// Find the path to a module's `package.json` +// We need to use `resolve` instead of `require.resolve()` because: +// - it is async +// - it preserves symlinks: +// - this is important because if a file does a `require('./symlink')`, we +// need to bundle the symlink and its target, not only the target +// - `path.resolve()` cannot be used for relative|absolute file paths +// because it does not resolve ommitted file extension, +// e.g. `require('./file')` instead of `require('./file.js')` +// - the CLI flag `--preserve-symlinks` can be used with Node.js, but it +// cannot be set runtime +// However it does not give helpful error messages. +// https://github.com/browserify/resolve/issues/223 +// So, on errors, we fallback to `require.resolve()` +const resolvePackage = async function(moduleName, basedir) { + try { + return await resolvePathPreserveSymlinks(`${moduleName}/package.json`, basedir) + } catch (error) { + if (ltVersion(nodeVersion, REQUEST_RESOLVE_MIN_VERSION)) { + throw error + } + + try { + return resolvePathFollowSymlinks(`${moduleName}/package.json`, basedir) + } catch (error) { + const packagePath = resolvePackageFallback(moduleName, basedir) + if (packagePath === undefined) { + throw error + } + return packagePath + } + } +} + +// TODO: remove after dropping support for Node <8.9.0 +// `require.resolve()` option `paths` was introduced in Node 8.9.0 +const REQUEST_RESOLVE_MIN_VERSION = '8.9.0' -// Like `require.resolve()` but works with a custom base directory. // We need to use `new Promise()` due to a bug with `utils.promisify()` on // `resolve`: // https://github.com/browserify/resolve/issues/151#issuecomment-368210310 -const resolveLocation = function(location, basedir) { +const resolvePathPreserveSymlinks = function(path, basedir) { return new Promise((success, reject) => { - resolve(location, { basedir, preserveSymlinks: true }, (error, resolvedLocation) => { + resolve(path, { basedir, preserveSymlinks: true }, (error, resolvedLocation) => { if (error) { return reject(error) } @@ -240629,7 +247975,36 @@ const resolveLocation = function(location, basedir) { }) } -module.exports = { resolveLocation } +const resolvePathFollowSymlinks = function(path, basedir) { + return require.resolve(path, { paths: [basedir] }) +} + +// `require.resolve()` on a module's specific file (like `package.json`) +// can be forbidden by the package author by using an `exports` field in +// their `package.json`. We need this fallback. +// It looks for the first directory up from a package's `main` file that: +// - is named like the package +// - has a `package.json` +// Theoritically, this might not the root `package.json`, but this is very +// unlikely, and we don't have any better alternative. +const resolvePackageFallback = async function(moduleName, basedir) { + const mainFilePath = resolvePathFollowSymlinks(moduleName, basedir) + return findUp(isPackageDir.bind(null, moduleName), { cwd: mainFilePath, type: 'directory' }) +} + +const isPackageDir = async function(moduleName, dir) { + // Need to use `endsWith()` to take into account `@scope/package`. + // Backslashes need to be converted for Windows. + if (!dir.replace(BACKSLASH_REGEXP, '/').endsWith(moduleName) || !(await pathExists(`${dir}/package.json`))) { + return + } + + return dir +} + +const BACKSLASH_REGEXP = /\\/g + +module.exports = { resolvePackage, resolvePathPreserveSymlinks } /***/ }), @@ -240988,9 +248363,40 @@ module.exports = flatten; /***/ }), -/* 803 */, -/* 804 */, -/* 805 */, +/* 803 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(147) +const valid = (version, options) => { + const v = parse(version, options) + return v ? v.version : null +} +module.exports = valid + + +/***/ }), +/* 804 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(682) +const eq = (a, b, loose) => compare(a, b, loose) === 0 +module.exports = eq + + +/***/ }), +/* 805 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const compareBuild = (a, b, loose) => { + const versionA = new SemVer(a, loose) + const versionB = new SemVer(b, loose) + return versionA.compare(versionB) || versionA.compareBuild(versionB) +} +module.exports = compareBuild + + +/***/ }), /* 806 */ /***/ (function(module) { @@ -241250,7 +248656,12 @@ function whichSync (cmd, opt) { /***/ }), -/* 815 */, +/* 815 */ +/***/ (function(module) { + +module.exports = {"assert":true,"async_hooks":">= 8","buffer_ieee754":"< 0.9.7","buffer":true,"child_process":true,"cluster":true,"console":true,"constants":true,"crypto":true,"_debug_agent":">= 1 && < 8","_debugger":"< 8","dgram":true,"dns":true,"domain":true,"events":true,"freelist":"< 6","fs":true,"fs/promises":">= 10 && < 10.1","_http_agent":">= 0.11.1","_http_client":">= 0.11.1","_http_common":">= 0.11.1","_http_incoming":">= 0.11.1","_http_outgoing":">= 0.11.1","_http_server":">= 0.11.1","http":true,"http2":">= 8.8","https":true,"inspector":">= 8.0.0","_linklist":"< 8","module":true,"net":true,"node-inspect/lib/_inspect":">= 7.6.0 && < 12","node-inspect/lib/internal/inspect_client":">= 7.6.0 && < 12","node-inspect/lib/internal/inspect_repl":">= 7.6.0 && < 12","os":true,"path":true,"perf_hooks":">= 8.5","process":">= 1","punycode":true,"querystring":true,"readline":true,"repl":true,"smalloc":">= 0.11.5 && < 3","_stream_duplex":">= 0.9.4","_stream_transform":">= 0.9.4","_stream_wrap":">= 1.4.1","_stream_passthrough":">= 0.9.4","_stream_readable":">= 0.9.4","_stream_writable":">= 0.9.4","stream":true,"string_decoder":true,"sys":true,"timers":true,"_tls_common":">= 0.11.13","_tls_legacy":">= 0.11.3 && < 10","_tls_wrap":">= 0.11.3","tls":true,"trace_events":">= 10","tty":true,"url":true,"util":true,"v8/tools/arguments":">= 10 && < 12","v8/tools/codemap":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/consarray":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/csvparser":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/logreader":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/profile_view":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8/tools/splaytree":[">= 4.4.0 && < 5",">= 5.2.0 && < 12"],"v8":">= 1","vm":true,"wasi":">= 13.4 && < 13.5","worker_threads":">= 11.7","zlib":true}; + +/***/ }), /* 816 */ /***/ (function(module) { @@ -243323,2113 +250734,755 @@ IndexedSourceMapConsumer.prototype.originalPositionFor = }); var section = this._sections[sectionIndex]; - if (!section) { - return { - source: null, - line: null, - column: null, - name: null - }; - } - - return section.consumer.originalPositionFor({ - line: needle.generatedLine - - (section.generatedOffset.generatedLine - 1), - column: needle.generatedColumn - - (section.generatedOffset.generatedLine === needle.generatedLine - ? section.generatedOffset.generatedColumn - 1 - : 0), - bias: aArgs.bias - }); - }; - -/** - * Return true if we have the source content for every source in the source - * map, false otherwise. - */ -IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = - function IndexedSourceMapConsumer_hasContentsOfAllSources() { - return this._sections.every(function (s) { - return s.consumer.hasContentsOfAllSources(); - }); - }; - -/** - * Returns the original source content. The only argument is the url of the - * original source file. Returns null if no original source content is - * available. - */ -IndexedSourceMapConsumer.prototype.sourceContentFor = - function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { - for (var i = 0; i < this._sections.length; i++) { - var section = this._sections[i]; - - var content = section.consumer.sourceContentFor(aSource, true); - if (content) { - return content; - } - } - if (nullOnMissing) { - return null; - } - else { - throw new Error('"' + aSource + '" is not in the SourceMap.'); - } - }; - -/** - * Returns the generated line and column information for the original source, - * line, and column positions provided. The only argument is an object with - * the following properties: - * - * - source: The filename of the original source. - * - line: The line number in the original source. The line number - * is 1-based. - * - column: The column number in the original source. The column - * number is 0-based. - * - * and an object is returned with the following properties: - * - * - line: The line number in the generated source, or null. The - * line number is 1-based. - * - column: The column number in the generated source, or null. - * The column number is 0-based. - */ -IndexedSourceMapConsumer.prototype.generatedPositionFor = - function IndexedSourceMapConsumer_generatedPositionFor(aArgs) { - for (var i = 0; i < this._sections.length; i++) { - var section = this._sections[i]; - - // Only consider this section if the requested source is in the list of - // sources of the consumer. - if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) { - continue; - } - var generatedPosition = section.consumer.generatedPositionFor(aArgs); - if (generatedPosition) { - var ret = { - line: generatedPosition.line + - (section.generatedOffset.generatedLine - 1), - column: generatedPosition.column + - (section.generatedOffset.generatedLine === generatedPosition.line - ? section.generatedOffset.generatedColumn - 1 - : 0) - }; - return ret; - } - } - - return { - line: null, - column: null - }; - }; - -/** - * Parse the mappings in a string in to a data structure which we can easily - * query (the ordered arrays in the `this.__generatedMappings` and - * `this.__originalMappings` properties). - */ -IndexedSourceMapConsumer.prototype._parseMappings = - function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) { - this.__generatedMappings = []; - this.__originalMappings = []; - for (var i = 0; i < this._sections.length; i++) { - var section = this._sections[i]; - var sectionMappings = section.consumer._generatedMappings; - for (var j = 0; j < sectionMappings.length; j++) { - var mapping = sectionMappings[j]; - - var source = section.consumer._sources.at(mapping.source); - source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL); - this._sources.add(source); - source = this._sources.indexOf(source); - - var name = null; - if (mapping.name) { - name = section.consumer._names.at(mapping.name); - this._names.add(name); - name = this._names.indexOf(name); - } - - // The mappings coming from the consumer for the section have - // generated positions relative to the start of the section, so we - // need to offset them to be relative to the start of the concatenated - // generated file. - var adjustedMapping = { - source: source, - generatedLine: mapping.generatedLine + - (section.generatedOffset.generatedLine - 1), - generatedColumn: mapping.generatedColumn + - (section.generatedOffset.generatedLine === mapping.generatedLine - ? section.generatedOffset.generatedColumn - 1 - : 0), - originalLine: mapping.originalLine, - originalColumn: mapping.originalColumn, - name: name - }; - - this.__generatedMappings.push(adjustedMapping); - if (typeof adjustedMapping.originalLine === 'number') { - this.__originalMappings.push(adjustedMapping); - } - } - } - - quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated); - quickSort(this.__originalMappings, util.compareByOriginalPositions); - }; - -exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; - - -/***/ }), -/* 820 */, -/* 821 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -var toString = __webpack_require__(428), - unescapeHtmlChar = __webpack_require__(673); - -/** Used to match HTML entities and HTML characters. */ -var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, - reHasEscapedHtml = RegExp(reEscapedHtml.source); - -/** - * The inverse of `_.escape`; this method converts the HTML entities - * `&`, `<`, `>`, `"`, and `'` in `string` to - * their corresponding characters. - * - * **Note:** No other HTML entities are unescaped. To unescape additional - * HTML entities use a third-party library like [_he_](https://mths.be/he). - * - * @static - * @memberOf _ - * @since 0.6.0 - * @category String - * @param {string} [string=''] The string to unescape. - * @returns {string} Returns the unescaped string. - * @example - * - * _.unescape('fred, barney, & pebbles'); - * // => 'fred, barney, & pebbles' - */ -function unescape(string) { - string = toString(string); - return (string && reHasEscapedHtml.test(string)) - ? string.replace(reEscapedHtml, unescapeHtmlChar) - : string; -} - -module.exports = unescape; - - -/***/ }), -/* 822 */ -/***/ (function(module) { - -"use strict"; - - -if (typeof process === 'undefined' || - !process.version || - process.version.indexOf('v0.') === 0 || - process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { - module.exports = { nextTick: nextTick }; -} else { - module.exports = process -} - -function nextTick(fn, arg1, arg2, arg3) { - if (typeof fn !== 'function') { - throw new TypeError('"callback" argument must be a function'); - } - var len = arguments.length; - var args, i; - switch (len) { - case 0: - case 1: - return process.nextTick(fn); - case 2: - return process.nextTick(function afterTickOne() { - fn.call(null, arg1); - }); - case 3: - return process.nextTick(function afterTickTwo() { - fn.call(null, arg1, arg2); - }); - case 4: - return process.nextTick(function afterTickThree() { - fn.call(null, arg1, arg2, arg3); - }); - default: - args = new Array(len - 1); - i = 0; - while (i < args.length) { - args[i++] = arguments[i]; - } - return process.nextTick(function afterTick() { - fn.apply(null, args); - }); - } -} - - - -/***/ }), -/* 823 */, -/* 824 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -var freeGlobal = __webpack_require__(973); - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -module.exports = root; - - -/***/ }), -/* 825 */, -/* 826 */ -/***/ (function(module) { - -"use strict"; - - -/* eslint complexity: [2, 18], max-statements: [2, 33] */ -module.exports = function hasSymbols() { - if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } - if (typeof Symbol.iterator === 'symbol') { return true; } - - var obj = {}; - var sym = Symbol('test'); - var symObj = Object(sym); - if (typeof sym === 'string') { return false; } - - if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; } - if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; } - - // temp disabled per https://github.com/ljharb/object.assign/issues/17 - // if (sym instanceof Symbol) { return false; } - // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4 - // if (!(symObj instanceof Symbol)) { return false; } - - // if (typeof Symbol.prototype.toString !== 'function') { return false; } - // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; } - - var symVal = 42; - obj[sym] = symVal; - for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax - if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } - - if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } - - var syms = Object.getOwnPropertySymbols(obj); - if (syms.length !== 1 || syms[0] !== sym) { return false; } - - if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } - - if (typeof Object.getOwnPropertyDescriptor === 'function') { - var descriptor = Object.getOwnPropertyDescriptor(obj, sym); - if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } - } - - return true; -}; - - -/***/ }), -/* 827 */, -/* 828 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -/**/ - -var pna = __webpack_require__(822); -/**/ - -// undocumented cb() API, needed for core, not for public API -function destroy(err, cb) { - var _this = this; - - var readableDestroyed = this._readableState && this._readableState.destroyed; - var writableDestroyed = this._writableState && this._writableState.destroyed; - - if (readableDestroyed || writableDestroyed) { - if (cb) { - cb(err); - } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { - pna.nextTick(emitErrorNT, this, err); - } - return this; - } - - // we set destroyed to true before firing error callbacks in order - // to make it re-entrance safe in case destroy() is called within callbacks - - if (this._readableState) { - this._readableState.destroyed = true; - } - - // if this is a duplex stream mark the writable part as destroyed as well - if (this._writableState) { - this._writableState.destroyed = true; - } - - this._destroy(err || null, function (err) { - if (!cb && err) { - pna.nextTick(emitErrorNT, _this, err); - if (_this._writableState) { - _this._writableState.errorEmitted = true; - } - } else if (cb) { - cb(err); - } - }); - - return this; -} - -function undestroy() { - if (this._readableState) { - this._readableState.destroyed = false; - this._readableState.reading = false; - this._readableState.ended = false; - this._readableState.endEmitted = false; - } - - if (this._writableState) { - this._writableState.destroyed = false; - this._writableState.ended = false; - this._writableState.ending = false; - this._writableState.finished = false; - this._writableState.errorEmitted = false; - } -} - -function emitErrorNT(self, err) { - self.emit('error', err); -} - -module.exports = { - destroy: destroy, - undestroy: undestroy -}; - -/***/ }), -/* 829 */ -/***/ (function(__unusedmodule, exports) { - -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ - -// It turns out that some (most?) JavaScript engines don't self-host -// `Array.prototype.sort`. This makes sense because C++ will likely remain -// faster than JS when doing raw CPU-intensive sorting. However, when using a -// custom comparator function, calling back and forth between the VM's C++ and -// JIT'd JS is rather slow *and* loses JIT type information, resulting in -// worse generated code for the comparator function than would be optimal. In -// fact, when sorting with a comparator, these costs outweigh the benefits of -// sorting in C++. By using our own JS-implemented Quick Sort (below), we get -// a ~3500ms mean speed-up in `bench/bench.html`. - -/** - * Swap the elements indexed by `x` and `y` in the array `ary`. - * - * @param {Array} ary - * The array. - * @param {Number} x - * The index of the first item. - * @param {Number} y - * The index of the second item. - */ -function swap(ary, x, y) { - var temp = ary[x]; - ary[x] = ary[y]; - ary[y] = temp; -} - -/** - * Returns a random integer within the range `low .. high` inclusive. - * - * @param {Number} low - * The lower bound on the range. - * @param {Number} high - * The upper bound on the range. - */ -function randomIntInRange(low, high) { - return Math.round(low + (Math.random() * (high - low))); -} - -/** - * The Quick Sort algorithm. - * - * @param {Array} ary - * An array to sort. - * @param {function} comparator - * Function to use to compare two items. - * @param {Number} p - * Start index of the array - * @param {Number} r - * End index of the array - */ -function doQuickSort(ary, comparator, p, r) { - // If our lower bound is less than our upper bound, we (1) partition the - // array into two pieces and (2) recurse on each half. If it is not, this is - // the empty array and our base case. - - if (p < r) { - // (1) Partitioning. - // - // The partitioning chooses a pivot between `p` and `r` and moves all - // elements that are less than or equal to the pivot to the before it, and - // all the elements that are greater than it after it. The effect is that - // once partition is done, the pivot is in the exact place it will be when - // the array is put in sorted order, and it will not need to be moved - // again. This runs in O(n) time. - - // Always choose a random pivot so that an input array which is reverse - // sorted does not cause O(n^2) running time. - var pivotIndex = randomIntInRange(p, r); - var i = p - 1; - - swap(ary, pivotIndex, r); - var pivot = ary[r]; - - // Immediately after `j` is incremented in this loop, the following hold - // true: - // - // * Every element in `ary[p .. i]` is less than or equal to the pivot. - // - // * Every element in `ary[i+1 .. j-1]` is greater than the pivot. - for (var j = p; j < r; j++) { - if (comparator(ary[j], pivot) <= 0) { - i += 1; - swap(ary, i, j); - } - } - - swap(ary, i + 1, j); - var q = i + 1; - - // (2) Recurse on each half. - - doQuickSort(ary, comparator, p, q - 1); - doQuickSort(ary, comparator, q + 1, r); - } -} - -/** - * Sort the given array in-place with the given comparator function. - * - * @param {Array} ary - * An array to sort. - * @param {function} comparator - * Function to use to compare two items. - */ -exports.quickSort = function (ary, comparator) { - doQuickSort(ary, comparator, 0, ary.length - 1); -}; - - -/***/ }), -/* 830 */, -/* 831 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. -// a duplex stream is just a stream that is both readable and writable. -// Since JS doesn't have multiple prototypal inheritance, this class -// prototypally inherits from Readable, and then parasitically from -// Writable. - -/**/ - -var objectKeys = Object.keys || function (obj) { - var keys = []; - - for (var key in obj) { - keys.push(key); - } - - return keys; -}; -/**/ - - -module.exports = Duplex; - -var Readable = __webpack_require__(226); - -var Writable = __webpack_require__(241); - -__webpack_require__(689)(Duplex, Readable); - -{ - // Allow the keys array to be GC'ed. - var keys = objectKeys(Writable.prototype); - - for (var v = 0; v < keys.length; v++) { - var method = keys[v]; - if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; - } -} - -function Duplex(options) { - if (!(this instanceof Duplex)) return new Duplex(options); - Readable.call(this, options); - Writable.call(this, options); - this.allowHalfOpen = true; - - if (options) { - if (options.readable === false) this.readable = false; - if (options.writable === false) this.writable = false; - - if (options.allowHalfOpen === false) { - this.allowHalfOpen = false; - this.once('end', onend); - } - } -} - -Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState.highWaterMark; - } -}); -Object.defineProperty(Duplex.prototype, 'writableBuffer', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState && this._writableState.getBuffer(); - } -}); -Object.defineProperty(Duplex.prototype, 'writableLength', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - return this._writableState.length; - } -}); // the no-half-open enforcer - -function onend() { - // If the writable side ended, then we're ok. - if (this._writableState.ended) return; // no more data can be written. - // But allow more writes to happen in this tick. - - process.nextTick(onEndNT, this); -} - -function onEndNT(self) { - self.end(); -} - -Object.defineProperty(Duplex.prototype, 'destroyed', { - // making it explicit this property is not enumerable - // because otherwise some prototype manipulation in - // userland will fail - enumerable: false, - get: function get() { - if (this._readableState === undefined || this._writableState === undefined) { - return false; - } - - return this._readableState.destroyed && this._writableState.destroyed; - }, - set: function set(value) { - // we ignore the value if the stream - // has not been initialized yet - if (this._readableState === undefined || this._writableState === undefined) { - return; - } // backward compatibility, the user is explicitly - // managing destroyed - - - this._readableState.destroyed = value; - this._writableState.destroyed = value; - } -}); - -/***/ }), -/* 832 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -module.exports = __webpack_require__(271).default; - - -/***/ }), -/* 833 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const ts = __webpack_require__(752); -const node_1 = __webpack_require__(10); -const _3_2_1 = __webpack_require__(584); -const type_1 = __webpack_require__(90); -function getChildOfKind(node, kind, sourceFile) { - for (const child of node.getChildren(sourceFile)) - if (child.kind === kind) - return child; -} -exports.getChildOfKind = getChildOfKind; -function isTokenKind(kind) { - return kind >= ts.SyntaxKind.FirstToken && kind <= ts.SyntaxKind.LastToken; -} -exports.isTokenKind = isTokenKind; -function isNodeKind(kind) { - return kind >= ts.SyntaxKind.FirstNode; -} -exports.isNodeKind = isNodeKind; -function isAssignmentKind(kind) { - return kind >= ts.SyntaxKind.FirstAssignment && kind <= ts.SyntaxKind.LastAssignment; -} -exports.isAssignmentKind = isAssignmentKind; -function isTypeNodeKind(kind) { - return kind >= ts.SyntaxKind.FirstTypeNode && kind <= ts.SyntaxKind.LastTypeNode; -} -exports.isTypeNodeKind = isTypeNodeKind; -function isJsDocKind(kind) { - return kind >= ts.SyntaxKind.FirstJSDocNode && kind <= ts.SyntaxKind.LastJSDocNode; -} -exports.isJsDocKind = isJsDocKind; -function isKeywordKind(kind) { - return kind >= ts.SyntaxKind.FirstKeyword && kind <= ts.SyntaxKind.LastKeyword; -} -exports.isKeywordKind = isKeywordKind; -function isThisParameter(parameter) { - return parameter.name.kind === ts.SyntaxKind.Identifier && parameter.name.originalKeywordKind === ts.SyntaxKind.ThisKeyword; -} -exports.isThisParameter = isThisParameter; -function getModifier(node, kind) { - if (node.modifiers !== undefined) - for (const modifier of node.modifiers) - if (modifier.kind === kind) - return modifier; -} -exports.getModifier = getModifier; -function hasModifier(modifiers, ...kinds) { - if (modifiers === undefined) - return false; - for (const modifier of modifiers) - if (kinds.includes(modifier.kind)) - return true; - return false; -} -exports.hasModifier = hasModifier; -function isParameterProperty(node) { - return hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ReadonlyKeyword); -} -exports.isParameterProperty = isParameterProperty; -function hasAccessModifier(node) { - return hasModifier(node.modifiers, ts.SyntaxKind.PublicKeyword, ts.SyntaxKind.ProtectedKeyword, ts.SyntaxKind.PrivateKeyword); -} -exports.hasAccessModifier = hasAccessModifier; -function isFlagSet(obj, flag) { - return (obj.flags & flag) !== 0; -} -exports.isNodeFlagSet = isFlagSet; -exports.isTypeFlagSet = isFlagSet; -exports.isSymbolFlagSet = isFlagSet; -function isObjectFlagSet(objectType, flag) { - return (objectType.objectFlags & flag) !== 0; -} -exports.isObjectFlagSet = isObjectFlagSet; -function isModifierFlagSet(node, flag) { - return (ts.getCombinedModifierFlags(node) & flag) !== 0; -} -exports.isModifierFlagSet = isModifierFlagSet; -function getPreviousStatement(statement) { - const parent = statement.parent; - if (node_1.isBlockLike(parent)) { - const index = parent.statements.indexOf(statement); - if (index > 0) - return parent.statements[index - 1]; - } -} -exports.getPreviousStatement = getPreviousStatement; -function getNextStatement(statement) { - const parent = statement.parent; - if (node_1.isBlockLike(parent)) { - const index = parent.statements.indexOf(statement); - if (index < parent.statements.length) - return parent.statements[index + 1]; - } -} -exports.getNextStatement = getNextStatement; -function getPreviousToken(node, sourceFile) { - let parent = node.parent; - while (parent !== undefined && parent.pos === node.pos) - parent = parent.parent; - if (parent === undefined) - return; - outer: while (true) { - const children = parent.getChildren(sourceFile); - for (let i = children.length - 1; i >= 0; --i) { - const child = children[i]; - if (child.pos < node.pos && child.kind !== ts.SyntaxKind.JSDocComment) { - if (isTokenKind(child.kind)) - return child; - parent = child; - continue outer; - } - } - return; - } -} -exports.getPreviousToken = getPreviousToken; -function getNextToken(node, sourceFile = node.getSourceFile()) { - if (node.kind === ts.SyntaxKind.SourceFile || node.kind === ts.SyntaxKind.EndOfFileToken) - return; - const end = node.end; - node = node.parent; - while (node.end === end) { - if (node.parent === undefined) - return node.endOfFileToken; - node = node.parent; - } - return getTokenAtPositionWorker(node, end, sourceFile, false); -} -exports.getNextToken = getNextToken; -function getTokenAtPosition(parent, pos, sourceFile, allowJsDoc) { - if (pos < parent.pos || pos >= parent.end) - return; - if (isTokenKind(parent.kind)) - return parent; - if (sourceFile === undefined) - sourceFile = parent.getSourceFile(); - return getTokenAtPositionWorker(parent, pos, sourceFile, allowJsDoc === true); -} -exports.getTokenAtPosition = getTokenAtPosition; -function getTokenAtPositionWorker(node, pos, sourceFile, allowJsDoc) { - outer: while (true) { - for (const child of node.getChildren(sourceFile)) { - if (child.end > pos && (allowJsDoc || child.kind !== ts.SyntaxKind.JSDocComment)) { - if (isTokenKind(child.kind)) - return child; - node = child; - continue outer; - } - } - return; - } -} -function getCommentAtPosition(sourceFile, pos, parent = sourceFile) { - const token = getTokenAtPosition(parent, pos, sourceFile); - if (token === undefined || token.kind === ts.SyntaxKind.JsxText || pos >= token.end - (ts.tokenToString(token.kind) || '').length) - return; - const startPos = token.pos === 0 - ? (ts.getShebang(sourceFile.text) || '').length - : token.pos; - return startPos !== 0 && ts.forEachTrailingCommentRange(sourceFile.text, startPos, commentAtPositionCallback, pos) || - ts.forEachLeadingCommentRange(sourceFile.text, startPos, commentAtPositionCallback, pos); -} -exports.getCommentAtPosition = getCommentAtPosition; -function commentAtPositionCallback(pos, end, kind, _nl, at) { - return at >= pos && at < end ? { pos, end, kind } : undefined; -} -function isPositionInComment(sourceFile, pos, parent) { - return getCommentAtPosition(sourceFile, pos, parent) !== undefined; -} -exports.isPositionInComment = isPositionInComment; -function commentText(sourceText, comment) { - return sourceText.substring(comment.pos + 2, comment.kind === ts.SyntaxKind.SingleLineCommentTrivia ? comment.end : comment.end - 2); -} -exports.commentText = commentText; -function getWrappedNodeAtPosition(wrap, pos) { - if (wrap.node.pos > pos || wrap.node.end <= pos) - return; - outer: while (true) { - for (const child of wrap.children) { - if (child.node.pos > pos) - return wrap; - if (child.node.end > pos) { - wrap = child; - continue outer; - } - } - return wrap; - } -} -exports.getWrappedNodeAtPosition = getWrappedNodeAtPosition; -function getPropertyName(propertyName) { - if (propertyName.kind === ts.SyntaxKind.ComputedPropertyName) { - if (!node_1.isLiteralExpression(propertyName.expression)) - return; - if (_3_2_1.isBigIntLiteral(propertyName.expression)) - return propertyName.expression.text.slice(0, -1); - return propertyName.expression.text; - } - return propertyName.text; -} -exports.getPropertyName = getPropertyName; -function forEachDestructuringIdentifier(pattern, fn) { - for (const element of pattern.elements) { - if (element.kind !== ts.SyntaxKind.BindingElement) - continue; - let result; - if (element.name.kind === ts.SyntaxKind.Identifier) { - result = fn(element); - } - else { - result = forEachDestructuringIdentifier(element.name, fn); - } - if (result) - return result; - } -} -exports.forEachDestructuringIdentifier = forEachDestructuringIdentifier; -function forEachDeclaredVariable(declarationList, cb) { - for (const declaration of declarationList.declarations) { - let result; - if (declaration.name.kind === ts.SyntaxKind.Identifier) { - result = cb(declaration); - } - else { - result = forEachDestructuringIdentifier(declaration.name, cb); - } - if (result) - return result; - } -} -exports.forEachDeclaredVariable = forEachDeclaredVariable; -var VariableDeclarationKind; -(function (VariableDeclarationKind) { - VariableDeclarationKind[VariableDeclarationKind["Var"] = 0] = "Var"; - VariableDeclarationKind[VariableDeclarationKind["Let"] = 1] = "Let"; - VariableDeclarationKind[VariableDeclarationKind["Const"] = 2] = "Const"; -})(VariableDeclarationKind = exports.VariableDeclarationKind || (exports.VariableDeclarationKind = {})); -function getVariableDeclarationKind(declarationList) { - if (declarationList.flags & ts.NodeFlags.Let) - return 1; - if (declarationList.flags & ts.NodeFlags.Const) - return 2; - return 0; -} -exports.getVariableDeclarationKind = getVariableDeclarationKind; -function isBlockScopedVariableDeclarationList(declarationList) { - return (declarationList.flags & ts.NodeFlags.BlockScoped) !== 0; -} -exports.isBlockScopedVariableDeclarationList = isBlockScopedVariableDeclarationList; -function isBlockScopedVariableDeclaration(declaration) { - const parent = declaration.parent; - return parent.kind === ts.SyntaxKind.CatchClause || - isBlockScopedVariableDeclarationList(parent); -} -exports.isBlockScopedVariableDeclaration = isBlockScopedVariableDeclaration; -function isBlockScopedDeclarationStatement(statement) { - switch (statement.kind) { - case ts.SyntaxKind.VariableStatement: - return isBlockScopedVariableDeclarationList(statement.declarationList); - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.EnumDeclaration: - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.TypeAliasDeclaration: - return true; - default: - return false; - } -} -exports.isBlockScopedDeclarationStatement = isBlockScopedDeclarationStatement; -function isInSingleStatementContext(statement) { - switch (statement.parent.kind) { - case ts.SyntaxKind.ForStatement: - case ts.SyntaxKind.ForInStatement: - case ts.SyntaxKind.ForOfStatement: - case ts.SyntaxKind.WhileStatement: - case ts.SyntaxKind.DoStatement: - case ts.SyntaxKind.IfStatement: - case ts.SyntaxKind.WithStatement: - case ts.SyntaxKind.LabeledStatement: - return true; - default: - return false; - } -} -exports.isInSingleStatementContext = isInSingleStatementContext; -var ScopeBoundary; -(function (ScopeBoundary) { - ScopeBoundary[ScopeBoundary["None"] = 0] = "None"; - ScopeBoundary[ScopeBoundary["Function"] = 1] = "Function"; - ScopeBoundary[ScopeBoundary["Block"] = 2] = "Block"; - ScopeBoundary[ScopeBoundary["Type"] = 4] = "Type"; - ScopeBoundary[ScopeBoundary["ConditionalType"] = 8] = "ConditionalType"; -})(ScopeBoundary = exports.ScopeBoundary || (exports.ScopeBoundary = {})); -var ScopeBoundarySelector; -(function (ScopeBoundarySelector) { - ScopeBoundarySelector[ScopeBoundarySelector["Function"] = 1] = "Function"; - ScopeBoundarySelector[ScopeBoundarySelector["Block"] = 3] = "Block"; - ScopeBoundarySelector[ScopeBoundarySelector["Type"] = 7] = "Type"; - ScopeBoundarySelector[ScopeBoundarySelector["InferType"] = 8] = "InferType"; -})(ScopeBoundarySelector = exports.ScopeBoundarySelector || (exports.ScopeBoundarySelector = {})); -function isScopeBoundary(node) { - return isFunctionScopeBoundary(node) || isBlockScopeBoundary(node) || isTypeScopeBoundary(node); -} -exports.isScopeBoundary = isScopeBoundary; -function isTypeScopeBoundary(node) { - switch (node.kind) { - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.TypeAliasDeclaration: - case ts.SyntaxKind.MappedType: - return 4; - case ts.SyntaxKind.ConditionalType: - return 8; - default: - return 0; - } -} -exports.isTypeScopeBoundary = isTypeScopeBoundary; -function isFunctionScopeBoundary(node) { - switch (node.kind) { - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.ArrowFunction: - case ts.SyntaxKind.Constructor: - case ts.SyntaxKind.ModuleDeclaration: - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: - case ts.SyntaxKind.EnumDeclaration: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - case ts.SyntaxKind.MethodSignature: - case ts.SyntaxKind.CallSignature: - case ts.SyntaxKind.ConstructSignature: - case ts.SyntaxKind.ConstructorType: - case ts.SyntaxKind.FunctionType: - return 1; - case ts.SyntaxKind.SourceFile: - return ts.isExternalModule(node) ? 1 : 0; - default: - return 0; - } -} -exports.isFunctionScopeBoundary = isFunctionScopeBoundary; -function isBlockScopeBoundary(node) { - switch (node.kind) { - case ts.SyntaxKind.Block: - const parent = node.parent; - return parent.kind !== ts.SyntaxKind.CatchClause && - (parent.kind === ts.SyntaxKind.SourceFile || - !isFunctionScopeBoundary(parent)) - ? 2 - : 0; - case ts.SyntaxKind.ForStatement: - case ts.SyntaxKind.ForInStatement: - case ts.SyntaxKind.ForOfStatement: - case ts.SyntaxKind.CaseBlock: - case ts.SyntaxKind.CatchClause: - case ts.SyntaxKind.WithStatement: - return 2; - default: - return 0; - } -} -exports.isBlockScopeBoundary = isBlockScopeBoundary; -function hasOwnThisReference(node) { - switch (node.kind) { - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: - case ts.SyntaxKind.FunctionExpression: - return true; - case ts.SyntaxKind.FunctionDeclaration: - return node.body !== undefined; - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - return node.parent.kind === ts.SyntaxKind.ObjectLiteralExpression; - default: - return false; - } -} -exports.hasOwnThisReference = hasOwnThisReference; -function isFunctionWithBody(node) { - switch (node.kind) { - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.Constructor: - return node.body !== undefined; - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.ArrowFunction: - return true; - default: - return false; - } -} -exports.isFunctionWithBody = isFunctionWithBody; -function forEachToken(node, cb, sourceFile = node.getSourceFile()) { - return (function iterate(child) { - if (isTokenKind(child.kind)) - return cb(child); - if (child.kind !== ts.SyntaxKind.JSDocComment) - return child.getChildren(sourceFile).forEach(iterate); - })(node); -} -exports.forEachToken = forEachToken; -function forEachTokenWithTrivia(node, cb, sourceFile = node.getSourceFile()) { - const fullText = sourceFile.text; - const scanner = ts.createScanner(sourceFile.languageVersion, false, sourceFile.languageVariant, fullText); - return forEachToken(node, (token) => { - const tokenStart = token.kind === ts.SyntaxKind.JsxText || token.pos === token.end ? token.pos : token.getStart(sourceFile); - if (tokenStart !== token.pos) { - scanner.setTextPos(token.pos); - let kind = scanner.scan(); - let pos = scanner.getTokenPos(); - while (pos < tokenStart) { - const textPos = scanner.getTextPos(); - cb(fullText, kind, { pos, end: textPos }, token.parent); - if (textPos === tokenStart) - break; - kind = scanner.scan(); - pos = scanner.getTokenPos(); - } - } - return cb(fullText, token.kind, { end: token.end, pos: tokenStart }, token.parent); - }, sourceFile); -} -exports.forEachTokenWithTrivia = forEachTokenWithTrivia; -function forEachComment(node, cb, sourceFile = node.getSourceFile()) { - const fullText = sourceFile.text; - const notJsx = sourceFile.languageVariant !== ts.LanguageVariant.JSX; - return forEachToken(node, (token) => { - if (token.pos === token.end) - return; - if (token.kind !== ts.SyntaxKind.JsxText) - ts.forEachLeadingCommentRange(fullText, token.pos === 0 ? (ts.getShebang(fullText) || '').length : token.pos, commentCallback); - if (notJsx || canHaveTrailingTrivia(token)) - return ts.forEachTrailingCommentRange(fullText, token.end, commentCallback); - }, sourceFile); - function commentCallback(pos, end, kind) { - cb(fullText, { pos, end, kind }); - } -} -exports.forEachComment = forEachComment; -function canHaveTrailingTrivia(token) { - switch (token.kind) { - case ts.SyntaxKind.CloseBraceToken: - return token.parent.kind !== ts.SyntaxKind.JsxExpression || !isJsxElementOrFragment(token.parent.parent); - case ts.SyntaxKind.GreaterThanToken: - switch (token.parent.kind) { - case ts.SyntaxKind.JsxOpeningElement: - return token.end !== token.parent.end; - case ts.SyntaxKind.JsxOpeningFragment: - return false; - case ts.SyntaxKind.JsxSelfClosingElement: - return token.end !== token.parent.end || - !isJsxElementOrFragment(token.parent.parent); - case ts.SyntaxKind.JsxClosingElement: - case ts.SyntaxKind.JsxClosingFragment: - return !isJsxElementOrFragment(token.parent.parent.parent); - } - } - return true; -} -function isJsxElementOrFragment(node) { - return node.kind === ts.SyntaxKind.JsxElement || node.kind === ts.SyntaxKind.JsxFragment; -} -function getLineRanges(sourceFile) { - const lineStarts = sourceFile.getLineStarts(); - const result = []; - const length = lineStarts.length; - const sourceText = sourceFile.text; - let pos = 0; - for (let i = 1; i < length; ++i) { - const end = lineStarts[i]; - let lineEnd = end; - for (; lineEnd > pos; --lineEnd) - if (!ts.isLineBreak(sourceText.charCodeAt(lineEnd - 1))) - break; - result.push({ - pos, - end, - contentLength: lineEnd - pos, - }); - pos = end; - } - result.push({ - pos, - end: sourceFile.end, - contentLength: sourceFile.end - pos, - }); - return result; -} -exports.getLineRanges = getLineRanges; -function getLineBreakStyle(sourceFile) { - const lineStarts = sourceFile.getLineStarts(); - return lineStarts.length === 1 || lineStarts[1] < 2 || sourceFile.text[lineStarts[1] - 2] !== '\r' - ? '\n' - : '\r\n'; -} -exports.getLineBreakStyle = getLineBreakStyle; -let cachedScanner; -function scanToken(text, languageVersion) { - if (cachedScanner === undefined) { - cachedScanner = ts.createScanner(languageVersion, false, undefined, text); - } - else { - cachedScanner.setScriptTarget(languageVersion); - cachedScanner.setText(text); - } - cachedScanner.scan(); - return cachedScanner; -} -function isValidIdentifier(text, languageVersion = ts.ScriptTarget.Latest) { - const scan = scanToken(text, languageVersion); - return scan.isIdentifier() && scan.getTextPos() === text.length && scan.getTokenPos() === 0; -} -exports.isValidIdentifier = isValidIdentifier; -function charSize(ch) { - return ch >= 0x10000 ? 2 : 1; -} -function isValidPropertyAccess(text, languageVersion = ts.ScriptTarget.Latest) { - if (text.length === 0) - return false; - let ch = text.codePointAt(0); - if (!ts.isIdentifierStart(ch, languageVersion)) - return false; - for (let i = charSize(ch); i < text.length; i += charSize(ch)) { - ch = text.codePointAt(i); - if (!ts.isIdentifierPart(ch, languageVersion)) - return false; - } - return true; -} -exports.isValidPropertyAccess = isValidPropertyAccess; -function isValidPropertyName(text, languageVersion = ts.ScriptTarget.Latest) { - if (isValidPropertyAccess(text, languageVersion)) - return true; - const scan = scanToken(text, languageVersion); - return scan.getTextPos() === text.length && - scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTokenValue() === text; -} -exports.isValidPropertyName = isValidPropertyName; -function isValidNumericLiteral(text, languageVersion = ts.ScriptTarget.Latest) { - const scan = scanToken(text, languageVersion); - return scan.getToken() === ts.SyntaxKind.NumericLiteral && scan.getTextPos() === text.length && scan.getTokenPos() === 0; -} -exports.isValidNumericLiteral = isValidNumericLiteral; -function isValidJsxIdentifier(text, languageVersion = ts.ScriptTarget.Latest) { - if (text.length === 0) - return false; - let ch = text.codePointAt(0); - if (!ts.isIdentifierStart(ch, languageVersion)) - return false; - for (let i = charSize(ch); i < text.length; i += charSize(ch)) { - ch = text.codePointAt(i); - if (!ts.isIdentifierPart(ch, languageVersion) && ch !== 45) - return false; - } - return true; -} -exports.isValidJsxIdentifier = isValidJsxIdentifier; -function isNumericPropertyName(name) { - return String(+name) === name; -} -exports.isNumericPropertyName = isNumericPropertyName; -function isSameLine(sourceFile, pos1, pos2) { - return ts.getLineAndCharacterOfPosition(sourceFile, pos1).line === ts.getLineAndCharacterOfPosition(sourceFile, pos2).line; -} -exports.isSameLine = isSameLine; -var SideEffectOptions; -(function (SideEffectOptions) { - SideEffectOptions[SideEffectOptions["None"] = 0] = "None"; - SideEffectOptions[SideEffectOptions["TaggedTemplate"] = 1] = "TaggedTemplate"; - SideEffectOptions[SideEffectOptions["Constructor"] = 2] = "Constructor"; - SideEffectOptions[SideEffectOptions["JsxElement"] = 4] = "JsxElement"; -})(SideEffectOptions = exports.SideEffectOptions || (exports.SideEffectOptions = {})); -function hasSideEffects(node, options) { - switch (node.kind) { - case ts.SyntaxKind.CallExpression: - case ts.SyntaxKind.PostfixUnaryExpression: - case ts.SyntaxKind.AwaitExpression: - case ts.SyntaxKind.YieldExpression: - case ts.SyntaxKind.DeleteExpression: - return true; - case ts.SyntaxKind.TypeAssertionExpression: - case ts.SyntaxKind.AsExpression: - case ts.SyntaxKind.ParenthesizedExpression: - case ts.SyntaxKind.NonNullExpression: - case ts.SyntaxKind.VoidExpression: - case ts.SyntaxKind.TypeOfExpression: - case ts.SyntaxKind.PropertyAccessExpression: - case ts.SyntaxKind.SpreadElement: - case ts.SyntaxKind.PartiallyEmittedExpression: - return hasSideEffects(node.expression, options); - case ts.SyntaxKind.BinaryExpression: - return isAssignmentKind(node.operatorToken.kind) || - hasSideEffects(node.left, options) || - hasSideEffects(node.right, options); - case ts.SyntaxKind.PrefixUnaryExpression: - switch (node.operator) { - case ts.SyntaxKind.PlusPlusToken: - case ts.SyntaxKind.MinusMinusToken: - return true; - default: - return hasSideEffects(node.operand, options); - } - case ts.SyntaxKind.ElementAccessExpression: - return hasSideEffects(node.expression, options) || - node.argumentExpression !== undefined && - hasSideEffects(node.argumentExpression, options); - case ts.SyntaxKind.ConditionalExpression: - return hasSideEffects(node.condition, options) || - hasSideEffects(node.whenTrue, options) || - hasSideEffects(node.whenFalse, options); - case ts.SyntaxKind.NewExpression: - if (options & 2 || hasSideEffects(node.expression, options)) - return true; - if (node.arguments !== undefined) - for (const child of node.arguments) - if (hasSideEffects(child, options)) - return true; - return false; - case ts.SyntaxKind.TaggedTemplateExpression: - if (options & 1 || hasSideEffects(node.tag, options)) - return true; - if (node.template.kind === ts.SyntaxKind.NoSubstitutionTemplateLiteral) - return false; - node = node.template; - case ts.SyntaxKind.TemplateExpression: - for (const child of node.templateSpans) - if (hasSideEffects(child.expression, options)) - return true; - return false; - case ts.SyntaxKind.ClassExpression: - return classExpressionHasSideEffects(node, options); - case ts.SyntaxKind.ArrayLiteralExpression: - for (const child of node.elements) - if (hasSideEffects(child, options)) - return true; - return false; - case ts.SyntaxKind.ObjectLiteralExpression: - for (const child of node.properties) { - if (child.name !== undefined && child.name.kind === ts.SyntaxKind.ComputedPropertyName && - hasSideEffects(child.name.expression, options)) - return true; - switch (child.kind) { - case ts.SyntaxKind.PropertyAssignment: - if (hasSideEffects(child.initializer, options)) - return true; - break; - case ts.SyntaxKind.SpreadAssignment: - if (hasSideEffects(child.expression, options)) - return true; - } - } - return false; - case ts.SyntaxKind.JsxExpression: - return node.expression !== undefined && hasSideEffects(node.expression, options); - case ts.SyntaxKind.JsxElement: - case ts.SyntaxKind.JsxFragment: - for (const child of node.children) - if (child.kind !== ts.SyntaxKind.JsxText && hasSideEffects(child, options)) - return true; - if (node.kind === ts.SyntaxKind.JsxFragment) - return false; - node = node.openingElement; - case ts.SyntaxKind.JsxSelfClosingElement: - case ts.SyntaxKind.JsxOpeningElement: - if (options & 4) - return true; - for (const child of node.attributes.properties) { - if (child.kind === ts.SyntaxKind.JsxSpreadAttribute) { - if (hasSideEffects(child.expression, options)) - return true; - } - else if (child.initializer !== undefined && hasSideEffects(child.initializer, options)) { - return true; - } - } - return false; - case ts.SyntaxKind.CommaListExpression: - for (const child of node.elements) - if (hasSideEffects(child, options)) - return true; - return false; - default: - return false; - } -} -exports.hasSideEffects = hasSideEffects; -function classExpressionHasSideEffects(node, options) { - if (node.heritageClauses !== undefined && node.heritageClauses[0].token === ts.SyntaxKind.ExtendsKeyword) - for (const base of node.heritageClauses[0].types) - if (hasSideEffects(base.expression, options)) - return true; - for (const child of node.members) - if (child.name !== undefined && child.name.kind === ts.SyntaxKind.ComputedPropertyName && - hasSideEffects(child.name.expression, options) || - node_1.isPropertyDeclaration(child) && child.initializer !== undefined && - hasSideEffects(child.initializer, options)) - return true; - return false; -} -function getDeclarationOfBindingElement(node) { - let parent = node.parent.parent; - while (parent.kind === ts.SyntaxKind.BindingElement) - parent = parent.parent.parent; - return parent; -} -exports.getDeclarationOfBindingElement = getDeclarationOfBindingElement; -function isExpressionValueUsed(node) { - while (true) { - const parent = node.parent; - switch (parent.kind) { - case ts.SyntaxKind.CallExpression: - case ts.SyntaxKind.NewExpression: - case ts.SyntaxKind.ElementAccessExpression: - case ts.SyntaxKind.WhileStatement: - case ts.SyntaxKind.DoStatement: - case ts.SyntaxKind.WithStatement: - case ts.SyntaxKind.ThrowStatement: - case ts.SyntaxKind.ReturnStatement: - case ts.SyntaxKind.JsxExpression: - case ts.SyntaxKind.JsxSpreadAttribute: - case ts.SyntaxKind.JsxElement: - case ts.SyntaxKind.JsxFragment: - case ts.SyntaxKind.JsxSelfClosingElement: - case ts.SyntaxKind.ComputedPropertyName: - case ts.SyntaxKind.ArrowFunction: - case ts.SyntaxKind.ExportSpecifier: - case ts.SyntaxKind.ExportAssignment: - case ts.SyntaxKind.ImportDeclaration: - case ts.SyntaxKind.ExternalModuleReference: - case ts.SyntaxKind.Decorator: - case ts.SyntaxKind.TaggedTemplateExpression: - case ts.SyntaxKind.TemplateSpan: - case ts.SyntaxKind.ExpressionWithTypeArguments: - case ts.SyntaxKind.TypeOfExpression: - case ts.SyntaxKind.AwaitExpression: - case ts.SyntaxKind.YieldExpression: - case ts.SyntaxKind.LiteralType: - case ts.SyntaxKind.JsxAttributes: - case ts.SyntaxKind.JsxOpeningElement: - case ts.SyntaxKind.JsxClosingElement: - case ts.SyntaxKind.IfStatement: - case ts.SyntaxKind.CaseClause: - case ts.SyntaxKind.SwitchStatement: - return true; - case ts.SyntaxKind.PropertyAccessExpression: - return parent.expression === node; - case ts.SyntaxKind.QualifiedName: - return parent.left === node; - case ts.SyntaxKind.ShorthandPropertyAssignment: - return parent.objectAssignmentInitializer === node || - !isInDestructuringAssignment(parent); - case ts.SyntaxKind.PropertyAssignment: - return parent.initializer === node && !isInDestructuringAssignment(parent); - case ts.SyntaxKind.SpreadAssignment: - case ts.SyntaxKind.SpreadElement: - case ts.SyntaxKind.ArrayLiteralExpression: - return !isInDestructuringAssignment(parent); - case ts.SyntaxKind.ParenthesizedExpression: - case ts.SyntaxKind.AsExpression: - case ts.SyntaxKind.TypeAssertionExpression: - case ts.SyntaxKind.PostfixUnaryExpression: - case ts.SyntaxKind.PrefixUnaryExpression: - case ts.SyntaxKind.NonNullExpression: - node = parent; - break; - case ts.SyntaxKind.ForStatement: - return parent.condition === node; - case ts.SyntaxKind.ForInStatement: - case ts.SyntaxKind.ForOfStatement: - return parent.expression === node; - case ts.SyntaxKind.ConditionalExpression: - if (parent.condition === node) - return true; - node = parent; - break; - case ts.SyntaxKind.PropertyDeclaration: - case ts.SyntaxKind.BindingElement: - case ts.SyntaxKind.VariableDeclaration: - case ts.SyntaxKind.Parameter: - case ts.SyntaxKind.EnumMember: - return parent.initializer === node; - case ts.SyntaxKind.ImportEqualsDeclaration: - return parent.moduleReference === node; - case ts.SyntaxKind.CommaListExpression: - if (parent.elements[parent.elements.length - 1] !== node) - return false; - node = parent; - break; - case ts.SyntaxKind.BinaryExpression: - if (parent.right === node) { - if (parent.operatorToken.kind === ts.SyntaxKind.CommaToken) { - node = parent; - break; - } - return true; - } - switch (parent.operatorToken.kind) { - case ts.SyntaxKind.CommaToken: - case ts.SyntaxKind.EqualsToken: - return false; - case ts.SyntaxKind.EqualsEqualsEqualsToken: - case ts.SyntaxKind.EqualsEqualsToken: - case ts.SyntaxKind.ExclamationEqualsEqualsToken: - case ts.SyntaxKind.ExclamationEqualsToken: - case ts.SyntaxKind.InstanceOfKeyword: - case ts.SyntaxKind.PlusToken: - case ts.SyntaxKind.MinusToken: - case ts.SyntaxKind.AsteriskToken: - case ts.SyntaxKind.SlashToken: - case ts.SyntaxKind.PercentToken: - case ts.SyntaxKind.AsteriskAsteriskToken: - case ts.SyntaxKind.GreaterThanToken: - case ts.SyntaxKind.GreaterThanGreaterThanToken: - case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken: - case ts.SyntaxKind.GreaterThanEqualsToken: - case ts.SyntaxKind.LessThanToken: - case ts.SyntaxKind.LessThanLessThanToken: - case ts.SyntaxKind.LessThanEqualsToken: - case ts.SyntaxKind.AmpersandToken: - case ts.SyntaxKind.BarToken: - case ts.SyntaxKind.CaretToken: - case ts.SyntaxKind.BarBarToken: - case ts.SyntaxKind.AmpersandAmpersandToken: - case ts.SyntaxKind.InKeyword: - return true; - default: - node = parent; - } - break; - default: - return false; - } - } -} -exports.isExpressionValueUsed = isExpressionValueUsed; -function isInDestructuringAssignment(node) { - switch (node.kind) { - case ts.SyntaxKind.ShorthandPropertyAssignment: - if (node.objectAssignmentInitializer !== undefined) - return true; - case ts.SyntaxKind.PropertyAssignment: - case ts.SyntaxKind.SpreadAssignment: - node = node.parent; - break; - case ts.SyntaxKind.SpreadElement: - if (node.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression) - return false; - node = node.parent; - } - while (true) { - switch (node.parent.kind) { - case ts.SyntaxKind.BinaryExpression: - return node.parent.left === node && - node.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken; - case ts.SyntaxKind.ForOfStatement: - return node.parent.initializer === node; - case ts.SyntaxKind.ArrayLiteralExpression: - case ts.SyntaxKind.ObjectLiteralExpression: - node = node.parent; - break; - case ts.SyntaxKind.SpreadAssignment: - case ts.SyntaxKind.PropertyAssignment: - node = node.parent.parent; - break; - case ts.SyntaxKind.SpreadElement: - if (node.parent.parent.kind !== ts.SyntaxKind.ArrayLiteralExpression) - return false; - node = node.parent.parent; - break; - default: - return false; - } - } -} -var AccessKind; -(function (AccessKind) { - AccessKind[AccessKind["None"] = 0] = "None"; - AccessKind[AccessKind["Read"] = 1] = "Read"; - AccessKind[AccessKind["Write"] = 2] = "Write"; - AccessKind[AccessKind["Delete"] = 4] = "Delete"; - AccessKind[AccessKind["ReadWrite"] = 3] = "ReadWrite"; - AccessKind[AccessKind["Modification"] = 6] = "Modification"; -})(AccessKind = exports.AccessKind || (exports.AccessKind = {})); -function getAccessKind(node) { - const parent = node.parent; - switch (parent.kind) { - case ts.SyntaxKind.DeleteExpression: - return 4; - case ts.SyntaxKind.PostfixUnaryExpression: - return 3; - case ts.SyntaxKind.PrefixUnaryExpression: - return parent.operator === ts.SyntaxKind.PlusPlusToken || - parent.operator === ts.SyntaxKind.MinusMinusToken - ? 3 - : 1; - case ts.SyntaxKind.BinaryExpression: - return parent.right === node - ? 1 - : !isAssignmentKind(parent.operatorToken.kind) - ? 1 - : parent.operatorToken.kind === ts.SyntaxKind.EqualsToken - ? 2 - : 3; - case ts.SyntaxKind.ShorthandPropertyAssignment: - return parent.objectAssignmentInitializer === node - ? 1 - : isInDestructuringAssignment(parent) - ? 2 - : 1; - case ts.SyntaxKind.PropertyAssignment: - return parent.name === node - ? 0 - : isInDestructuringAssignment(parent) - ? 2 - : 1; - case ts.SyntaxKind.ArrayLiteralExpression: - case ts.SyntaxKind.SpreadElement: - case ts.SyntaxKind.SpreadAssignment: - return isInDestructuringAssignment(parent) - ? 2 - : 1; - case ts.SyntaxKind.ParenthesizedExpression: - case ts.SyntaxKind.NonNullExpression: - case ts.SyntaxKind.TypeAssertionExpression: - case ts.SyntaxKind.AsExpression: - return getAccessKind(parent); - case ts.SyntaxKind.ForOfStatement: - case ts.SyntaxKind.ForInStatement: - return parent.initializer === node - ? 2 - : 1; - case ts.SyntaxKind.ExpressionWithTypeArguments: - return parent.parent.token === ts.SyntaxKind.ExtendsKeyword && - parent.parent.parent.kind !== ts.SyntaxKind.InterfaceDeclaration - ? 1 - : 0; - case ts.SyntaxKind.ComputedPropertyName: - case ts.SyntaxKind.ExpressionStatement: - case ts.SyntaxKind.TypeOfExpression: - case ts.SyntaxKind.ElementAccessExpression: - case ts.SyntaxKind.ForStatement: - case ts.SyntaxKind.IfStatement: - case ts.SyntaxKind.DoStatement: - case ts.SyntaxKind.WhileStatement: - case ts.SyntaxKind.SwitchStatement: - case ts.SyntaxKind.WithStatement: - case ts.SyntaxKind.ThrowStatement: - case ts.SyntaxKind.CallExpression: - case ts.SyntaxKind.NewExpression: - case ts.SyntaxKind.TaggedTemplateExpression: - case ts.SyntaxKind.JsxExpression: - case ts.SyntaxKind.Decorator: - case ts.SyntaxKind.TemplateSpan: - case ts.SyntaxKind.JsxOpeningElement: - case ts.SyntaxKind.JsxSelfClosingElement: - case ts.SyntaxKind.JsxSpreadAttribute: - case ts.SyntaxKind.VoidExpression: - case ts.SyntaxKind.ReturnStatement: - case ts.SyntaxKind.AwaitExpression: - case ts.SyntaxKind.YieldExpression: - case ts.SyntaxKind.ConditionalExpression: - case ts.SyntaxKind.CaseClause: - case ts.SyntaxKind.JsxElement: - return 1; - case ts.SyntaxKind.ArrowFunction: - return parent.body === node - ? 1 - : 2; - case ts.SyntaxKind.PropertyDeclaration: - case ts.SyntaxKind.VariableDeclaration: - case ts.SyntaxKind.Parameter: - case ts.SyntaxKind.EnumMember: - case ts.SyntaxKind.BindingElement: - case ts.SyntaxKind.JsxAttribute: - return parent.initializer === node - ? 1 - : 0; - case ts.SyntaxKind.PropertyAccessExpression: - return parent.expression === node - ? 1 - : 0; - case ts.SyntaxKind.ExportAssignment: - return parent.isExportEquals - ? 1 - : 0; - } - return 0; -} -exports.getAccessKind = getAccessKind; -function isReassignmentTarget(node) { - return (getAccessKind(node) & 2) !== 0; -} -exports.isReassignmentTarget = isReassignmentTarget; -function canHaveJsDoc(node) { - const kind = node.kind; - switch (kind) { - case ts.SyntaxKind.Parameter: - case ts.SyntaxKind.CallSignature: - case ts.SyntaxKind.ConstructSignature: - case ts.SyntaxKind.MethodSignature: - case ts.SyntaxKind.PropertySignature: - case ts.SyntaxKind.ArrowFunction: - case ts.SyntaxKind.ParenthesizedExpression: - case ts.SyntaxKind.SpreadAssignment: - case ts.SyntaxKind.ShorthandPropertyAssignment: - case ts.SyntaxKind.PropertyAssignment: - case ts.SyntaxKind.FunctionExpression: - case ts.SyntaxKind.FunctionDeclaration: - case ts.SyntaxKind.LabeledStatement: - case ts.SyntaxKind.ExpressionStatement: - case ts.SyntaxKind.VariableStatement: - case ts.SyntaxKind.Constructor: - case ts.SyntaxKind.MethodDeclaration: - case ts.SyntaxKind.PropertyDeclaration: - case ts.SyntaxKind.GetAccessor: - case ts.SyntaxKind.SetAccessor: - case ts.SyntaxKind.ClassDeclaration: - case ts.SyntaxKind.ClassExpression: - case ts.SyntaxKind.InterfaceDeclaration: - case ts.SyntaxKind.TypeAliasDeclaration: - case ts.SyntaxKind.EnumMember: - case ts.SyntaxKind.EnumDeclaration: - case ts.SyntaxKind.ModuleDeclaration: - case ts.SyntaxKind.ImportEqualsDeclaration: - case ts.SyntaxKind.IndexSignature: - case ts.SyntaxKind.FunctionType: - case ts.SyntaxKind.ConstructorType: - case ts.SyntaxKind.JSDocFunctionType: - case ts.SyntaxKind.EndOfFileToken: - case ts.SyntaxKind.ExportDeclaration: - return true; - default: - return false; - } -} -exports.canHaveJsDoc = canHaveJsDoc; -function getJsDoc(node, sourceFile) { - if (node.kind === ts.SyntaxKind.EndOfFileToken) - return parseJsDocWorker(node, sourceFile || node.parent); - const result = []; - for (const child of node.getChildren(sourceFile)) { - if (!node_1.isJsDoc(child)) - break; - result.push(child); - } - return result; -} -exports.getJsDoc = getJsDoc; -function parseJsDocOfNode(node, considerTrailingComments, sourceFile = node.getSourceFile()) { - if (canHaveJsDoc(node) && node.kind !== ts.SyntaxKind.EndOfFileToken) { - const result = getJsDoc(node, sourceFile); - if (result.length !== 0 || !considerTrailingComments) - return result; - } - return parseJsDocWorker(node, sourceFile, considerTrailingComments); -} -exports.parseJsDocOfNode = parseJsDocOfNode; -function parseJsDocWorker(node, sourceFile, considerTrailingComments) { - const nodeStart = node.getStart(sourceFile); - const start = ts[considerTrailingComments && isSameLine(sourceFile, node.pos, nodeStart) - ? 'forEachTrailingCommentRange' - : 'forEachLeadingCommentRange'](sourceFile.text, node.pos, (pos, _end, kind) => kind === ts.SyntaxKind.MultiLineCommentTrivia && sourceFile.text[pos + 2] === '*' ? { pos } : undefined); - if (start === undefined) - return []; - const startPos = start.pos; - const text = sourceFile.text.slice(startPos, nodeStart); - const newSourceFile = ts.createSourceFile('jsdoc.ts', `${text}var a;`, sourceFile.languageVersion); - const result = getJsDoc(newSourceFile.statements[0], newSourceFile); - for (const doc of result) - updateNode(doc, node); - return result; - function updateNode(n, parent) { - n.pos += startPos; - n.end += startPos; - n.parent = parent; - return ts.forEachChild(n, (child) => updateNode(child, n), (children) => { - children.pos += startPos; - children.end += startPos; - for (const child of children) - updateNode(child, n); - }); - } -} -var ImportKind; -(function (ImportKind) { - ImportKind[ImportKind["ImportDeclaration"] = 1] = "ImportDeclaration"; - ImportKind[ImportKind["ImportEquals"] = 2] = "ImportEquals"; - ImportKind[ImportKind["ExportFrom"] = 4] = "ExportFrom"; - ImportKind[ImportKind["DynamicImport"] = 8] = "DynamicImport"; - ImportKind[ImportKind["Require"] = 16] = "Require"; - ImportKind[ImportKind["ImportType"] = 32] = "ImportType"; - ImportKind[ImportKind["All"] = 63] = "All"; - ImportKind[ImportKind["AllImports"] = 59] = "AllImports"; - ImportKind[ImportKind["AllStaticImports"] = 3] = "AllStaticImports"; - ImportKind[ImportKind["AllImportExpressions"] = 24] = "AllImportExpressions"; - ImportKind[ImportKind["AllRequireLike"] = 18] = "AllRequireLike"; - ImportKind[ImportKind["AllNestedImports"] = 56] = "AllNestedImports"; - ImportKind[ImportKind["AllTopLevelImports"] = 7] = "AllTopLevelImports"; -})(ImportKind = exports.ImportKind || (exports.ImportKind = {})); -function findImports(sourceFile, kinds) { - const result = []; - for (const node of findImportLikeNodes(sourceFile, kinds)) { - switch (node.kind) { - case ts.SyntaxKind.ImportDeclaration: - addIfTextualLiteral(node.moduleSpecifier); - break; - case ts.SyntaxKind.ImportEqualsDeclaration: - addIfTextualLiteral(node.moduleReference.expression); - break; - case ts.SyntaxKind.ExportDeclaration: - addIfTextualLiteral(node.moduleSpecifier); - break; - case ts.SyntaxKind.CallExpression: - addIfTextualLiteral(node.arguments[0]); - break; - case ts.SyntaxKind.ImportType: - if (node_1.isLiteralTypeNode(node.argument)) - addIfTextualLiteral(node.argument.literal); - break; - default: - throw new Error('unexpected node'); - } - } - return result; - function addIfTextualLiteral(node) { - if (node_1.isTextualLiteral(node)) - result.push(node); - } -} -exports.findImports = findImports; -function findImportLikeNodes(sourceFile, kinds) { - return new ImportFinder(sourceFile, kinds).find(); -} -exports.findImportLikeNodes = findImportLikeNodes; -class ImportFinder { - constructor(_sourceFile, _options) { - this._sourceFile = _sourceFile; - this._options = _options; - this._result = []; + if (!section) { + return { + source: null, + line: null, + column: null, + name: null + }; } - find() { - if (this._sourceFile.isDeclarationFile) - this._options &= ~24; - if (this._options & 7) - this._findImports(this._sourceFile.statements); - if (this._options & 56) - this._findNestedImports(); - return this._result; + + return section.consumer.originalPositionFor({ + line: needle.generatedLine - + (section.generatedOffset.generatedLine - 1), + column: needle.generatedColumn - + (section.generatedOffset.generatedLine === needle.generatedLine + ? section.generatedOffset.generatedColumn - 1 + : 0), + bias: aArgs.bias + }); + }; + +/** + * Return true if we have the source content for every source in the source + * map, false otherwise. + */ +IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = + function IndexedSourceMapConsumer_hasContentsOfAllSources() { + return this._sections.every(function (s) { + return s.consumer.hasContentsOfAllSources(); + }); + }; + +/** + * Returns the original source content. The only argument is the url of the + * original source file. Returns null if no original source content is + * available. + */ +IndexedSourceMapConsumer.prototype.sourceContentFor = + function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + + var content = section.consumer.sourceContentFor(aSource, true); + if (content) { + return content; + } } - _findImports(statements) { - for (const statement of statements) { - if (node_1.isImportDeclaration(statement)) { - if (this._options & 1) - this._result.push(statement); - } - else if (node_1.isImportEqualsDeclaration(statement)) { - if (this._options & 2 && - statement.moduleReference.kind === ts.SyntaxKind.ExternalModuleReference) - this._result.push(statement); - } - else if (node_1.isExportDeclaration(statement)) { - if (statement.moduleSpecifier !== undefined && this._options & 4) - this._result.push(statement); - } - else if (node_1.isModuleDeclaration(statement)) { - this._findImportsInModule(statement); - } - } + if (nullOnMissing) { + return null; } - _findImportsInModule(declaration) { - if (declaration.body === undefined) - return; - if (declaration.body.kind === ts.SyntaxKind.ModuleDeclaration) - return this._findImportsInModule(declaration.body); - this._findImports(declaration.body.statements); + else { + throw new Error('"' + aSource + '" is not in the SourceMap.'); } - _findNestedImports() { - let re; - if ((this._options & 56) === 16) { - re = /\brequire\s*[ 'fred, barney, & pebbles' + */ +function unescape(string) { + string = toString(string); + return (string && reHasEscapedHtml.test(string)) + ? string.replace(reEscapedHtml, unescapeHtmlChar) + : string; } -function isStatementInAmbientContext(node) { - while (node.flags & ts.NodeFlags.NestedNamespace) - node = node.parent; - return hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword) || isAmbientModuleBlock(node.parent); -} -exports.isStatementInAmbientContext = isStatementInAmbientContext; -function isAmbientModuleBlock(node) { - while (node.kind === ts.SyntaxKind.ModuleBlock) { - do - node = node.parent; - while (node.flags & ts.NodeFlags.NestedNamespace); - if (hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) - return true; - node = node.parent; - } - return false; -} -exports.isAmbientModuleBlock = isAmbientModuleBlock; -function getIIFE(func) { - let node = func.parent; - while (node.kind === ts.SyntaxKind.ParenthesizedExpression) - node = node.parent; - return node_1.isCallExpression(node) && func.end <= node.expression.end ? node : undefined; -} -exports.getIIFE = getIIFE; -function isStrictCompilerOptionEnabled(options, option) { - return (options.strict ? options[option] !== false : options[option] === true) && - (option !== 'strictPropertyInitialization' || isStrictCompilerOptionEnabled(options, 'strictNullChecks')); + +module.exports = unescape; + + +/***/ }), +/* 822 */ +/***/ (function(module) { + +"use strict"; + + +if (typeof process === 'undefined' || + !process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = { nextTick: nextTick }; +} else { + module.exports = process } -exports.isStrictCompilerOptionEnabled = isStrictCompilerOptionEnabled; -function isCompilerOptionEnabled(options, option) { - switch (option) { - case 'stripInternal': - return options.stripInternal === true && isCompilerOptionEnabled(options, 'declaration'); - case 'declaration': - return options.declaration || isCompilerOptionEnabled(options, 'composite'); - case 'incremental': - return options.incremental === undefined ? isCompilerOptionEnabled(options, 'composite') : options.incremental; - case 'skipDefaultLibCheck': - return options.skipDefaultLibCheck || isCompilerOptionEnabled(options, 'skipLibCheck'); - case 'suppressImplicitAnyIndexErrors': - return options.suppressImplicitAnyIndexErrors === true && isCompilerOptionEnabled(options, 'noImplicitAny'); - case 'allowSyntheticDefaultImports': - return options.allowSyntheticDefaultImports !== undefined - ? options.allowSyntheticDefaultImports - : isCompilerOptionEnabled(options, 'esModuleInterop') || options.module === ts.ModuleKind.System; - case 'noImplicitAny': - case 'noImplicitThis': - case 'strictNullChecks': - case 'strictFunctionTypes': - case 'strictPropertyInitialization': - case 'alwaysStrict': - case 'strictBindCallApply': - return isStrictCompilerOptionEnabled(options, option); + +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; } - return options[option] === true; -} -exports.isCompilerOptionEnabled = isCompilerOptionEnabled; -function isAmbientModule(node) { - return node.name.kind === ts.SyntaxKind.StringLiteral || (node.flags & ts.NodeFlags.GlobalAugmentation) !== 0; -} -exports.isAmbientModule = isAmbientModule; -function getCheckJsDirective(source) { - let directive; - ts.forEachLeadingCommentRange(source, (ts.getShebang(source) || '').length, (pos, end, kind) => { - if (kind === ts.SyntaxKind.SingleLineCommentTrivia) { - const text = source.slice(pos, end); - const match = /^\/{2,3}\s*@ts-(no)?check(?:\s|$)/i.exec(text); - if (match !== null) - directive = { pos, end, enabled: match[1] === undefined }; - } + return process.nextTick(function afterTick() { + fn.apply(null, args); }); - return directive; -} -exports.getCheckJsDirective = getCheckJsDirective; -function isConstAssertion(node) { - return node_1.isTypeReferenceNode(node.type) && - node.type.typeName.kind === ts.SyntaxKind.Identifier && - node.type.typeName.escapedText === 'const'; + } } -exports.isConstAssertion = isConstAssertion; -function isInConstContext(node) { - let current = node; - while (true) { - const parent = current.parent; - outer: switch (parent.kind) { - case ts.SyntaxKind.TypeAssertionExpression: - case ts.SyntaxKind.AsExpression: - return isConstAssertion(parent); - case ts.SyntaxKind.PrefixUnaryExpression: - if (current.kind !== ts.SyntaxKind.NumericLiteral) - return false; - switch (parent.operator) { - case ts.SyntaxKind.PlusToken: - case ts.SyntaxKind.MinusToken: - current = parent; - break outer; - default: - return false; - } - case ts.SyntaxKind.PropertyAssignment: - if (parent.initializer !== current) - return false; - current = parent.parent; - break; - case ts.SyntaxKind.ShorthandPropertyAssignment: - current = parent.parent; - break; - case ts.SyntaxKind.ParenthesizedExpression: - case ts.SyntaxKind.ArrayLiteralExpression: - case ts.SyntaxKind.ObjectLiteralExpression: - current = parent; - break; - default: - return false; - } + + + +/***/ }), +/* 823 */, +/* 824 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +var freeGlobal = __webpack_require__(973); + +/** Detect free variable `self`. */ +var freeSelf = typeof self == 'object' && self && self.Object === Object && self; + +/** Used as a reference to the global object. */ +var root = freeGlobal || freeSelf || Function('return this')(); + +module.exports = root; + + +/***/ }), +/* 825 */, +/* 826 */ +/***/ (function(module) { + +"use strict"; + + +/* eslint complexity: [2, 18], max-statements: [2, 33] */ +module.exports = function hasSymbols() { + if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } + if (typeof Symbol.iterator === 'symbol') { return true; } + + var obj = {}; + var sym = Symbol('test'); + var symObj = Object(sym); + if (typeof sym === 'string') { return false; } + + if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; } + if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; } + + // temp disabled per https://github.com/ljharb/object.assign/issues/17 + // if (sym instanceof Symbol) { return false; } + // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4 + // if (!(symObj instanceof Symbol)) { return false; } + + // if (typeof Symbol.prototype.toString !== 'function') { return false; } + // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; } + + var symVal = 42; + obj[sym] = symVal; + for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax + if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } + + if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } + + var syms = Object.getOwnPropertySymbols(obj); + if (syms.length !== 1 || syms[0] !== sym) { return false; } + + if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } + + if (typeof Object.getOwnPropertyDescriptor === 'function') { + var descriptor = Object.getOwnPropertyDescriptor(obj, sym); + if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } + } + + return true; +}; + + +/***/ }), +/* 827 */, +/* 828 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + + +/**/ + +var pna = __webpack_require__(822); +/**/ + +// undocumented cb() API, needed for core, not for public API +function destroy(err, cb) { + var _this = this; + + var readableDestroyed = this._readableState && this._readableState.destroyed; + var writableDestroyed = this._writableState && this._writableState.destroyed; + + if (readableDestroyed || writableDestroyed) { + if (cb) { + cb(err); + } else if (err && (!this._writableState || !this._writableState.errorEmitted)) { + pna.nextTick(emitErrorNT, this, err); + } + return this; + } + + // we set destroyed to true before firing error callbacks in order + // to make it re-entrance safe in case destroy() is called within callbacks + + if (this._readableState) { + this._readableState.destroyed = true; + } + + // if this is a duplex stream mark the writable part as destroyed as well + if (this._writableState) { + this._writableState.destroyed = true; + } + + this._destroy(err || null, function (err) { + if (!cb && err) { + pna.nextTick(emitErrorNT, _this, err); + if (_this._writableState) { + _this._writableState.errorEmitted = true; + } + } else if (cb) { + cb(err); } + }); + + return this; } -exports.isInConstContext = isInConstContext; -function isReadonlyAssignmentDeclaration(node, checker) { - if (!isBindableObjectDefinePropertyCall(node)) - return false; - const descriptorType = checker.getTypeAtLocation(node.arguments[2]); - if (descriptorType.getProperty('value') === undefined) - return descriptorType.getProperty('set') === undefined; - const writableProp = descriptorType.getProperty('writable'); - if (writableProp === undefined) - return false; - const writableType = writableProp.valueDeclaration !== undefined && node_1.isPropertyAssignment(writableProp.valueDeclaration) - ? checker.getTypeAtLocation(writableProp.valueDeclaration.initializer) - : checker.getTypeOfSymbolAtLocation(writableProp, node.arguments[2]); - return type_1.isBooleanLiteralType(writableType, false); + +function undestroy() { + if (this._readableState) { + this._readableState.destroyed = false; + this._readableState.reading = false; + this._readableState.ended = false; + this._readableState.endEmitted = false; + } + + if (this._writableState) { + this._writableState.destroyed = false; + this._writableState.ended = false; + this._writableState.ending = false; + this._writableState.finished = false; + this._writableState.errorEmitted = false; + } } -exports.isReadonlyAssignmentDeclaration = isReadonlyAssignmentDeclaration; -function isBindableObjectDefinePropertyCall(node) { - return node.arguments.length === 3 && - node_1.isEntityNameExpression(node.arguments[0]) && - node_1.isNumericOrStringLikeLiteral(node.arguments[1]) && - node_1.isPropertyAccessExpression(node.expression) && - node.expression.name.escapedText === 'defineProperty' && - node_1.isIdentifier(node.expression.expression) && - node.expression.expression.escapedText === 'Object'; + +function emitErrorNT(self, err) { + self.emit('error', err); } -exports.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; -function isWellKnownSymbolLiterally(node) { - return ts.isPropertyAccessExpression(node) && - ts.isIdentifier(node.expression) && - node.expression.escapedText === 'Symbol'; + +module.exports = { + destroy: destroy, + undestroy: undestroy +}; + +/***/ }), +/* 829 */ +/***/ (function(__unusedmodule, exports) { + +/* -*- Mode: js; js-indent-level: 2; -*- */ +/* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + +// It turns out that some (most?) JavaScript engines don't self-host +// `Array.prototype.sort`. This makes sense because C++ will likely remain +// faster than JS when doing raw CPU-intensive sorting. However, when using a +// custom comparator function, calling back and forth between the VM's C++ and +// JIT'd JS is rather slow *and* loses JIT type information, resulting in +// worse generated code for the comparator function than would be optimal. In +// fact, when sorting with a comparator, these costs outweigh the benefits of +// sorting in C++. By using our own JS-implemented Quick Sort (below), we get +// a ~3500ms mean speed-up in `bench/bench.html`. + +/** + * Swap the elements indexed by `x` and `y` in the array `ary`. + * + * @param {Array} ary + * The array. + * @param {Number} x + * The index of the first item. + * @param {Number} y + * The index of the second item. + */ +function swap(ary, x, y) { + var temp = ary[x]; + ary[x] = ary[y]; + ary[y] = temp; } -exports.isWellKnownSymbolLiterally = isWellKnownSymbolLiterally; -function getPropertyNameOfWellKnownSymbol(node) { - return { - displayName: `[Symbol.${node.name.text}]`, - symbolName: ('__@' + node.name.text), - }; + +/** + * Returns a random integer within the range `low .. high` inclusive. + * + * @param {Number} low + * The lower bound on the range. + * @param {Number} high + * The upper bound on the range. + */ +function randomIntInRange(low, high) { + return Math.round(low + (Math.random() * (high - low))); } -exports.getPropertyNameOfWellKnownSymbol = getPropertyNameOfWellKnownSymbol; -function getLateBoundPropertyNames(node, checker) { - const result = { - known: true, - names: [], - }; - node = unwrapParentheses(node); - if (isWellKnownSymbolLiterally(node)) { - result.names.push(getPropertyNameOfWellKnownSymbol(node)); + +/** + * The Quick Sort algorithm. + * + * @param {Array} ary + * An array to sort. + * @param {function} comparator + * Function to use to compare two items. + * @param {Number} p + * Start index of the array + * @param {Number} r + * End index of the array + */ +function doQuickSort(ary, comparator, p, r) { + // If our lower bound is less than our upper bound, we (1) partition the + // array into two pieces and (2) recurse on each half. If it is not, this is + // the empty array and our base case. + + if (p < r) { + // (1) Partitioning. + // + // The partitioning chooses a pivot between `p` and `r` and moves all + // elements that are less than or equal to the pivot to the before it, and + // all the elements that are greater than it after it. The effect is that + // once partition is done, the pivot is in the exact place it will be when + // the array is put in sorted order, and it will not need to be moved + // again. This runs in O(n) time. + + // Always choose a random pivot so that an input array which is reverse + // sorted does not cause O(n^2) running time. + var pivotIndex = randomIntInRange(p, r); + var i = p - 1; + + swap(ary, pivotIndex, r); + var pivot = ary[r]; + + // Immediately after `j` is incremented in this loop, the following hold + // true: + // + // * Every element in `ary[p .. i]` is less than or equal to the pivot. + // + // * Every element in `ary[i+1 .. j-1]` is greater than the pivot. + for (var j = p; j < r; j++) { + if (comparator(ary[j], pivot) <= 0) { + i += 1; + swap(ary, i, j); + } } - else { - const type = checker.getTypeAtLocation(node); - for (const key of type_1.unionTypeParts(checker.getBaseConstraintOfType(type) || type)) { - const propertyName = type_1.getPropertyNameFromType(key); - if (propertyName) { - result.names.push(propertyName); - } - else { - result.known = false; - } - } + + swap(ary, i + 1, j); + var q = i + 1; + + // (2) Recurse on each half. + + doQuickSort(ary, comparator, p, q - 1); + doQuickSort(ary, comparator, q + 1, r); + } +} + +/** + * Sort the given array in-place with the given comparator function. + * + * @param {Array} ary + * An array to sort. + * @param {function} comparator + * Function to use to compare two items. + */ +exports.quickSort = function (ary, comparator) { + doQuickSort(ary, comparator, 0, ary.length - 1); +}; + + +/***/ }), +/* 830 */, +/* 831 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +/**/ + +var objectKeys = Object.keys || function (obj) { + var keys = []; + + for (var key in obj) { + keys.push(key); + } + + return keys; +}; +/**/ + + +module.exports = Duplex; + +var Readable = __webpack_require__(226); + +var Writable = __webpack_require__(241); + +__webpack_require__(689)(Duplex, Readable); + +{ + // Allow the keys array to be GC'ed. + var keys = objectKeys(Writable.prototype); + + for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; + } +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + Readable.call(this, options); + Writable.call(this, options); + this.allowHalfOpen = true; + + if (options) { + if (options.readable === false) this.readable = false; + if (options.writable === false) this.writable = false; + + if (options.allowHalfOpen === false) { + this.allowHalfOpen = false; + this.once('end', onend); } - return result; + } } -exports.getLateBoundPropertyNames = getLateBoundPropertyNames; -function getLateBoundPropertyNamesOfPropertyName(node, checker) { - const staticName = getPropertyName(node); - return staticName !== undefined - ? { known: true, names: [{ displayName: staticName, symbolName: ts.escapeLeadingUnderscores(staticName) }] } - : getLateBoundPropertyNames(node.expression, checker); + +Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.highWaterMark; + } +}); +Object.defineProperty(Duplex.prototype, 'writableBuffer', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState && this._writableState.getBuffer(); + } +}); +Object.defineProperty(Duplex.prototype, 'writableLength', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + return this._writableState.length; + } +}); // the no-half-open enforcer + +function onend() { + // If the writable side ended, then we're ok. + if (this._writableState.ended) return; // no more data can be written. + // But allow more writes to happen in this tick. + + process.nextTick(onEndNT, this); } -exports.getLateBoundPropertyNamesOfPropertyName = getLateBoundPropertyNamesOfPropertyName; -function getSingleLateBoundPropertyNameOfPropertyName(node, checker) { - const staticName = getPropertyName(node); - if (staticName !== undefined) - return { displayName: staticName, symbolName: ts.escapeLeadingUnderscores(staticName) }; - const { expression } = node; - return isWellKnownSymbolLiterally(expression) - ? getPropertyNameOfWellKnownSymbol(expression) - : type_1.getPropertyNameFromType(checker.getTypeAtLocation(expression)); + +function onEndNT(self) { + self.end(); } -exports.getSingleLateBoundPropertyNameOfPropertyName = getSingleLateBoundPropertyNameOfPropertyName; -function unwrapParentheses(node) { - while (node.kind === ts.SyntaxKind.ParenthesizedExpression) - node = node.expression; - return node; + +Object.defineProperty(Duplex.prototype, 'destroyed', { + // making it explicit this property is not enumerable + // because otherwise some prototype manipulation in + // userland will fail + enumerable: false, + get: function get() { + if (this._readableState === undefined || this._writableState === undefined) { + return false; + } + + return this._readableState.destroyed && this._writableState.destroyed; + }, + set: function set(value) { + // we ignore the value if the stream + // has not been initialized yet + if (this._readableState === undefined || this._writableState === undefined) { + return; + } // backward compatibility, the user is explicitly + // managing destroyed + + + this._readableState.destroyed = value; + this._writableState.destroyed = value; + } +}); + +/***/ }), +/* 832 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + + +module.exports = __webpack_require__(271).default; + + +/***/ }), +/* 833 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const Range = __webpack_require__(986) +const gt = __webpack_require__(136) + +const minVersion = (range, loose) => { + range = new Range(range, loose) + + let minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } + + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } + + minver = null + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] + + comparators.forEach((comparator) => { + // Clone to avoid manipulating the comparator's semver object. + const compver = new SemVer(comparator.semver.version) + switch (comparator.operator) { + case '>': + if (compver.prerelease.length === 0) { + compver.patch++ + } else { + compver.prerelease.push(0) + } + compver.raw = compver.format() + /* fallthrough */ + case '': + case '>=': + if (!minver || gt(minver, compver)) { + minver = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error(`Unexpected operation: ${comparator.operator}`) + } + }) + } + + if (minver && range.test(minver)) { + return minver + } + + return null } -exports.unwrapParentheses = unwrapParentheses; +module.exports = minVersion + + +/***/ }), +/* 834 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const minor = (a, loose) => new SemVer(a, loose).minor +module.exports = minor /***/ }), -/* 834 */, /* 835 */ /***/ (function(module) { @@ -245593,14 +251646,27 @@ exports.ArraySet = ArraySet; "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultInputs = void 0; const core = __importStar(__webpack_require__(470)); exports.defaultInputs = { publishDir() { @@ -245626,6 +251692,9 @@ exports.defaultInputs = { overwritesPullRequestComment() { // Default: true return ((core.getInput('overwrites-pull-request-comment') || 'true') === 'true'); + }, + netlifyConfigPath() { + return core.getInput('netlify-config-path') || undefined; } }; @@ -258836,7 +264905,19 @@ exports.restEndpointMethods = restEndpointMethods; /***/ }), /* 843 */, -/* 844 */, +/* 844 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(986) +const intersects = (r1, r2, options) => { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) +} +module.exports = intersects + + +/***/ }), /* 845 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -259436,7 +265517,35 @@ function paginationMethodsPlugin (octokit) { /***/ }), /* 851 */, /* 852 */, -/* 853 */, +/* 853 */ +/***/ (function(module) { + +const numeric = /^[0-9]+$/ +const compareIdentifiers = (a, b) => { + const anum = numeric.test(a) + const bnum = numeric.test(b) + + if (anum && bnum) { + a = +a + b = +b + } + + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +} + +const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) + +module.exports = { + compareIdentifiers, + rcompareIdentifiers +} + + +/***/ }), /* 854 */ /***/ (function(module) { @@ -260416,7 +266525,7 @@ module.exports = __webpack_require__(160).default; var replace = String.prototype.replace; var percentTwenties = /%20/g; -var util = __webpack_require__(658); +var util = __webpack_require__(733); var Format = { RFC1738: 'RFC1738', @@ -261327,7 +267436,35 @@ Duplex.prototype._destroy = function (err, cb) { /***/ }), /* 878 */, -/* 879 */, +/* 879 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(658) +const eq = __webpack_require__(804) + +const diff = (version1, version2) => { + if (eq(version1, version2)) { + return null + } else { + const v1 = parse(version1) + const v2 = parse(version2) + const hasPre = v1.prerelease.length || v2.prerelease.length + const prefix = hasPre ? 'pre' : '' + const defaultResult = hasPre ? 'prerelease' : '' + for (const key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key + } + } + } + return defaultResult // may be undefined + } +} +module.exports = diff + + +/***/ }), /* 880 */ /***/ (function(module, exports, __webpack_require__) { @@ -263614,7 +269751,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); var request = __webpack_require__(753); var universalUserAgent = __webpack_require__(796); -const VERSION = "4.4.0"; +const VERSION = "4.5.0"; class GraphqlError extends Error { constructor(request, response) { @@ -263695,8 +269832,69 @@ exports.withCustomRequest = withCustomRequest; /***/ }), -/* 899 */, -/* 900 */, +/* 899 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compareBuild = __webpack_require__(50) +const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) +module.exports = sort + + +/***/ }), +/* 900 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// just pre-load all the stuff that index.js lazily exports +const internalRe = __webpack_require__(590) +module.exports = { + re: internalRe.re, + src: internalRe.src, + tokens: internalRe.t, + SEMVER_SPEC_VERSION: __webpack_require__(627).SEMVER_SPEC_VERSION, + SemVer: __webpack_require__(369), + compareIdentifiers: __webpack_require__(853).compareIdentifiers, + rcompareIdentifiers: __webpack_require__(853).rcompareIdentifiers, + parse: __webpack_require__(658), + valid: __webpack_require__(64), + clean: __webpack_require__(386), + inc: __webpack_require__(767), + diff: __webpack_require__(879), + major: __webpack_require__(476), + minor: __webpack_require__(834), + patch: __webpack_require__(32), + prerelease: __webpack_require__(609), + compare: __webpack_require__(682), + rcompare: __webpack_require__(972), + compareLoose: __webpack_require__(467), + compareBuild: __webpack_require__(805), + sort: __webpack_require__(638), + rsort: __webpack_require__(150), + gt: __webpack_require__(136), + lt: __webpack_require__(342), + eq: __webpack_require__(804), + neq: __webpack_require__(335), + gte: __webpack_require__(618), + lte: __webpack_require__(495), + cmp: __webpack_require__(134), + coerce: __webpack_require__(719), + Comparator: __webpack_require__(123), + Range: __webpack_require__(986), + satisfies: __webpack_require__(121), + toComparators: __webpack_require__(770), + maxSatisfying: __webpack_require__(994), + minSatisfying: __webpack_require__(217), + minVersion: __webpack_require__(833), + validRange: __webpack_require__(292), + outside: __webpack_require__(750), + gtr: __webpack_require__(530), + ltr: __webpack_require__(589), + intersects: __webpack_require__(844), + simplifyRange: __webpack_require__(930), + subset: __webpack_require__(321), +} + + +/***/ }), /* 901 */ /***/ (function(__unusedmodule, exports) { @@ -266172,860 +272370,330 @@ function isObjectLike(value) { } /** - * This method returns `undefined`. - * - * @static - * @memberOf _ - * @since 2.3.0 - * @category Util - * @example - * - * _.times(2, _.noop); - * // => [undefined, undefined] - */ -function noop() { - // No operation performed. -} - -module.exports = union; - - -/***/ }), -/* 924 */, -/* 925 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. -// a transform stream is a readable/writable stream where you do -// something with the data. Sometimes it's called a "filter", -// but that's not a great name for it, since that implies a thing where -// some bits pass through, and others are simply ignored. (That would -// be a valid example of a transform, of course.) -// -// While the output is causally related to the input, it's not a -// necessarily symmetric or synchronous transformation. For example, -// a zlib stream might take multiple plain-text writes(), and then -// emit a single compressed chunk some time in the future. -// -// Here's how this works: -// -// The Transform stream has all the aspects of the readable and writable -// stream classes. When you write(chunk), that calls _write(chunk,cb) -// internally, and returns false if there's a lot of pending writes -// buffered up. When you call read(), that calls _read(n) until -// there's enough pending readable data buffered up. -// -// In a transform stream, the written data is placed in a buffer. When -// _read(n) is called, it transforms the queued up data, calling the -// buffered _write cb's as it consumes chunks. If consuming a single -// written chunk would result in multiple output chunks, then the first -// outputted bit calls the readcb, and subsequent chunks just go into -// the read buffer, and will cause it to emit 'readable' if necessary. -// -// This way, back-pressure is actually determined by the reading side, -// since _read has to be called to start processing a new chunk. However, -// a pathological inflate type of transform can cause excessive buffering -// here. For example, imagine a stream where every byte of input is -// interpreted as an integer from 0-255, and then results in that many -// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in -// 1kb of data being output. In this case, you could write a very small -// amount of input, and end up with a very large amount of output. In -// such a pathological inflating mechanism, there'd be no way to tell -// the system to stop doing the transform. A single 4MB write could -// cause the system to run out of memory. -// -// However, even in such a pathological case, only a single written chunk -// would be consumed, and then the rest would wait (un-transformed) until -// the results of the previous transformed chunk were consumed. - - -module.exports = Transform; - -var _require$codes = __webpack_require__(38).codes, - ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, - ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, - ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, - ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; - -var Duplex = __webpack_require__(831); - -__webpack_require__(689)(Transform, Duplex); - -function afterTransform(er, data) { - var ts = this._transformState; - ts.transforming = false; - var cb = ts.writecb; - - if (cb === null) { - return this.emit('error', new ERR_MULTIPLE_CALLBACK()); - } - - ts.writechunk = null; - ts.writecb = null; - if (data != null) // single equals check for both `null` and `undefined` - this.push(data); - cb(er); - var rs = this._readableState; - rs.reading = false; - - if (rs.needReadable || rs.length < rs.highWaterMark) { - this._read(rs.highWaterMark); - } -} - -function Transform(options) { - if (!(this instanceof Transform)) return new Transform(options); - Duplex.call(this, options); - this._transformState = { - afterTransform: afterTransform.bind(this), - needTransform: false, - transforming: false, - writecb: null, - writechunk: null, - writeencoding: null - }; // start out asking for a readable event once data is transformed. - - this._readableState.needReadable = true; // we have implemented the _read method, and done the other things - // that Readable wants before the first _read call, so unset the - // sync guard flag. - - this._readableState.sync = false; - - if (options) { - if (typeof options.transform === 'function') this._transform = options.transform; - if (typeof options.flush === 'function') this._flush = options.flush; - } // When the writable side finishes, then flush out anything remaining. - - - this.on('prefinish', prefinish); -} - -function prefinish() { - var _this = this; - - if (typeof this._flush === 'function' && !this._readableState.destroyed) { - this._flush(function (er, data) { - done(_this, er, data); - }); - } else { - done(this, null, null); - } -} - -Transform.prototype.push = function (chunk, encoding) { - this._transformState.needTransform = false; - return Duplex.prototype.push.call(this, chunk, encoding); -}; // This is the part where you do stuff! -// override this function in implementation classes. -// 'chunk' is an input chunk. -// -// Call `push(newChunk)` to pass along transformed output -// to the readable side. You may call 'push' zero or more times. -// -// Call `cb(err)` when you are done with this chunk. If you pass -// an error, then that'll put the hurt on the whole operation. If you -// never call cb(), then you'll never get another chunk. - - -Transform.prototype._transform = function (chunk, encoding, cb) { - cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); -}; - -Transform.prototype._write = function (chunk, encoding, cb) { - var ts = this._transformState; - ts.writecb = cb; - ts.writechunk = chunk; - ts.writeencoding = encoding; - - if (!ts.transforming) { - var rs = this._readableState; - if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); - } -}; // Doesn't matter what the args are here. -// _transform does all the work. -// That we got here means that the readable side wants more data. - - -Transform.prototype._read = function (n) { - var ts = this._transformState; - - if (ts.writechunk !== null && !ts.transforming) { - ts.transforming = true; - - this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); - } else { - // mark that we need a transform, so that any data that comes in - // will get processed, now that we've asked for it. - ts.needTransform = true; - } -}; - -Transform.prototype._destroy = function (err, cb) { - Duplex.prototype._destroy.call(this, err, function (err2) { - cb(err2); - }); -}; - -function done(stream, er, data) { - if (er) return stream.emit('error', er); - if (data != null) // single equals check for both `null` and `undefined` - stream.push(data); // TODO(BridgeAR): Write a test for these two error cases - // if there's nothing in the write buffer, then that means - // that nothing more will ever be provided - - if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); - if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); - return stream.push(null); -} - -/***/ }), -/* 926 */, -/* 927 */, -/* 928 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -module.exports = __webpack_require__(413); - - -/***/ }), -/* 929 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -module.exports = hasNextPage - -const deprecate = __webpack_require__(370) -const getPageLinks = __webpack_require__(577) - -function hasNextPage (link) { - deprecate(`octokit.hasNextPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) - return getPageLinks(link).next -} - - -/***/ }), -/* 930 */, -/* 931 */ -/***/ (function(module) { - -/** - * lodash (Custom Build) - * Build: `lodash modularize exports="npm" -o ./` - * Copyright jQuery Foundation and other contributors - * Released under MIT license - * Based on Underscore.js 1.8.3 - * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */ - -/** Used as references for various `Number` constants. */ -var INFINITY = 1 / 0; - -/** `Object#toString` result references. */ -var symbolTag = '[object Symbol]'; - -/** Used to match words composed of alphanumeric characters. */ -var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; - -/** Used to match Latin Unicode letters (excluding mathematical operators). */ -var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; - -/** Used to compose unicode character classes. */ -var rsAstralRange = '\\ud800-\\udfff', - rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', - rsComboSymbolsRange = '\\u20d0-\\u20f0', - rsDingbatRange = '\\u2700-\\u27bf', - rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', - rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', - rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', - rsPunctuationRange = '\\u2000-\\u206f', - rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', - rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', - rsVarRange = '\\ufe0e\\ufe0f', - rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; - -/** Used to compose unicode capture groups. */ -var rsApos = "['\u2019]", - rsAstral = '[' + rsAstralRange + ']', - rsBreak = '[' + rsBreakRange + ']', - rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']', - rsDigits = '\\d+', - rsDingbat = '[' + rsDingbatRange + ']', - rsLower = '[' + rsLowerRange + ']', - rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', - rsFitz = '\\ud83c[\\udffb-\\udfff]', - rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', - rsNonAstral = '[^' + rsAstralRange + ']', - rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', - rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', - rsUpper = '[' + rsUpperRange + ']', - rsZWJ = '\\u200d'; - -/** Used to compose unicode regexes. */ -var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')', - rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')', - rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', - rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', - reOptMod = rsModifier + '?', - rsOptVar = '[' + rsVarRange + ']?', - rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', - rsSeq = rsOptVar + reOptMod + rsOptJoin, - rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, - rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; - -/** Used to match apostrophes. */ -var reApos = RegExp(rsApos, 'g'); - -/** - * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and - * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). - */ -var reComboMark = RegExp(rsCombo, 'g'); - -/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ -var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); - -/** Used to match complex or compound words. */ -var reUnicodeWord = RegExp([ - rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', - rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')', - rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr, - rsUpper + '+' + rsOptUpperContr, - rsDigits, - rsEmoji -].join('|'), 'g'); - -/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ -var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); - -/** Used to detect strings that need a more robust regexp to match words. */ -var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; - -/** Used to map Latin Unicode letters to basic Latin letters. */ -var deburredLetters = { - // Latin-1 Supplement block. - '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', - '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', - '\xc7': 'C', '\xe7': 'c', - '\xd0': 'D', '\xf0': 'd', - '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', - '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', - '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', - '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', - '\xd1': 'N', '\xf1': 'n', - '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', - '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', - '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', - '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', - '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', - '\xc6': 'Ae', '\xe6': 'ae', - '\xde': 'Th', '\xfe': 'th', - '\xdf': 'ss', - // Latin Extended-A block. - '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', - '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', - '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', - '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', - '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', - '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', - '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', - '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', - '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', - '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', - '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', - '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', - '\u0134': 'J', '\u0135': 'j', - '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', - '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', - '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', - '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', - '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', - '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', - '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', - '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', - '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', - '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', - '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', - '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', - '\u0163': 't', '\u0165': 't', '\u0167': 't', - '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', - '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', - '\u0174': 'W', '\u0175': 'w', - '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', - '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', - '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', - '\u0132': 'IJ', '\u0133': 'ij', - '\u0152': 'Oe', '\u0153': 'oe', - '\u0149': "'n", '\u017f': 'ss' -}; - -/** Detect free variable `global` from Node.js. */ -var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; - -/** Detect free variable `self`. */ -var freeSelf = typeof self == 'object' && self && self.Object === Object && self; - -/** Used as a reference to the global object. */ -var root = freeGlobal || freeSelf || Function('return this')(); - -/** - * A specialized version of `_.reduce` for arrays without support for - * iteratee shorthands. - * - * @private - * @param {Array} [array] The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @param {*} [accumulator] The initial value. - * @param {boolean} [initAccum] Specify using the first element of `array` as - * the initial value. - * @returns {*} Returns the accumulated value. - */ -function arrayReduce(array, iteratee, accumulator, initAccum) { - var index = -1, - length = array ? array.length : 0; - - if (initAccum && length) { - accumulator = array[++index]; - } - while (++index < length) { - accumulator = iteratee(accumulator, array[index], index, array); - } - return accumulator; -} - -/** - * Converts an ASCII `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -function asciiToArray(string) { - return string.split(''); -} - -/** - * Splits an ASCII `string` into an array of its words. - * - * @private - * @param {string} The string to inspect. - * @returns {Array} Returns the words of `string`. - */ -function asciiWords(string) { - return string.match(reAsciiWord) || []; -} - -/** - * The base implementation of `_.propertyOf` without support for deep paths. - * - * @private - * @param {Object} object The object to query. - * @returns {Function} Returns the new accessor function. - */ -function basePropertyOf(object) { - return function(key) { - return object == null ? undefined : object[key]; - }; -} - -/** - * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A - * letters to basic Latin letters. - * - * @private - * @param {string} letter The matched letter to deburr. - * @returns {string} Returns the deburred letter. - */ -var deburrLetter = basePropertyOf(deburredLetters); - -/** - * Checks if `string` contains Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a symbol is found, else `false`. - */ -function hasUnicode(string) { - return reHasUnicode.test(string); -} - -/** - * Checks if `string` contains a word composed of Unicode symbols. - * - * @private - * @param {string} string The string to inspect. - * @returns {boolean} Returns `true` if a word is found, else `false`. - */ -function hasUnicodeWord(string) { - return reHasUnicodeWord.test(string); -} - -/** - * Converts `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -function stringToArray(string) { - return hasUnicode(string) - ? unicodeToArray(string) - : asciiToArray(string); -} - -/** - * Converts a Unicode `string` to an array. - * - * @private - * @param {string} string The string to convert. - * @returns {Array} Returns the converted array. - */ -function unicodeToArray(string) { - return string.match(reUnicode) || []; -} - -/** - * Splits a Unicode `string` into an array of its words. - * - * @private - * @param {string} The string to inspect. - * @returns {Array} Returns the words of `string`. - */ -function unicodeWords(string) { - return string.match(reUnicodeWord) || []; -} - -/** Used for built-in method references. */ -var objectProto = Object.prototype; - -/** - * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) - * of values. - */ -var objectToString = objectProto.toString; - -/** Built-in value references. */ -var Symbol = root.Symbol; - -/** Used to convert symbols to primitives and strings. */ -var symbolProto = Symbol ? Symbol.prototype : undefined, - symbolToString = symbolProto ? symbolProto.toString : undefined; - -/** - * The base implementation of `_.slice` without an iteratee call guard. - * - * @private - * @param {Array} array The array to slice. - * @param {number} [start=0] The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the slice of `array`. - */ -function baseSlice(array, start, end) { - var index = -1, - length = array.length; - - if (start < 0) { - start = -start > length ? 0 : (length + start); - } - end = end > length ? length : end; - if (end < 0) { - end += length; - } - length = start > end ? 0 : ((end - start) >>> 0); - start >>>= 0; - - var result = Array(length); - while (++index < length) { - result[index] = array[index + start]; - } - return result; -} - -/** - * The base implementation of `_.toString` which doesn't convert nullish - * values to empty strings. - * - * @private - * @param {*} value The value to process. - * @returns {string} Returns the string. - */ -function baseToString(value) { - // Exit early for strings to avoid a performance hit in some environments. - if (typeof value == 'string') { - return value; - } - if (isSymbol(value)) { - return symbolToString ? symbolToString.call(value) : ''; - } - var result = (value + ''); - return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; -} - -/** - * Casts `array` to a slice if it's needed. - * - * @private - * @param {Array} array The array to inspect. - * @param {number} start The start position. - * @param {number} [end=array.length] The end position. - * @returns {Array} Returns the cast slice. - */ -function castSlice(array, start, end) { - var length = array.length; - end = end === undefined ? length : end; - return (!start && end >= length) ? array : baseSlice(array, start, end); -} - -/** - * Creates a function like `_.lowerFirst`. - * - * @private - * @param {string} methodName The name of the `String` case method to use. - * @returns {Function} Returns the new case function. - */ -function createCaseFirst(methodName) { - return function(string) { - string = toString(string); - - var strSymbols = hasUnicode(string) - ? stringToArray(string) - : undefined; - - var chr = strSymbols - ? strSymbols[0] - : string.charAt(0); - - var trailing = strSymbols - ? castSlice(strSymbols, 1).join('') - : string.slice(1); - - return chr[methodName]() + trailing; - }; -} - -/** - * Creates a function like `_.camelCase`. - * - * @private - * @param {Function} callback The function to combine each word. - * @returns {Function} Returns the new compounder function. - */ -function createCompounder(callback) { - return function(string) { - return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); - }; -} - -/** - * Checks if `value` is object-like. A value is object-like if it's not `null` - * and has a `typeof` result of "object". - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is object-like, else `false`. - * @example - * - * _.isObjectLike({}); - * // => true - * - * _.isObjectLike([1, 2, 3]); - * // => true - * - * _.isObjectLike(_.noop); - * // => false - * - * _.isObjectLike(null); - * // => false - */ -function isObjectLike(value) { - return !!value && typeof value == 'object'; -} - -/** - * Checks if `value` is classified as a `Symbol` primitive or object. + * This method returns `undefined`. * * @static * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. + * @since 2.3.0 + * @category Util * @example * - * _.isSymbol(Symbol.iterator); - * // => true - * - * _.isSymbol('abc'); - * // => false + * _.times(2, _.noop); + * // => [undefined, undefined] */ -function isSymbol(value) { - return typeof value == 'symbol' || - (isObjectLike(value) && objectToString.call(value) == symbolTag); +function noop() { + // No operation performed. } -/** - * Converts `value` to a string. An empty string is returned for `null` - * and `undefined` values. The sign of `-0` is preserved. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category Lang - * @param {*} value The value to process. - * @returns {string} Returns the string. - * @example - * - * _.toString(null); - * // => '' - * - * _.toString(-0); - * // => '-0' - * - * _.toString([1, 2, 3]); - * // => '1,2,3' - */ -function toString(value) { - return value == null ? '' : baseToString(value); +module.exports = union; + + +/***/ }), +/* 924 */, +/* 925 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + + +module.exports = Transform; + +var _require$codes = __webpack_require__(38).codes, + ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED, + ERR_MULTIPLE_CALLBACK = _require$codes.ERR_MULTIPLE_CALLBACK, + ERR_TRANSFORM_ALREADY_TRANSFORMING = _require$codes.ERR_TRANSFORM_ALREADY_TRANSFORMING, + ERR_TRANSFORM_WITH_LENGTH_0 = _require$codes.ERR_TRANSFORM_WITH_LENGTH_0; + +var Duplex = __webpack_require__(831); + +__webpack_require__(689)(Transform, Duplex); + +function afterTransform(er, data) { + var ts = this._transformState; + ts.transforming = false; + var cb = ts.writecb; + + if (cb === null) { + return this.emit('error', new ERR_MULTIPLE_CALLBACK()); + } + + ts.writechunk = null; + ts.writecb = null; + if (data != null) // single equals check for both `null` and `undefined` + this.push(data); + cb(er); + var rs = this._readableState; + rs.reading = false; + + if (rs.needReadable || rs.length < rs.highWaterMark) { + this._read(rs.highWaterMark); + } } -/** - * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the camel cased string. - * @example - * - * _.camelCase('Foo Bar'); - * // => 'fooBar' - * - * _.camelCase('--foo-bar--'); - * // => 'fooBar' - * - * _.camelCase('__FOO_BAR__'); - * // => 'fooBar' - */ -var camelCase = createCompounder(function(result, word, index) { - word = word.toLowerCase(); - return result + (index ? capitalize(word) : word); -}); +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + Duplex.call(this, options); + this._transformState = { + afterTransform: afterTransform.bind(this), + needTransform: false, + transforming: false, + writecb: null, + writechunk: null, + writeencoding: null + }; // start out asking for a readable event once data is transformed. -/** - * Converts the first character of `string` to upper case and the remaining - * to lower case. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to capitalize. - * @returns {string} Returns the capitalized string. - * @example - * - * _.capitalize('FRED'); - * // => 'Fred' - */ -function capitalize(string) { - return upperFirst(toString(string).toLowerCase()); + this._readableState.needReadable = true; // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + if (typeof options.flush === 'function') this._flush = options.flush; + } // When the writable side finishes, then flush out anything remaining. + + + this.on('prefinish', prefinish); } -/** - * Deburrs `string` by converting - * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) - * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) - * letters to basic Latin letters and removing - * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to deburr. - * @returns {string} Returns the deburred string. - * @example - * - * _.deburr('déjà vu'); - * // => 'deja vu' - */ -function deburr(string) { - string = toString(string); - return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); +function prefinish() { + var _this = this; + + if (typeof this._flush === 'function' && !this._readableState.destroyed) { + this._flush(function (er, data) { + done(_this, er, data); + }); + } else { + done(this, null, null); + } } -/** - * Converts the first character of `string` to upper case. - * - * @static - * @memberOf _ - * @since 4.0.0 - * @category String - * @param {string} [string=''] The string to convert. - * @returns {string} Returns the converted string. - * @example - * - * _.upperFirst('fred'); - * // => 'Fred' - * - * _.upperFirst('FRED'); - * // => 'FRED' - */ -var upperFirst = createCaseFirst('toUpperCase'); +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; // This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. -/** - * Splits `string` into an array of its words. - * - * @static - * @memberOf _ - * @since 3.0.0 - * @category String - * @param {string} [string=''] The string to inspect. - * @param {RegExp|string} [pattern] The pattern to match words. - * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. - * @returns {Array} Returns the words of `string`. - * @example - * - * _.words('fred, barney, & pebbles'); - * // => ['fred', 'barney', 'pebbles'] - * - * _.words('fred, barney, & pebbles', /[^, ]+/g); - * // => ['fred', 'barney', '&', 'pebbles'] - */ -function words(string, pattern, guard) { - string = toString(string); - pattern = guard ? undefined : pattern; - if (pattern === undefined) { - return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); +Transform.prototype._transform = function (chunk, encoding, cb) { + cb(new ERR_METHOD_NOT_IMPLEMENTED('_transform()')); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); } - return string.match(pattern) || []; +}; // Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. + + +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && !ts.transforming) { + ts.transforming = true; + + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +Transform.prototype._destroy = function (err, cb) { + Duplex.prototype._destroy.call(this, err, function (err2) { + cb(err2); + }); +}; + +function done(stream, er, data) { + if (er) return stream.emit('error', er); + if (data != null) // single equals check for both `null` and `undefined` + stream.push(data); // TODO(BridgeAR): Write a test for these two error cases + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + + if (stream._writableState.length) throw new ERR_TRANSFORM_WITH_LENGTH_0(); + if (stream._transformState.transforming) throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); + return stream.push(null); } -module.exports = camelCase; +/***/ }), +/* 926 */, +/* 927 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(635) +const intersects = (r1, r2, options) => { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) +} +module.exports = intersects + + +/***/ }), +/* 928 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +module.exports = __webpack_require__(413); + + +/***/ }), +/* 929 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +module.exports = hasNextPage + +const deprecate = __webpack_require__(370) +const getPageLinks = __webpack_require__(577) + +function hasNextPage (link) { + deprecate(`octokit.hasNextPage() – You can use octokit.paginate or async iterators instead: https://github.com/octokit/rest.js#pagination.`) + return getPageLinks(link).next +} + + +/***/ }), +/* 930 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// given a set of versions and a range, create a "simplified" range +// that includes the same versions that the original range does +// If the original range is shorter than the simplified one, return that. +const satisfies = __webpack_require__(121) +const compare = __webpack_require__(682) +module.exports = (versions, range, options) => { + const set = [] + let min = null + let prev = null + const v = versions.sort((a, b) => compare(a, b, options)) + for (const version of v) { + const included = satisfies(version, range, options) + if (included) { + prev = version + if (!min) + min = version + } else { + if (prev) { + set.push([min, prev]) + } + prev = null + min = null + } + } + if (min) + set.push([min, null]) + + const ranges = [] + for (const [min, max] of set) { + if (min === max) + ranges.push(min) + else if (!max && min === v[0]) + ranges.push('*') + else if (!max) + ranges.push(`>=${min}`) + else if (min === v[0]) + ranges.push(`<=${max}`) + else + ranges.push(`${min} - ${max}`) + } + const simplified = ranges.join(' || ') + const original = typeof range.raw === 'string' ? range.raw : String(range) + return simplified.length < original.length ? simplified : range +} + + +/***/ }), +/* 931 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(635) + +// Mostly just for testing and legacy API reasons +const toComparators = (range, options) => + new Range(range, options).set + .map(comp => comp.map(c => c.value).join(' ').trim().split(' ')) + +module.exports = toComparators /***/ }), @@ -268705,7 +274373,7 @@ var fs = __webpack_require__(747); var path = __webpack_require__(622); var caller = __webpack_require__(433); var nodeModulesPaths = __webpack_require__(194); -var normalizeOptions = __webpack_require__(590); +var normalizeOptions = __webpack_require__(791); var isCore = __webpack_require__(127); var defaultIsFile = function isFile(file, cb) { @@ -269642,7 +275310,12 @@ module.exports.shellSync = (cmd, opts) => handleShell(module.exports.sync, cmd, /***/ }), -/* 956 */, +/* 956 */ +/***/ (function(module) { + +module.exports = require("process"); + +/***/ }), /* 957 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -270893,9 +276566,25 @@ function onceStrict (fn) { /***/ }), -/* 970 */, +/* 970 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(570) +const compareLoose = (a, b) => compare(a, b, true) +module.exports = compareLoose + + +/***/ }), /* 971 */, -/* 972 */, +/* 972 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(682) +const rcompare = (a, b, loose) => compare(b, a, loose) +module.exports = rcompare + + +/***/ }), /* 973 */ /***/ (function(module) { @@ -270918,7 +276607,7 @@ const precinct = __webpack_require__(92) const requirePackageName = __webpack_require__(332) const promisify = __webpack_require__(799) -const { resolveLocation } = __webpack_require__(801) +const { resolvePathPreserveSymlinks, resolvePackage } = __webpack_require__(801) const pGlob = promisify(glob) @@ -270977,7 +276666,7 @@ const LOCAL_IMPORT_REGEXP = /^(\.|\/)/ // When a file requires another one, we apply the top-level logic recursively const getLocalImportDependencies = async function(dependency, basedir, packageJson, state) { - const dependencyPath = await resolveLocation(dependency, basedir) + const dependencyPath = await resolvePathPreserveSymlinks(dependency, basedir) const depsPath = await getFileDependencies(dependencyPath, packageJson, state) return [dependencyPath, ...depsPath] } @@ -271002,7 +276691,7 @@ const getModuleNameDependencies = async function(moduleName, basedir, state) { } // Find the Node.js module directory path - const packagePath = await resolveLocation(`${moduleName}/package.json`, basedir) + const packagePath = await resolvePackage(moduleName, basedir) const modulePath = dirname(packagePath) if (state.modulePaths.includes(modulePath)) { @@ -285116,7 +290805,475 @@ exports.tokTypes = types; /***/ }), -/* 986 */, +/* 986 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// hoisted class for cyclic dependency +class Range { + constructor (range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + if (range instanceof Range) { + if ( + range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease + ) { + return range + } else { + return new Range(range.raw, options) + } + } + + if (range instanceof Comparator) { + // just put it in the set and return + this.raw = range.value + this.set = [[range]] + this.format() + return this + } + + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease + + // First, split based on boolean or || + this.raw = range + this.set = range + .split(/\s*\|\|\s*/) + // map the range to a 2d array of comparators + .map(range => this.parseRange(range.trim())) + // throw out any comparator lists that are empty + // this generally means that it was not a valid range, which is allowed + // in loose mode, but will still throw if the WHOLE range is invalid. + .filter(c => c.length) + + if (!this.set.length) { + throw new TypeError(`Invalid SemVer Range: ${range}`) + } + + this.format() + } + + format () { + this.range = this.set + .map((comps) => { + return comps.join(' ').trim() + }) + .join('||') + .trim() + return this.range + } + + toString () { + return this.range + } + + parseRange (range) { + const loose = this.options.loose + range = range.trim() + // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4` + const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE] + range = range.replace(hr, hyphenReplace(this.options.includePrerelease)) + debug('hyphen replace', range) + // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5` + range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace) + debug('comparator trim', range, re[t.COMPARATORTRIM]) + + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[t.TILDETRIM], tildeTrimReplace) + + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[t.CARETTRIM], caretTrimReplace) + + // normalize spaces + range = range.split(/\s+/).join(' ') + + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + return range + .split(' ') + .map(comp => parseComparator(comp, this.options)) + .join(' ') + .split(/\s+/) + .map(comp => replaceGTE0(comp, this.options)) + // in loose mode, throw out any that are not valid comparators + .filter(this.options.loose ? comp => !!comp.match(compRe) : () => true) + .map(comp => new Comparator(comp, this.options)) + } + + intersects (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + return this.set.some((thisComparators) => { + return ( + isSatisfiable(thisComparators, options) && + range.set.some((rangeComparators) => { + return ( + isSatisfiable(rangeComparators, options) && + thisComparators.every((thisComparator) => { + return rangeComparators.every((rangeComparator) => { + return thisComparator.intersects(rangeComparator, options) + }) + }) + ) + }) + ) + }) + } + + // if ANY of the sets match ALL of its comparators, then pass + test (version) { + if (!version) { + return false + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + for (let i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } + } + return false + } +} +module.exports = Range + +const Comparator = __webpack_require__(123) +const debug = __webpack_require__(487) +const SemVer = __webpack_require__(369) +const { + re, + t, + comparatorTrimReplace, + tildeTrimReplace, + caretTrimReplace +} = __webpack_require__(590) + +// take a set of comparators and determine whether there +// exists a version which can satisfy it +const isSatisfiable = (comparators, options) => { + let result = true + const remainingComparators = comparators.slice() + let testComparator = remainingComparators.pop() + + while (result && remainingComparators.length) { + result = remainingComparators.every((otherComparator) => { + return testComparator.intersects(otherComparator, options) + }) + + testComparator = remainingComparators.pop() + } + + return result +} + +// comprised of xranges, tildes, stars, and gtlt's at this point. +// already replaced the hyphen ranges +// turn into a set of JUST comparators. +const parseComparator = (comp, options) => { + debug('comp', comp, options) + comp = replaceCarets(comp, options) + debug('caret', comp) + comp = replaceTildes(comp, options) + debug('tildes', comp) + comp = replaceXRanges(comp, options) + debug('xrange', comp) + comp = replaceStars(comp, options) + debug('stars', comp) + return comp +} + +const isX = id => !id || id.toLowerCase() === 'x' || id === '*' + +// ~, ~> --> * (any, kinda silly) +// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0 +// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0 +// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0 +// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0 +// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0 +const replaceTildes = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { + return replaceTilde(comp, options) + }).join(' ') + +const replaceTilde = (comp, options) => { + const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE] + return comp.replace(r, (_, M, m, p, pr) => { + debug('tilde', comp, _, M, m, p, pr) + let ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${M}.0.0 <${+M + 1}.0.0-0` + } else if (isX(p)) { + // ~1.2 == >=1.2.0 <1.3.0-0 + ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0` + } else if (pr) { + debug('replaceTilde pr', pr) + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0` + } else { + // ~1.2.3 == >=1.2.3 <1.3.0-0 + ret = `>=${M}.${m}.${p + } <${M}.${+m + 1}.0-0` + } + + debug('tilde return', ret) + return ret + }) +} + +// ^ --> * (any, kinda silly) +// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0 +// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0 +// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0 +// ^1.2.3 --> >=1.2.3 <2.0.0-0 +// ^1.2.0 --> >=1.2.0 <2.0.0-0 +const replaceCarets = (comp, options) => + comp.trim().split(/\s+/).map((comp) => { + return replaceCaret(comp, options) + }).join(' ') + +const replaceCaret = (comp, options) => { + debug('caret', comp, options) + const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET] + const z = options.includePrerelease ? '-0' : '' + return comp.replace(r, (_, M, m, p, pr) => { + debug('caret', comp, _, M, m, p, pr) + let ret + + if (isX(M)) { + ret = '' + } else if (isX(m)) { + ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0` + } else if (isX(p)) { + if (M === '0') { + ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0` + } else { + ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0` + } + } else if (pr) { + debug('replaceCaret pr', pr) + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${m}.${+p + 1}-0` + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${M}.${+m + 1}.0-0` + } + } else { + ret = `>=${M}.${m}.${p}-${pr + } <${+M + 1}.0.0-0` + } + } else { + debug('no pr') + if (M === '0') { + if (m === '0') { + ret = `>=${M}.${m}.${p + }${z} <${M}.${m}.${+p + 1}-0` + } else { + ret = `>=${M}.${m}.${p + }${z} <${M}.${+m + 1}.0-0` + } + } else { + ret = `>=${M}.${m}.${p + } <${+M + 1}.0.0-0` + } + } + + debug('caret return', ret) + return ret + }) +} + +const replaceXRanges = (comp, options) => { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map((comp) => { + return replaceXRange(comp, options) + }).join(' ') +} + +const replaceXRange = (comp, options) => { + comp = comp.trim() + const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE] + return comp.replace(r, (ret, gtlt, M, m, p, pr) => { + debug('xRange', comp, ret, gtlt, M, m, p, pr) + const xM = isX(M) + const xm = xM || isX(m) + const xp = xm || isX(p) + const anyX = xp + + if (gtlt === '=' && anyX) { + gtlt = '' + } + + // if we're including prereleases in the match, then we need + // to fix this to -0, the lowest possible prerelease value + pr = options.includePrerelease ? '-0' : '' + + if (xM) { + if (gtlt === '>' || gtlt === '<') { + // nothing is allowed + ret = '<0.0.0-0' + } else { + // nothing is forbidden + ret = '*' + } + } else if (gtlt && anyX) { + // we know patch is an x, because we have any x at all. + // replace X with 0 + if (xm) { + m = 0 + } + p = 0 + + if (gtlt === '>') { + // >1 => >=2.0.0 + // >1.2 => >=1.3.0 + gtlt = '>=' + if (xm) { + M = +M + 1 + m = 0 + p = 0 + } else { + m = +m + 1 + p = 0 + } + } else if (gtlt === '<=') { + // <=0.7.x is actually <0.8.0, since any 0.7.x should + // pass. Similarly, <=7.x is actually <8.0.0, etc. + gtlt = '<' + if (xm) { + M = +M + 1 + } else { + m = +m + 1 + } + } + + if (gtlt === '<') + pr = '-0' + + ret = `${gtlt + M}.${m}.${p}${pr}` + } else if (xm) { + ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0` + } else if (xp) { + ret = `>=${M}.${m}.0${pr + } <${M}.${+m + 1}.0-0` + } + + debug('xRange return', ret) + + return ret + }) +} + +// Because * is AND-ed with everything else in the comparator, +// and '' means "any version", just remove the *s entirely. +const replaceStars = (comp, options) => { + debug('replaceStars', comp, options) + // Looseness is ignored here. star is always as loose as it gets! + return comp.trim().replace(re[t.STAR], '') +} + +const replaceGTE0 = (comp, options) => { + debug('replaceGTE0', comp, options) + return comp.trim() + .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') +} + +// This function is passed to string.replace(re[t.HYPHENRANGE]) +// M, m, patch, prerelease, build +// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5 +// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do +// 1.2 - 3.4 => >=1.2.0 <3.5.0-0 +const hyphenReplace = incPr => ($0, + from, fM, fm, fp, fpr, fb, + to, tM, tm, tp, tpr, tb) => { + if (isX(fM)) { + from = '' + } else if (isX(fm)) { + from = `>=${fM}.0.0${incPr ? '-0' : ''}` + } else if (isX(fp)) { + from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}` + } else if (fpr) { + from = `>=${from}` + } else { + from = `>=${from}${incPr ? '-0' : ''}` + } + + if (isX(tM)) { + to = '' + } else if (isX(tm)) { + to = `<${+tM + 1}.0.0-0` + } else if (isX(tp)) { + to = `<${tM}.${+tm + 1}.0-0` + } else if (tpr) { + to = `<=${tM}.${tm}.${tp}-${tpr}` + } else if (incPr) { + to = `<${tM}.${tm}.${+tp + 1}-0` + } else { + to = `<=${to}` + } + + return (`${from} ${to}`).trim() +} + +const testSet = (set, version, options) => { + for (let i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } + + if (version.prerelease.length && !options.includePrerelease) { + // Find the set of versions that are allowed to have prereleases + // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0 + // That should allow `1.2.3-pr.2` to pass. + // However, `1.2.4-alpha.notready` should NOT be allowed, + // even though it's within the range set by the comparators. + for (let i = 0; i < set.length; i++) { + debug(set[i].semver) + if (set[i].semver === Comparator.ANY) { + continue + } + + if (set[i].semver.prerelease.length > 0) { + const allowed = set[i].semver + if (allowed.major === version.major && + allowed.minor === version.minor && + allowed.patch === version.patch) { + return true + } + } + } + + // Version has a -pre, but it's not one of the ones we like. + return false + } + + return true +} + + +/***/ }), /* 987 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -285125,7 +291282,7 @@ var fs = __webpack_require__(747); var path = __webpack_require__(622); var caller = __webpack_require__(433); var nodeModulesPaths = __webpack_require__(194); -var normalizeOptions = __webpack_require__(590); +var normalizeOptions = __webpack_require__(791); var defaultIsFile = function isFile(file) { try { @@ -285362,7 +291519,27 @@ module.exports = getRawTag; /***/ }), -/* 989 */, +/* 989 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(243) + +const inc = (version, release, options, identifier) => { + if (typeof (options) === 'string') { + identifier = options + options = undefined + } + + try { + return new SemVer(version, options).inc(release, identifier).version + } catch (er) { + return null + } +} +module.exports = inc + + +/***/ }), /* 990 */ /***/ (function(module, exports, __webpack_require__) { @@ -286735,7 +292912,37 @@ exports.computeSourceURL = computeSourceURL; /***/ }), /* 993 */, -/* 994 */, +/* 994 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(369) +const Range = __webpack_require__(986) + +const maxSatisfying = (versions, range, options) => { + let max = null + let maxSV = null + let rangeObj = null + try { + rangeObj = new Range(range, options) + } catch (er) { + return null + } + versions.forEach((v) => { + if (rangeObj.test(v)) { + // satisfies(v, range, options) + if (!max || maxSV.compare(v) === -1) { + // compare(max, v, true) + max = v + maxSV = new SemVer(max, options) + } + } + }) + return max +} +module.exports = maxSatisfying + + +/***/ }), /* 995 */ /***/ (function(module) { @@ -287417,7 +293624,7 @@ module.exports = defaults; "use strict"; -var utils = __webpack_require__(658); +var utils = __webpack_require__(733); var has = Object.prototype.hasOwnProperty; var isArray = Array.isArray; diff --git a/doc_assets/github-deployment.png b/doc_assets/github-deployment.png new file mode 100644 index 00000000..01a70657 Binary files /dev/null and b/doc_assets/github-deployment.png differ diff --git a/package-lock.json b/package-lock.json index a38dd045..6c2004de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "actions-netlify", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -37,19 +37,19 @@ } }, "@babel/core": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.9.6.tgz", - "integrity": "sha512-nD3deLvbsApbHAHttzIssYqgb883yU/d9roe4RZymBCDaZryMJDbptVpEpeQuRh4BJ+SYI8le9YGxKvFEvl1Wg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.8.3", - "@babel/generator": "^7.9.6", - "@babel/helper-module-transforms": "^7.9.0", - "@babel/helpers": "^7.9.6", - "@babel/parser": "^7.9.6", - "@babel/template": "^7.8.6", - "@babel/traverse": "^7.9.6", - "@babel/types": "^7.9.6", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.1.tgz", + "integrity": "sha512-u8XiZ6sMXW/gPmoP5ijonSUln4unazG291X0XAQ5h0s8qnAFr6BRRZGUEK+jtRWdmB0NTJQt7Uga25q8GetIIg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.1", + "@babel/generator": "^7.10.1", + "@babel/helper-module-transforms": "^7.10.1", + "@babel/helpers": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/template": "^7.10.1", + "@babel/traverse": "^7.10.1", + "@babel/types": "^7.10.1", "convert-source-map": "^1.7.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.1", @@ -60,68 +60,167 @@ "source-map": "^0.5.0" }, "dependencies": { + "@babel/code-frame": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz", + "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.1" + } + }, "@babel/generator": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.6.tgz", - "integrity": "sha512-+htwWKJbH2bL72HRluF8zumBxzuX0ZZUFl3JLNyoUjM/Ho8wnVpPXM6aUz8cfKDqQ/h7zHqKt4xzJteUosckqQ==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.1.tgz", + "integrity": "sha512-AT0YPLQw9DI21tliuJIdplVfLHya6mcGa8ctkv7n4Qv+hYacJrKmNWIteAK1P9iyLikFIAkwqJ7HAOqIDLFfgA==", "dev": true, "requires": { - "@babel/types": "^7.9.6", + "@babel/types": "^7.10.1", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" } }, "@babel/helper-function-name": { - "version": "7.9.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz", - "integrity": "sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.1.tgz", + "integrity": "sha512-fcpumwhs3YyZ/ttd5Rz0xn0TpIwVkN7X0V38B9TWNfVF42KEkhkAAuPCQ3oXmtTRtiPJrmZ0TrfS0GKF0eMaRQ==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.10.1", + "@babel/template": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.1.tgz", + "integrity": "sha512-F5qdXkYGOQUb0hpRaPoetF9AnsXknKjWMZ+wmsIRsp5ge5sFh4c3h1eH2pRTTuy9KKAA2+TTYomGXAtEL2fQEw==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz", + "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "^7.8.3", - "@babel/template": "^7.8.3", - "@babel/types": "^7.9.5" + "@babel/types": "^7.10.1" } }, "@babel/helper-validator-identifier": { - "version": "7.9.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz", - "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", + "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", "dev": true }, + "@babel/highlight": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz", + "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, "@babel/parser": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.6.tgz", - "integrity": "sha512-AoeIEJn8vt+d/6+PXDRPaksYhnlbMIiejioBZvvMQsOjW/JYK6k/0dKnvvP3EhK5GfMBWDPtrxRtegWdAcdq9Q==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz", + "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==", "dev": true }, + "@babel/template": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz", + "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, "@babel/traverse": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.6.tgz", - "integrity": "sha512-b3rAHSjbxy6VEAvlxM8OV/0X4XrG72zoxme6q1MOoe2vd0bEc+TwayhuC1+Dfgqh1QEG+pj7atQqvUprHIccsg==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.1.tgz", + "integrity": "sha512-C/cTuXeKt85K+p08jN6vMDz8vSV0vZcI0wmQ36o6mjbuo++kPMdpOYw23W2XH04dbRt9/nMEfA4W3eR21CD+TQ==", "dev": true, "requires": { - "@babel/code-frame": "^7.8.3", - "@babel/generator": "^7.9.6", - "@babel/helper-function-name": "^7.9.5", - "@babel/helper-split-export-declaration": "^7.8.3", - "@babel/parser": "^7.9.6", - "@babel/types": "^7.9.6", + "@babel/code-frame": "^7.10.1", + "@babel/generator": "^7.10.1", + "@babel/helper-function-name": "^7.10.1", + "@babel/helper-split-export-declaration": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" } }, "@babel/types": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.6.tgz", - "integrity": "sha512-qxXzvBO//jO9ZnoasKF1uJzHd2+M6Q2ZPIVfnFps8JJvXy0ZBbwbNOmE6SGIY5XOY6d1Bo5lb9d9RJ8nv3WSeA==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz", + "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.9.5", + "@babel/helper-validator-identifier": "^7.10.1", "lodash": "^4.17.13", "to-fast-properties": "^2.0.0" } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } } } }, @@ -158,138 +257,515 @@ } }, "@babel/helper-member-expression-to-functions": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.8.3.tgz", - "integrity": "sha512-fO4Egq88utkQFjbPrSHGmGLFqmrshs11d46WI+WZDESt7Wu7wN2G2Iu+NMMZJFDOVRHAMIkB5SNh30NtwCA7RA==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.1.tgz", + "integrity": "sha512-u7XLXeM2n50gb6PWJ9hoO5oO7JFPaZtrh35t8RqKLT1jFKj9IWeD1zrcrYp1q1qiZTdEarfDWfTIP8nGsu0h5g==", "dev": true, "requires": { - "@babel/types": "^7.8.3" + "@babel/types": "^7.10.1" + }, + "dependencies": { + "@babel/helper-validator-identifier": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", + "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", + "dev": true + }, + "@babel/types": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz", + "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + } } }, "@babel/helper-module-imports": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.8.3.tgz", - "integrity": "sha512-R0Bx3jippsbAEtzkpZ/6FIiuzOURPcMjHp+Z6xPe6DtApDJx+w7UYyOLanZqO8+wKR9G10s/FmHXvxaMd9s6Kg==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.1.tgz", + "integrity": "sha512-SFxgwYmZ3HZPyZwJRiVNLRHWuW2OgE5k2nrVs6D9Iv4PPnXVffuEHy83Sfx/l4SqF+5kyJXjAyUmrG7tNm+qVg==", "dev": true, "requires": { - "@babel/types": "^7.8.3" + "@babel/types": "^7.10.1" + }, + "dependencies": { + "@babel/helper-validator-identifier": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", + "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", + "dev": true + }, + "@babel/types": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz", + "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + } } }, "@babel/helper-module-transforms": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.9.0.tgz", - "integrity": "sha512-0FvKyu0gpPfIQ8EkxlrAydOWROdHpBmiCiRwLkUiBGhCUPRRbVD2/tm3sFr/c/GWFrQ/ffutGUAnx7V0FzT2wA==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.1.tgz", + "integrity": "sha512-RLHRCAzyJe7Q7sF4oy2cB+kRnU4wDZY/H2xJFGof+M+SJEGhZsb+GFj5j1AD8NiSaVBJ+Pf0/WObiXu/zxWpFg==", "dev": true, "requires": { - "@babel/helper-module-imports": "^7.8.3", - "@babel/helper-replace-supers": "^7.8.6", - "@babel/helper-simple-access": "^7.8.3", - "@babel/helper-split-export-declaration": "^7.8.3", - "@babel/template": "^7.8.6", - "@babel/types": "^7.9.0", + "@babel/helper-module-imports": "^7.10.1", + "@babel/helper-replace-supers": "^7.10.1", + "@babel/helper-simple-access": "^7.10.1", + "@babel/helper-split-export-declaration": "^7.10.1", + "@babel/template": "^7.10.1", + "@babel/types": "^7.10.1", "lodash": "^4.17.13" + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz", + "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.1" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz", + "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", + "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", + "dev": true + }, + "@babel/highlight": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz", + "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz", + "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==", + "dev": true + }, + "@babel/template": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz", + "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/types": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz", + "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "@babel/helper-optimise-call-expression": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.8.3.tgz", - "integrity": "sha512-Kag20n86cbO2AvHca6EJsvqAd82gc6VMGule4HwebwMlwkpXuVqrNRj6CkCV2sKxgi9MyAUnZVnZ6lJ1/vKhHQ==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.1.tgz", + "integrity": "sha512-a0DjNS1prnBsoKx83dP2falChcs7p3i8VMzdrSbfLhuQra/2ENC4sbri34dz/rWmDADsmF1q5GbfaXydh0Jbjg==", "dev": true, "requires": { - "@babel/types": "^7.8.3" + "@babel/types": "^7.10.1" + }, + "dependencies": { + "@babel/helper-validator-identifier": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", + "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", + "dev": true + }, + "@babel/types": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz", + "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + } } }, "@babel/helper-plugin-utils": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.8.3.tgz", - "integrity": "sha512-j+fq49Xds2smCUNYmEHF9kGNkhbet6yVIBp4e6oeQpH1RUs/Ir06xUKzDjDkGcaaokPiTNs2JBWHjaE4csUkZQ==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.1.tgz", + "integrity": "sha512-fvoGeXt0bJc7VMWZGCAEBEMo/HAjW2mP8apF5eXK0wSqwLAVHAISCWRoLMBMUs2kqeaG77jltVqu4Hn8Egl3nA==", "dev": true }, "@babel/helper-replace-supers": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.9.6.tgz", - "integrity": "sha512-qX+chbxkbArLyCImk3bWV+jB5gTNU/rsze+JlcF6Nf8tVTigPJSI1o1oBow/9Resa1yehUO9lIipsmu9oG4RzA==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.1.tgz", + "integrity": "sha512-SOwJzEfpuQwInzzQJGjGaiG578UYmyi2Xw668klPWV5n07B73S0a9btjLk/52Mlcxa+5AdIYqws1KyXRfMoB7A==", "dev": true, "requires": { - "@babel/helper-member-expression-to-functions": "^7.8.3", - "@babel/helper-optimise-call-expression": "^7.8.3", - "@babel/traverse": "^7.9.6", - "@babel/types": "^7.9.6" + "@babel/helper-member-expression-to-functions": "^7.10.1", + "@babel/helper-optimise-call-expression": "^7.10.1", + "@babel/traverse": "^7.10.1", + "@babel/types": "^7.10.1" }, "dependencies": { + "@babel/code-frame": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz", + "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.1" + } + }, "@babel/generator": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.6.tgz", - "integrity": "sha512-+htwWKJbH2bL72HRluF8zumBxzuX0ZZUFl3JLNyoUjM/Ho8wnVpPXM6aUz8cfKDqQ/h7zHqKt4xzJteUosckqQ==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.1.tgz", + "integrity": "sha512-AT0YPLQw9DI21tliuJIdplVfLHya6mcGa8ctkv7n4Qv+hYacJrKmNWIteAK1P9iyLikFIAkwqJ7HAOqIDLFfgA==", "dev": true, "requires": { - "@babel/types": "^7.9.6", + "@babel/types": "^7.10.1", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" } }, "@babel/helper-function-name": { - "version": "7.9.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz", - "integrity": "sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.1.tgz", + "integrity": "sha512-fcpumwhs3YyZ/ttd5Rz0xn0TpIwVkN7X0V38B9TWNfVF42KEkhkAAuPCQ3oXmtTRtiPJrmZ0TrfS0GKF0eMaRQ==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.10.1", + "@babel/template": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.1.tgz", + "integrity": "sha512-F5qdXkYGOQUb0hpRaPoetF9AnsXknKjWMZ+wmsIRsp5ge5sFh4c3h1eH2pRTTuy9KKAA2+TTYomGXAtEL2fQEw==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "^7.8.3", - "@babel/template": "^7.8.3", - "@babel/types": "^7.9.5" + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz", + "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" } }, "@babel/helper-validator-identifier": { - "version": "7.9.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz", - "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", + "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", "dev": true }, + "@babel/highlight": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz", + "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, "@babel/parser": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.6.tgz", - "integrity": "sha512-AoeIEJn8vt+d/6+PXDRPaksYhnlbMIiejioBZvvMQsOjW/JYK6k/0dKnvvP3EhK5GfMBWDPtrxRtegWdAcdq9Q==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz", + "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==", "dev": true }, + "@babel/template": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz", + "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, "@babel/traverse": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.6.tgz", - "integrity": "sha512-b3rAHSjbxy6VEAvlxM8OV/0X4XrG72zoxme6q1MOoe2vd0bEc+TwayhuC1+Dfgqh1QEG+pj7atQqvUprHIccsg==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.1.tgz", + "integrity": "sha512-C/cTuXeKt85K+p08jN6vMDz8vSV0vZcI0wmQ36o6mjbuo++kPMdpOYw23W2XH04dbRt9/nMEfA4W3eR21CD+TQ==", "dev": true, "requires": { - "@babel/code-frame": "^7.8.3", - "@babel/generator": "^7.9.6", - "@babel/helper-function-name": "^7.9.5", - "@babel/helper-split-export-declaration": "^7.8.3", - "@babel/parser": "^7.9.6", - "@babel/types": "^7.9.6", + "@babel/code-frame": "^7.10.1", + "@babel/generator": "^7.10.1", + "@babel/helper-function-name": "^7.10.1", + "@babel/helper-split-export-declaration": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" } }, "@babel/types": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.6.tgz", - "integrity": "sha512-qxXzvBO//jO9ZnoasKF1uJzHd2+M6Q2ZPIVfnFps8JJvXy0ZBbwbNOmE6SGIY5XOY6d1Bo5lb9d9RJ8nv3WSeA==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz", + "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.9.5", + "@babel/helper-validator-identifier": "^7.10.1", "lodash": "^4.17.13", "to-fast-properties": "^2.0.0" } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } } } }, "@babel/helper-simple-access": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.8.3.tgz", - "integrity": "sha512-VNGUDjx5cCWg4vvCTR8qQ7YJYZ+HBjxOgXEl7ounz+4Sn7+LMD3CFrCTEU6/qXKbA2nKg21CwhhBzO0RpRbdCw==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.1.tgz", + "integrity": "sha512-VSWpWzRzn9VtgMJBIWTZ+GP107kZdQ4YplJlCmIrjoLVSi/0upixezHCDG8kpPVTBJpKfxTH01wDhh+jS2zKbw==", "dev": true, "requires": { - "@babel/template": "^7.8.3", - "@babel/types": "^7.8.3" + "@babel/template": "^7.10.1", + "@babel/types": "^7.10.1" + }, + "dependencies": { + "@babel/code-frame": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz", + "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.1" + } + }, + "@babel/helper-validator-identifier": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", + "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", + "dev": true + }, + "@babel/highlight": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz", + "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz", + "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==", + "dev": true + }, + "@babel/template": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz", + "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/types": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz", + "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } } }, "@babel/helper-split-export-declaration": { @@ -308,78 +784,177 @@ "dev": true }, "@babel/helpers": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.9.6.tgz", - "integrity": "sha512-tI4bUbldloLcHWoRUMAj4g1bF313M/o6fBKhIsb3QnGVPwRm9JsNf/gqMkQ7zjqReABiffPV6RWj7hEglID5Iw==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.1.tgz", + "integrity": "sha512-muQNHF+IdU6wGgkaJyhhEmI54MOZBKsFfsXFhboz1ybwJ1Kl7IHlbm2a++4jwrmY5UYsgitt5lfqo1wMFcHmyw==", "dev": true, "requires": { - "@babel/template": "^7.8.3", - "@babel/traverse": "^7.9.6", - "@babel/types": "^7.9.6" + "@babel/template": "^7.10.1", + "@babel/traverse": "^7.10.1", + "@babel/types": "^7.10.1" }, "dependencies": { + "@babel/code-frame": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz", + "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.1" + } + }, "@babel/generator": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.6.tgz", - "integrity": "sha512-+htwWKJbH2bL72HRluF8zumBxzuX0ZZUFl3JLNyoUjM/Ho8wnVpPXM6aUz8cfKDqQ/h7zHqKt4xzJteUosckqQ==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.1.tgz", + "integrity": "sha512-AT0YPLQw9DI21tliuJIdplVfLHya6mcGa8ctkv7n4Qv+hYacJrKmNWIteAK1P9iyLikFIAkwqJ7HAOqIDLFfgA==", "dev": true, "requires": { - "@babel/types": "^7.9.6", + "@babel/types": "^7.10.1", "jsesc": "^2.5.1", "lodash": "^4.17.13", "source-map": "^0.5.0" } }, "@babel/helper-function-name": { - "version": "7.9.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.9.5.tgz", - "integrity": "sha512-JVcQZeXM59Cd1qanDUxv9fgJpt3NeKUaqBqUEvfmQ+BCOKq2xUgaWZW2hr0dkbyJgezYuplEoh5knmrnS68efw==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.1.tgz", + "integrity": "sha512-fcpumwhs3YyZ/ttd5Rz0xn0TpIwVkN7X0V38B9TWNfVF42KEkhkAAuPCQ3oXmtTRtiPJrmZ0TrfS0GKF0eMaRQ==", "dev": true, "requires": { - "@babel/helper-get-function-arity": "^7.8.3", - "@babel/template": "^7.8.3", - "@babel/types": "^7.9.5" + "@babel/helper-get-function-arity": "^7.10.1", + "@babel/template": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.1.tgz", + "integrity": "sha512-F5qdXkYGOQUb0hpRaPoetF9AnsXknKjWMZ+wmsIRsp5ge5sFh4c3h1eH2pRTTuy9KKAA2+TTYomGXAtEL2fQEw==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz", + "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" } }, "@babel/helper-validator-identifier": { - "version": "7.9.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz", - "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", + "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", "dev": true }, + "@babel/highlight": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz", + "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, "@babel/parser": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.6.tgz", - "integrity": "sha512-AoeIEJn8vt+d/6+PXDRPaksYhnlbMIiejioBZvvMQsOjW/JYK6k/0dKnvvP3EhK5GfMBWDPtrxRtegWdAcdq9Q==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.1.tgz", + "integrity": "sha512-AUTksaz3FqugBkbTZ1i+lDLG5qy8hIzCaAxEtttU6C0BtZZU9pkNZtWSVAht4EW9kl46YBiyTGMp9xTTGqViNg==", "dev": true }, + "@babel/template": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz", + "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, "@babel/traverse": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.6.tgz", - "integrity": "sha512-b3rAHSjbxy6VEAvlxM8OV/0X4XrG72zoxme6q1MOoe2vd0bEc+TwayhuC1+Dfgqh1QEG+pj7atQqvUprHIccsg==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.1.tgz", + "integrity": "sha512-C/cTuXeKt85K+p08jN6vMDz8vSV0vZcI0wmQ36o6mjbuo++kPMdpOYw23W2XH04dbRt9/nMEfA4W3eR21CD+TQ==", "dev": true, "requires": { - "@babel/code-frame": "^7.8.3", - "@babel/generator": "^7.9.6", - "@babel/helper-function-name": "^7.9.5", - "@babel/helper-split-export-declaration": "^7.8.3", - "@babel/parser": "^7.9.6", - "@babel/types": "^7.9.6", + "@babel/code-frame": "^7.10.1", + "@babel/generator": "^7.10.1", + "@babel/helper-function-name": "^7.10.1", + "@babel/helper-split-export-declaration": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.13" } }, "@babel/types": { - "version": "7.9.6", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.6.tgz", - "integrity": "sha512-qxXzvBO//jO9ZnoasKF1uJzHd2+M6Q2ZPIVfnFps8JJvXy0ZBbwbNOmE6SGIY5XOY6d1Bo5lb9d9RJ8nv3WSeA==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.1.tgz", + "integrity": "sha512-L2yqUOpf3tzlW9GVuipgLEcZxnO+96SzR6fjXMuxxNkIgFJ5+07mHCZ+HkHqaeZu8+3LKnNJJ1bKbjBETQAsrA==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.9.5", + "@babel/helper-validator-identifier": "^7.10.1", "lodash": "^4.17.13", "to-fast-properties": "^2.0.0" } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } } } }, @@ -470,12 +1045,12 @@ } }, "@babel/plugin-syntax-class-properties": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.8.3.tgz", - "integrity": "sha512-UcAyQWg2bAN647Q+O811tG9MrJ38Z10jjhQdKNAL8fsyPzE3cCN/uT+f55cFVY4aGO4jqJAvmqsuY3GQDwAoXg==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.10.1.tgz", + "integrity": "sha512-Gf2Yx/iRs1JREDtVZ56OrjjgFHCaldpTnuy9BHla10qyVT3YkIIGEtoDWhyop0ksu1GvNjHIoYRBqm3zoR1jyQ==", "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.8.3" + "@babel/helper-plugin-utils": "^7.10.1" } }, "@babel/plugin-syntax-json-strings": { @@ -488,12 +1063,12 @@ } }, "@babel/plugin-syntax-logical-assignment-operators": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.8.3.tgz", - "integrity": "sha512-Zpg2Sgc++37kuFl6ppq2Q7Awc6E6AIW671x5PY8E/f7MCIyPPGK/EoeZXvvY3P42exZ3Q4/t3YOzP/HiN79jDg==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.1.tgz", + "integrity": "sha512-XyHIFa9kdrgJS91CUH+ccPVTnJShr8nLGc5bG2IhGXv5p1Rd+8BleGE5yzIg2Nc1QZAdHDa0Qp4m6066OL96Iw==", "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.8.3" + "@babel/helper-plugin-utils": "^7.10.1" } }, "@babel/plugin-syntax-nullish-coalescing-operator": { @@ -506,12 +1081,12 @@ } }, "@babel/plugin-syntax-numeric-separator": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.8.3.tgz", - "integrity": "sha512-H7dCMAdN83PcCmqmkHB5dtp+Xa9a6LKSvA2hiFBC/5alSHxM5VgWZXFqDi0YFe8XNGT6iCa+z4V4zSt/PdZ7Dw==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.1.tgz", + "integrity": "sha512-uTd0OsHrpe3tH5gRPTxG8Voh99/WCU78vIm5NMRYPAqC8lR4vajt6KkCAknCHrx24vkPdd/05yfdGSB4EIY2mg==", "dev": true, "requires": { - "@babel/helper-plugin-utils": "^7.8.3" + "@babel/helper-plugin-utils": "^7.10.1" } }, "@babel/plugin-syntax-object-rest-spread": { @@ -616,13 +1191,14 @@ } }, "@istanbuljs/load-nyc-config": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.0.0.tgz", - "integrity": "sha512-ZR0rq/f/E4f4XcgnDvtMWXCUJpi8eO0rssVhmztsZqLIEFA9UUP9zmpE0VxlM+kv/E1ul2I876Fwil2ayptDVg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", "dev": true, "requires": { "camelcase": "^5.3.1", "find-up": "^4.1.0", + "get-package-type": "^0.1.0", "js-yaml": "^3.13.1", "resolve-from": "^5.0.0" }, @@ -971,20 +1547,21 @@ } }, "@netlify/open-api": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/@netlify/open-api/-/open-api-0.14.0.tgz", - "integrity": "sha512-epAbGVkUtFutiVDBqqepW/6Le619rGk79bnhEO7pMRMoVlPt3ga/hiFrqxozXI+QUvcHw6lvDSli6MLAonBIig==" + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@netlify/open-api/-/open-api-0.15.0.tgz", + "integrity": "sha512-Nk1NswVrUtI7SDbyn/uvITYeIG5iukKlhsu/6fg4k1G5RMHqMDtVHy+2qcOhKmkf7Qc3ZkIKKd2mQfM6zg2cxw==" }, "@netlify/zip-it-and-ship-it": { - "version": "0.4.0-18", - "resolved": "https://registry.npmjs.org/@netlify/zip-it-and-ship-it/-/zip-it-and-ship-it-0.4.0-18.tgz", - "integrity": "sha512-UzmG6WWi8tspqQX3nwIw9qtN2i5HJin51KC25Y2DnRjUXj1QEX0OCa/NJEfjHD4tPd0tEjmhZ1k2vuZ5ndjZ7w==", + "version": "0.4.0-19", + "resolved": "https://registry.npmjs.org/@netlify/zip-it-and-ship-it/-/zip-it-and-ship-it-0.4.0-19.tgz", + "integrity": "sha512-QjGw5d8iTa9JLqFzMJw2DPYAmG0q7mfZsahf5rPPCmdNty/HkmNTkSswgxuTX+BCXsfjCnfCGbVZbM+8crIT0w==", "requires": { "archiver": "^3.0.0", "common-path-prefix": "^2.0.0", "cp-file": "^7.0.0", "elf-tools": "^1.1.1", "end-of-stream": "^1.4.4", + "find-up": "^4.1.0", "glob": "^7.1.6", "make-dir": "^3.0.2", "p-map": "^3.0.0", @@ -993,6 +1570,7 @@ "precinct": "^6.2.0", "require-package-name": "^2.0.1", "resolve": "^2.0.0-next.1", + "semver": "^7.3.2", "unixify": "^1.0.0", "util.promisify": "^1.0.1", "yargs": "^15.3.1" @@ -1056,34 +1634,39 @@ "requires": { "path-parse": "^1.0.6" } + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==" } } }, "@octokit/auth-token": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.0.tgz", - "integrity": "sha512-eoOVMjILna7FVQf96iWc3+ZtE/ZT6y8ob8ZzcqKY1ibSQCnu4O/B7pJvzMx5cyZ/RjAff6DAdEb0O0Cjcxidkg==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.4.1.tgz", + "integrity": "sha512-NB81O5h39KfHYGtgfWr2booRxp2bWOJoqbWwbyUg2hw6h35ArWYlAST5B3XwAkbdcx13yt84hFXyFP5X0QToWA==", "requires": { - "@octokit/types": "^2.0.0" + "@octokit/types": "^4.0.1" } }, "@octokit/endpoint": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.1.tgz", - "integrity": "sha512-pOPHaSz57SFT/m3R5P8MUu4wLPszokn5pXcB/pzavLTQf2jbU+6iayTvzaY6/BiotuRS0qyEUkx3QglT4U958A==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.2.tgz", + "integrity": "sha512-xs1mmCEZ2y4shXCpFjNq3UbmNR+bLzxtZim2L0zfEtj9R6O6kc4qLDvYw66hvO6lUsYzPTM5hMkltbuNAbRAcQ==", "requires": { - "@octokit/types": "^2.11.1", + "@octokit/types": "^4.0.1", "is-plain-object": "^3.0.0", "universal-user-agent": "^5.0.0" } }, "@octokit/graphql": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.4.0.tgz", - "integrity": "sha512-Du3hAaSROQ8EatmYoSAJjzAz3t79t9Opj/WY1zUgxVUGfIKn0AEjg+hlOLscF6fv6i/4y/CeUvsWgIfwMkTccw==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.5.0.tgz", + "integrity": "sha512-StJWfn0M1QfhL3NKBz31e1TdDNZrHLLS57J2hin92SIfzlOVBuUaRkp31AGkGOAFOAVtyEX6ZiZcsjcJDjeb5g==", "requires": { "@octokit/request": "^5.3.0", - "@octokit/types": "^2.0.0", + "@octokit/types": "^4.0.1", "universal-user-agent": "^5.0.0" } }, @@ -1093,6 +1676,16 @@ "integrity": "sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q==", "requires": { "@octokit/types": "^2.0.1" + }, + "dependencies": { + "@octokit/types": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.16.2.tgz", + "integrity": "sha512-O75k56TYvJ8WpAakWwYRN8Bgu60KrmX0z1KqFp1kNiFNkgW+JW+9EBKZ+S33PU6SLvbihqd+3drvPxKK68Ee8Q==", + "requires": { + "@types/node": ">= 8" + } + } } }, "@octokit/plugin-request-log": { @@ -1107,16 +1700,26 @@ "requires": { "@octokit/types": "^2.0.1", "deprecation": "^2.3.1" + }, + "dependencies": { + "@octokit/types": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.16.2.tgz", + "integrity": "sha512-O75k56TYvJ8WpAakWwYRN8Bgu60KrmX0z1KqFp1kNiFNkgW+JW+9EBKZ+S33PU6SLvbihqd+3drvPxKK68Ee8Q==", + "requires": { + "@types/node": ">= 8" + } + } } }, "@octokit/request": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.2.tgz", - "integrity": "sha512-zKdnGuQ2TQ2vFk9VU8awFT4+EYf92Z/v3OlzRaSh4RIP0H6cvW1BFPXq4XYvNez+TPQjqN+0uSkCYnMFFhcFrw==", + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.4.tgz", + "integrity": "sha512-vqv1lz41c6VTxUvF9nM+a6U+vvP3vGk7drDpr0DVQg4zyqlOiKVrY17DLD6de5okj+YLHKcoqaUZTBtlNZ1BtQ==", "requires": { "@octokit/endpoint": "^6.0.1", "@octokit/request-error": "^2.0.0", - "@octokit/types": "^2.11.1", + "@octokit/types": "^4.0.1", "deprecation": "^2.0.0", "is-plain-object": "^3.0.0", "node-fetch": "^2.3.0", @@ -1125,11 +1728,11 @@ } }, "@octokit/request-error": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.0.tgz", - "integrity": "sha512-rtYicB4Absc60rUv74Rjpzek84UbVHGHJRu4fNVlZ1mCcyUPPuzFfG9Rn6sjHrd95DEsmjSt1Axlc699ZlbDkw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.0.1.tgz", + "integrity": "sha512-5lqBDJ9/TOehK82VvomQ6zFiZjPeSom8fLkFVLuYL3sKiIb5RB8iN/lenLkY7oBmyQcGP7FBMGiIZTO8jufaRQ==", "requires": { - "@octokit/types": "^2.0.0", + "@octokit/types": "^4.0.1", "deprecation": "^2.0.0", "once": "^1.4.0" } @@ -1167,6 +1770,14 @@ "once": "^1.4.0" } }, + "@octokit/types": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.16.2.tgz", + "integrity": "sha512-O75k56TYvJ8WpAakWwYRN8Bgu60KrmX0z1KqFp1kNiFNkgW+JW+9EBKZ+S33PU6SLvbihqd+3drvPxKK68Ee8Q==", + "requires": { + "@types/node": ">= 8" + } + }, "universal-user-agent": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-4.0.1.tgz", @@ -1178,17 +1789,17 @@ } }, "@octokit/types": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-2.15.0.tgz", - "integrity": "sha512-0mnpenB8rLhBVu8VUklp38gWi+EatjvcEcLWcdProMKauSaQWWepOAybZ714sOGsEyhXPlIcHICggn8HUsCXVw==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-4.0.2.tgz", + "integrity": "sha512-+4X6qfhT/fk/5FD66395NrFLxCzD6FsGlpPwfwvnukdyfYbhiZB/FJltiT1XM5Q63rGGBSf9FPaNV3WpNHm54A==", "requires": { "@types/node": ">= 8" } }, "@sinonjs/commons": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.7.2.tgz", - "integrity": "sha512-+DUO6pnp3udV/v2VfUWgaY5BIE1IfT7lLfeDzPVeMT1XKkaAp9LgSI9x5RtrFQoZ9Oi0PgXQQHPaoKu7dCjVxw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.0.tgz", + "integrity": "sha512-wEj54PfsZ5jGSwMX68G8ZXFawcSglQSXqCftWX3ec8MDUzQdHgcKvw97awHbY0efQEL5iKUOAmmVtoYgmrSG4Q==", "dev": true, "requires": { "type-detect": "4.0.8" @@ -1265,9 +1876,9 @@ } }, "@types/istanbul-lib-coverage": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz", - "integrity": "sha512-hRJD2ahnnpLgsj6KWMYSrmXkM3rm2Dl1qkx6IOFD5FnuNPXJIG5L0dhgKXCYTRMGzU4n0wImQ/xfmRc4POUFlg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.2.tgz", + "integrity": "sha512-rsZg7eL+Xcxsxk2XlBt9KcG8nOp9iYdKCOikY9x2RFJCyOdNj4MKPQty0e8oZr29vVAzKXr1BmR+kZauti3o1w==", "dev": true }, "@types/istanbul-lib-report": { @@ -1280,9 +1891,9 @@ } }, "@types/istanbul-reports": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-1.1.1.tgz", - "integrity": "sha512-UpYjBi8xefVChsCoBpKShdxTllC9pwISirfoZsUa2AAdQg/Jd2KQGtSbw+ya7GPo7x/wAPlH6JBhKhAsXUEZNA==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-1.1.2.tgz", + "integrity": "sha512-P/W9yOX/3oPZSpaYOCQzGqgCQRXn0FFO/V8bWrCQs+wLmvVVxk6CRBXALEvNs9OHIatlnlFokfhuDo2ug01ciw==", "dev": true, "requires": { "@types/istanbul-lib-coverage": "*", @@ -1290,9 +1901,9 @@ } }, "@types/jest": { - "version": "25.2.1", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.2.1.tgz", - "integrity": "sha512-msra1bCaAeEdkSyA0CZ6gW1ukMIvZ5YoJkdXw/qhQdsuuDlFTcEUrUw8CLCPt2rVRUfXlClVvK2gvPs9IokZaA==", + "version": "25.2.3", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.2.3.tgz", + "integrity": "sha512-JXc1nK/tXHiDhV55dvfzqtmP4S3sy3T3ouV2tkViZgxY/zeUkcpQcQPGRlgF4KmWzWW5oiWYSZwtCB+2RsE4Fw==", "dev": true, "requires": { "jest-diff": "^25.2.1", @@ -1306,9 +1917,9 @@ "dev": true }, "@types/node": { - "version": "12.12.38", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.38.tgz", - "integrity": "sha512-75eLjX0pFuTcUXnnWmALMzzkYorjND0ezNEycaKesbUBg9eGZp4GHPuDmkRc4mQQvIpe29zrzATNRA6hkYqwmA==" + "version": "12.12.42", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.42.tgz", + "integrity": "sha512-R/9QdYFLL9dE9l5cWWzWIZByVGFd7lk7JVOJ7KD+E1SJ4gni7XJRLz9QTjyYQiHIqEAgku9VgxdLjMlhhUaAFg==" }, "@types/normalize-package-data": { "version": "2.4.0", @@ -1329,9 +1940,9 @@ "dev": true }, "@types/yargs": { - "version": "15.0.4", - "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.4.tgz", - "integrity": "sha512-9T1auFmbPZoxHz0enUFlUuKRy3it01R+hlggyVUMtnCTQRunsQYifnSGb8hET4Xo8yiC0o0r1paW3ud5+rbURg==", + "version": "15.0.5", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.5.tgz", + "integrity": "sha512-Dk/IDOPtOgubt/IaevIUbTgV7doaKkoorvOyYM2CMwuDyP89bekI7H4xLIwunNYiK9jhCkmc6pUrJk3cj2AB9w==", "dev": true, "requires": { "@types/yargs-parser": "*" @@ -1405,54 +2016,89 @@ } }, "@typescript-eslint/experimental-utils": { - "version": "2.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.31.0.tgz", - "integrity": "sha512-MI6IWkutLYQYTQgZ48IVnRXmLR/0Q6oAyJgiOror74arUMh7EWjJkADfirZhRsUMHeLJ85U2iySDwHTSnNi9vA==", + "version": "2.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.34.0.tgz", + "integrity": "sha512-eS6FTkq+wuMJ+sgtuNTtcqavWXqsflWcfBnlYhg/nS4aZ1leewkXGbvBhaapn1q6qf4M71bsR1tez5JTRMuqwA==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.31.0", + "@typescript-eslint/typescript-estree": "2.34.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { - "version": "2.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.31.0.tgz", - "integrity": "sha512-uph+w6xUOlyV2DLSC6o+fBDzZ5i7+3/TxAsH4h3eC64tlga57oMb96vVlXoMwjR/nN+xyWlsnxtbDkB46M2EPQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-3.0.2.tgz", + "integrity": "sha512-80Z7s83e8QXHNUspqVlWwb4t5gdz/1bBBmafElbK1wwAwiD/yvJsFyHRxlEpNrt4rdK6eB3p+2WEFkEDHAKk9w==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.31.0", - "@typescript-eslint/typescript-estree": "2.31.0", + "@typescript-eslint/experimental-utils": "3.0.2", + "@typescript-eslint/typescript-estree": "3.0.2", "eslint-visitor-keys": "^1.1.0" + }, + "dependencies": { + "@typescript-eslint/experimental-utils": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-3.0.2.tgz", + "integrity": "sha512-4Wc4EczvoY183SSEnKgqAfkj1eLtRgBQ04AAeG+m4RhTVyaazxc1uI8IHf0qLmu7xXe9j1nn+UoDJjbmGmuqXQ==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.3", + "@typescript-eslint/typescript-estree": "3.0.2", + "eslint-scope": "^5.0.0", + "eslint-utils": "^2.0.0" + } + }, + "@typescript-eslint/typescript-estree": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-3.0.2.tgz", + "integrity": "sha512-cs84mxgC9zQ6viV8MEcigfIKQmKtBkZNDYf8Gru2M+MhnA6z9q0NFMZm2IEzKqAwN8lY5mFVd1Z8DiHj6zQ3Tw==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "eslint-visitor-keys": "^1.1.0", + "glob": "^7.1.6", + "is-glob": "^4.0.1", + "lodash": "^4.17.15", + "semver": "^7.3.2", + "tsutils": "^3.17.1" + } + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + } } }, "@typescript-eslint/typescript-estree": { - "version": "2.31.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.31.0.tgz", - "integrity": "sha512-vxW149bXFXXuBrAak0eKHOzbcu9cvi6iNcJDzEtOkRwGHxJG15chiAQAwhLOsk+86p9GTr/TziYvw+H9kMaIgA==", + "version": "2.34.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.34.0.tgz", + "integrity": "sha512-OMAr+nJWKdlVM9LOqCqh3pQQPwxHAN7Du8DR6dmwCrAmxtiXQnhHJ6tBNtf+cggqfo51SG/FCwnKhXCIM7hnVg==", "requires": { "debug": "^4.1.1", "eslint-visitor-keys": "^1.1.0", "glob": "^7.1.6", "is-glob": "^4.0.1", "lodash": "^4.17.15", - "semver": "^6.3.0", + "semver": "^7.3.2", "tsutils": "^3.17.1" }, "dependencies": { "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==" } } }, "@zeit/ncc": { - "version": "0.22.1", - "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.1.tgz", - "integrity": "sha512-Qq3bMuonkcnV/96jhy9SQYdh39NXHxNMJ1O31ZFzWG9n52fR2DLtgrNzhj/ahlEjnBziMLGVWDbaS9sf03/fEw==", + "version": "0.22.3", + "resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.22.3.tgz", + "integrity": "sha512-jnCLpLXWuw/PAiJiVbLjA8WBC0IJQbFeUwF4I9M+23MvIxTxk5pD4Q8byQBSPmHQjz5aBoA7AKAElQxMpjrCLQ==", "dev": true }, "abab": { @@ -1727,9 +2373,9 @@ "dev": true }, "aws4": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz", - "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.0.tgz", + "integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==", "dev": true }, "axobject-query": { @@ -3092,9 +3738,9 @@ } }, "eslint-plugin-jest": { - "version": "23.10.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.10.0.tgz", - "integrity": "sha512-cHC//nesojSO1MLxVmFJR/bUaQQG7xvMHQD8YLbsQzevR41WKm8paKDUv2wMHlUy5XLZUmNcWuflOi4apS8D+Q==", + "version": "23.13.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.13.2.tgz", + "integrity": "sha512-qZit+moTXTyZFNDqSIR88/L3rdBlTU7CuW6XmyErD2FfHEkdoLgThkRbiQjzgYnX6rfgLx3Ci4eJmF4Ui5v1Cw==", "dev": true, "requires": { "@typescript-eslint/experimental-utils": "^2.5.0" @@ -3693,6 +4339,12 @@ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" }, + "get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true + }, "get-stdin": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", @@ -4411,15 +5063,12 @@ "dev": true }, "istanbul-lib-instrument": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.1.tgz", - "integrity": "sha512-imIchxnodll7pvQBYOqUu88EufLCU56LMeFPZZM/fJZ1irYcYdqroaV+ACK1Ila8ls09iEYArp+nqyC6lW1Vfg==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", + "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", "dev": true, "requires": { "@babel/core": "^7.7.5", - "@babel/parser": "^7.7.5", - "@babel/template": "^7.7.4", - "@babel/traverse": "^7.7.4", "@istanbuljs/schema": "^0.1.2", "istanbul-lib-coverage": "^3.0.0", "semver": "^6.3.0" @@ -4526,9 +5175,9 @@ }, "dependencies": { "cross-spawn": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.2.tgz", - "integrity": "sha512-PD6G8QG3S4FK/XCGFbEQrDqO2AnMMsy0meR7lerlIOHAAbkuavGU/pOqprrlvfTNjvowivTeBsjebAL0NSoMxw==", + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "requires": { "path-key": "^3.1.0", @@ -4777,15 +5426,15 @@ } }, "@types/prettier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.0.0.tgz", - "integrity": "sha512-/rM+sWiuOZ5dvuVzV37sUuklsbg+JPOP8d+nNFlo2ZtfpzPiPvh1/gc8liWOLBqe+sR+ZM7guPaIcTt6UZTo7Q==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.0.1.tgz", + "integrity": "sha512-boy4xPNEtiw6N3abRhBi/e7hNvy3Tt8E9ZRAQrwAGzoCGZS/1wjo9KY7JHhnfnEsG5wSjDbymCozUM9a3ea7OQ==", "dev": true }, "acorn": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", - "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", + "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", "dev": true }, "acorn-globals": { @@ -6105,9 +6754,9 @@ "dev": true }, "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", + "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -6155,9 +6804,9 @@ }, "dependencies": { "acorn": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", - "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", + "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", "dev": true } } @@ -6605,12 +7254,12 @@ "integrity": "sha512-AO81vsIO1k1sM4Zrd6Hu7regmJN1NSiAja10gc4bX3F0wd+9rQmcuHQaHVQCYIEC8iFXnE+mavh23GOt7wBgug==" }, "netlify": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/netlify/-/netlify-4.1.5.tgz", - "integrity": "sha512-73OLoP60bc09fKXyOzTel+QALKJQS5Y9WYZphzTmkNTqXeq3vDVfaF7e50Cl7vppTxwpZ0r4YQVQt24TPu3UDw==", + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/netlify/-/netlify-4.1.7.tgz", + "integrity": "sha512-MMI84bLb1QrkAadnNRvglcUbje+hJNQo3ZEUAYJSUiQ4QPpIp9cuayFtfJ/N/dYRPehNiH7B6ZbSZ9FfmpUyVA==", "requires": { - "@netlify/open-api": "^0.14.0", - "@netlify/zip-it-and-ship-it": "^0.4.0-18", + "@netlify/open-api": "^0.15.0", + "@netlify/zip-it-and-ship-it": "^0.4.0-19", "backoff": "^2.5.0", "clean-deep": "^3.3.0", "filter-obj": "^2.0.1", @@ -7145,9 +7794,9 @@ "dev": true }, "postcss": { - "version": "7.0.29", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.29.tgz", - "integrity": "sha512-ba0ApvR3LxGvRMMiUa9n0WR4HjzcYm7tS+ht4/2Nd0NLtHpPIH77fuB9Xh1/yJVz9O/E/95Y/dn8ygWsyffXtw==", + "version": "7.0.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-7.0.31.tgz", + "integrity": "sha512-a937VDHE1ftkjk+8/7nj/mrjtmkn69xxzJgRETXdAUU+IgOYPQNJF17haGWbeDxSyk++HA14UA98FurvPyBJOA==", "requires": { "chalk": "^2.4.2", "source-map": "^0.6.1", @@ -8788,9 +9437,9 @@ } }, "typescript": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", - "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==" + "version": "3.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", + "integrity": "sha512-D/wqnB2xzNFIcoBG9FG8cXRDjiqSTbG2wd8DMZeQyJlP1vfTkIxH4GKveWaEBYySKIg+USu+E+EDIR47SqnaMQ==" }, "union-value": { "version": "1.0.1", @@ -9132,9 +9781,9 @@ } }, "ws": { - "version": "7.2.5", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.5.tgz", - "integrity": "sha512-C34cIU4+DB2vMyAbmEKossWq2ZQDr6QEyuuCzWrM9zfw1sGc0mYiJ0UnG9zzNykt49C2Fi34hvr2vssFQRS6EA==", + "version": "7.3.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", + "integrity": "sha512-iFtXzngZVXPGgpTlP1rBqsUK82p9tKqsWRPg5L56egiljujJT3vGAYnHANvFxBieXrTFavhzhxW52jnaWV+w2w==", "dev": true }, "xml-name-validator": { diff --git a/package.json b/package.json index 76bb330b..add61868 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "actions-netlify", - "version": "1.1.0", + "version": "1.1.1", "private": true, "description": "GitHub Actions for Netlify", "main": "lib/main.js", @@ -26,21 +26,21 @@ "dependencies": { "@actions/core": "^1.2.4", "@actions/github": "^2.2.0", - "netlify": "^4.1.5" + "netlify": "^4.1.7" }, "devDependencies": { - "@types/jest": "^25.2.1", - "@types/node": "^12.12.38", - "@typescript-eslint/parser": "^2.31.0", - "@zeit/ncc": "^0.22.1", + "@types/jest": "^25.2.3", + "@types/node": "^12.12.42", + "@typescript-eslint/parser": "^3.0.2", + "@zeit/ncc": "^0.22.3", "eslint": "^5.16.0", "eslint-plugin-github": "^2.0.0", - "eslint-plugin-jest": "^23.10.0", + "eslint-plugin-jest": "^23.13.2", "jest": "^25.5.4", "jest-circus": "^26.0.1", - "js-yaml": "^3.13.1", + "js-yaml": "^3.14.0", "prettier": "^2.0.5", "ts-jest": "^25.5.1", - "typescript": "^3.8.3" + "typescript": "^3.9.3" } } diff --git a/src/inputs.ts b/src/inputs.ts index 964f76d1..b1d97587 100644 --- a/src/inputs.ts +++ b/src/inputs.ts @@ -9,6 +9,7 @@ export interface Inputs { enableCommitComment(): boolean githubToken(): string overwritesPullRequestComment(): boolean + netlifyConfigPath(): string | undefined } export const defaultInputs: Inputs = { @@ -37,5 +38,8 @@ export const defaultInputs: Inputs = { return ( (core.getInput('overwrites-pull-request-comment') || 'true') === 'true' ) + }, + netlifyConfigPath() { + return core.getInput('netlify-config-path') || undefined } } diff --git a/src/main.ts b/src/main.ts index 427fc7aa..3b11127d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -27,6 +27,33 @@ async function findIssueComment( return undefined } +async function createGitHubDeployment( + githubClient: GitHub, + environmentUrl: string, + environment: string +): Promise { + const {ref} = context + const deployment = await githubClient.repos.createDeployment({ + // eslint-disable-next-line @typescript-eslint/camelcase + auto_merge: false, + owner: context.repo.owner, + repo: context.repo.repo, + ref, + environment, + // eslint-disable-next-line @typescript-eslint/camelcase + required_contexts: [] + }) + await githubClient.repos.createDeploymentStatus({ + state: 'success', + // eslint-disable-next-line @typescript-eslint/camelcase + environment_url: environmentUrl, + owner: context.repo.owner, + repo: context.repo.repo, + // eslint-disable-next-line @typescript-eslint/camelcase + deployment_id: deployment.data.id + }) +} + async function run(inputs: Inputs): Promise { try { const netlifyAuthToken = process.env.NETLIFY_AUTH_TOKEN @@ -42,6 +69,7 @@ async function run(inputs: Inputs): Promise { const enablePullRequestComment: boolean = inputs.enablePullRequestComment() const enableCommitComment: boolean = inputs.enableCommitComment() const overwritesPullRequestComment: boolean = inputs.overwritesPullRequestComment() + const netlifyConfigPath: string | undefined = inputs.netlifyConfigPath() const isDraft: boolean = productionBranch === undefined || context.ref !== `refs/heads/${productionBranch}` @@ -53,7 +81,8 @@ async function run(inputs: Inputs): Promise { // Deploy to Netlify const deploy = await netlifyClient.deploy(siteId, deployFolder, { draft: isDraft, - message: deployMessage + message: deployMessage, + configPath: netlifyConfigPath }) // Create a message const message = isDraft @@ -95,35 +124,67 @@ async function run(inputs: Inputs): Promise { } } - // If it is a pull request and enable comment on pull request - if (context.issue.number !== undefined && enablePullRequestComment) { - let commentId: number | undefined = undefined - if (overwritesPullRequestComment) { - // Find issue comment - commentId = await findIssueComment(githubClient) + if (context.issue.number === undefined) { + try { + const environmentUrl = isDraft + ? deploy.deploy.deploy_ssl_url + : deploy.deploy.ssl_url + const environment = isDraft ? 'commit' : 'production' + // Create GitHub Deployment + await createGitHubDeployment( + githubClient, + environmentUrl, + environment + ) + } catch (err) { + // eslint-disable-next-line no-console + console.error(err) } + } + + // If it is a pull request and enable comment on pull request + if (context.issue.number !== undefined) { + if (enablePullRequestComment) { + let commentId: number | undefined = undefined + if (overwritesPullRequestComment) { + // Find issue comment + commentId = await findIssueComment(githubClient) + } - // NOTE: if not overwrite, commentId is always undefined - if (commentId !== undefined) { - // Update comment of the deploy URL - await githubClient.issues.updateComment({ - owner: context.issue.owner, - repo: context.issue.repo, - // eslint-disable-next-line @typescript-eslint/camelcase - comment_id: commentId, - body: markdownComment - }) - return + // NOTE: if not overwrite, commentId is always undefined + if (commentId !== undefined) { + // Update comment of the deploy URL + await githubClient.issues.updateComment({ + owner: context.issue.owner, + repo: context.issue.repo, + // eslint-disable-next-line @typescript-eslint/camelcase + comment_id: commentId, + body: markdownComment + }) + } else { + // Comment the deploy URL + await githubClient.issues.createComment({ + // eslint-disable-next-line @typescript-eslint/camelcase + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: markdownComment + }) + } } - // Comment the deploy URL - await githubClient.issues.createComment({ - // eslint-disable-next-line @typescript-eslint/camelcase - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: markdownComment - }) + try { + const environmentUrl = deploy.deploy.deploy_ssl_url + // Create GitHub Deployment + await createGitHubDeployment( + githubClient, + environmentUrl, + 'pull request' + ) + } catch (err) { + // eslint-disable-next-line no-console + console.error(err) + } } } } catch (error) {