From 8f3a7c87ff74f694e8d2496c3238fe6c05aa2745 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 18 Mar 2021 12:18:52 +0300 Subject: [PATCH 01/13] add changes for check-latest --- .github/workflows/e2e-versions.yml | 37 + __tests__/distributors/base-installer.test.ts | 65 +- action.yml | 4 + dist/cleanup/index.js | 9471 ++---- dist/setup/index.js | 26616 +++++++--------- src/constants.ts | 1 + src/distributions/base-installer.ts | 12 +- src/distributions/base-models.ts | 1 + src/setup-java.ts | 4 +- 9 files changed, 15158 insertions(+), 21053 deletions(-) diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 40b2b473f..d283e078b 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -69,6 +69,43 @@ jobs: - name: Verify Java run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" shell: bash + + setup-java-major-minor-versions-with-check-latest: + name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} + needs: setup-java-major-versions + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + distribution: ['adopt', 'zulu'] + version: + - '11.0' + - '8.0.282' + - '11.0.2+7' + include: + - distribution: 'adopt' + version: '12.0.2+10.1' + os: macos-latest + - distribution: 'adopt' + version: '12.0.2+10.1' + os: windows-latest + - distribution: 'adopt' + version: '12.0.2+10.1' + os: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: setup-java + uses: ./ + id: setup-java + with: + java-version: ${{ matrix.version }} + distribution: ${{ matrix.distribution }} + check-latest: true + - name: Verify Java + run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" + shell: bash setup-java-ea-versions-zulu: name: zulu ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index e23c972b1..3fd28f53d 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -19,13 +19,13 @@ class EmptyJavaBase extends JavaBase { protected async downloadTool(javaRelease: JavaDownloadRelease): Promise { return { - version: '11.0.8', - path: `/toolcache/${this.toolcacheFolderName}/11.0.8/${this.architecture}` + version: '11.0.9', + path: `toolcache/${this.toolcacheFolderName}/11.0.9/${this.architecture}` }; } protected async findPackageForDownload(range: string): Promise { - const availableVersion = '11.0.8'; + const availableVersion = '11.0.9'; if (!semver.satisfies(availableVersion, range)) { throw new Error('Available version not found'); } @@ -38,7 +38,7 @@ class EmptyJavaBase extends JavaBase { } describe('findInToolcache', () => { - const actualJavaVersion = '11.1.10'; + const actualJavaVersion = '11.0.8'; const javaPath = path.join('Java_Empty_jdk', actualJavaVersion, 'x64'); let mockJavaBase: EmptyJavaBase; @@ -62,18 +62,30 @@ describe('findInToolcache', () => { { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.1', architecture: 'x64', packageType: 'jdk' }, + { version: '11.0', architecture: 'x64', packageType: 'jdk' }, { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.1.10', architecture: 'x64', packageType: 'jdk' }, + { version: '11.0.8', architecture: 'x64', packageType: 'jdk' }, + { version: actualJavaVersion, path: javaPath } + ], + [ + { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: true }, + { version: actualJavaVersion, path: javaPath } + ], + [ + { version: '11.0', architecture: 'x64', packageType: 'jdk', checkLatest: true }, + { version: actualJavaVersion, path: javaPath } + ], + [ + { version: '11.0.8', architecture: 'x64', packageType: 'jdk', checkLatest: true }, { version: actualJavaVersion, path: javaPath } ], [{ version: '11', architecture: 'x64', packageType: 'jre' }, null], [{ version: '8', architecture: 'x64', packageType: 'jdk' }, null], [{ version: '11', architecture: 'x86', packageType: 'jdk' }, null], [{ version: '11', architecture: 'x86', packageType: 'jre' }, null] - ])(`should find java for path %s -> %s`, (input, expected) => { + ])(`should find java for path %o -> %o`, (input, expected) => { spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); spyGetToolcachePath.mockImplementation( (toolname: string, javaVersion: string, architecture: string) => { @@ -122,8 +134,10 @@ describe('findInToolcache', () => { }); describe('setupJava', () => { - const actualJavaVersion = '11.1.10'; + const actualJavaVersion = '11.0.8'; + const installedJavaVersion = '11.0.9'; const javaPath = path.join('Java_Empty_jdk', actualJavaVersion, 'x86'); + const javaPathInstalled = path.join('toolcache', 'Java_Empty_jdk', installedJavaVersion, 'x86'); let mockJavaBase: EmptyJavaBase; @@ -181,31 +195,54 @@ describe('setupJava', () => { { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.1', architecture: 'x86', packageType: 'jdk' }, + { version: '11.0', architecture: 'x86', packageType: 'jdk' }, { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.1.10', architecture: 'x86', packageType: 'jdk' }, + { version: '11.0.8', architecture: 'x86', packageType: 'jdk' }, { version: actualJavaVersion, path: javaPath } ] - ])('should find java locally for %s', (input, expected) => { + ])('should find java locally for %o', (input, expected) => { mockJavaBase = new EmptyJavaBase(input); expect(mockJavaBase.setupJava()).resolves.toEqual(expected); expect(spyGetToolcachePath).toHaveBeenCalled(); }); + it.each([ + [ + { version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: true }, + { version: installedJavaVersion, path: javaPathInstalled } + ], + [ + { version: '11.0', architecture: 'x86', packageType: 'jdk', checkLatest: true }, + { version: installedJavaVersion, path: javaPathInstalled } + ], + [ + { version: '11.0.x', architecture: 'x86', packageType: 'jdk', checkLatest: true }, + { version: installedJavaVersion, path: javaPathInstalled } + ] + ])('should check the latest java version for %o', async (input, expected) => { + mockJavaBase = new EmptyJavaBase(input); + await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); + expect(spyGetToolcachePath).toHaveBeenCalled(); + expect(spyCoreInfo).toHaveBeenCalledWith( + `Java ${input.version} was not found in tool-cache. Trying to download...` + ); + expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${installedJavaVersion} was downloaded`); + }); + it.each([ [ { version: '11', architecture: 'x86', packageType: 'jre' }, - { path: `/toolcache/Java_Empty_jre/11.0.8/x86`, version: '11.0.8' } + { path: `toolcache/Java_Empty_jre/11.0.9/x86`, version: '11.0.9' } ], [ { version: '11', architecture: 'x64', packageType: 'jdk' }, - { path: `/toolcache/Java_Empty_jdk/11.0.8/x64`, version: '11.0.8' } + { path: `toolcache/Java_Empty_jdk/11.0.9/x64`, version: '11.0.9' } ], [ { version: '11', architecture: 'x64', packageType: 'jre' }, - { path: `/toolcache/Java_Empty_jre/11.0.8/x64`, version: '11.0.8' } + { path: `toolcache/Java_Empty_jre/11.0.9/x64`, version: '11.0.9' } ] ])('download java with configuration %s', async (input, expected) => { mockJavaBase = new EmptyJavaBase(input); diff --git a/action.yml b/action.yml index 406ad3a3e..5ba822884 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,10 @@ inputs: jdkFile: description: 'Path to where the compressed JDK is located' required: false + check-latest: + description: 'Set this option if you want the action to check for the latest available version that satisfies the version spec' + required: false + default: false server-id: description: 'ID of the distributionManagement repository in the pom.xml file. Default is `github`' diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index ca595b1bb..c63c2ae56 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -948,31 +948,9 @@ class ExecState extends events.EventEmitter { /***/ }), /***/ 16: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -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 - - -/***/ }), - -/***/ 20: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const Range = __webpack_require__(124) - -// 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 +/***/ (function(module) { +module.exports = require("tls"); /***/ }), @@ -998,7 +976,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const semver = __importStar(__webpack_require__(550)); +const semver = __importStar(__webpack_require__(280)); const core_1 = __webpack_require__(470); // needs to be require for core node modules to be mocked /* eslint @typescript-eslint/no-require-imports: 0 */ @@ -1087,300 +1065,6 @@ function _readLinuxVersionFile() { exports._readLinuxVersionFile = _readLinuxVersionFile; //# sourceMappingURL=manifest.js.map -/***/ }), - -/***/ 65: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const debug = __webpack_require__(548) -const { MAX_LENGTH, MAX_SAFE_INTEGER } = __webpack_require__(181) -const { re, t } = __webpack_require__(976) - -const parseOptions = __webpack_require__(143) -const { compareIdentifiers } = __webpack_require__(760) -class SemVer { - constructor (version, options) { - options = parseOptions(options) - - 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 - - /***/ }), /***/ 82: @@ -1452,5134 +1136,3553 @@ exports.issueCommand = issueCommand; /***/ }), -/***/ 120: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compareBuild = __webpack_require__(16) -const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) -module.exports = sort +/***/ 129: +/***/ (function(module) { +module.exports = require("child_process"); /***/ }), -/***/ 124: +/***/ 139: /***/ (function(module, __unusedexports, __webpack_require__) { -// hoisted class for cyclic dependency -class Range { - constructor (range, options) { - options = parseOptions(options) - - 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}`) - } - - // if we have any that are not the null set, throw out null sets. - if (this.set.length > 1) { - // keep the first one, in case they're all null sets - const first = this.set[0] - this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) - this.set = [first] - else if (this.set.length > 1) { - // if we have any that are *, then the range is just * - for (const c of this.set) { - if (c.length === 1 && isAny(c[0])) { - this.set = [c] - break - } - } - } - } - - this.format() - } - - format () { - this.range = this.set - .map((comps) => { - return comps.join(' ').trim() - }) - .join('||') - .trim() - return this.range - } +// Unique ID creation requires a high quality random # generator. In node.js +// this is pretty straight-forward - we use the crypto API. - toString () { - return this.range - } +var crypto = __webpack_require__(417); - parseRange (range) { - range = range.trim() - - // memoize range parsing for performance. - // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` - const cached = cache.get(memoKey) - if (cached) - return cached - - const loose = this.options.loose - // `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] - const rangeList = range - .split(' ') - .map(comp => parseComparator(comp, this.options)) - .join(' ') - .split(/\s+/) - // >=0.0.0 is equivalent to * - .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)) - - // if any comparators are the null set, then replace with JUST null set - // if more than one comparator, remove any * comparators - // also, don't include the same comparator more than once - const l = rangeList.length - const rangeMap = new Map() - for (const comp of rangeList) { - if (isNullSet(comp)) - return [comp] - rangeMap.set(comp.value, comp) - } - if (rangeMap.size > 1 && rangeMap.has('')) - rangeMap.delete('') - - const result = [...rangeMap.values()] - cache.set(memoKey, result) - return result - } +module.exports = function nodeRNG() { + return crypto.randomBytes(16); +}; - 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 - } - } +/***/ 141: +/***/ (function(__unusedmodule, exports, __webpack_require__) { - for (let i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true - } - } - return false - } -} -module.exports = Range +"use strict"; -const LRU = __webpack_require__(702) -const cache = new LRU({ max: 1000 }) -const parseOptions = __webpack_require__(143) -const Comparator = __webpack_require__(174) -const debug = __webpack_require__(548) -const SemVer = __webpack_require__(65) -const { - re, - t, - comparatorTrimReplace, - tildeTrimReplace, - caretTrimReplace -} = __webpack_require__(976) +var net = __webpack_require__(631); +var tls = __webpack_require__(16); +var http = __webpack_require__(605); +var https = __webpack_require__(211); +var events = __webpack_require__(614); +var assert = __webpack_require__(357); +var util = __webpack_require__(669); -const isNullSet = c => c.value === '<0.0.0-0' -const isAny = c => c.value === '' -// 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() +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; - while (result && remainingComparators.length) { - result = remainingComparators.every((otherComparator) => { - return testComparator.intersects(otherComparator, options) - }) - testComparator = remainingComparators.pop() - } +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; +} - return result +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; } -// 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 +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; } -const isX = id => !id || id.toLowerCase() === 'x' || id === '*' +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} -// ~, ~> --> * (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 +function TunnelingAgent(options) { + var self = this; + self.options = options || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; - 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` + self.on('free', function onFree(socket, host, port, localAddress) { + var options = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options.host && pending.port === options.port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } } - - debug('tilde return', ret) - return ret - }) + socket.destroy(); + self.removeSocket(socket); + }); } +util.inherits(TunnelingAgent, events.EventEmitter); -// ^ --> * (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(' ') +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); -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 (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; + } - 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` - } - } + // If we are under maxSockets create a new one. + self.createSocket(options, function(socket) { + socket.on('free', onFree); + socket.on('close', onCloseOrRemove); + socket.on('agentRemove', onCloseOrRemove); + req.onSocket(socket); - debug('caret return', ret) - return ret - }) -} + function onFree() { + self.emit('free', socket, options); + } -const replaceXRanges = (comp, options) => { - debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map((comp) => { - return replaceXRange(comp, options) - }).join(' ') -} + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; -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 +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); - if (gtlt === '=' && anyX) { - gtlt = '' + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: 'CONNECT', + path: options.host + ':' + options.port, + agent: false, + headers: { + host: options.host + ':' + options.port } + }); + if (options.localAddress) { + connectOptions.localAddress = options.localAddress; + } + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64'); + } - // 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' : '' + debug('making CONNECT request'); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; // for v0.6 + connectReq.once('response', onResponse); // for v0.6 + connectReq.once('upgrade', onUpgrade); // for v0.6 + connectReq.once('connect', onConnect); // for v0.7 or later + connectReq.once('error', onError); + connectReq.end(); - 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 + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } - 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 - } - } + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); + } - if (gtlt === '<') - pr = '-0' + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); - 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` + if (res.statusCode !== 200) { + debug('tunneling socket could not be established, statusCode=%d', + res.statusCode); + socket.destroy(); + var error = new Error('tunneling socket could not be established, ' + + 'statusCode=' + res.statusCode); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; } + if (head.length > 0) { + debug('got illegal response body from proxy'); + socket.destroy(); + var error = new Error('got illegal response body from proxy'); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + debug('tunneling connection has established'); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + return cb(socket); + } - 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], '') -} + function onError(cause) { + connectReq.removeAllListeners(); -const replaceGTE0 = (comp, options) => { - debug('replaceGTE0', comp, options) - return comp.trim() - .replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '') -} + debug('tunneling socket could not be established, cause=%s\n', + cause.message, cause.stack); + var error = new Error('tunneling socket could not be established, ' + + 'cause=' + cause.message); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + } +}; -// 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' : ''}` +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; } + this.sockets.splice(pos, 1); - 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}` + var pending = this.requests.shift(); + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket); + }); } +}; + +function createSecureSocket(options, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + var hostHeader = options.request.getHeader('host'); + var tlsOptions = mergeOptions({}, self.options, { + socket: socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host + }); - return (`${from} ${to}`).trim() + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); } -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 - } +function toOptions(host, port, localAddress) { + if (typeof host === 'string') { // since v0.10 + return { + host: host, + port: port, + localAddress: localAddress + }; + } + return host; // for v0.11 or later +} - 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 +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === 'object') { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== undefined) { + target[k] = overrides[k]; } } } - - // Version has a -pre, but it's not one of the ones we like. - return false } + return target; +} - return true + +var debug; +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0]; + } else { + args.unshift('TUNNEL:'); + } + console.error.apply(console, args); + } +} else { + debug = function() {}; } +exports.debug = debug; // for test /***/ }), -/***/ 129: +/***/ 211: /***/ (function(module) { -module.exports = require("child_process"); +module.exports = require("https"); /***/ }), -/***/ 139: -/***/ (function(module, __unusedexports, __webpack_require__) { - -// Unique ID creation requires a high quality random # generator. In node.js -// this is pretty straight-forward - we use the crypto API. +/***/ 219: +/***/ (function(__unusedmodule, exports, __webpack_require__) { -var crypto = __webpack_require__(417); +"use strict"; -module.exports = function nodeRNG() { - return crypto.randomBytes(16); +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 (k !== "default" && 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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); }; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(__webpack_require__(470)); +const gpg = __importStar(__webpack_require__(884)); +const constants = __importStar(__webpack_require__(694)); +function run() { + return __awaiter(this, void 0, void 0, function* () { + if (core.getInput(constants.INPUT_GPG_PRIVATE_KEY, { required: false })) { + core.info('Removing private key from keychain'); + try { + const keyFingerprint = core.getState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT); + yield gpg.deleteKey(keyFingerprint); + } + catch (error) { + core.setFailed('Failed to remove private key'); + } + } + }); +} +run(); /***/ }), -/***/ 141: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/***/ 280: +/***/ (function(module, exports) { -"use strict"; +exports = module.exports = SemVer +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 () {} +} -var net = __webpack_require__(631); -var tls = __webpack_require__(818); -var http = __webpack_require__(605); -var https = __webpack_require__(211); -var events = __webpack_require__(614); -var assert = __webpack_require__(357); -var util = __webpack_require__(669); +// 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' +var MAX_LENGTH = 256 +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 -exports.httpOverHttp = httpOverHttp; -exports.httpsOverHttp = httpsOverHttp; -exports.httpOverHttps = httpOverHttps; -exports.httpsOverHttps = httpsOverHttps; +// Max safe segment length for coercion. +var MAX_SAFE_COMPONENT_LENGTH = 16 +// The actual regexps go on exports.re +var re = exports.re = [] +var src = exports.src = [] +var t = exports.tokens = {} +var R = 0 -function httpOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - return agent; +function tok (n) { + t[n] = R++ } -function httpsOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} +// The following Regular Expressions can be used for tokenizing, +// validating, and parsing SemVer version strings. -function httpOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - return agent; -} +// ## Numeric Identifier +// A single `0`, or a non-zero digit followed by zero or more digits. -function httpsOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} +tok('NUMERICIDENTIFIER') +src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' +tok('NUMERICIDENTIFIERLOOSE') +src[t.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. -function TunnelingAgent(options) { - var self = this; - self.options = options || {}; - self.proxyOptions = self.options.proxy || {}; - self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; - self.requests = []; - self.sockets = []; +tok('NONNUMERICIDENTIFIER') +src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' - self.on('free', function onFree(socket, host, port, localAddress) { - var options = toOptions(host, port, localAddress); - for (var i = 0, len = self.requests.length; i < len; ++i) { - var pending = self.requests[i]; - if (pending.host === options.host && pending.port === options.port) { - // Detect the request to connect same origin server, - // reuse the connection. - self.requests.splice(i, 1); - pending.request.onSocket(socket); - return; - } - } - socket.destroy(); - self.removeSocket(socket); - }); -} -util.inherits(TunnelingAgent, events.EventEmitter); +// ## Main Version +// Three dot-separated numeric identifiers. -TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { - var self = this; - var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); +tok('MAINVERSION') +src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')' - if (self.sockets.length >= this.maxSockets) { - // We are over limit so we'll add it to the queue. - self.requests.push(options); - return; - } +tok('MAINVERSIONLOOSE') +src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' - // If we are under maxSockets create a new one. - self.createSocket(options, function(socket) { - socket.on('free', onFree); - socket.on('close', onCloseOrRemove); - socket.on('agentRemove', onCloseOrRemove); - req.onSocket(socket); +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. - function onFree() { - self.emit('free', socket, options); - } +tok('PRERELEASEIDENTIFIER') +src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' - function onCloseOrRemove(err) { - self.removeSocket(socket); - socket.removeListener('free', onFree); - socket.removeListener('close', onCloseOrRemove); - socket.removeListener('agentRemove', onCloseOrRemove); - } - }); -}; +tok('PRERELEASEIDENTIFIERLOOSE') +src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' -TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { - var self = this; - var placeholder = {}; - self.sockets.push(placeholder); +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. - var connectOptions = mergeOptions({}, self.proxyOptions, { - method: 'CONNECT', - path: options.host + ':' + options.port, - agent: false, - headers: { - host: options.host + ':' + options.port - } - }); - if (options.localAddress) { - connectOptions.localAddress = options.localAddress; - } - if (connectOptions.proxyAuth) { - connectOptions.headers = connectOptions.headers || {}; - connectOptions.headers['Proxy-Authorization'] = 'Basic ' + - new Buffer(connectOptions.proxyAuth).toString('base64'); - } +tok('PRERELEASE') +src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' - debug('making CONNECT request'); - var connectReq = self.request(connectOptions); - connectReq.useChunkedEncodingByDefault = false; // for v0.6 - connectReq.once('response', onResponse); // for v0.6 - connectReq.once('upgrade', onUpgrade); // for v0.6 - connectReq.once('connect', onConnect); // for v0.7 or later - connectReq.once('error', onError); - connectReq.end(); - - function onResponse(res) { - // Very hacky. This is necessary to avoid http-parser leaks. - res.upgrade = true; - } +tok('PRERELEASELOOSE') +src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' - function onUpgrade(res, socket, head) { - // Hacky. - process.nextTick(function() { - onConnect(res, socket, head); - }); - } +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. - function onConnect(res, socket, head) { - connectReq.removeAllListeners(); - socket.removeAllListeners(); +tok('BUILDIDENTIFIER') +src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' - if (res.statusCode !== 200) { - debug('tunneling socket could not be established, statusCode=%d', - res.statusCode); - socket.destroy(); - var error = new Error('tunneling socket could not be established, ' + - 'statusCode=' + res.statusCode); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - if (head.length > 0) { - debug('got illegal response body from proxy'); - socket.destroy(); - var error = new Error('got illegal response body from proxy'); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - debug('tunneling connection has established'); - self.sockets[self.sockets.indexOf(placeholder)] = socket; - return cb(socket); - } +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. - function onError(cause) { - connectReq.removeAllListeners(); +tok('BUILD') +src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + + '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))' - debug('tunneling socket could not be established, cause=%s\n', - cause.message, cause.stack); - var error = new Error('tunneling socket could not be established, ' + - 'cause=' + cause.message); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - } -}; +// ## Full Version String +// A main version, followed optionally by a pre-release version and +// build metadata. -TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { - var pos = this.sockets.indexOf(socket) - if (pos === -1) { - return; - } - this.sockets.splice(pos, 1); +// 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. - var pending = this.requests.shift(); - if (pending) { - // If we have pending requests and a socket gets closed a new one - // needs to be created to take over in the pool for the one that closed. - this.createSocket(pending, function(socket) { - pending.request.onSocket(socket); - }); - } -}; +tok('FULL') +tok('FULLPLAIN') +src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + + src[t.PRERELEASE] + '?' + + src[t.BUILD] + '?' -function createSecureSocket(options, cb) { - var self = this; - TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { - var hostHeader = options.request.getHeader('host'); - var tlsOptions = mergeOptions({}, self.options, { - socket: socket, - servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host - }); +src[t.FULL] = '^' + src[t.FULLPLAIN] + '$' - // 0 is dummy port for v0.6 - var secureSocket = tls.connect(0, tlsOptions); - self.sockets[self.sockets.indexOf(socket)] = secureSocket; - cb(secureSocket); - }); -} +// 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] + '?' +tok('LOOSE') +src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' -function toOptions(host, port, localAddress) { - if (typeof host === 'string') { // since v0.10 - return { - host: host, - port: port, - localAddress: localAddress - }; - } - return host; // for v0.11 or later -} +tok('GTLT') +src[t.GTLT] = '((?:<|>)?=?)' -function mergeOptions(target) { - for (var i = 1, len = arguments.length; i < len; ++i) { - var overrides = arguments[i]; - if (typeof overrides === 'object') { - var keys = Object.keys(overrides); - for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { - var k = keys[j]; - if (overrides[k] !== undefined) { - target[k] = overrides[k]; - } - } - } - } - return target; -} +// 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|\\*' +tok('XRANGEPLAIN') +src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:' + src[t.PRERELEASE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' -var debug; -if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { - debug = function() { - var args = Array.prototype.slice.call(arguments); - if (typeof args[0] === 'string') { - args[0] = 'TUNNEL: ' + args[0]; - } else { - args.unshift('TUNNEL:'); - } - console.error.apply(console, args); - } -} else { - debug = function() {}; -} -exports.debug = debug; // for test +tok('XRANGEPLAINLOOSE') +src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:' + src[t.PRERELEASELOOSE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' +tok('XRANGE') +src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' +tok('XRANGELOOSE') +src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' -/***/ }), +// 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') -/***/ 143: -/***/ (function(module) { +// Tilde ranges. +// Meaning is "reasonably at or greater than" +tok('LONETILDE') +src[t.LONETILDE] = '(?:~>?)' -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) -module.exports = parseOptions +tok('TILDETRIM') +src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' +re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') +var tildeTrimReplace = '$1~' +tok('TILDE') +src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' +tok('TILDELOOSE') +src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' -/***/ }), +// Caret ranges. +// Meaning is "at least and backwards compatible with" +tok('LONECARET') +src[t.LONECARET] = '(?:\\^)' -/***/ 164: -/***/ (function(module, __unusedexports, __webpack_require__) { +tok('CARETTRIM') +src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' +re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') +var caretTrimReplace = '$1^' -const SemVer = __webpack_require__(65) -const Range = __webpack_require__(124) -const gt = __webpack_require__(486) +tok('CARET') +src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' +tok('CARETLOOSE') +src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' -const minVersion = (range, loose) => { - range = new Range(range, loose) +// 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] + ')$|^$' - let minver = new SemVer('0.0.0') - if (range.test(minver)) { - return minver - } +// 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] + ')' - minver = new SemVer('0.0.0-0') - if (range.test(minver)) { - return minver - } +// this one has to use the /g flag +re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') +var comparatorTrimReplace = '$1$2$3' - minver = null - for (let i = 0; i < range.set.length; ++i) { - const comparators = range.set[i] +// 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*$' - let setMin = null - 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 (!setMin || gt(compver, setMin)) { - setMin = compver - } - break - case '<': - case '<=': - /* Ignore maximum versions */ - break - /* istanbul ignore next */ - default: - throw new Error(`Unexpected operation: ${comparator.operator}`) - } - }) - if (setMin && (!minver || gt(minver, setMin))) - minver = setMin - } +tok('HYPHENRANGELOOSE') +src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s*$' - if (minver && range.test(minver)) { - return minver - } +// Star ranges basically just allow anything at all. +tok('STAR') +src[t.STAR] = '(<|>)?=?\\s*\\*' - return null +// 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]) + } } -module.exports = minVersion - - -/***/ }), - -/***/ 167: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const gte = (a, b, loose) => compare(a, b, loose) >= 0 -module.exports = gte - -/***/ }), - -/***/ 174: -/***/ (function(module, __unusedexports, __webpack_require__) { +exports.parse = parse +function parse (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } -const ANY = Symbol('SemVer ANY') -// hoisted class for cyclic dependency -class Comparator { - static get ANY () { - return ANY + if (version instanceof SemVer) { + return version } - constructor (comp, options) { - options = parseOptions(options) - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp - } else { - comp = comp.value - } - } + if (typeof version !== 'string') { + return null + } - debug('comparator', comp, options) - this.options = options - this.loose = !!options.loose - this.parse(comp) + if (version.length > MAX_LENGTH) { + return null + } - if (this.semver === ANY) { - this.value = '' - } else { - this.value = this.operator + this.semver.version - } + var r = options.loose ? re[t.LOOSE] : re[t.FULL] + if (!r.test(version)) { + return null + } - debug('comp', this) + try { + return new SemVer(version, options) + } catch (er) { + return null } +} - parse (comp) { - const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - const m = comp.match(r) +exports.valid = valid +function valid (version, options) { + var v = parse(version, options) + return v ? v.version : null +} - if (!m) { - throw new TypeError(`Invalid comparator: ${comp}`) - } +exports.clean = clean +function clean (version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} - this.operator = m[1] !== undefined ? m[1] : '' - if (this.operator === '=') { - this.operator = '' - } +exports.SemVer = SemVer - // if it literally is just '>' or '' then allow anything. - if (!m[2]) { - this.semver = ANY +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 { - this.semver = new SemVer(m[2], this.options.loose) + version = version.version } + } else if (typeof version !== 'string') { + throw new TypeError('Invalid Version: ' + version) } - toString () { - return this.value + if (version.length > MAX_LENGTH) { + throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') } - test (version) { - debug('Comparator.test', version, this.options.loose) + if (!(this instanceof SemVer)) { + return new SemVer(version, options) + } - if (this.semver === ANY || version === ANY) { - return true - } + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } + var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) - return cmp(version, this.operator, this.semver, this.options) + if (!m) { + throw new TypeError('Invalid Version: ' + version) } - intersects (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } - - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } + this.raw = version - 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 === '>') + // these are actually numbers + this.major = +m[1] + this.minor = +m[2] + this.patch = +m[3] - return ( - sameDirectionIncreasing || - sameDirectionDecreasing || - (sameSemVer && differentDirectionsInclusive) || - oppositeDirectionsLessThan || - oppositeDirectionsGreaterThan - ) + if (this.major > MAX_SAFE_INTEGER || this.major < 0) { + throw new TypeError('Invalid major version') } -} -module.exports = Comparator - -const parseOptions = __webpack_require__(143) -const {re, t} = __webpack_require__(976) -const cmp = __webpack_require__(752) -const debug = __webpack_require__(548) -const SemVer = __webpack_require__(65) -const Range = __webpack_require__(124) + 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(function (id) { + if (/^[0-9]+$/.test(id)) { + var num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } -/***/ 181: -/***/ (function(module) { + this.build = m[5] ? m[5].split('.') : [] + this.format() +} -// 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' +SemVer.prototype.format = function () { + this.version = this.major + '.' + this.minor + '.' + this.patch + if (this.prerelease.length) { + this.version += '-' + this.prerelease.join('.') + } + return this.version +} -const MAX_LENGTH = 256 -const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +SemVer.prototype.toString = function () { + return this.version +} -// Max safe segment length for coercion. -const MAX_SAFE_COMPONENT_LENGTH = 16 +SemVer.prototype.compare = function (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } -module.exports = { - SEMVER_SPEC_VERSION, - MAX_LENGTH, - MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH + return this.compareMain(other) || this.comparePre(other) } +SemVer.prototype.compareMain = function (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) +} -/***/ 211: -/***/ (function(module) { +SemVer.prototype.comparePre = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } -module.exports = require("https"); + // 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 + } -/***/ }), + 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) +} -/***/ 219: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +SemVer.prototype.compareBuild = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } -"use strict"; + 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) +} -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 (k !== "default" && Object.prototype.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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(__webpack_require__(470)); -const gpg = __importStar(__webpack_require__(884)); -const constants = __importStar(__webpack_require__(694)); -function run() { - return __awaiter(this, void 0, void 0, function* () { - if (core.getInput(constants.INPUT_GPG_PRIVATE_KEY, { required: false })) { - core.info('Removing private key from keychain'); - try { - const keyFingerprint = core.getState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT); - yield gpg.deleteKey(keyFingerprint); - } - catch (error) { - core.setFailed('Failed to remove private key'); - } - } - }); -} -run(); +// 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 -/***/ }), + default: + throw new Error('invalid increment argument: ' + release) + } + this.format() + this.raw = this.version + return this +} -/***/ 259: -/***/ (function(module, __unusedexports, __webpack_require__) { +exports.inc = inc +function inc (version, release, loose, identifier) { + if (typeof (loose) === 'string') { + identifier = loose + loose = undefined + } -const Range = __webpack_require__(124) -const intersects = (r1, r2, options) => { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } } -module.exports = intersects - -/***/ }), +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 + } + } + } + return defaultResult // may be undefined + } +} -/***/ 283: -/***/ (function(module, __unusedexports, __webpack_require__) { +exports.compareIdentifiers = compareIdentifiers -const compare = __webpack_require__(874) -const compareLoose = (a, b) => compare(a, b, true) -module.exports = compareLoose +var numeric = /^[0-9]+$/ +function compareIdentifiers (a, b) { + var anum = numeric.test(a) + var 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 +} -/***/ 298: -/***/ (function(module, __unusedexports, __webpack_require__) { +exports.rcompareIdentifiers = rcompareIdentifiers +function rcompareIdentifiers (a, b) { + return compareIdentifiers(b, a) +} -const compare = __webpack_require__(874) -const eq = (a, b, loose) => compare(a, b, loose) === 0 -module.exports = eq +exports.major = major +function major (a, loose) { + return new SemVer(a, loose).major +} +exports.minor = minor +function minor (a, loose) { + return new SemVer(a, loose).minor +} -/***/ }), +exports.patch = patch +function patch (a, loose) { + return new SemVer(a, loose).patch +} -/***/ 310: -/***/ (function(module, __unusedexports, __webpack_require__) { +exports.compare = compare +function compare (a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) +} -const Range = __webpack_require__(124) -const satisfies = (version, range, options) => { - try { - range = new Range(range, options) - } catch (er) { - return false - } - return range.test(version) +exports.compareLoose = compareLoose +function compareLoose (a, b) { + return compare(a, b, true) } -module.exports = satisfies +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) +} -/***/ }), +exports.rcompare = rcompare +function rcompare (a, b, loose) { + return compare(b, a, loose) +} -/***/ 322: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +exports.sort = sort +function sort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(a, b, loose) + }) +} -"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 (k !== "default" && Object.prototype.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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; -const os_1 = __importDefault(__webpack_require__(87)); -const path_1 = __importDefault(__webpack_require__(622)); -const fs = __importStar(__webpack_require__(747)); -const semver = __importStar(__webpack_require__(876)); -const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(533)); -function getTempDir() { - let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); - return tempDirectory; -} -exports.getTempDir = getTempDir; -function getBooleanInput(inputName, defaultValue = false) { - return (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'; +exports.rsort = rsort +function rsort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(b, a, loose) + }) } -exports.getBooleanInput = getBooleanInput; -function getVersionFromToolcachePath(toolPath) { - if (toolPath) { - return path_1.default.basename(path_1.default.dirname(toolPath)); - } - return toolPath; + +exports.gt = gt +function gt (a, b, loose) { + return compare(a, b, loose) > 0 } -exports.getVersionFromToolcachePath = getVersionFromToolcachePath; -function extractJdkFile(toolPath, extension) { - return __awaiter(this, void 0, void 0, function* () { - if (!extension) { - extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); - if (extension.startsWith('.')) { - extension = extension.substring(1); - } - } - switch (extension) { - case 'tar.gz': - case 'tar': - return yield tc.extractTar(toolPath); - case 'zip': - return yield tc.extractZip(toolPath); - default: - return yield tc.extract7z(toolPath); - } - }); + +exports.lt = lt +function lt (a, b, loose) { + return compare(a, b, loose) < 0 } -exports.extractJdkFile = extractJdkFile; -function getDownloadArchiveExtension() { - return process.platform === 'win32' ? 'zip' : 'tar.gz'; + +exports.eq = eq +function eq (a, b, loose) { + return compare(a, b, loose) === 0 } -exports.getDownloadArchiveExtension = getDownloadArchiveExtension; -function isVersionSatisfies(range, version) { - var _a; - if (semver.valid(range)) { - // if full version with build digit is provided as a range (such as '1.2.3+4') - // we should check for exact equal via compareBuild - // since semver.satisfies doesn't handle 4th digit - const semRange = semver.parse(range); - if (semRange && ((_a = semRange.build) === null || _a === void 0 ? void 0 : _a.length) > 0) { - return semver.compareBuild(range, version) === 0; - } - } - return semver.satisfies(version, range); + +exports.neq = neq +function neq (a, b, loose) { + return compare(a, b, loose) !== 0 } -exports.isVersionSatisfies = isVersionSatisfies; -function getToolcachePath(toolName, version, architecture) { - var _a; - const toolcacheRoot = (_a = process.env['RUNNER_TOOL_CACHE']) !== null && _a !== void 0 ? _a : ''; - const fullPath = path_1.default.join(toolcacheRoot, toolName, version, architecture); - if (fs.existsSync(fullPath)) { - return fullPath; - } - return null; + +exports.gte = gte +function gte (a, b, loose) { + return compare(a, b, loose) >= 0 } -exports.getToolcachePath = getToolcachePath; +exports.lte = lte +function lte (a, b, loose) { + return compare(a, b, loose) <= 0 +} -/***/ }), +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 -/***/ 323: -/***/ (function(module, __unusedexports, __webpack_require__) { + case '!==': + if (typeof a === 'object') + a = a.version + if (typeof b === 'object') + b = b.version + return a !== b -const outside = __webpack_require__(462) -// 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 + case '': + case '=': + case '==': + return eq(a, b, loose) + case '!=': + return neq(a, b, loose) -/***/ }), + case '>': + return gt(a, b, loose) -/***/ 357: -/***/ (function(module) { + case '>=': + return gte(a, b, loose) -module.exports = require("assert"); + case '<': + return lt(a, b, loose) -/***/ }), + case '<=': + return lte(a, b, loose) -/***/ 396: -/***/ (function(module) { + default: + throw new TypeError('Invalid operator: ' + op) + } +} -"use strict"; +exports.Comparator = Comparator +function Comparator (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } -module.exports = function (Yallist) { - Yallist.prototype[Symbol.iterator] = function* () { - for (let walker = this.head; walker; walker = walker.next) { - yield walker.value + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value } } + + 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 + } + + debug('comp', this) } +var ANY = {} +Comparator.prototype.parse = function (comp) { + var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var m = comp.match(r) -/***/ }), + if (!m) { + throw new TypeError('Invalid comparator: ' + comp) + } -/***/ 413: -/***/ (function(module, __unusedexports, __webpack_require__) { + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } -module.exports = __webpack_require__(141); + // 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) + } +} +Comparator.prototype.toString = function () { + return this.value +} -/***/ }), +Comparator.prototype.test = function (version) { + debug('Comparator.test', version, this.options.loose) -/***/ 417: -/***/ (function(module) { + if (this.semver === ANY || version === ANY) { + return true + } -module.exports = require("crypto"); + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } -/***/ }), + return cmp(version, this.operator, this.semver, this.options) +} -/***/ 431: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +Comparator.prototype.intersects = function (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } -"use strict"; + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } -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; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const os = __importStar(__webpack_require__(87)); -const utils_1 = __webpack_require__(82); -/** - * Commands - * - * Command Format: - * ::name key=value,key=value::message - * - * Examples: - * ::warning::This is the message - * ::set-env name=MY_VAR::some value - */ -function issueCommand(command, properties, message) { - const cmd = new Command(command, properties, message); - process.stdout.write(cmd.toString() + os.EOL); -} -exports.issueCommand = issueCommand; -function issue(name, message = '') { - issueCommand(name, {}, message); -} -exports.issue = issue; -const CMD_STRING = '::'; -class Command { - constructor(command, properties, message) { - if (!command) { - command = 'missing.command'; - } - this.command = command; - this.properties = properties; - this.message = message; + var rangeTmp + + if (this.operator === '') { + if (this.value === '') { + return true } - toString() { - let cmdStr = CMD_STRING + this.command; - if (this.properties && Object.keys(this.properties).length > 0) { - cmdStr += ' '; - let first = true; - for (const key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - const val = this.properties[key]; - if (val) { - if (first) { - first = false; - } - else { - cmdStr += ','; - } - cmdStr += `${key}=${escapeProperty(val)}`; - } - } - } - } - cmdStr += `${CMD_STRING}${escapeData(this.message)}`; - return cmdStr; + rangeTmp = new Range(comp.value, options) + return satisfies(this.value, rangeTmp, options) + } else if (comp.operator === '') { + if (comp.value === '') { + return true } -} -function escapeData(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A'); -} -function escapeProperty(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A') - .replace(/:/g, '%3A') - .replace(/,/g, '%2C'); -} -//# sourceMappingURL=command.js.map + rangeTmp = new Range(this.value, options) + return satisfies(comp.semver, rangeTmp, options) + } -/***/ }), + 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 === '>')) -/***/ 462: -/***/ (function(module, __unusedexports, __webpack_require__) { + return sameDirectionIncreasing || sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || oppositeDirectionsGreaterThan +} -const SemVer = __webpack_require__(65) -const Comparator = __webpack_require__(174) -const {ANY} = Comparator -const Range = __webpack_require__(124) -const satisfies = __webpack_require__(310) -const gt = __webpack_require__(486) -const lt = __webpack_require__(586) -const lte = __webpack_require__(898) -const gte = __webpack_require__(167) - -const outside = (version, range, hilo, options) => { - version = new SemVer(version, options) - range = new Range(range, options) +exports.Range = Range +function Range (range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } - 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 (range instanceof Range) { + if (range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease) { + return range + } else { + return new Range(range.raw, options) + } } - // If it satisfies the range it is not outside - if (satisfies(version, range, options)) { - return false + if (range instanceof Comparator) { + return new Range(range.value, options) } - // From now on, variable terms are as if we're in "gtr" mode. - // but note that everything is flipped for the "ltr" function. + if (!(this instanceof Range)) { + return new Range(range, options) + } - for (let i = 0; i < range.set.length; ++i) { - const comparators = range.set[i] + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease - let high = null - let low = null + // 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 + }) - 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 (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range) + } - // If the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false - } + this.format() +} - // 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 +Range.prototype.format = function () { + this.range = this.set.map(function (comps) { + return comps.join(' ').trim() + }).join('||').trim() + return this.range } -module.exports = outside +Range.prototype.toString = function () { + return this.range +} +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]) -/***/ }), + // `~ 1.2.3` => `~1.2.3` + range = range.replace(re[t.TILDETRIM], tildeTrimReplace) -/***/ 470: -/***/ (function(__unusedmodule, exports, __webpack_require__) { + // `^ 1.2.3` => `^1.2.3` + range = range.replace(re[t.CARETTRIM], caretTrimReplace) -"use strict"; + // normalize spaces + range = range.split(/\s+/).join(' ') -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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - 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; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const command_1 = __webpack_require__(431); -const file_command_1 = __webpack_require__(102); -const utils_1 = __webpack_require__(82); -const os = __importStar(__webpack_require__(87)); -const path = __importStar(__webpack_require__(622)); -/** - * The code to exit an action - */ -var ExitCode; -(function (ExitCode) { - /** - * A code indicating that the action was successful - */ - ExitCode[ExitCode["Success"] = 0] = "Success"; - /** - * A code indicating that the action was a failure - */ - ExitCode[ExitCode["Failure"] = 1] = "Failure"; -})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); -//----------------------------------------------------------------------- -// Variables -//----------------------------------------------------------------------- -/** - * Sets env variable for this action and future actions in the job - * @param name the name of the variable to set - * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function exportVariable(name, val) { - const convertedVal = utils_1.toCommandValue(val); - process.env[name] = convertedVal; - const filePath = process.env['GITHUB_ENV'] || ''; - if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); - } -} -exports.exportVariable = exportVariable; -/** - * Registers a secret which will get masked from logs - * @param secret value of the secret - */ -function setSecret(secret) { - command_1.issueCommand('add-mask', {}, secret); -} -exports.setSecret = setSecret; -/** - * Prepends inputPath to the PATH (for this action and future actions) - * @param inputPath - */ -function addPath(inputPath) { - const filePath = process.env['GITHUB_PATH'] || ''; - if (filePath) { - file_command_1.issueCommand('PATH', inputPath); - } - else { - command_1.issueCommand('add-path', {}, inputPath); - } - process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; + // At this point, the range is completely trimmed and + // ready to be split into comparators. + + 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) + + return set } -exports.addPath = addPath; -/** - * Gets the value of an input. The value is also trimmed. - * - * @param name name of the input to get - * @param options optional. See InputOptions. - * @returns string - */ -function getInput(name, options) { - const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; - if (options && options.required && !val) { - throw new Error(`Input required and not supplied: ${name}`); - } - return val.trim(); + +Range.prototype.intersects = function (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + 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) + }) + }) + ) + }) + ) + }) } -exports.getInput = getInput; -/** - * Sets the value of an output. - * - * @param name name of the output to set - * @param value value to store. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function setOutput(name, value) { - command_1.issueCommand('set-output', { name }, value); + +// 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) + }) + + testComparator = remainingComparators.pop() + } + + return result } -exports.setOutput = setOutput; -/** - * Enables or disables the echoing of commands into stdout for the rest of the step. - * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. - * - */ -function setCommandEcho(enabled) { - command_1.issue('echo', enabled ? 'on' : 'off'); + +// 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(' ') + }) } -exports.setCommandEcho = setCommandEcho; -//----------------------------------------------------------------------- -// Results -//----------------------------------------------------------------------- -/** - * Sets the action status to failed. - * When the action exits it will be with an exit code of 1 - * @param message add error issue message - */ -function setFailed(message) { - process.exitCode = ExitCode.Failure; - error(message); + +// 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 } -exports.setFailed = setFailed; -//----------------------------------------------------------------------- -// Logging Commands -//----------------------------------------------------------------------- -/** - * Gets whether Actions Step Debug is on or not - */ -function isDebug() { - return process.env['RUNNER_DEBUG'] === '1'; + +function isX (id) { + return !id || id.toLowerCase() === 'x' || id === '*' } -exports.isDebug = isDebug; -/** - * Writes debug message to user log - * @param message debug message - */ -function debug(message) { - command_1.issueCommand('debug', {}, message); + +// ~, ~> --> * (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(' ') } -exports.debug = debug; -/** - * Adds an error issue - * @param message error issue message. Errors will be converted to string via toString() - */ -function error(message) { - command_1.issue('error', message instanceof Error ? message.toString() : message); + +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 + }) } -exports.error = error; -/** - * Adds an warning issue - * @param message warning issue message. Errors will be converted to string via toString() - */ -function warning(message) { - command_1.issue('warning', message instanceof Error ? message.toString() : message); + +// ^ --> * (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(' ') } -exports.warning = warning; -/** - * Writes info to log with console.log. - * @param message info message - */ -function info(message) { - process.stdout.write(message + os.EOL); -} -exports.info = info; -/** - * Begin an output group. - * - * Output until the next `groupEnd` will be foldable in this group - * - * @param name The name of the output group - */ -function startGroup(name) { - command_1.issue('group', name); -} -exports.startGroup = startGroup; -/** - * End an output group. - */ -function endGroup() { - command_1.issue('endgroup'); -} -exports.endGroup = endGroup; -/** - * Wrap an asynchronous function call in a group. - * - * Returns the same type as the function itself. - * - * @param name The name of the group - * @param fn The function to wrap in the group - */ -function group(name, fn) { - return __awaiter(this, void 0, void 0, function* () { - startGroup(name); - let result; - try { - result = yield fn(); + +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' } - finally { - endGroup(); + } 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' } - return result; - }); -} -exports.group = group; -//----------------------------------------------------------------------- -// Wrapper action state -//----------------------------------------------------------------------- -/** - * Saves state for current action, the state can only be retrieved by this action's post job execution. - * - * @param name name of the state to store - * @param value value to store. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); -} -exports.saveState = saveState; -/** - * Gets the value of an state set by this action's main execution. - * - * @param name name of the state to get - * @returns string - */ -function getState(name) { - return process.env[`STATE_${name}`] || ''; -} -exports.getState = getState; -//# sourceMappingURL=core.js.map - -/***/ }), + } else { + ret = '>=' + M + '.' + m + '.' + p + + ' <' + (+M + 1) + '.0.0' + } + } -/***/ 480: -/***/ (function(module, __unusedexports, __webpack_require__) { + debug('caret return', ret) + return ret + }) +} -const Range = __webpack_require__(124) -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 - } +function replaceXRanges (comp, options) { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map(function (comp) { + return replaceXRange(comp, options) + }).join(' ') } -module.exports = validRange +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 = '' + } -/***/ 486: -/***/ (function(module, __unusedexports, __webpack_require__) { + // 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' : '' -const compare = __webpack_require__(874) -const gt = (a, b, loose) => compare(a, b, loose) > 0 -module.exports = gt + 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 + } -/***/ 489: -/***/ (function(module, __unusedexports, __webpack_require__) { + debug('xRange return', ret) -const SemVer = __webpack_require__(65) -const patch = (a, loose) => new SemVer(a, loose).patch -module.exports = patch + 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 + } -/***/ 499: -/***/ (function(module, __unusedexports, __webpack_require__) { + 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 + } -const SemVer = __webpack_require__(65) -const parse = __webpack_require__(830) -const {re, t} = __webpack_require__(976) + return (from + ' ' + to).trim() +} -const coerce = (version, options) => { - if (version instanceof SemVer) { - return version +// if ANY of the sets match ALL of its comparators, then pass +Range.prototype.test = function (version) { + if (!version) { + return false } - if (typeof version === 'number') { - version = String(version) + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } } - if (typeof version !== 'string') { - return null + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } } + return false +} - options = options || {} +function testSet (set, version, options) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } - 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 + 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 + } } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length } - // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 + + // 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) +} - if (match === null) +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 +} - return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) +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 } -module.exports = coerce +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 + } -/***/ 503: -/***/ (function(module, __unusedexports, __webpack_require__) { + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } -const parse = __webpack_require__(830) -const clean = (version, options) => { - const s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null -} -module.exports = clean + 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 + } -/***/ }), + return null +} -/***/ 531: -/***/ (function(module, __unusedexports, __webpack_require__) { +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 + } +} + +// 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. -const outside = __webpack_require__(462) -const gtr = (version, range, options) => outside(version, range, '>', options) -module.exports = gtr +exports.gtr = gtr +function gtr (version, range, options) { + return outside(version, range, '>', options) +} +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 ">"') + } -/***/ 533: -/***/ (function(__unusedmodule, exports, __webpack_require__) { + // If it satisifes the range it is not outside + if (satisfies(version, range, options)) { + return false + } -"use strict"; + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. -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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - 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 }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(__webpack_require__(470)); -const io = __importStar(__webpack_require__(1)); -const fs = __importStar(__webpack_require__(747)); -const mm = __importStar(__webpack_require__(31)); -const os = __importStar(__webpack_require__(87)); -const path = __importStar(__webpack_require__(622)); -const httpm = __importStar(__webpack_require__(539)); -const semver = __importStar(__webpack_require__(550)); -const stream = __importStar(__webpack_require__(794)); -const util = __importStar(__webpack_require__(669)); -const v4_1 = __importDefault(__webpack_require__(826)); -const exec_1 = __webpack_require__(986); -const assert_1 = __webpack_require__(357); -const retry_helper_1 = __webpack_require__(979); -class HTTPError extends Error { - constructor(httpStatusCode) { - super(`Unexpected HTTP response: ${httpStatusCode}`); - this.httpStatusCode = httpStatusCode; - Object.setPrototypeOf(this, new.target.prototype); - } -} -exports.HTTPError = HTTPError; -const IS_WINDOWS = process.platform === 'win32'; -const IS_MAC = process.platform === 'darwin'; -const userAgent = 'actions/tool-cache'; -/** - * Download a tool from an url and stream it into a file - * - * @param url url of tool to download - * @param dest path to download tool - * @param auth authorization header - * @returns path to downloaded tool - */ -function downloadTool(url, dest, auth) { - return __awaiter(this, void 0, void 0, function* () { - dest = dest || path.join(_getTempDirectory(), v4_1.default()); - yield io.mkdirP(path.dirname(dest)); - core.debug(`Downloading ${url}`); - core.debug(`Destination ${dest}`); - const maxAttempts = 3; - const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10); - const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20); - const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); - return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { - return yield downloadToolAttempt(url, dest || '', auth); - }), (err) => { - if (err instanceof HTTPError && err.httpStatusCode) { - // Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests - if (err.httpStatusCode < 500 && - err.httpStatusCode !== 408 && - err.httpStatusCode !== 429) { - return false; - } - } - // Otherwise retry - return true; - }); + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] + + var high = null + var low = null + + 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 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) +} + +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 + } + + options = options || {} + + 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 + } + // 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) +} + + +/***/ }), + +/***/ 322: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"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 (k !== "default" && 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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +const os_1 = __importDefault(__webpack_require__(87)); +const path_1 = __importDefault(__webpack_require__(622)); +const fs = __importStar(__webpack_require__(747)); +const semver = __importStar(__webpack_require__(280)); +const core = __importStar(__webpack_require__(470)); +const tc = __importStar(__webpack_require__(533)); +function getTempDir() { + let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); + return tempDirectory; } -exports.downloadTool = downloadTool; -function downloadToolAttempt(url, dest, auth) { +exports.getTempDir = getTempDir; +function getBooleanInput(inputName, defaultValue = false) { + return (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'; +} +exports.getBooleanInput = getBooleanInput; +function getVersionFromToolcachePath(toolPath) { + if (toolPath) { + return path_1.default.basename(path_1.default.dirname(toolPath)); + } + return toolPath; +} +exports.getVersionFromToolcachePath = getVersionFromToolcachePath; +function extractJdkFile(toolPath, extension) { return __awaiter(this, void 0, void 0, function* () { - if (fs.existsSync(dest)) { - throw new Error(`Destination file path ${dest} already exists`); - } - // Get the response headers - const http = new httpm.HttpClient(userAgent, [], { - allowRetries: false - }); - let headers; - if (auth) { - core.debug('set auth'); - headers = { - authorization: auth - }; - } - const response = yield http.get(url, headers); - if (response.message.statusCode !== 200) { - const err = new HTTPError(response.message.statusCode); - core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); - throw err; - } - // Download the response body - const pipeline = util.promisify(stream.pipeline); - const responseMessageFactory = _getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message); - const readStream = responseMessageFactory(); - let succeeded = false; - try { - yield pipeline(readStream, fs.createWriteStream(dest)); - core.debug('download complete'); - succeeded = true; - return dest; - } - finally { - // Error, delete dest before retry - if (!succeeded) { - core.debug('download failed'); - try { - yield io.rmRF(dest); - } - catch (err) { - core.debug(`Failed to delete '${dest}'. ${err.message}`); - } + if (!extension) { + extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); + if (extension.startsWith('.')) { + extension = extension.substring(1); } } + switch (extension) { + case 'tar.gz': + case 'tar': + return yield tc.extractTar(toolPath); + case 'zip': + return yield tc.extractZip(toolPath); + default: + return yield tc.extract7z(toolPath); + } }); } -/** - * Extract a .7z file - * - * @param file path to the .7z file - * @param dest destination directory. Optional. - * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this - * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will - * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is - * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line - * interface, it is smaller than the full command line interface, and it does support long paths. At the - * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. - * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path - * to 7zr.exe can be pass to this function. - * @returns path to the destination directory - */ -function extract7z(file, dest, _7zPath) { - return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); - assert_1.ok(file, 'parameter "file" is required'); - dest = yield _createExtractFolder(dest); - const originalCwd = process.cwd(); - process.chdir(dest); - if (_7zPath) { - try { - const logLevel = core.isDebug() ? '-bb1' : '-bb0'; - const args = [ - 'x', - logLevel, - '-bd', - '-sccUTF-8', - file - ]; - const options = { - silent: true - }; - yield exec_1.exec(`"${_7zPath}"`, args, options); - } - finally { - process.chdir(originalCwd); - } - } - else { - const escapedScript = path - .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') - .replace(/'/g, "''") - .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; - const args = [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ]; - const options = { - silent: true - }; - try { - const powershellPath = yield io.which('powershell', true); - yield exec_1.exec(`"${powershellPath}"`, args, options); - } - finally { - process.chdir(originalCwd); - } +exports.extractJdkFile = extractJdkFile; +function getDownloadArchiveExtension() { + return process.platform === 'win32' ? 'zip' : 'tar.gz'; +} +exports.getDownloadArchiveExtension = getDownloadArchiveExtension; +function isVersionSatisfies(range, version) { + var _a; + if (semver.valid(range)) { + // if full version with build digit is provided as a range (such as '1.2.3+4') + // we should check for exact equal via compareBuild + // since semver.satisfies doesn't handle 4th digit + const semRange = semver.parse(range); + if (semRange && ((_a = semRange.build) === null || _a === void 0 ? void 0 : _a.length) > 0) { + return semver.compareBuild(range, version) === 0; } - return dest; - }); + } + return semver.satisfies(version, range); } -exports.extract7z = extract7z; +exports.isVersionSatisfies = isVersionSatisfies; +function getToolcachePath(toolName, version, architecture) { + var _a; + const toolcacheRoot = (_a = process.env['RUNNER_TOOL_CACHE']) !== null && _a !== void 0 ? _a : ''; + const fullPath = path_1.default.join(toolcacheRoot, toolName, version, architecture); + if (fs.existsSync(fullPath)) { + return fullPath; + } + return null; +} +exports.getToolcachePath = getToolcachePath; + + +/***/ }), + +/***/ 357: +/***/ (function(module) { + +module.exports = require("assert"); + +/***/ }), + +/***/ 413: +/***/ (function(module, __unusedexports, __webpack_require__) { + +module.exports = __webpack_require__(141); + + +/***/ }), + +/***/ 417: +/***/ (function(module) { + +module.exports = require("crypto"); + +/***/ }), + +/***/ 431: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +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; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); /** - * Extract a compressed tar archive + * Commands * - * @param file path to the tar - * @param dest destination directory. Optional. - * @param flags flags for the tar command to use for extraction. Defaults to 'xz' (extracting gzipped tars). Optional. - * @returns path to the destination directory + * Command Format: + * ::name key=value,key=value::message + * + * Examples: + * ::warning::This is the message + * ::set-env name=MY_VAR::some value */ -function extractTar(file, dest, flags = 'xz') { - return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); +function issueCommand(command, properties, message) { + const cmd = new Command(command, properties, message); + process.stdout.write(cmd.toString() + os.EOL); +} +exports.issueCommand = issueCommand; +function issue(name, message = '') { + issueCommand(name, {}, message); +} +exports.issue = issue; +const CMD_STRING = '::'; +class Command { + constructor(command, properties, message) { + if (!command) { + command = 'missing.command'; } - // Create dest - dest = yield _createExtractFolder(dest); - // Determine whether GNU tar - core.debug('Checking tar --version'); - let versionOutput = ''; - yield exec_1.exec('tar --version', [], { - ignoreReturnCode: true, - silent: true, - listeners: { - stdout: (data) => (versionOutput += data.toString()), - stderr: (data) => (versionOutput += data.toString()) + this.command = command; + this.properties = properties; + this.message = message; + } + toString() { + let cmdStr = CMD_STRING + this.command; + if (this.properties && Object.keys(this.properties).length > 0) { + cmdStr += ' '; + let first = true; + for (const key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + const val = this.properties[key]; + if (val) { + if (first) { + first = false; + } + else { + cmdStr += ','; + } + cmdStr += `${key}=${escapeProperty(val)}`; + } + } } - }); - core.debug(versionOutput.trim()); - const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR'); - // Initialize args - let args; - if (flags instanceof Array) { - args = flags; - } - else { - args = [flags]; - } - if (core.isDebug() && !flags.includes('v')) { - args.push('-v'); - } - let destArg = dest; - let fileArg = file; - if (IS_WINDOWS && isGnuTar) { - args.push('--force-local'); - destArg = dest.replace(/\\/g, '/'); - // Technically only the dest needs to have `/` but for aesthetic consistency - // convert slashes in the file arg too. - fileArg = file.replace(/\\/g, '/'); - } - if (isGnuTar) { - // Suppress warnings when using GNU tar to extract archives created by BSD tar - args.push('--warning=no-unknown-keyword'); } - args.push('-C', destArg, '-f', fileArg); - yield exec_1.exec(`tar`, args); - return dest; - }); + cmdStr += `${CMD_STRING}${escapeData(this.message)}`; + return cmdStr; + } } -exports.extractTar = extractTar; -/** - * Extract a xar compatible archive - * - * @param file path to the archive - * @param dest destination directory. Optional. - * @param flags flags for the xar. Optional. - * @returns path to the destination directory - */ -function extractXar(file, dest, flags = []) { - return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(IS_MAC, 'extractXar() not supported on current OS'); - assert_1.ok(file, 'parameter "file" is required'); - dest = yield _createExtractFolder(dest); - let args; - if (flags instanceof Array) { - args = flags; - } - else { - args = [flags]; - } - args.push('-x', '-C', dest, '-f', file); - if (core.isDebug()) { - args.push('-v'); - } - const xarPath = yield io.which('xar', true); - yield exec_1.exec(`"${xarPath}"`, _unique(args)); - return dest; - }); +function escapeData(s) { + return utils_1.toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A'); } -exports.extractXar = extractXar; -/** - * Extract a zip - * - * @param file path to the zip - * @param dest destination directory. Optional. - * @returns path to the destination directory - */ -function extractZip(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); - } - dest = yield _createExtractFolder(dest); - if (IS_WINDOWS) { - yield extractZipWin(file, dest); - } - else { - yield extractZipNix(file, dest); - } - return dest; - }); -} -exports.extractZip = extractZip; -function extractZipWin(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - // build the powershell command - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines - const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`; - // run powershell - const powershellPath = yield io.which('powershell', true); - const args = [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ]; - yield exec_1.exec(`"${powershellPath}"`, args); - }); +function escapeProperty(s) { + return utils_1.toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A') + .replace(/:/g, '%3A') + .replace(/,/g, '%2C'); } -function extractZipNix(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - const unzipPath = yield io.which('unzip', true); - const args = [file]; - if (!core.isDebug()) { - args.unshift('-q'); - } - yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); +//# sourceMappingURL=command.js.map + +/***/ }), + +/***/ 470: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + 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; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const command_1 = __webpack_require__(431); +const file_command_1 = __webpack_require__(102); +const utils_1 = __webpack_require__(82); +const os = __importStar(__webpack_require__(87)); +const path = __importStar(__webpack_require__(622)); /** - * Caches a directory and installs it into the tool cacheDir - * - * @param sourceDir the directory to cache into tools - * @param tool tool name - * @param version version of the tool. semver format - * @param arch architecture of the tool. Optional. Defaults to machine architecture + * The code to exit an action */ -function cacheDir(sourceDir, tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - version = semver.clean(version) || version; - arch = arch || os.arch(); - core.debug(`Caching tool ${tool} ${version} ${arch}`); - core.debug(`source dir: ${sourceDir}`); - if (!fs.statSync(sourceDir).isDirectory()) { - throw new Error('sourceDir is not a directory'); - } - // Create the tool dir - const destPath = yield _createToolPath(tool, version, arch); - // copy each child item. do not move. move can fail on Windows - // due to anti-virus software having an open handle on a file. - for (const itemName of fs.readdirSync(sourceDir)) { - const s = path.join(sourceDir, itemName); - yield io.cp(s, destPath, { recursive: true }); - } - // write .complete - _completeToolPath(tool, version, arch); - return destPath; - }); +var ExitCode; +(function (ExitCode) { + /** + * A code indicating that the action was successful + */ + ExitCode[ExitCode["Success"] = 0] = "Success"; + /** + * A code indicating that the action was a failure + */ + ExitCode[ExitCode["Failure"] = 1] = "Failure"; +})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); +//----------------------------------------------------------------------- +// Variables +//----------------------------------------------------------------------- +/** + * Sets env variable for this action and future actions in the job + * @param name the name of the variable to set + * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function exportVariable(name, val) { + const convertedVal = utils_1.toCommandValue(val); + process.env[name] = convertedVal; + const filePath = process.env['GITHUB_ENV'] || ''; + if (filePath) { + const delimiter = '_GitHubActionsFileCommandDelimeter_'; + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); + } + else { + command_1.issueCommand('set-env', { name }, convertedVal); + } } -exports.cacheDir = cacheDir; +exports.exportVariable = exportVariable; /** - * Caches a downloaded file (GUID) and installs it - * into the tool cache with a given targetName - * - * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. - * @param targetFile the name of the file name in the tools directory - * @param tool tool name - * @param version version of the tool. semver format - * @param arch architecture of the tool. Optional. Defaults to machine architecture + * Registers a secret which will get masked from logs + * @param secret value of the secret */ -function cacheFile(sourceFile, targetFile, tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - version = semver.clean(version) || version; - arch = arch || os.arch(); - core.debug(`Caching tool ${tool} ${version} ${arch}`); - core.debug(`source file: ${sourceFile}`); - if (!fs.statSync(sourceFile).isFile()) { - throw new Error('sourceFile is not a file'); - } - // create the tool dir - const destFolder = yield _createToolPath(tool, version, arch); - // copy instead of move. move can fail on Windows due to - // anti-virus software having an open handle on a file. - const destPath = path.join(destFolder, targetFile); - core.debug(`destination file ${destPath}`); - yield io.cp(sourceFile, destPath); - // write .complete - _completeToolPath(tool, version, arch); - return destFolder; - }); +function setSecret(secret) { + command_1.issueCommand('add-mask', {}, secret); } -exports.cacheFile = cacheFile; +exports.setSecret = setSecret; /** - * Finds the path to a tool version in the local installed tool cache - * - * @param toolName name of the tool - * @param versionSpec version of the tool - * @param arch optional arch. defaults to arch of computer + * Prepends inputPath to the PATH (for this action and future actions) + * @param inputPath */ -function find(toolName, versionSpec, arch) { - if (!toolName) { - throw new Error('toolName parameter is required'); - } - if (!versionSpec) { - throw new Error('versionSpec parameter is required'); - } - arch = arch || os.arch(); - // attempt to resolve an explicit version - if (!_isExplicitVersion(versionSpec)) { - const localVersions = findAllVersions(toolName, arch); - const match = _evaluateVersions(localVersions, versionSpec); - versionSpec = match; +function addPath(inputPath) { + const filePath = process.env['GITHUB_PATH'] || ''; + if (filePath) { + file_command_1.issueCommand('PATH', inputPath); } - // check for the explicit version in the cache - let toolPath = ''; - if (versionSpec) { - versionSpec = semver.clean(versionSpec) || ''; - const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch); - core.debug(`checking cache: ${cachePath}`); - if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { - core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); - toolPath = cachePath; - } - else { - core.debug('not found'); - } + else { + command_1.issueCommand('add-path', {}, inputPath); } - return toolPath; + process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; } -exports.find = find; +exports.addPath = addPath; /** - * Finds the paths to all versions of a tool that are installed in the local tool cache + * Gets the value of an input. The value is also trimmed. * - * @param toolName name of the tool - * @param arch optional arch. defaults to arch of computer + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string */ -function findAllVersions(toolName, arch) { - const versions = []; - arch = arch || os.arch(); - const toolPath = path.join(_getCacheDirectory(), toolName); - if (fs.existsSync(toolPath)) { - const children = fs.readdirSync(toolPath); - for (const child of children) { - if (_isExplicitVersion(child)) { - const fullPath = path.join(toolPath, child, arch || ''); - if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { - versions.push(child); - } - } - } +function getInput(name, options) { + const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; + if (options && options.required && !val) { + throw new Error(`Input required and not supplied: ${name}`); } - return versions; + return val.trim(); } -exports.findAllVersions = findAllVersions; -function getManifestFromRepo(owner, repo, auth, branch = 'master') { - return __awaiter(this, void 0, void 0, function* () { - let releases = []; - const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`; - const http = new httpm.HttpClient('tool-cache'); - const headers = {}; - if (auth) { - core.debug('set auth'); - headers.authorization = auth; - } - const response = yield http.getJson(treeUrl, headers); - if (!response.result) { - return releases; - } - let manifestUrl = ''; - for (const item of response.result.tree) { - if (item.path === 'versions-manifest.json') { - manifestUrl = item.url; - break; - } - } - headers['accept'] = 'application/vnd.github.VERSION.raw'; - let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody(); - if (versionsRaw) { - // shouldn't be needed but protects against invalid json saved with BOM - versionsRaw = versionsRaw.replace(/^\uFEFF/, ''); - try { - releases = JSON.parse(versionsRaw); - } - catch (_a) { - core.debug('Invalid json'); - } - } - return releases; - }); +exports.getInput = getInput; +/** + * Sets the value of an output. + * + * @param name name of the output to set + * @param value value to store. Non-string values will be converted to a string via JSON.stringify + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function setOutput(name, value) { + command_1.issueCommand('set-output', { name }, value); } -exports.getManifestFromRepo = getManifestFromRepo; -function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) { - return __awaiter(this, void 0, void 0, function* () { - // wrap the internal impl - const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter); - return match; - }); +exports.setOutput = setOutput; +/** + * Enables or disables the echoing of commands into stdout for the rest of the step. + * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. + * + */ +function setCommandEcho(enabled) { + command_1.issue('echo', enabled ? 'on' : 'off'); } -exports.findFromManifest = findFromManifest; -function _createExtractFolder(dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!dest) { - // create a temp dir - dest = path.join(_getTempDirectory(), v4_1.default()); - } - yield io.mkdirP(dest); - return dest; - }); +exports.setCommandEcho = setCommandEcho; +//----------------------------------------------------------------------- +// Results +//----------------------------------------------------------------------- +/** + * Sets the action status to failed. + * When the action exits it will be with an exit code of 1 + * @param message add error issue message + */ +function setFailed(message) { + process.exitCode = ExitCode.Failure; + error(message); } -function _createToolPath(tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); - core.debug(`destination ${folderPath}`); - const markerPath = `${folderPath}.complete`; - yield io.rmRF(folderPath); - yield io.rmRF(markerPath); - yield io.mkdirP(folderPath); - return folderPath; - }); +exports.setFailed = setFailed; +//----------------------------------------------------------------------- +// Logging Commands +//----------------------------------------------------------------------- +/** + * Gets whether Actions Step Debug is on or not + */ +function isDebug() { + return process.env['RUNNER_DEBUG'] === '1'; } -function _completeToolPath(tool, version, arch) { - const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); - const markerPath = `${folderPath}.complete`; - fs.writeFileSync(markerPath, ''); - core.debug('finished caching tool'); +exports.isDebug = isDebug; +/** + * Writes debug message to user log + * @param message debug message + */ +function debug(message) { + command_1.issueCommand('debug', {}, message); } -function _isExplicitVersion(versionSpec) { - const c = semver.clean(versionSpec) || ''; - core.debug(`isExplicit: ${c}`); - const valid = semver.valid(c) != null; - core.debug(`explicit? ${valid}`); - return valid; +exports.debug = debug; +/** + * Adds an error issue + * @param message error issue message. Errors will be converted to string via toString() + */ +function error(message) { + command_1.issue('error', message instanceof Error ? message.toString() : message); } -function _evaluateVersions(versions, versionSpec) { - let version = ''; - core.debug(`evaluating ${versions.length} versions`); - versions = versions.sort((a, b) => { - if (semver.gt(a, b)) { - return 1; - } - return -1; - }); - for (let i = versions.length - 1; i >= 0; i--) { - const potential = versions[i]; - const satisfied = semver.satisfies(potential, versionSpec); - if (satisfied) { - version = potential; - break; - } - } - if (version) { - core.debug(`matched: ${version}`); - } - else { - core.debug('match not found'); - } - return version; +exports.error = error; +/** + * Adds an warning issue + * @param message warning issue message. Errors will be converted to string via toString() + */ +function warning(message) { + command_1.issue('warning', message instanceof Error ? message.toString() : message); } +exports.warning = warning; /** - * Gets RUNNER_TOOL_CACHE + * Writes info to log with console.log. + * @param message info message */ -function _getCacheDirectory() { - const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; - assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); - return cacheDirectory; +function info(message) { + process.stdout.write(message + os.EOL); } +exports.info = info; /** - * Gets RUNNER_TEMP + * Begin an output group. + * + * Output until the next `groupEnd` will be foldable in this group + * + * @param name The name of the output group */ -function _getTempDirectory() { - const tempDirectory = process.env['RUNNER_TEMP'] || ''; - assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); - return tempDirectory; +function startGroup(name) { + command_1.issue('group', name); } +exports.startGroup = startGroup; /** - * Gets a global variable + * End an output group. */ -function _getGlobal(key, defaultValue) { - /* eslint-disable @typescript-eslint/no-explicit-any */ - const value = global[key]; - /* eslint-enable @typescript-eslint/no-explicit-any */ - return value !== undefined ? value : defaultValue; +function endGroup() { + command_1.issue('endgroup'); +} +exports.endGroup = endGroup; +/** + * Wrap an asynchronous function call in a group. + * + * Returns the same type as the function itself. + * + * @param name The name of the group + * @param fn The function to wrap in the group + */ +function group(name, fn) { + return __awaiter(this, void 0, void 0, function* () { + startGroup(name); + let result; + try { + result = yield fn(); + } + finally { + endGroup(); + } + return result; + }); } +exports.group = group; +//----------------------------------------------------------------------- +// Wrapper action state +//----------------------------------------------------------------------- /** - * Returns an array of unique values. - * @param values Values to make unique. + * Saves state for current action, the state can only be retrieved by this action's post job execution. + * + * @param name name of the state to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify */ -function _unique(values) { - return Array.from(new Set(values)); +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function saveState(name, value) { + command_1.issueCommand('save-state', { name }, value); } -//# sourceMappingURL=tool-cache.js.map +exports.saveState = saveState; +/** + * Gets the value of an state set by this action's main execution. + * + * @param name name of the state to get + * @returns string + */ +function getState(name) { + return process.env[`STATE_${name}`] || ''; +} +exports.getState = getState; +//# sourceMappingURL=core.js.map /***/ }), -/***/ 539: +/***/ 533: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const http = __webpack_require__(605); -const https = __webpack_require__(211); -const pm = __webpack_require__(950); -let tunnel; -var HttpCodes; -(function (HttpCodes) { - HttpCodes[HttpCodes["OK"] = 200] = "OK"; - HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; - HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; - HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; - HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; - HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; - HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; - HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; - HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; - HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; - HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); -var Headers; -(function (Headers) { - Headers["Accept"] = "accept"; - Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); -var MediaTypes; -(function (MediaTypes) { - MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); -/** - * Returns the proxy URL, depending upon the supplied url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ -function getProxyUrl(serverUrl) { - let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); - return proxyUrl ? proxyUrl.href : ''; -} -exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [ - HttpCodes.MovedPermanently, - HttpCodes.ResourceMoved, - HttpCodes.SeeOther, - HttpCodes.TemporaryRedirect, - HttpCodes.PermanentRedirect -]; -const HttpResponseRetryCodes = [ - HttpCodes.BadGateway, - HttpCodes.ServiceUnavailable, - HttpCodes.GatewayTimeout -]; -const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; -const ExponentialBackoffCeiling = 10; -const ExponentialBackoffTimeSlice = 5; -class HttpClientError extends Error { - constructor(message, statusCode) { - super(message); - this.name = 'HttpClientError'; - this.statusCode = statusCode; - Object.setPrototypeOf(this, HttpClientError.prototype); +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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + 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 }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(__webpack_require__(470)); +const io = __importStar(__webpack_require__(1)); +const fs = __importStar(__webpack_require__(747)); +const mm = __importStar(__webpack_require__(31)); +const os = __importStar(__webpack_require__(87)); +const path = __importStar(__webpack_require__(622)); +const httpm = __importStar(__webpack_require__(539)); +const semver = __importStar(__webpack_require__(280)); +const stream = __importStar(__webpack_require__(794)); +const util = __importStar(__webpack_require__(669)); +const v4_1 = __importDefault(__webpack_require__(826)); +const exec_1 = __webpack_require__(986); +const assert_1 = __webpack_require__(357); +const retry_helper_1 = __webpack_require__(979); +class HTTPError extends Error { + constructor(httpStatusCode) { + super(`Unexpected HTTP response: ${httpStatusCode}`); + this.httpStatusCode = httpStatusCode; + Object.setPrototypeOf(this, new.target.prototype); } } -exports.HttpClientError = HttpClientError; -class HttpClientResponse { - constructor(message) { - this.message = message; - } - readBody() { - return new Promise(async (resolve, reject) => { - let output = Buffer.alloc(0); - this.message.on('data', (chunk) => { - output = Buffer.concat([output, chunk]); - }); - this.message.on('end', () => { - resolve(output.toString()); - }); +exports.HTTPError = HTTPError; +const IS_WINDOWS = process.platform === 'win32'; +const userAgent = 'actions/tool-cache'; +/** + * Download a tool from an url and stream it into a file + * + * @param url url of tool to download + * @param dest path to download tool + * @param auth authorization header + * @returns path to downloaded tool + */ +function downloadTool(url, dest, auth) { + return __awaiter(this, void 0, void 0, function* () { + dest = dest || path.join(_getTempDirectory(), v4_1.default()); + yield io.mkdirP(path.dirname(dest)); + core.debug(`Downloading ${url}`); + core.debug(`Destination ${dest}`); + const maxAttempts = 3; + const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10); + const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20); + const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); + return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { + return yield downloadToolAttempt(url, dest || '', auth); + }), (err) => { + if (err instanceof HTTPError && err.httpStatusCode) { + // Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests + if (err.httpStatusCode < 500 && + err.httpStatusCode !== 408 && + err.httpStatusCode !== 429) { + return false; + } + } + // Otherwise retry + return true; }); - } -} -exports.HttpClientResponse = HttpClientResponse; -function isHttps(requestUrl) { - let parsedUrl = new URL(requestUrl); - return parsedUrl.protocol === 'https:'; + }); } -exports.isHttps = isHttps; -class HttpClient { - constructor(userAgent, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = userAgent; - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { - if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; +exports.downloadTool = downloadTool; +function downloadToolAttempt(url, dest, auth) { + return __awaiter(this, void 0, void 0, function* () { + if (fs.existsSync(dest)) { + throw new Error(`Destination file path ${dest} already exists`); + } + // Get the response headers + const http = new httpm.HttpClient(userAgent, [], { + allowRetries: false + }); + let headers; + if (auth) { + core.debug('set auth'); + headers = { + authorization: auth + }; + } + const response = yield http.get(url, headers); + if (response.message.statusCode !== 200) { + const err = new HTTPError(response.message.statusCode); + core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + throw err; + } + // Download the response body + const pipeline = util.promisify(stream.pipeline); + const responseMessageFactory = _getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message); + const readStream = responseMessageFactory(); + let succeeded = false; + try { + yield pipeline(readStream, fs.createWriteStream(dest)); + core.debug('download complete'); + succeeded = true; + return dest; + } + finally { + // Error, delete dest before retry + if (!succeeded) { + core.debug('download failed'); + try { + yield io.rmRF(dest); + } + catch (err) { + core.debug(`Failed to delete '${dest}'. ${err.message}`); + } } - this._socketTimeout = requestOptions.socketTimeout; - if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; + } + }); +} +/** + * Extract a .7z file + * + * @param file path to the .7z file + * @param dest destination directory. Optional. + * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this + * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will + * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is + * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line + * interface, it is smaller than the full command line interface, and it does support long paths. At the + * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. + * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path + * to 7zr.exe can be pass to this function. + * @returns path to the destination directory + */ +function extract7z(file, dest, _7zPath) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); + assert_1.ok(file, 'parameter "file" is required'); + dest = yield _createExtractFolder(dest); + const originalCwd = process.cwd(); + process.chdir(dest); + if (_7zPath) { + try { + const logLevel = core.isDebug() ? '-bb1' : '-bb0'; + const args = [ + 'x', + logLevel, + '-bd', + '-sccUTF-8', + file + ]; + const options = { + silent: true + }; + yield exec_1.exec(`"${_7zPath}"`, args, options); } - if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + finally { + process.chdir(originalCwd); } - if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); - } - if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; - } - if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; + } + else { + const escapedScript = path + .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') + .replace(/'/g, "''") + .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; + const args = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ]; + const options = { + silent: true + }; + try { + const powershellPath = yield io.which('powershell', true); + yield exec_1.exec(`"${powershellPath}"`, args, options); } - if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; + finally { + process.chdir(originalCwd); } } - } - options(requestUrl, additionalHeaders) { - return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); - } - get(requestUrl, additionalHeaders) { - return this.request('GET', requestUrl, null, additionalHeaders || {}); - } - del(requestUrl, additionalHeaders) { - return this.request('DELETE', requestUrl, null, additionalHeaders || {}); - } - post(requestUrl, data, additionalHeaders) { - return this.request('POST', requestUrl, data, additionalHeaders || {}); - } - patch(requestUrl, data, additionalHeaders) { - return this.request('PATCH', requestUrl, data, additionalHeaders || {}); - } - put(requestUrl, data, additionalHeaders) { - return this.request('PUT', requestUrl, data, additionalHeaders || {}); - } - head(requestUrl, additionalHeaders) { - return this.request('HEAD', requestUrl, null, additionalHeaders || {}); - } - sendStream(verb, requestUrl, stream, additionalHeaders) { - return this.request(verb, requestUrl, stream, additionalHeaders); - } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ - async getJson(requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - let res = await this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async postJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async putJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async patchJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ - async request(verb, requestUrl, data, headers) { - if (this._disposed) { - throw new Error('Client has already been disposed.'); + return dest; + }); +} +exports.extract7z = extract7z; +/** + * Extract a compressed tar archive + * + * @param file path to the tar + * @param dest destination directory. Optional. + * @param flags flags for the tar command to use for extraction. Defaults to 'xz' (extracting gzipped tars). Optional. + * @returns path to the destination directory + */ +function extractTar(file, dest, flags = 'xz') { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); } - let parsedUrl = new URL(requestUrl); - let info = this._prepareRequest(verb, parsedUrl, headers); - // Only perform retries on reads since writes may not be idempotent. - let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 - ? this._maxRetries + 1 - : 1; - let numTries = 0; - let response; - while (numTries < maxTries) { - response = await this.requestRaw(info, data); - // Check if it's an authentication challenge - if (response && - response.message && - response.message.statusCode === HttpCodes.Unauthorized) { - let authenticationHandler; - for (let i = 0; i < this.handlers.length; i++) { - if (this.handlers[i].canHandleAuthentication(response)) { - authenticationHandler = this.handlers[i]; - break; - } - } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info, data); - } - else { - // We have received an unauthorized response but have no handlers to handle it. - // Let the response return to the caller. - return response; - } - } - let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && - this._allowRedirects && - redirectsRemaining > 0) { - const redirectUrl = response.message.headers['location']; - if (!redirectUrl) { - // if there's no location to redirect to, we won't - break; - } - let parsedRedirectUrl = new URL(redirectUrl); - if (parsedUrl.protocol == 'https:' && - parsedUrl.protocol != parsedRedirectUrl.protocol && - !this._allowRedirectDowngrade) { - throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); - } - // we need to finish reading the response before reassigning response - // which will leak the open socket. - await response.readBody(); - // strip authorization header if redirected to a different hostname - if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { - for (let header in headers) { - // header names are case insensitive - if (header.toLowerCase() === 'authorization') { - delete headers[header]; - } - } - } - // let's make the request with the new redirectUrl - info = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = await this.requestRaw(info, data); - redirectsRemaining--; - } - if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { - // If not a retry code, return immediately instead of retrying - return response; - } - numTries += 1; - if (numTries < maxTries) { - await response.readBody(); - await this._performExponentialBackoff(numTries); + // Create dest + dest = yield _createExtractFolder(dest); + // Determine whether GNU tar + core.debug('Checking tar --version'); + let versionOutput = ''; + yield exec_1.exec('tar --version', [], { + ignoreReturnCode: true, + silent: true, + listeners: { + stdout: (data) => (versionOutput += data.toString()), + stderr: (data) => (versionOutput += data.toString()) } + }); + core.debug(versionOutput.trim()); + const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR'); + // Initialize args + let args; + if (flags instanceof Array) { + args = flags; } - return response; - } - /** - * Needs to be called if keepAlive is set to true in request options. - */ - dispose() { - if (this._agent) { - this._agent.destroy(); + else { + args = [flags]; } - this._disposed = true; - } - /** - * Raw request. - * @param info - * @param data - */ - requestRaw(info, data) { - return new Promise((resolve, reject) => { - let callbackForResult = function (err, res) { - if (err) { - reject(err); - } - resolve(res); - }; - this.requestRawWithCallback(info, data, callbackForResult); - }); - } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ - requestRawWithCallback(info, data, onResult) { - let socket; - if (typeof data === 'string') { - info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); + if (core.isDebug() && !flags.includes('v')) { + args.push('-v'); } - let callbackCalled = false; - let handleResult = (err, res) => { - if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); - } - }; - let req = info.httpModule.request(info.options, (msg) => { - let res = new HttpClientResponse(msg); - handleResult(null, res); - }); - req.on('socket', sock => { - socket = sock; - }); - // If we ever get disconnected, we want the socket to timeout eventually - req.setTimeout(this._socketTimeout || 3 * 60000, () => { - if (socket) { - socket.end(); - } - handleResult(new Error('Request timeout: ' + info.options.path), null); - }); - req.on('error', function (err) { - // err has statusCode property - // res should have headers - handleResult(err, null); - }); - if (data && typeof data === 'string') { - req.write(data, 'utf8'); + let destArg = dest; + let fileArg = file; + if (IS_WINDOWS && isGnuTar) { + args.push('--force-local'); + destArg = dest.replace(/\\/g, '/'); + // Technically only the dest needs to have `/` but for aesthetic consistency + // convert slashes in the file arg too. + fileArg = file.replace(/\\/g, '/'); } - if (data && typeof data !== 'string') { - data.on('close', function () { - req.end(); - }); - data.pipe(req); + if (isGnuTar) { + // Suppress warnings when using GNU tar to extract archives created by BSD tar + args.push('--warning=no-unknown-keyword'); } - else { - req.end(); + args.push('-C', destArg, '-f', fileArg); + yield exec_1.exec(`tar`, args); + return dest; + }); +} +exports.extractTar = extractTar; +/** + * Extract a zip + * + * @param file path to the zip + * @param dest destination directory. Optional. + * @returns path to the destination directory + */ +function extractZip(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); } - } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ - getAgent(serverUrl) { - let parsedUrl = new URL(serverUrl); - return this._getAgent(parsedUrl); - } - _prepareRequest(method, requestUrl, headers) { - const info = {}; - info.parsedUrl = requestUrl; - const usingSsl = info.parsedUrl.protocol === 'https:'; - info.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info.options = {}; - info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port - ? parseInt(info.parsedUrl.port) - : defaultPort; - info.options.path = - (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); - info.options.method = method; - info.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info.options.headers['user-agent'] = this.userAgent; + dest = yield _createExtractFolder(dest); + if (IS_WINDOWS) { + yield extractZipWin(file, dest); } - info.options.agent = this._getAgent(info.parsedUrl); - // gives handlers an opportunity to participate - if (this.handlers) { - this.handlers.forEach(handler => { - handler.prepareRequest(info.options); - }); + else { + yield extractZipNix(file, dest); } - return info; - } - _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); + return dest; + }); +} +exports.extractZip = extractZip; +function extractZipWin(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + // build the powershell command + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines + const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`; + // run powershell + const powershellPath = yield io.which('powershell', true); + const args = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ]; + yield exec_1.exec(`"${powershellPath}"`, args); + }); +} +function extractZipNix(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + const unzipPath = yield io.which('unzip', true); + const args = [file]; + if (!core.isDebug()) { + args.unshift('-q'); } - return lowercaseKeys(headers || {}); - } - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; + yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); + }); +} +/** + * Caches a directory and installs it into the tool cacheDir + * + * @param sourceDir the directory to cache into tools + * @param tool tool name + * @param version version of the tool. semver format + * @param arch architecture of the tool. Optional. Defaults to machine architecture + */ +function cacheDir(sourceDir, tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + version = semver.clean(version) || version; + arch = arch || os.arch(); + core.debug(`Caching tool ${tool} ${version} ${arch}`); + core.debug(`source dir: ${sourceDir}`); + if (!fs.statSync(sourceDir).isDirectory()) { + throw new Error('sourceDir is not a directory'); } - return additionalHeaders[header] || clientHeader || _default; - } - _getAgent(parsedUrl) { - let agent; - let proxyUrl = pm.getProxyUrl(parsedUrl); - let useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; + // Create the tool dir + const destPath = yield _createToolPath(tool, version, arch); + // copy each child item. do not move. move can fail on Windows + // due to anti-virus software having an open handle on a file. + for (const itemName of fs.readdirSync(sourceDir)) { + const s = path.join(sourceDir, itemName); + yield io.cp(s, destPath, { recursive: true }); } - if (this._keepAlive && !useProxy) { - agent = this._agent; + // write .complete + _completeToolPath(tool, version, arch); + return destPath; + }); +} +exports.cacheDir = cacheDir; +/** + * Caches a downloaded file (GUID) and installs it + * into the tool cache with a given targetName + * + * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. + * @param targetFile the name of the file name in the tools directory + * @param tool tool name + * @param version version of the tool. semver format + * @param arch architecture of the tool. Optional. Defaults to machine architecture + */ +function cacheFile(sourceFile, targetFile, tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + version = semver.clean(version) || version; + arch = arch || os.arch(); + core.debug(`Caching tool ${tool} ${version} ${arch}`); + core.debug(`source file: ${sourceFile}`); + if (!fs.statSync(sourceFile).isFile()) { + throw new Error('sourceFile is not a file'); } - // if agent is already assigned use that agent. - if (!!agent) { - return agent; + // create the tool dir + const destFolder = yield _createToolPath(tool, version, arch); + // copy instead of move. move can fail on Windows due to + // anti-virus software having an open handle on a file. + const destPath = path.join(destFolder, targetFile); + core.debug(`destination file ${destPath}`); + yield io.cp(sourceFile, destPath); + // write .complete + _completeToolPath(tool, version, arch); + return destFolder; + }); +} +exports.cacheFile = cacheFile; +/** + * Finds the path to a tool version in the local installed tool cache + * + * @param toolName name of the tool + * @param versionSpec version of the tool + * @param arch optional arch. defaults to arch of computer + */ +function find(toolName, versionSpec, arch) { + if (!toolName) { + throw new Error('toolName parameter is required'); + } + if (!versionSpec) { + throw new Error('versionSpec parameter is required'); + } + arch = arch || os.arch(); + // attempt to resolve an explicit version + if (!_isExplicitVersion(versionSpec)) { + const localVersions = findAllVersions(toolName, arch); + const match = _evaluateVersions(localVersions, versionSpec); + versionSpec = match; + } + // check for the explicit version in the cache + let toolPath = ''; + if (versionSpec) { + versionSpec = semver.clean(versionSpec) || ''; + const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch); + core.debug(`checking cache: ${cachePath}`); + if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { + core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + toolPath = cachePath; } - const usingSsl = parsedUrl.protocol === 'https:'; - let maxSockets = 100; - if (!!this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; + else { + core.debug('not found'); } - if (useProxy) { - // If using proxy, need tunnel - if (!tunnel) { - tunnel = __webpack_require__(413); - } - const agentOptions = { - maxSockets: maxSockets, - keepAlive: this._keepAlive, - proxy: { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`, - host: proxyUrl.hostname, - port: proxyUrl.port + } + return toolPath; +} +exports.find = find; +/** + * Finds the paths to all versions of a tool that are installed in the local tool cache + * + * @param toolName name of the tool + * @param arch optional arch. defaults to arch of computer + */ +function findAllVersions(toolName, arch) { + const versions = []; + arch = arch || os.arch(); + const toolPath = path.join(_getCacheDirectory(), toolName); + if (fs.existsSync(toolPath)) { + const children = fs.readdirSync(toolPath); + for (const child of children) { + if (_isExplicitVersion(child)) { + const fullPath = path.join(toolPath, child, arch || ''); + if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { + versions.push(child); } - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === 'https:'; - if (usingSsl) { - tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; - } - else { - tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { - const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; - } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; + } + return versions; +} +exports.findAllVersions = findAllVersions; +function getManifestFromRepo(owner, repo, auth, branch = 'master') { + return __awaiter(this, void 0, void 0, function* () { + let releases = []; + const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`; + const http = new httpm.HttpClient('tool-cache'); + const headers = {}; + if (auth) { + core.debug('set auth'); + headers.authorization = auth; } - if (usingSsl && this._ignoreSslError) { - // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process - // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options - // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { - rejectUnauthorized: false - }); + const response = yield http.getJson(treeUrl, headers); + if (!response.result) { + return releases; } - return agent; - } - _performExponentialBackoff(retryNumber) { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise(resolve => setTimeout(() => resolve(), ms)); - } - static dateTimeDeserializer(key, value) { - if (typeof value === 'string') { - let a = new Date(value); - if (!isNaN(a.valueOf())) { - return a; + let manifestUrl = ''; + for (const item of response.result.tree) { + if (item.path === 'versions-manifest.json') { + manifestUrl = item.url; + break; } } - return value; - } - async _processResponse(res, options) { - return new Promise(async (resolve, reject) => { - const statusCode = res.message.statusCode; - const response = { - statusCode: statusCode, - result: null, - headers: {} - }; - // not found leads to null obj returned - if (statusCode == HttpCodes.NotFound) { - resolve(response); - } - let obj; - let contents; - // get the result from the body + headers['accept'] = 'application/vnd.github.VERSION.raw'; + let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody(); + if (versionsRaw) { + // shouldn't be needed but protects against invalid json saved with BOM + versionsRaw = versionsRaw.replace(/^\uFEFF/, ''); try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; - } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null - } - // note that 3xx redirects are handled by the http layer. - if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = 'Failed request: (' + statusCode + ')'; - } - let err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); + releases = JSON.parse(versionsRaw); } - else { - resolve(response); + catch (_a) { + core.debug('Invalid json'); } - }); + } + return releases; + }); +} +exports.getManifestFromRepo = getManifestFromRepo; +function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) { + return __awaiter(this, void 0, void 0, function* () { + // wrap the internal impl + const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter); + return match; + }); +} +exports.findFromManifest = findFromManifest; +function _createExtractFolder(dest) { + return __awaiter(this, void 0, void 0, function* () { + if (!dest) { + // create a temp dir + dest = path.join(_getTempDirectory(), v4_1.default()); + } + yield io.mkdirP(dest); + return dest; + }); +} +function _createToolPath(tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); + core.debug(`destination ${folderPath}`); + const markerPath = `${folderPath}.complete`; + yield io.rmRF(folderPath); + yield io.rmRF(markerPath); + yield io.mkdirP(folderPath); + return folderPath; + }); +} +function _completeToolPath(tool, version, arch) { + const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); + const markerPath = `${folderPath}.complete`; + fs.writeFileSync(markerPath, ''); + core.debug('finished caching tool'); +} +function _isExplicitVersion(versionSpec) { + const c = semver.clean(versionSpec) || ''; + core.debug(`isExplicit: ${c}`); + const valid = semver.valid(c) != null; + core.debug(`explicit? ${valid}`); + return valid; +} +function _evaluateVersions(versions, versionSpec) { + let version = ''; + core.debug(`evaluating ${versions.length} versions`); + versions = versions.sort((a, b) => { + if (semver.gt(a, b)) { + return 1; + } + return -1; + }); + for (let i = versions.length - 1; i >= 0; i--) { + const potential = versions[i]; + const satisfied = semver.satisfies(potential, versionSpec); + if (satisfied) { + version = potential; + break; + } + } + if (version) { + core.debug(`matched: ${version}`); + } + else { + core.debug('match not found'); } + return version; } -exports.HttpClient = HttpClient; - - -/***/ }), - -/***/ 548: -/***/ (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 - +/** + * Gets RUNNER_TOOL_CACHE + */ +function _getCacheDirectory() { + const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; + assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); + return cacheDirectory; +} +/** + * Gets RUNNER_TEMP + */ +function _getTempDirectory() { + const tempDirectory = process.env['RUNNER_TEMP'] || ''; + assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); + return tempDirectory; +} +/** + * Gets a global variable + */ +function _getGlobal(key, defaultValue) { + /* eslint-disable @typescript-eslint/no-explicit-any */ + const value = global[key]; + /* eslint-enable @typescript-eslint/no-explicit-any */ + return value !== undefined ? value : defaultValue; +} +//# sourceMappingURL=tool-cache.js.map /***/ }), -/***/ 550: -/***/ (function(module, exports) { +/***/ 539: +/***/ (function(__unusedmodule, exports, __webpack_require__) { -exports = module.exports = SemVer +"use strict"; -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 () {} -} - -// 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' - -var MAX_LENGTH = 256 -var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 - -// Max safe segment length for coercion. -var MAX_SAFE_COMPONENT_LENGTH = 16 - -// The actual regexps go on exports.re -var re = exports.re = [] -var src = exports.src = [] -var t = exports.tokens = {} -var R = 0 - -function tok (n) { - t[n] = R++ -} - -// 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. - -tok('NUMERICIDENTIFIER') -src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' -tok('NUMERICIDENTIFIERLOOSE') -src[t.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. - -tok('NONNUMERICIDENTIFIER') -src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' - -// ## Main Version -// Three dot-separated numeric identifiers. - -tok('MAINVERSION') -src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')' - -tok('MAINVERSIONLOOSE') -src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' - -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. - -tok('PRERELEASEIDENTIFIER') -src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' - -tok('PRERELEASEIDENTIFIERLOOSE') -src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' - -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. - -tok('PRERELEASE') -src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' - -tok('PRERELEASELOOSE') -src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' - -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. - -tok('BUILDIDENTIFIER') -src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' - -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. - -tok('BUILD') -src[t.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. - -tok('FULL') -tok('FULLPLAIN') -src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + - src[t.PRERELEASE] + '?' + - src[t.BUILD] + '?' - -src[t.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. -tok('LOOSEPLAIN') -src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + - src[t.PRERELEASELOOSE] + '?' + - src[t.BUILD] + '?' - -tok('LOOSE') -src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' - -tok('GTLT') -src[t.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. -tok('XRANGEIDENTIFIERLOOSE') -src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' -tok('XRANGEIDENTIFIER') -src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' - -tok('XRANGEPLAIN') -src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:' + src[t.PRERELEASE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' - -tok('XRANGEPLAINLOOSE') -src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:' + src[t.PRERELEASELOOSE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' - -tok('XRANGE') -src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' -tok('XRANGELOOSE') -src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' - -// 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') - -// Tilde ranges. -// Meaning is "reasonably at or greater than" -tok('LONETILDE') -src[t.LONETILDE] = '(?:~>?)' - -tok('TILDETRIM') -src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' -re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') -var tildeTrimReplace = '$1~' - -tok('TILDE') -src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' -tok('TILDELOOSE') -src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' - -// Caret ranges. -// Meaning is "at least and backwards compatible with" -tok('LONECARET') -src[t.LONECARET] = '(?:\\^)' - -tok('CARETTRIM') -src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' -re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') -var caretTrimReplace = '$1^' - -tok('CARET') -src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' -tok('CARETLOOSE') -src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' - -// 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] + ')$|^$' - -// 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] + ')' - -// this one has to use the /g flag -re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') -var 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. -tok('HYPHENRANGE') -src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAIN] + ')' + - '\\s*$' - -tok('HYPHENRANGELOOSE') -src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s*$' - -// Star ranges basically just allow anything at all. -tok('STAR') -src[t.STAR] = '(<|>)?=?\\s*\\*' - -// 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]) - } -} - -exports.parse = parse -function 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 - } - - var 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 - } -} - -exports.valid = valid -function valid (version, options) { - var v = parse(version, options) - return v ? v.version : null -} - -exports.clean = clean -function clean (version, options) { - var s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null -} - -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) - } - - if (version.length > MAX_LENGTH) { - throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') - } - - if (!(this instanceof SemVer)) { - return new SemVer(version, options) - } - - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose - - var 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(function (id) { - if (/^[0-9]+$/.test(id)) { - var num = +id - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num - } - } - return id - }) - } - - this.build = m[5] ? m[5].split('.') : [] - this.format() -} - -SemVer.prototype.format = function () { - this.version = this.major + '.' + this.minor + '.' + this.patch - if (this.prerelease.length) { - this.version += '-' + this.prerelease.join('.') - } - return this.version -} - -SemVer.prototype.toString = function () { - return this.version -} - -SemVer.prototype.compare = function (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - return this.compareMain(other) || this.comparePre(other) -} - -SemVer.prototype.compareMain = function (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) -} - -SemVer.prototype.comparePre = function (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 - } - - 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) -} - -SemVer.prototype.compareBuild = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - 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) -} - -// 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 - - default: - throw new Error('invalid increment argument: ' + release) - } - this.format() - this.raw = this.version - return this -} - -exports.inc = inc -function inc (version, release, loose, identifier) { - if (typeof (loose) === 'string') { - identifier = loose - loose = undefined - } - - try { - return new SemVer(version, loose).inc(release, identifier).version - } catch (er) { - return null - } -} - -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 - } - } - } - return defaultResult // may be undefined - } -} - -exports.compareIdentifiers = compareIdentifiers - -var numeric = /^[0-9]+$/ -function compareIdentifiers (a, b) { - var anum = numeric.test(a) - var 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 -} - -exports.rcompareIdentifiers = rcompareIdentifiers -function rcompareIdentifiers (a, b) { - return compareIdentifiers(b, a) -} - -exports.major = major -function major (a, loose) { - return new SemVer(a, loose).major -} - -exports.minor = minor -function minor (a, loose) { - return new SemVer(a, loose).minor -} - -exports.patch = patch -function patch (a, loose) { - return new SemVer(a, loose).patch -} - -exports.compare = compare -function compare (a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)) -} - -exports.compareLoose = compareLoose -function compareLoose (a, b) { - return compare(a, b, true) -} - -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) -} - -exports.rcompare = rcompare -function rcompare (a, b, loose) { - return compare(b, a, loose) -} - -exports.sort = sort -function sort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(a, b, loose) - }) -} - -exports.rsort = rsort -function rsort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(b, a, loose) - }) -} - -exports.gt = gt -function gt (a, b, loose) { - return compare(a, b, loose) > 0 -} - -exports.lt = lt -function lt (a, b, loose) { - return compare(a, b, loose) < 0 -} - -exports.eq = eq -function eq (a, b, loose) { - return compare(a, b, loose) === 0 -} - -exports.neq = neq -function neq (a, b, loose) { - return compare(a, b, loose) !== 0 -} - -exports.gte = gte -function gte (a, b, loose) { - return compare(a, b, loose) >= 0 -} - -exports.lte = lte -function lte (a, b, loose) { - return compare(a, b, loose) <= 0 -} - -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) - - default: - throw new TypeError('Invalid operator: ' + op) - } -} - -exports.Comparator = Comparator -function Comparator (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 - } - } - - 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 - } - - debug('comp', this) -} - -var ANY = {} -Comparator.prototype.parse = function (comp) { - var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var 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) - } -} - -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 - } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } - - return cmp(version, this.operator, this.semver, this.options) -} - -Comparator.prototype.intersects = function (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } - - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - - var rangeTmp - - 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) - } - - 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 +Object.defineProperty(exports, "__esModule", { value: true }); +const http = __webpack_require__(605); +const https = __webpack_require__(211); +const pm = __webpack_require__(950); +let tunnel; +var HttpCodes; +(function (HttpCodes) { + HttpCodes[HttpCodes["OK"] = 200] = "OK"; + HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; + HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; + HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; + HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; + HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; + HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; + HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; + HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; + HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; + HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; + HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; + HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; + HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; + HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; + HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; + HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; + HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; + HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; + HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; + HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; + HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; + HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; + HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; + HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; + HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; + HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; +})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); +var Headers; +(function (Headers) { + Headers["Accept"] = "accept"; + Headers["ContentType"] = "content-type"; +})(Headers = exports.Headers || (exports.Headers = {})); +var MediaTypes; +(function (MediaTypes) { + MediaTypes["ApplicationJson"] = "application/json"; +})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); +/** + * Returns the proxy URL, depending upon the supplied url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ +function getProxyUrl(serverUrl) { + let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); + return proxyUrl ? proxyUrl.href : ''; } - -exports.Range = Range -function Range (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) +exports.getProxyUrl = getProxyUrl; +const HttpRedirectCodes = [ + HttpCodes.MovedPermanently, + HttpCodes.ResourceMoved, + HttpCodes.SeeOther, + HttpCodes.TemporaryRedirect, + HttpCodes.PermanentRedirect +]; +const HttpResponseRetryCodes = [ + HttpCodes.BadGateway, + HttpCodes.ServiceUnavailable, + HttpCodes.GatewayTimeout +]; +const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; +const ExponentialBackoffCeiling = 10; +const ExponentialBackoffTimeSlice = 5; +class HttpClientError extends Error { + constructor(message, statusCode) { + super(message); + this.name = 'HttpClientError'; + this.statusCode = statusCode; + Object.setPrototypeOf(this, HttpClientError.prototype); } - } - - if (range instanceof Comparator) { - return new Range(range.value, options) - } - - if (!(this instanceof Range)) { - return new Range(range, options) - } - - 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(function (range) { - return this.parseRange(range.trim()) - }, this).filter(function (c) { - // throw out any that are not relevant for whatever reason - return c.length - }) - - if (!this.set.length) { - throw new TypeError('Invalid SemVer Range: ' + range) - } - - this.format() -} - -Range.prototype.format = function () { - this.range = this.set.map(function (comps) { - return comps.join(' ').trim() - }).join('||').trim() - return this.range -} - -Range.prototype.toString = function () { - return this.range -} - -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]) - - // `~ 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. - - 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) - - return set -} - -Range.prototype.intersects = function (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') - } - - 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) - }) - - testComparator = remainingComparators.pop() - } - - 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' +exports.HttpClientError = HttpClientError; +class HttpClientResponse { + constructor(message) { + this.message = message; + } + readBody() { + return new Promise(async (resolve, reject) => { + let output = Buffer.alloc(0); + this.message.on('data', (chunk) => { + output = Buffer.concat([output, chunk]); + }); + this.message.on('end', () => { + resolve(output.toString()); + }); + }); } - - 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(' ') +exports.HttpClientResponse = HttpClientResponse; +function isHttps(requestUrl) { + let parsedUrl = new URL(requestUrl); + return parsedUrl.protocol === 'https:'; } - -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' +exports.isHttps = isHttps; +class HttpClient { + constructor(userAgent, handlers, requestOptions) { + this._ignoreSslError = false; + this._allowRedirects = true; + this._allowRedirectDowngrade = false; + this._maxRedirects = 50; + this._allowRetries = false; + this._maxRetries = 1; + this._keepAlive = false; + this._disposed = false; + this.userAgent = userAgent; + this.handlers = handlers || []; + this.requestOptions = requestOptions; + if (requestOptions) { + if (requestOptions.ignoreSslError != null) { + this._ignoreSslError = requestOptions.ignoreSslError; + } + this._socketTimeout = requestOptions.socketTimeout; + if (requestOptions.allowRedirects != null) { + this._allowRedirects = requestOptions.allowRedirects; + } + if (requestOptions.allowRedirectDowngrade != null) { + this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + } + if (requestOptions.maxRedirects != null) { + this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + } + if (requestOptions.keepAlive != null) { + this._keepAlive = requestOptions.keepAlive; + } + if (requestOptions.allowRetries != null) { + this._allowRetries = requestOptions.allowRetries; + } + if (requestOptions.maxRetries != null) { + this._maxRetries = requestOptions.maxRetries; + } } - } 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 = '' + options(requestUrl, additionalHeaders) { + return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); } - - // 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 + get(requestUrl, additionalHeaders) { + return this.request('GET', requestUrl, null, additionalHeaders || {}); } - - 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 - } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false + del(requestUrl, additionalHeaders) { + return this.request('DELETE', requestUrl, null, additionalHeaders || {}); + } + post(requestUrl, data, additionalHeaders) { + return this.request('POST', requestUrl, data, additionalHeaders || {}); + } + patch(requestUrl, data, additionalHeaders) { + return this.request('PATCH', requestUrl, data, additionalHeaders || {}); + } + put(requestUrl, data, additionalHeaders) { + return this.request('PUT', requestUrl, data, additionalHeaders || {}); + } + head(requestUrl, additionalHeaders) { + return this.request('HEAD', requestUrl, null, additionalHeaders || {}); } - } - - for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true + sendStream(verb, requestUrl, stream, additionalHeaders) { + return this.request(verb, requestUrl, stream, additionalHeaders); } - } - return false -} - -function testSet (set, version, options) { - for (var i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false + /** + * Gets a typed object from an endpoint + * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise + */ + async getJson(requestUrl, additionalHeaders = {}) { + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + let res = await this.get(requestUrl, additionalHeaders); + return this._processResponse(res, this.requestOptions); } - } - - 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 + async postJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.post(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async putJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.put(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async patchJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.patch(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + /** + * Makes a raw http request. + * All other methods such as get, post, patch, and request ultimately call this. + * Prefer get, del, post and patch + */ + async request(verb, requestUrl, data, headers) { + if (this._disposed) { + throw new Error('Client has already been disposed.'); } - } + let parsedUrl = new URL(requestUrl); + let info = this._prepareRequest(verb, parsedUrl, headers); + // Only perform retries on reads since writes may not be idempotent. + let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 + ? this._maxRetries + 1 + : 1; + let numTries = 0; + let response; + while (numTries < maxTries) { + response = await this.requestRaw(info, data); + // Check if it's an authentication challenge + if (response && + response.message && + response.message.statusCode === HttpCodes.Unauthorized) { + let authenticationHandler; + for (let i = 0; i < this.handlers.length; i++) { + if (this.handlers[i].canHandleAuthentication(response)) { + authenticationHandler = this.handlers[i]; + break; + } + } + if (authenticationHandler) { + return authenticationHandler.handleAuthentication(this, info, data); + } + else { + // We have received an unauthorized response but have no handlers to handle it. + // Let the response return to the caller. + return response; + } + } + let redirectsRemaining = this._maxRedirects; + while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && + this._allowRedirects && + redirectsRemaining > 0) { + const redirectUrl = response.message.headers['location']; + if (!redirectUrl) { + // if there's no location to redirect to, we won't + break; + } + let parsedRedirectUrl = new URL(redirectUrl); + if (parsedUrl.protocol == 'https:' && + parsedUrl.protocol != parsedRedirectUrl.protocol && + !this._allowRedirectDowngrade) { + throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); + } + // we need to finish reading the response before reassigning response + // which will leak the open socket. + await response.readBody(); + // strip authorization header if redirected to a different hostname + if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { + for (let header in headers) { + // header names are case insensitive + if (header.toLowerCase() === 'authorization') { + delete headers[header]; + } + } + } + // let's make the request with the new redirectUrl + info = this._prepareRequest(verb, parsedRedirectUrl, headers); + response = await this.requestRaw(info, data); + redirectsRemaining--; + } + if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { + // If not a retry code, return immediately instead of retrying + return response; + } + numTries += 1; + if (numTries < maxTries) { + await response.readBody(); + await this._performExponentialBackoff(numTries); + } + } + return response; } - - // 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) - } + /** + * Needs to be called if keepAlive is set to true in request options. + */ + dispose() { + if (this._agent) { + this._agent.destroy(); + } + this._disposed = true; } - }) - return max -} - -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) - } + /** + * Raw request. + * @param info + * @param data + */ + requestRaw(info, data) { + return new Promise((resolve, reject) => { + let callbackForResult = function (err, res) { + if (err) { + reject(err); + } + resolve(res); + }; + this.requestRawWithCallback(info, data, callbackForResult); + }); + } + /** + * Raw request with callback. + * @param info + * @param data + * @param onResult + */ + requestRawWithCallback(info, data, onResult) { + let socket; + if (typeof data === 'string') { + info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); + } + let callbackCalled = false; + let handleResult = (err, res) => { + if (!callbackCalled) { + callbackCalled = true; + onResult(err, res); + } + }; + let req = info.httpModule.request(info.options, (msg) => { + let res = new HttpClientResponse(msg); + handleResult(null, res); + }); + req.on('socket', sock => { + socket = sock; + }); + // If we ever get disconnected, we want the socket to timeout eventually + req.setTimeout(this._socketTimeout || 3 * 60000, () => { + if (socket) { + socket.end(); + } + handleResult(new Error('Request timeout: ' + info.options.path), null); + }); + req.on('error', function (err) { + // err has statusCode property + // res should have headers + handleResult(err, null); + }); + if (data && typeof data === 'string') { + req.write(data, 'utf8'); + } + if (data && typeof data !== 'string') { + data.on('close', function () { + req.end(); + }); + data.pipe(req); + } + else { + req.end(); + } } - }) - return min -} - -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 - } - - return null -} - -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 - } -} - -// 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) -} - -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] - - var high = null - var low = null - - 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 the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false + /** + * Gets an http agent. This function is useful when you need an http agent that handles + * routing through a proxy server - depending upon the url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ + getAgent(serverUrl) { + let parsedUrl = new URL(serverUrl); + return this._getAgent(parsedUrl); } - - // 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 + _prepareRequest(method, requestUrl, headers) { + const info = {}; + info.parsedUrl = requestUrl; + const usingSsl = info.parsedUrl.protocol === 'https:'; + info.httpModule = usingSsl ? https : http; + const defaultPort = usingSsl ? 443 : 80; + info.options = {}; + info.options.host = info.parsedUrl.hostname; + info.options.port = info.parsedUrl.port + ? parseInt(info.parsedUrl.port) + : defaultPort; + info.options.path = + (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); + info.options.method = method; + info.options.headers = this._mergeHeaders(headers); + if (this.userAgent != null) { + info.options.headers['user-agent'] = this.userAgent; + } + info.options.agent = this._getAgent(info.parsedUrl); + // gives handlers an opportunity to participate + if (this.handlers) { + this.handlers.forEach(handler => { + handler.prepareRequest(info.options); + }); + } + return info; } - } - 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) -} - -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 - } - - options = options || {} - - 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 + _mergeHeaders(headers) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + if (this.requestOptions && this.requestOptions.headers) { + return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); + } + return lowercaseKeys(headers || {}); } - // 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) -} - - -/***/ }), - -/***/ 586: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const lt = (a, b, loose) => compare(a, b, loose) < 0 -module.exports = lt - - -/***/ }), - -/***/ 593: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compareBuild = __webpack_require__(16) -const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) -module.exports = rsort - - -/***/ }), - -/***/ 605: -/***/ (function(module) { - -module.exports = require("http"); - -/***/ }), - -/***/ 612: -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - -module.exports = Yallist - -Yallist.Node = Node -Yallist.create = Yallist - -function Yallist (list) { - var self = this - if (!(self instanceof Yallist)) { - self = new Yallist() - } - - self.tail = null - self.head = null - self.length = 0 - - if (list && typeof list.forEach === 'function') { - list.forEach(function (item) { - self.push(item) - }) - } else if (arguments.length > 0) { - for (var i = 0, l = arguments.length; i < l; i++) { - self.push(arguments[i]) + _getExistingOrDefaultHeader(additionalHeaders, header, _default) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + let clientHeader; + if (this.requestOptions && this.requestOptions.headers) { + clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; + } + return additionalHeaders[header] || clientHeader || _default; + } + _getAgent(parsedUrl) { + let agent; + let proxyUrl = pm.getProxyUrl(parsedUrl); + let useProxy = proxyUrl && proxyUrl.hostname; + if (this._keepAlive && useProxy) { + agent = this._proxyAgent; + } + if (this._keepAlive && !useProxy) { + agent = this._agent; + } + // if agent is already assigned use that agent. + if (!!agent) { + return agent; + } + const usingSsl = parsedUrl.protocol === 'https:'; + let maxSockets = 100; + if (!!this.requestOptions) { + maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; + } + if (useProxy) { + // If using proxy, need tunnel + if (!tunnel) { + tunnel = __webpack_require__(413); + } + const agentOptions = { + maxSockets: maxSockets, + keepAlive: this._keepAlive, + proxy: { + proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`, + host: proxyUrl.hostname, + port: proxyUrl.port + } + }; + let tunnelAgent; + const overHttps = proxyUrl.protocol === 'https:'; + if (usingSsl) { + tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; + } + else { + tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; + } + agent = tunnelAgent(agentOptions); + this._proxyAgent = agent; + } + // if reusing agent across request and tunneling agent isn't assigned create a new agent + if (this._keepAlive && !agent) { + const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; + agent = usingSsl ? new https.Agent(options) : new http.Agent(options); + this._agent = agent; + } + // if not using private agent and tunnel agent isn't setup then use global agent + if (!agent) { + agent = usingSsl ? https.globalAgent : http.globalAgent; + } + if (usingSsl && this._ignoreSslError) { + // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process + // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options + // we have to cast it to any and change it directly + agent.options = Object.assign(agent.options || {}, { + rejectUnauthorized: false + }); + } + return agent; + } + _performExponentialBackoff(retryNumber) { + retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); + const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); + return new Promise(resolve => setTimeout(() => resolve(), ms)); + } + static dateTimeDeserializer(key, value) { + if (typeof value === 'string') { + let a = new Date(value); + if (!isNaN(a.valueOf())) { + return a; + } + } + return value; + } + async _processResponse(res, options) { + return new Promise(async (resolve, reject) => { + const statusCode = res.message.statusCode; + const response = { + statusCode: statusCode, + result: null, + headers: {} + }; + // not found leads to null obj returned + if (statusCode == HttpCodes.NotFound) { + resolve(response); + } + let obj; + let contents; + // get the result from the body + try { + contents = await res.readBody(); + if (contents && contents.length > 0) { + if (options && options.deserializeDates) { + obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); + } + else { + obj = JSON.parse(contents); + } + response.result = obj; + } + response.headers = res.message.headers; + } + catch (err) { + // Invalid resource (contents not json); leaving result obj null + } + // note that 3xx redirects are handled by the http layer. + if (statusCode > 299) { + let msg; + // if exception/error in body, attempt to get better error + if (obj && obj.message) { + msg = obj.message; + } + else if (contents && contents.length > 0) { + // it may be the case that the exception is in the body message as string + msg = contents; + } + else { + msg = 'Failed request: (' + statusCode + ')'; + } + let err = new HttpClientError(msg, statusCode); + err.result = response.result; + reject(err); + } + else { + resolve(response); + } + }); } - } - - return self -} - -Yallist.prototype.removeNode = function (node) { - if (node.list !== this) { - throw new Error('removing node which does not belong to this list') - } - - var next = node.next - var prev = node.prev - - if (next) { - next.prev = prev - } - - if (prev) { - prev.next = next - } - - if (node === this.head) { - this.head = next - } - if (node === this.tail) { - this.tail = prev - } - - node.list.length-- - node.next = null - node.prev = null - node.list = null - - return next -} - -Yallist.prototype.unshiftNode = function (node) { - if (node === this.head) { - return - } - - if (node.list) { - node.list.removeNode(node) - } - - var head = this.head - node.list = this - node.next = head - if (head) { - head.prev = node - } - - this.head = node - if (!this.tail) { - this.tail = node - } - this.length++ -} - -Yallist.prototype.pushNode = function (node) { - if (node === this.tail) { - return - } - - if (node.list) { - node.list.removeNode(node) - } - - var tail = this.tail - node.list = this - node.prev = tail - if (tail) { - tail.next = node - } - - this.tail = node - if (!this.head) { - this.head = node - } - this.length++ -} - -Yallist.prototype.push = function () { - for (var i = 0, l = arguments.length; i < l; i++) { - push(this, arguments[i]) - } - return this.length -} - -Yallist.prototype.unshift = function () { - for (var i = 0, l = arguments.length; i < l; i++) { - unshift(this, arguments[i]) - } - return this.length -} - -Yallist.prototype.pop = function () { - if (!this.tail) { - return undefined - } - - var res = this.tail.value - this.tail = this.tail.prev - if (this.tail) { - this.tail.next = null - } else { - this.head = null - } - this.length-- - return res -} - -Yallist.prototype.shift = function () { - if (!this.head) { - return undefined - } - - var res = this.head.value - this.head = this.head.next - if (this.head) { - this.head.prev = null - } else { - this.tail = null - } - this.length-- - return res -} - -Yallist.prototype.forEach = function (fn, thisp) { - thisp = thisp || this - for (var walker = this.head, i = 0; walker !== null; i++) { - fn.call(thisp, walker.value, i, this) - walker = walker.next - } -} - -Yallist.prototype.forEachReverse = function (fn, thisp) { - thisp = thisp || this - for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { - fn.call(thisp, walker.value, i, this) - walker = walker.prev - } -} - -Yallist.prototype.get = function (n) { - for (var i = 0, walker = this.head; walker !== null && i < n; i++) { - // abort out of the list early if we hit a cycle - walker = walker.next - } - if (i === n && walker !== null) { - return walker.value - } -} - -Yallist.prototype.getReverse = function (n) { - for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { - // abort out of the list early if we hit a cycle - walker = walker.prev - } - if (i === n && walker !== null) { - return walker.value - } -} - -Yallist.prototype.map = function (fn, thisp) { - thisp = thisp || this - var res = new Yallist() - for (var walker = this.head; walker !== null;) { - res.push(fn.call(thisp, walker.value, this)) - walker = walker.next - } - return res -} - -Yallist.prototype.mapReverse = function (fn, thisp) { - thisp = thisp || this - var res = new Yallist() - for (var walker = this.tail; walker !== null;) { - res.push(fn.call(thisp, walker.value, this)) - walker = walker.prev - } - return res -} - -Yallist.prototype.reduce = function (fn, initial) { - var acc - var walker = this.head - if (arguments.length > 1) { - acc = initial - } else if (this.head) { - walker = this.head.next - acc = this.head.value - } else { - throw new TypeError('Reduce of empty list with no initial value') - } - - for (var i = 0; walker !== null; i++) { - acc = fn(acc, walker.value, i) - walker = walker.next - } - - return acc -} - -Yallist.prototype.reduceReverse = function (fn, initial) { - var acc - var walker = this.tail - if (arguments.length > 1) { - acc = initial - } else if (this.tail) { - walker = this.tail.prev - acc = this.tail.value - } else { - throw new TypeError('Reduce of empty list with no initial value') - } - - for (var i = this.length - 1; walker !== null; i--) { - acc = fn(acc, walker.value, i) - walker = walker.prev - } - - return acc -} - -Yallist.prototype.toArray = function () { - var arr = new Array(this.length) - for (var i = 0, walker = this.head; walker !== null; i++) { - arr[i] = walker.value - walker = walker.next - } - return arr -} - -Yallist.prototype.toArrayReverse = function () { - var arr = new Array(this.length) - for (var i = 0, walker = this.tail; walker !== null; i++) { - arr[i] = walker.value - walker = walker.prev - } - return arr -} - -Yallist.prototype.slice = function (from, to) { - to = to || this.length - if (to < 0) { - to += this.length - } - from = from || 0 - if (from < 0) { - from += this.length - } - var ret = new Yallist() - if (to < from || to < 0) { - return ret - } - if (from < 0) { - from = 0 - } - if (to > this.length) { - to = this.length - } - for (var i = 0, walker = this.head; walker !== null && i < from; i++) { - walker = walker.next - } - for (; walker !== null && i < to; i++, walker = walker.next) { - ret.push(walker.value) - } - return ret -} - -Yallist.prototype.sliceReverse = function (from, to) { - to = to || this.length - if (to < 0) { - to += this.length - } - from = from || 0 - if (from < 0) { - from += this.length - } - var ret = new Yallist() - if (to < from || to < 0) { - return ret - } - if (from < 0) { - from = 0 - } - if (to > this.length) { - to = this.length - } - for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { - walker = walker.prev - } - for (; walker !== null && i > from; i--, walker = walker.prev) { - ret.push(walker.value) - } - return ret -} - -Yallist.prototype.splice = function (start, deleteCount, ...nodes) { - if (start > this.length) { - start = this.length - 1 - } - if (start < 0) { - start = this.length + start; - } - - for (var i = 0, walker = this.head; walker !== null && i < start; i++) { - walker = walker.next - } - - var ret = [] - for (var i = 0; walker && i < deleteCount; i++) { - ret.push(walker.value) - walker = this.removeNode(walker) - } - if (walker === null) { - walker = this.tail - } - - if (walker !== this.head && walker !== this.tail) { - walker = walker.prev - } - - for (var i = 0; i < nodes.length; i++) { - walker = insert(this, walker, nodes[i]) - } - return ret; -} - -Yallist.prototype.reverse = function () { - var head = this.head - var tail = this.tail - for (var walker = head; walker !== null; walker = walker.prev) { - var p = walker.prev - walker.prev = walker.next - walker.next = p - } - this.head = tail - this.tail = head - return this -} - -function insert (self, node, value) { - var inserted = node === self.head ? - new Node(value, null, node, self) : - new Node(value, node, node.next, self) - - if (inserted.next === null) { - self.tail = inserted - } - if (inserted.prev === null) { - self.head = inserted - } - - self.length++ - - return inserted -} - -function push (self, item) { - self.tail = new Node(item, self.tail, null, self) - if (!self.head) { - self.head = self.tail - } - self.length++ -} - -function unshift (self, item) { - self.head = new Node(item, null, self.head, self) - if (!self.tail) { - self.tail = self.head - } - self.length++ } +exports.HttpClient = HttpClient; -function Node (value, prev, next, list) { - if (!(this instanceof Node)) { - return new Node(value, prev, next, list) - } - - this.list = list - this.value = value - - if (prev) { - prev.next = this - this.prev = prev - } else { - this.prev = null - } - if (next) { - next.prev = this - this.next = next - } else { - this.next = null - } -} +/***/ }), -try { - // add if support for Symbol.iterator is present - __webpack_require__(396)(Yallist) -} catch (er) {} +/***/ 605: +/***/ (function(module) { +module.exports = require("http"); /***/ }), @@ -6595,16 +4698,6 @@ module.exports = require("events"); module.exports = require("path"); -/***/ }), - -/***/ 630: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const rcompare = (a, b, loose) => compare(b, a, loose) -module.exports = rcompare - - /***/ }), /***/ 631: @@ -6754,453 +4847,99 @@ function tryGetExecutablePath(filePath, extensions) { if (isUnixExecutable(stats)) { return filePath; } - } - } - // try each extension - const originalFilePath = filePath; - for (const extension of extensions) { - filePath = originalFilePath + extension; - stats = undefined; - try { - stats = yield exports.stat(filePath); - } - catch (err) { - if (err.code !== 'ENOENT') { - // eslint-disable-next-line no-console - console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); - } - } - if (stats && stats.isFile()) { - if (exports.IS_WINDOWS) { - // preserve the case of the actual file (since an extension was appended) - try { - const directory = path.dirname(filePath); - const upperName = path.basename(filePath).toUpperCase(); - for (const actualName of yield exports.readdir(directory)) { - if (upperName === actualName.toUpperCase()) { - filePath = path.join(directory, actualName); - break; - } - } - } - catch (err) { - // eslint-disable-next-line no-console - console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); - } - return filePath; - } - else { - if (isUnixExecutable(stats)) { - return filePath; - } - } - } - } - return ''; - }); -} -exports.tryGetExecutablePath = tryGetExecutablePath; -function normalizeSeparators(p) { - p = p || ''; - if (exports.IS_WINDOWS) { - // convert slashes on Windows - p = p.replace(/\//g, '\\'); - // remove redundant slashes - return p.replace(/\\\\+/g, '\\'); - } - // remove redundant slashes - return p.replace(/\/\/+/g, '/'); -} -// on Mac/Linux, test the execute bit -// R W X R W X R W X -// 256 128 64 32 16 8 4 2 1 -function isUnixExecutable(stats) { - return ((stats.mode & 1) > 0 || - ((stats.mode & 8) > 0 && stats.gid === process.getgid()) || - ((stats.mode & 64) > 0 && stats.uid === process.getuid())); -} -//# sourceMappingURL=io-util.js.map - -/***/ }), - -/***/ 694: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; -exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home'; -exports.INPUT_JAVA_VERSION = 'java-version'; -exports.INPUT_ARCHITECTURE = 'architecture'; -exports.INPUT_JAVA_PACKAGE = 'java-package'; -exports.INPUT_DISTRIBUTION = 'distribution'; -exports.INPUT_JDK_FILE = 'jdkFile'; -exports.INPUT_SERVER_ID = 'server-id'; -exports.INPUT_SERVER_USERNAME = 'server-username'; -exports.INPUT_SERVER_PASSWORD = 'server-password'; -exports.INPUT_SETTINGS_PATH = 'settings-path'; -exports.INPUT_OVERWRITE_SETTINGS = 'overwrite-settings'; -exports.INPUT_GPG_PRIVATE_KEY = 'gpg-private-key'; -exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase'; -exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined; -exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE'; -exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; - - -/***/ }), - -/***/ 702: -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -// A linked list to keep track of recently-used-ness -const Yallist = __webpack_require__(612) - -const MAX = Symbol('max') -const LENGTH = Symbol('length') -const LENGTH_CALCULATOR = Symbol('lengthCalculator') -const ALLOW_STALE = Symbol('allowStale') -const MAX_AGE = Symbol('maxAge') -const DISPOSE = Symbol('dispose') -const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet') -const LRU_LIST = Symbol('lruList') -const CACHE = Symbol('cache') -const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet') - -const naiveLength = () => 1 - -// lruList is a yallist where the head is the youngest -// item, and the tail is the oldest. the list contains the Hit -// objects as the entries. -// Each Hit object has a reference to its Yallist.Node. This -// never changes. -// -// cache is a Map (or PseudoMap) that matches the keys to -// the Yallist.Node object. -class LRUCache { - constructor (options) { - if (typeof options === 'number') - options = { max: options } - - if (!options) - options = {} - - if (options.max && (typeof options.max !== 'number' || options.max < 0)) - throw new TypeError('max must be a non-negative number') - // Kind of weird to have a default max of Infinity, but oh well. - const max = this[MAX] = options.max || Infinity - - const lc = options.length || naiveLength - this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc - this[ALLOW_STALE] = options.stale || false - if (options.maxAge && typeof options.maxAge !== 'number') - throw new TypeError('maxAge must be a number') - this[MAX_AGE] = options.maxAge || 0 - this[DISPOSE] = options.dispose - this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false - this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false - this.reset() - } - - // resize the cache when the max changes. - set max (mL) { - if (typeof mL !== 'number' || mL < 0) - throw new TypeError('max must be a non-negative number') - - this[MAX] = mL || Infinity - trim(this) - } - get max () { - return this[MAX] - } - - set allowStale (allowStale) { - this[ALLOW_STALE] = !!allowStale - } - get allowStale () { - return this[ALLOW_STALE] - } - - set maxAge (mA) { - if (typeof mA !== 'number') - throw new TypeError('maxAge must be a non-negative number') - - this[MAX_AGE] = mA - trim(this) - } - get maxAge () { - return this[MAX_AGE] - } - - // resize the cache when the lengthCalculator changes. - set lengthCalculator (lC) { - if (typeof lC !== 'function') - lC = naiveLength - - if (lC !== this[LENGTH_CALCULATOR]) { - this[LENGTH_CALCULATOR] = lC - this[LENGTH] = 0 - this[LRU_LIST].forEach(hit => { - hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key) - this[LENGTH] += hit.length - }) - } - trim(this) - } - get lengthCalculator () { return this[LENGTH_CALCULATOR] } - - get length () { return this[LENGTH] } - get itemCount () { return this[LRU_LIST].length } - - rforEach (fn, thisp) { - thisp = thisp || this - for (let walker = this[LRU_LIST].tail; walker !== null;) { - const prev = walker.prev - forEachStep(this, fn, walker, thisp) - walker = prev - } - } - - forEach (fn, thisp) { - thisp = thisp || this - for (let walker = this[LRU_LIST].head; walker !== null;) { - const next = walker.next - forEachStep(this, fn, walker, thisp) - walker = next - } - } - - keys () { - return this[LRU_LIST].toArray().map(k => k.key) - } - - values () { - return this[LRU_LIST].toArray().map(k => k.value) - } - - reset () { - if (this[DISPOSE] && - this[LRU_LIST] && - this[LRU_LIST].length) { - this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)) - } - - this[CACHE] = new Map() // hash of items by key - this[LRU_LIST] = new Yallist() // list of items in order of use recency - this[LENGTH] = 0 // length of items in the list - } - - dump () { - return this[LRU_LIST].map(hit => - isStale(this, hit) ? false : { - k: hit.key, - v: hit.value, - e: hit.now + (hit.maxAge || 0) - }).toArray().filter(h => h) - } - - dumpLru () { - return this[LRU_LIST] - } - - set (key, value, maxAge) { - maxAge = maxAge || this[MAX_AGE] - - if (maxAge && typeof maxAge !== 'number') - throw new TypeError('maxAge must be a number') - - const now = maxAge ? Date.now() : 0 - const len = this[LENGTH_CALCULATOR](value, key) - - if (this[CACHE].has(key)) { - if (len > this[MAX]) { - del(this, this[CACHE].get(key)) - return false - } - - const node = this[CACHE].get(key) - const item = node.value - - // dispose of the old one before overwriting - // split out into 2 ifs for better coverage tracking - if (this[DISPOSE]) { - if (!this[NO_DISPOSE_ON_SET]) - this[DISPOSE](key, item.value) - } - - item.now = now - item.maxAge = maxAge - item.value = value - this[LENGTH] += len - item.length - item.length = len - this.get(key) - trim(this) - return true - } - - const hit = new Entry(key, value, len, now, maxAge) - - // oversized objects fall out of cache automatically. - if (hit.length > this[MAX]) { - if (this[DISPOSE]) - this[DISPOSE](key, value) - - return false - } - - this[LENGTH] += hit.length - this[LRU_LIST].unshift(hit) - this[CACHE].set(key, this[LRU_LIST].head) - trim(this) - return true - } - - has (key) { - if (!this[CACHE].has(key)) return false - const hit = this[CACHE].get(key).value - return !isStale(this, hit) - } - - get (key) { - return get(this, key, true) - } - - peek (key) { - return get(this, key, false) - } - - pop () { - const node = this[LRU_LIST].tail - if (!node) - return null - - del(this, node) - return node.value - } - - del (key) { - del(this, this[CACHE].get(key)) - } - - load (arr) { - // reset the cache - this.reset() - - const now = Date.now() - // A previous serialized cache has the most recent items first - for (let l = arr.length - 1; l >= 0; l--) { - const hit = arr[l] - const expiresAt = hit.e || 0 - if (expiresAt === 0) - // the item was created without expiration in a non aged cache - this.set(hit.k, hit.v) - else { - const maxAge = expiresAt - now - // dont add already expired items - if (maxAge > 0) { - this.set(hit.k, hit.v, maxAge) + } } - } - } - } - - prune () { - this[CACHE].forEach((value, key) => get(this, key, false)) - } -} - -const get = (self, key, doUse) => { - const node = self[CACHE].get(key) - if (node) { - const hit = node.value - if (isStale(self, hit)) { - del(self, node) - if (!self[ALLOW_STALE]) - return undefined - } else { - if (doUse) { - if (self[UPDATE_AGE_ON_GET]) - node.value.now = Date.now() - self[LRU_LIST].unshiftNode(node) - } - } - return hit.value - } -} - -const isStale = (self, hit) => { - if (!hit || (!hit.maxAge && !self[MAX_AGE])) - return false - - const diff = Date.now() - hit.now - return hit.maxAge ? diff > hit.maxAge - : self[MAX_AGE] && (diff > self[MAX_AGE]) + // try each extension + const originalFilePath = filePath; + for (const extension of extensions) { + filePath = originalFilePath + extension; + stats = undefined; + try { + stats = yield exports.stat(filePath); + } + catch (err) { + if (err.code !== 'ENOENT') { + // eslint-disable-next-line no-console + console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); + } + } + if (stats && stats.isFile()) { + if (exports.IS_WINDOWS) { + // preserve the case of the actual file (since an extension was appended) + try { + const directory = path.dirname(filePath); + const upperName = path.basename(filePath).toUpperCase(); + for (const actualName of yield exports.readdir(directory)) { + if (upperName === actualName.toUpperCase()) { + filePath = path.join(directory, actualName); + break; + } + } + } + catch (err) { + // eslint-disable-next-line no-console + console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); + } + return filePath; + } + else { + if (isUnixExecutable(stats)) { + return filePath; + } + } + } + } + return ''; + }); } - -const trim = self => { - if (self[LENGTH] > self[MAX]) { - for (let walker = self[LRU_LIST].tail; - self[LENGTH] > self[MAX] && walker !== null;) { - // We know that we're about to delete this one, and also - // what the next least recently used key will be, so just - // go ahead and set it now. - const prev = walker.prev - del(self, walker) - walker = prev +exports.tryGetExecutablePath = tryGetExecutablePath; +function normalizeSeparators(p) { + p = p || ''; + if (exports.IS_WINDOWS) { + // convert slashes on Windows + p = p.replace(/\//g, '\\'); + // remove redundant slashes + return p.replace(/\\\\+/g, '\\'); } - } -} - -const del = (self, node) => { - if (node) { - const hit = node.value - if (self[DISPOSE]) - self[DISPOSE](hit.key, hit.value) - - self[LENGTH] -= hit.length - self[CACHE].delete(hit.key) - self[LRU_LIST].removeNode(node) - } -} - -class Entry { - constructor (key, value, length, now, maxAge) { - this.key = key - this.value = value - this.length = length - this.now = now - this.maxAge = maxAge || 0 - } + // remove redundant slashes + return p.replace(/\/\/+/g, '/'); } - -const forEachStep = (self, fn, node, thisp) => { - let hit = node.value - if (isStale(self, hit)) { - del(self, node) - if (!self[ALLOW_STALE]) - hit = undefined - } - if (hit) - fn.call(thisp, hit.value, hit.key, self) +// on Mac/Linux, test the execute bit +// R W X R W X R W X +// 256 128 64 32 16 8 4 2 1 +function isUnixExecutable(stats) { + return ((stats.mode & 1) > 0 || + ((stats.mode & 8) > 0 && stats.gid === process.getgid()) || + ((stats.mode & 64) > 0 && stats.uid === process.getuid())); } - -module.exports = LRUCache - +//# sourceMappingURL=io-util.js.map /***/ }), -/***/ 714: -/***/ (function(module, __unusedexports, __webpack_require__) { +/***/ 694: +/***/ (function(__unusedmodule, exports) { -const parse = __webpack_require__(830) -const valid = (version, options) => { - const v = parse(version, options) - return v ? v.version : null -} -module.exports = valid +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; +exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home'; +exports.INPUT_JAVA_VERSION = 'java-version'; +exports.INPUT_ARCHITECTURE = 'architecture'; +exports.INPUT_JAVA_PACKAGE = 'java-package'; +exports.INPUT_DISTRIBUTION = 'distribution'; +exports.INPUT_JDK_FILE = 'jdkFile'; +exports.INPUT_CHECK_LATEST = 'check-latest'; +exports.INPUT_SERVER_ID = 'server-id'; +exports.INPUT_SERVER_USERNAME = 'server-username'; +exports.INPUT_SERVER_PASSWORD = 'server-password'; +exports.INPUT_SETTINGS_PATH = 'settings-path'; +exports.INPUT_OVERWRITE_SETTINGS = 'overwrite-settings'; +exports.INPUT_GPG_PRIVATE_KEY = 'gpg-private-key'; +exports.INPUT_GPG_PASSPHRASE = 'gpg-passphrase'; +exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = undefined; +exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE'; +exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; /***/ }), @@ -7225,235 +4964,30 @@ function bytesToUuid(buf, offset) { bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', - bth[buf[i++]], bth[buf[i++]], '-', - bth[buf[i++]], bth[buf[i++]], '-', - bth[buf[i++]], bth[buf[i++]], - bth[buf[i++]], bth[buf[i++]], - bth[buf[i++]], bth[buf[i++]] - ]).join(''); -} - -module.exports = bytesToUuid; - - -/***/ }), - -/***/ 740: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const Range = __webpack_require__(124) -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 - - -/***/ }), - -/***/ 744: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const major = (a, loose) => new SemVer(a, loose).major -module.exports = major - - -/***/ }), - -/***/ 747: -/***/ (function(module) { - -module.exports = require("fs"); - -/***/ }), - -/***/ 752: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const eq = __webpack_require__(298) -const neq = __webpack_require__(873) -const gt = __webpack_require__(486) -const gte = __webpack_require__(167) -const lt = __webpack_require__(586) -const lte = __webpack_require__(898) - -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 - - -/***/ }), - -/***/ 760: -/***/ (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 -} - - -/***/ }), - -/***/ 794: -/***/ (function(module) { - -module.exports = require("stream"); - -/***/ }), - -/***/ 803: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const minor = (a, loose) => new SemVer(a, loose).minor -module.exports = minor - - -/***/ }), - -/***/ 811: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const Range = __webpack_require__(124) - -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 + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]] + ]).join(''); } -module.exports = maxSatisfying + +module.exports = bytesToUuid; /***/ }), -/***/ 818: +/***/ 747: /***/ (function(module) { -module.exports = require("tls"); +module.exports = require("fs"); /***/ }), -/***/ 822: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const parse = __webpack_require__(830) -const eq = __webpack_require__(298) - -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 +/***/ 794: +/***/ (function(module) { +module.exports = require("stream"); /***/ }), @@ -7491,174 +5025,6 @@ function v4(options, buf, offset) { module.exports = v4; -/***/ }), - -/***/ 830: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const {MAX_LENGTH} = __webpack_require__(181) -const { re, t } = __webpack_require__(976) -const SemVer = __webpack_require__(65) - -const parseOptions = __webpack_require__(143) -const parse = (version, options) => { - options = parseOptions(options) - - 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 - - -/***/ }), - -/***/ 873: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const neq = (a, b, loose) => compare(a, b, loose) !== 0 -module.exports = neq - - -/***/ }), - -/***/ 874: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const compare = (a, b, loose) => - new SemVer(a, loose).compare(new SemVer(b, loose)) - -module.exports = compare - - -/***/ }), - -/***/ 876: -/***/ (function(module, __unusedexports, __webpack_require__) { - -// just pre-load all the stuff that index.js lazily exports -const internalRe = __webpack_require__(976) -module.exports = { - re: internalRe.re, - src: internalRe.src, - tokens: internalRe.t, - SEMVER_SPEC_VERSION: __webpack_require__(181).SEMVER_SPEC_VERSION, - SemVer: __webpack_require__(65), - compareIdentifiers: __webpack_require__(760).compareIdentifiers, - rcompareIdentifiers: __webpack_require__(760).rcompareIdentifiers, - parse: __webpack_require__(830), - valid: __webpack_require__(714), - clean: __webpack_require__(503), - inc: __webpack_require__(928), - diff: __webpack_require__(822), - major: __webpack_require__(744), - minor: __webpack_require__(803), - patch: __webpack_require__(489), - prerelease: __webpack_require__(968), - compare: __webpack_require__(874), - rcompare: __webpack_require__(630), - compareLoose: __webpack_require__(283), - compareBuild: __webpack_require__(16), - sort: __webpack_require__(120), - rsort: __webpack_require__(593), - gt: __webpack_require__(486), - lt: __webpack_require__(586), - eq: __webpack_require__(298), - neq: __webpack_require__(873), - gte: __webpack_require__(167), - lte: __webpack_require__(898), - cmp: __webpack_require__(752), - coerce: __webpack_require__(499), - Comparator: __webpack_require__(174), - Range: __webpack_require__(124), - satisfies: __webpack_require__(310), - toComparators: __webpack_require__(20), - maxSatisfying: __webpack_require__(811), - minSatisfying: __webpack_require__(740), - minVersion: __webpack_require__(164), - validRange: __webpack_require__(480), - outside: __webpack_require__(462), - gtr: __webpack_require__(531), - ltr: __webpack_require__(323), - intersects: __webpack_require__(259), - simplifyRange: __webpack_require__(877), - subset: __webpack_require__(999), -} - - -/***/ }), - -/***/ 877: -/***/ (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__(310) -const compare = __webpack_require__(874) -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 -} - - /***/ }), /***/ 884: @@ -7681,7 +5047,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -7736,38 +5102,6 @@ function deleteKey(keyFingerprint) { exports.deleteKey = deleteKey; -/***/ }), - -/***/ 898: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const lte = (a, b, loose) => compare(a, b, loose) <= 0 -module.exports = lte - - -/***/ }), - -/***/ 928: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) - -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 - - /***/ }), /***/ 950: @@ -7833,208 +5167,6 @@ function checkBypass(reqUrl) { exports.checkBypass = checkBypass; -/***/ }), - -/***/ 968: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const parse = __webpack_require__(830) -const prerelease = (version, options) => { - const parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} -module.exports = prerelease - - -/***/ }), - -/***/ 976: -/***/ (function(module, exports, __webpack_require__) { - -const { MAX_SAFE_COMPONENT_LENGTH } = __webpack_require__(181) -const debug = __webpack_require__(548) -exports = module.exports = {} - -// 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*$') - - /***/ }), /***/ 979: @@ -8163,175 +5295,6 @@ function exec(commandLine, args, options) { exports.exec = exec; //# sourceMappingURL=exec.js.map -/***/ }), - -/***/ 999: -/***/ (function(module, __unusedexports, __webpack_require__) { - -const Range = __webpack_require__(124) -const { ANY } = __webpack_require__(174) -const satisfies = __webpack_require__(310) -const compare = __webpack_require__(874) - -// 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.semver 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 any < or <= 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) => { - if (sub === dom) - return true - - 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 === dom) - return true - - 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 && higher !== gt) - 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 && lower !== lt) - 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 - - /***/ }) /******/ }); \ No newline at end of file diff --git a/dist/setup/index.js b/dist/setup/index.js index f102f9003..7e37bdb37 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -486,49 +486,12 @@ exports.ASCIIAlphanumeric = /[0-9A-Za-z]/; /***/ }), /* 12 */, /* 13 */, -/* 14 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const Range = __webpack_require__(124) - -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 - - -/***/ }), +/* 14 */, /* 15 */, /* 16 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -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 +/***/ (function(module) { +module.exports = require("tls"); /***/ }), /* 17 */, @@ -1674,7 +1637,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const semver = __importStar(__webpack_require__(550)); +const semver = __importStar(__webpack_require__(280)); const core_1 = __webpack_require__(470); // needs to be require for core node modules to be mocked /* eslint @typescript-eslint/no-require-imports: 0 */ @@ -3518,299 +3481,7 @@ exports.parentNode_convertNodesIntoANode = parentNode_convertNodesIntoANode; /* 62 */, /* 63 */, /* 64 */, -/* 65 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const debug = __webpack_require__(548) -const { MAX_LENGTH, MAX_SAFE_INTEGER } = __webpack_require__(181) -const { re, t } = __webpack_require__(976) - -const parseOptions = __webpack_require__(143) -const { compareIdentifiers } = __webpack_require__(954) -class SemVer { - constructor (version, options) { - options = parseOptions(options) - - 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 - - -/***/ }), +/* 65 */, /* 66 */, /* 67 */, /* 68 */, @@ -3931,7 +3602,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -3951,7 +3622,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.JavaBase = void 0; const tc = __importStar(__webpack_require__(139)); const core = __importStar(__webpack_require__(470)); -const semver_1 = __importDefault(__webpack_require__(876)); +const semver_1 = __importDefault(__webpack_require__(280)); const path_1 = __importDefault(__webpack_require__(622)); const httpm = __importStar(__webpack_require__(539)); const util_1 = __webpack_require__(322); @@ -3965,18 +3636,22 @@ class JavaBase { ({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version)); this.architecture = installerOptions.architecture; this.packageType = installerOptions.packageType; + this.checkLatest = !!installerOptions.checkLatest; } setupJava() { return __awaiter(this, void 0, void 0, function* () { let foundJava = this.findInToolcache(); - if (foundJava) { + if (foundJava && !this.checkLatest) { core.info(`Resolved Java ${foundJava.version} from tool-cache`); } else { core.info(`Java ${this.version} was not found in tool-cache. Trying to download...`); const javaRelease = yield this.findPackageForDownload(this.version); - foundJava = yield this.downloadTool(javaRelease); - core.info(`Java ${foundJava.version} was downloaded`); + if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) != javaRelease.version) { + foundJava = yield this.downloadTool(javaRelease); + core.info(`Java ${foundJava.version} was downloaded`); + } + core.info(`Java ${foundJava.version} was resolved`); } core.info(`Setting Java ${foundJava.version} as the default`); this.setJavaDefault(foundJava.version, foundJava.path); @@ -4046,15 +3721,7 @@ exports.JavaBase = JavaBase; /***/ }), /* 84 */, -/* 85 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const neq = (a, b, loose) => compare(a, b, loose) !== 0 -module.exports = neq - - -/***/ }), +/* 85 */, /* 86 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -7829,534 +7496,11 @@ util_1.applyMixin(ElementImpl_1.ElementImpl, SlotableImpl_1.SlotableImpl); /* 117 */, /* 118 */, /* 119 */, -/* 120 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compareBuild = __webpack_require__(16) -const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) -module.exports = sort - - -/***/ }), +/* 120 */, /* 121 */, /* 122 */, /* 123 */, -/* 124 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -// hoisted class for cyclic dependency -class Range { - constructor (range, options) { - options = parseOptions(options) - - 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}`) - } - - // if we have any that are not the null set, throw out null sets. - if (this.set.length > 1) { - // keep the first one, in case they're all null sets - const first = this.set[0] - this.set = this.set.filter(c => !isNullSet(c[0])) - if (this.set.length === 0) - this.set = [first] - else if (this.set.length > 1) { - // if we have any that are *, then the range is just * - for (const c of this.set) { - if (c.length === 1 && isAny(c[0])) { - this.set = [c] - break - } - } - } - } - - this.format() - } - - format () { - this.range = this.set - .map((comps) => { - return comps.join(' ').trim() - }) - .join('||') - .trim() - return this.range - } - - toString () { - return this.range - } - - parseRange (range) { - range = range.trim() - - // memoize range parsing for performance. - // this is a very hot path, and fully deterministic. - const memoOpts = Object.keys(this.options).join(',') - const memoKey = `parseRange:${memoOpts}:${range}` - const cached = cache.get(memoKey) - if (cached) - return cached - - const loose = this.options.loose - // `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] - const rangeList = range - .split(' ') - .map(comp => parseComparator(comp, this.options)) - .join(' ') - .split(/\s+/) - // >=0.0.0 is equivalent to * - .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)) - - // if any comparators are the null set, then replace with JUST null set - // if more than one comparator, remove any * comparators - // also, don't include the same comparator more than once - const l = rangeList.length - const rangeMap = new Map() - for (const comp of rangeList) { - if (isNullSet(comp)) - return [comp] - rangeMap.set(comp.value, comp) - } - if (rangeMap.size > 1 && rangeMap.has('')) - rangeMap.delete('') - - const result = [...rangeMap.values()] - cache.set(memoKey, result) - return result - } - - 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 LRU = __webpack_require__(702) -const cache = new LRU({ max: 1000 }) - -const parseOptions = __webpack_require__(143) -const Comparator = __webpack_require__(536) -const debug = __webpack_require__(548) -const SemVer = __webpack_require__(65) -const { - re, - t, - comparatorTrimReplace, - tildeTrimReplace, - caretTrimReplace -} = __webpack_require__(976) - -const isNullSet = c => c.value === '<0.0.0-0' -const isAny = c => c.value === '' - -// 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 -} - - -/***/ }), +/* 124 */, /* 125 */, /* 126 */, /* 127 */, @@ -8435,7 +7579,7 @@ const mm = __importStar(__webpack_require__(31)); const os = __importStar(__webpack_require__(87)); const path = __importStar(__webpack_require__(622)); const httpm = __importStar(__webpack_require__(539)); -const semver = __importStar(__webpack_require__(550)); +const semver = __importStar(__webpack_require__(280)); const stream = __importStar(__webpack_require__(794)); const util = __importStar(__webpack_require__(669)); const v4_1 = __importDefault(__webpack_require__(494)); @@ -8451,7 +7595,6 @@ class HTTPError extends Error { } exports.HTTPError = HTTPError; const IS_WINDOWS = process.platform === 'win32'; -const IS_MAC = process.platform === 'darwin'; const userAgent = 'actions/tool-cache'; /** * Download a tool from an url and stream it into a file @@ -8667,36 +7810,6 @@ function extractTar(file, dest, flags = 'xz') { }); } exports.extractTar = extractTar; -/** - * Extract a xar compatible archive - * - * @param file path to the archive - * @param dest destination directory. Optional. - * @param flags flags for the xar. Optional. - * @returns path to the destination directory - */ -function extractXar(file, dest, flags = []) { - return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(IS_MAC, 'extractXar() not supported on current OS'); - assert_1.ok(file, 'parameter "file" is required'); - dest = yield _createExtractFolder(dest); - let args; - if (flags instanceof Array) { - args = flags; - } - else { - args = [flags]; - } - args.push('-x', '-C', dest, '-f', file); - if (core.isDebug()) { - args.push('-v'); - } - const xarPath = yield io.which('xar', true); - yield exec_1.exec(`"${xarPath}"`, _unique(args)); - return dest; - }); -} -exports.extractXar = extractXar; /** * Extract a zip * @@ -9005,13 +8118,6 @@ function _getGlobal(key, defaultValue) { /* eslint-enable @typescript-eslint/no-explicit-any */ return value !== undefined ? value : defaultValue; } -/** - * Returns an array of unique values. - * @param values Values to make unique. - */ -function _unique(values) { - return Array.from(new Set(values)); -} //# sourceMappingURL=tool-cache.js.map /***/ }), @@ -9023,7 +8129,7 @@ function _unique(values) { var net = __webpack_require__(631); -var tls = __webpack_require__(818); +var tls = __webpack_require__(16); var http = __webpack_require__(605); var https = __webpack_require__(34); var events = __webpack_require__(614); @@ -9288,23 +8394,7 @@ exports.debug = debug; // for test /***/ }), /* 142 */, -/* 143 */ -/***/ (function(module) { - -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) -module.exports = parseOptions - - -/***/ }), +/* 143 */, /* 144 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -9325,7 +8415,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -10203,15 +9293,7 @@ exports.CustomEventImpl = CustomEventImpl; /***/ }), /* 165 */, /* 166 */, -/* 167 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const gte = (a, b, loose) => compare(a, b, loose) >= 0 -module.exports = gte - - -/***/ }), +/* 167 */, /* 168 */, /* 169 */, /* 170 */, @@ -10912,29 +9994,7 @@ exports.shadowTree_assignASlot = shadowTree_assignASlot; //# sourceMappingURL=ShadowTreeAlgorithm.js.map /***/ }), -/* 181 */ -/***/ (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 -} - - -/***/ }), +/* 181 */, /* 182 */, /* 183 */, /* 184 */, @@ -11302,13 +10362,14 @@ exports.HTMLCollectionImpl = HTMLCollectionImpl; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; +exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_DEFAULT_GPG_PASSPHRASE = exports.INPUT_DEFAULT_GPG_PRIVATE_KEY = exports.INPUT_GPG_PASSPHRASE = exports.INPUT_GPG_PRIVATE_KEY = exports.INPUT_OVERWRITE_SETTINGS = exports.INPUT_SETTINGS_PATH = exports.INPUT_SERVER_PASSWORD = exports.INPUT_SERVER_USERNAME = exports.INPUT_SERVER_ID = exports.INPUT_CHECK_LATEST = exports.INPUT_JDK_FILE = exports.INPUT_DISTRIBUTION = exports.INPUT_JAVA_PACKAGE = exports.INPUT_ARCHITECTURE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; exports.MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home'; exports.INPUT_JAVA_VERSION = 'java-version'; exports.INPUT_ARCHITECTURE = 'architecture'; exports.INPUT_JAVA_PACKAGE = 'java-package'; exports.INPUT_DISTRIBUTION = 'distribution'; exports.INPUT_JDK_FILE = 'jdkFile'; +exports.INPUT_CHECK_LATEST = 'check-latest'; exports.INPUT_SERVER_ID = 'server-id'; exports.INPUT_SERVER_USERNAME = 'server-username'; exports.INPUT_SERVER_PASSWORD = 'server-password'; @@ -11340,20 +10401,7 @@ exports.DOMParser = DOMParserImpl_1.DOMParserImpl; /* 216 */, /* 217 */, /* 218 */, -/* 219 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const Range = __webpack_require__(124) - -// 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 - - -/***/ }), +/* 219 */, /* 220 */, /* 221 */, /* 222 */, @@ -11487,19 +10535,7 @@ exports.fragmentCB = builder_1.fragmentCB; /* 256 */, /* 257 */, /* 258 */, -/* 259 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const Range = __webpack_require__(124) -const intersects = (r1, r2, options) => { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) -} -module.exports = intersects - - -/***/ }), +/* 259 */, /* 260 */, /* 261 */, /* 262 */, @@ -12335,2000 +11371,2254 @@ exports.sortInDescendingOrder = sortInDescendingOrder; //# sourceMappingURL=Map.js.map /***/ }), -/* 280 */, -/* 281 */, -/* 282 */, -/* 283 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const compareLoose = (a, b) => compare(a, b, true) -module.exports = compareLoose +/* 280 */ +/***/ (function(module, exports) { +exports = module.exports = SemVer -/***/ }), -/* 284 */, -/* 285 */, -/* 286 */ -/***/ (function(__unusedmodule, exports) { +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 () {} +} -"use strict"; +// 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' -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Represents the state of the URL parser. - */ -var ParserState; -(function (ParserState) { - ParserState[ParserState["SchemeStart"] = 0] = "SchemeStart"; - ParserState[ParserState["Scheme"] = 1] = "Scheme"; - ParserState[ParserState["NoScheme"] = 2] = "NoScheme"; - ParserState[ParserState["SpecialRelativeOrAuthority"] = 3] = "SpecialRelativeOrAuthority"; - ParserState[ParserState["PathOrAuthority"] = 4] = "PathOrAuthority"; - ParserState[ParserState["Relative"] = 5] = "Relative"; - ParserState[ParserState["RelativeSlash"] = 6] = "RelativeSlash"; - ParserState[ParserState["SpecialAuthoritySlashes"] = 7] = "SpecialAuthoritySlashes"; - ParserState[ParserState["SpecialAuthorityIgnoreSlashes"] = 8] = "SpecialAuthorityIgnoreSlashes"; - ParserState[ParserState["Authority"] = 9] = "Authority"; - ParserState[ParserState["Host"] = 10] = "Host"; - ParserState[ParserState["Hostname"] = 11] = "Hostname"; - ParserState[ParserState["Port"] = 12] = "Port"; - ParserState[ParserState["File"] = 13] = "File"; - ParserState[ParserState["FileSlash"] = 14] = "FileSlash"; - ParserState[ParserState["FileHost"] = 15] = "FileHost"; - ParserState[ParserState["PathStart"] = 16] = "PathStart"; - ParserState[ParserState["Path"] = 17] = "Path"; - ParserState[ParserState["CannotBeABaseURLPath"] = 18] = "CannotBeABaseURLPath"; - ParserState[ParserState["Query"] = 19] = "Query"; - ParserState[ParserState["Fragment"] = 20] = "Fragment"; -})(ParserState = exports.ParserState || (exports.ParserState = {})); -exports.OpaqueOrigin = ["", "", null, null]; -//# sourceMappingURL=interfaces.js.map +var MAX_LENGTH = 256 +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 -/***/ }), -/* 287 */, -/* 288 */, -/* 289 */, -/* 290 */, -/* 291 */, -/* 292 */, -/* 293 */, -/* 294 */, -/* 295 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +// Max safe segment length for coercion. +var MAX_SAFE_COMPONENT_LENGTH = 16 -"use strict"; +// The actual regexps go on exports.re +var re = exports.re = [] +var src = exports.src = [] +var t = exports.tokens = {} +var R = 0 -Object.defineProperty(exports, "__esModule", { value: true }); -var _1 = __webpack_require__(535); -/** - * Creates an XML builder which serializes the document in chunks. - * - * @param options - callback builder options - * - * @returns callback builder - */ -function createCB(options) { - return new _1.XMLBuilderCBImpl(options); +function tok (n) { + t[n] = R++ } -exports.createCB = createCB; -/** - * Creates an XML builder which serializes the fragment in chunks. - * - * @param options - callback builder options - * - * @returns callback builder - */ -function fragmentCB(options) { - return new _1.XMLBuilderCBImpl(options, true); + +// 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. + +tok('NUMERICIDENTIFIER') +src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' +tok('NUMERICIDENTIFIERLOOSE') +src[t.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. + +tok('NONNUMERICIDENTIFIER') +src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' + +// ## Main Version +// Three dot-separated numeric identifiers. + +tok('MAINVERSION') +src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')' + +tok('MAINVERSIONLOOSE') +src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +tok('PRERELEASEIDENTIFIER') +src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' + +tok('PRERELEASEIDENTIFIERLOOSE') +src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +tok('PRERELEASE') +src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' + +tok('PRERELEASELOOSE') +src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +tok('BUILDIDENTIFIER') +src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +tok('BUILD') +src[t.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. + +tok('FULL') +tok('FULLPLAIN') +src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + + src[t.PRERELEASE] + '?' + + src[t.BUILD] + '?' + +src[t.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. +tok('LOOSEPLAIN') +src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + + src[t.PRERELEASELOOSE] + '?' + + src[t.BUILD] + '?' + +tok('LOOSE') +src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' + +tok('GTLT') +src[t.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. +tok('XRANGEIDENTIFIERLOOSE') +src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' +tok('XRANGEIDENTIFIER') +src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' + +tok('XRANGEPLAIN') +src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:' + src[t.PRERELEASE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' + +tok('XRANGEPLAINLOOSE') +src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:' + src[t.PRERELEASELOOSE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' + +tok('XRANGE') +src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' +tok('XRANGELOOSE') +src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' + +// 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') + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +tok('LONETILDE') +src[t.LONETILDE] = '(?:~>?)' + +tok('TILDETRIM') +src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' +re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') +var tildeTrimReplace = '$1~' + +tok('TILDE') +src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' +tok('TILDELOOSE') +src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +tok('LONECARET') +src[t.LONECARET] = '(?:\\^)' + +tok('CARETTRIM') +src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' +re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') +var caretTrimReplace = '$1^' + +tok('CARET') +src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' +tok('CARETLOOSE') +src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' + +// 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] + ')$|^$' + +// 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] + ')' + +// this one has to use the /g flag +re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') +var 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. +tok('HYPHENRANGE') +src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAIN] + ')' + + '\\s*$' + +tok('HYPHENRANGELOOSE') +src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s*$' + +// Star ranges basically just allow anything at all. +tok('STAR') +src[t.STAR] = '(<|>)?=?\\s*\\*' + +// 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]) + } } -exports.fragmentCB = fragmentCB; -//# sourceMappingURL=BuilderFunctionsCB.js.map -/***/ }), -/* 296 */, -/* 297 */, -/* 298 */ -/***/ (function(module, __unusedexports, __webpack_require__) { +exports.parse = parse +function parse (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } -const compare = __webpack_require__(874) -const eq = (a, b, loose) => compare(a, b, loose) === 0 -module.exports = eq + if (version instanceof SemVer) { + return version + } + if (typeof version !== 'string') { + return null + } -/***/ }), -/* 299 */, -/* 300 */, -/* 301 */, -/* 302 */, -/* 303 */, -/* 304 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { + if (version.length > MAX_LENGTH) { + return null + } -"use strict"; + var r = options.loose ? re[t.LOOSE] : re[t.FULL] + if (!r.test(version)) { + return null + } -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var TreeAlgorithm_1 = __webpack_require__(873); -var util_1 = __webpack_require__(918); -var ShadowTreeAlgorithm_1 = __webpack_require__(180); -var supportedTokens = new Map(); -/** - * Runs removing steps for node. - * - * @param removedNode - removed node - * @param oldParent - old parent node - */ -function dom_runRemovingSteps(removedNode, oldParent) { - // No steps defined + try { + return new SemVer(version, options) + } catch (er) { + return null + } } -exports.dom_runRemovingSteps = dom_runRemovingSteps; -/** - * Runs cloning steps for node. - * - * @param copy - node clone - * @param node - node - * @param document - document to own the cloned node - * @param cloneChildrenFlag - whether child nodes are cloned - */ -function dom_runCloningSteps(copy, node, document, cloneChildrenFlag) { - // No steps defined + +exports.valid = valid +function valid (version, options) { + var v = parse(version, options) + return v ? v.version : null } -exports.dom_runCloningSteps = dom_runCloningSteps; -/** - * Runs adopting steps for node. - * - * @param node - node - * @param oldDocument - old document - */ -function dom_runAdoptingSteps(node, oldDocument) { - // No steps defined + +exports.clean = clean +function clean (version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null } -exports.dom_runAdoptingSteps = dom_runAdoptingSteps; -/** - * Runs attribute change steps for an element node. - * - * @param element - element node owning the attribute - * @param localName - attribute's local name - * @param oldValue - attribute's old value - * @param value - attribute's new value - * @param namespace - attribute's namespace - */ -function dom_runAttributeChangeSteps(element, localName, oldValue, value, namespace) { - var e_1, _a; - // run default steps - if (DOMImpl_1.dom.features.slots) { - updateASlotablesName.call(element, element, localName, oldValue, value, namespace); - updateASlotsName.call(element, element, localName, oldValue, value, namespace); - } - updateAnElementID.call(element, element, localName, value, namespace); - try { - // run custom steps - for (var _b = __values(element._attributeChangeSteps), _c = _b.next(); !_c.done; _c = _b.next()) { - var step = _c.value; - step.call(element, element, localName, oldValue, value, namespace); - } + +exports.SemVer = SemVer + +function SemVer (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_1) throw e_1.error; } + } + 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) + } + + if (version.length > MAX_LENGTH) { + throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') + } + + if (!(this instanceof SemVer)) { + return new SemVer(version, options) + } + + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + + var 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(function (id) { + if (/^[0-9]+$/.test(id)) { + var num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } + + this.build = m[5] ? m[5].split('.') : [] + this.format() } -exports.dom_runAttributeChangeSteps = dom_runAttributeChangeSteps; -/** - * Runs insertion steps for a node. - * - * @param insertedNode - inserted node - */ -function dom_runInsertionSteps(insertedNode) { - // No steps defined -} -exports.dom_runInsertionSteps = dom_runInsertionSteps; -/** - * Runs pre-removing steps for a node iterator and node. - * - * @param nodeIterator - a node iterator - * @param toBeRemoved - node to be removed - */ -function dom_runNodeIteratorPreRemovingSteps(nodeIterator, toBeRemoved) { - removeNodeIterator.call(nodeIterator, nodeIterator, toBeRemoved); + +SemVer.prototype.format = function () { + this.version = this.major + '.' + this.minor + '.' + this.patch + if (this.prerelease.length) { + this.version += '-' + this.prerelease.join('.') + } + return this.version } -exports.dom_runNodeIteratorPreRemovingSteps = dom_runNodeIteratorPreRemovingSteps; -/** - * Determines if there are any supported tokens defined for the given - * attribute name. - * - * @param attributeName - an attribute name - */ -function dom_hasSupportedTokens(attributeName) { - return supportedTokens.has(attributeName); + +SemVer.prototype.toString = function () { + return this.version } -exports.dom_hasSupportedTokens = dom_hasSupportedTokens; -/** - * Returns the set of supported tokens defined for the given attribute name. - * - * @param attributeName - an attribute name - */ -function dom_getSupportedTokens(attributeName) { - return supportedTokens.get(attributeName) || new Set(); + +SemVer.prototype.compare = function (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return this.compareMain(other) || this.comparePre(other) } -exports.dom_getSupportedTokens = dom_getSupportedTokens; -/** - * Runs event construction steps. - * - * @param event - an event - */ -function dom_runEventConstructingSteps(event) { - // No steps defined + +SemVer.prototype.compareMain = function (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) } -exports.dom_runEventConstructingSteps = dom_runEventConstructingSteps; -/** - * Runs child text content change steps for a parent node. - * - * @param parent - parent node with text node child nodes - */ -function dom_runChildTextContentChangeSteps(parent) { - // No steps defined + +SemVer.prototype.comparePre = function (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 + } + + 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) } -exports.dom_runChildTextContentChangeSteps = dom_runChildTextContentChangeSteps; -/** - * Defines pre-removing steps for a node iterator. - */ -function removeNodeIterator(nodeIterator, toBeRemovedNode) { - /** - * 1. If toBeRemovedNode is not an inclusive ancestor of nodeIterator’s - * reference, or toBeRemovedNode is nodeIterator’s root, then return. - */ - if (toBeRemovedNode === nodeIterator._root || - !TreeAlgorithm_1.tree_isAncestorOf(nodeIterator._reference, toBeRemovedNode, true)) { - return; + +SemVer.prototype.compareBuild = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + 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) } - /** - * 2. If nodeIterator’s pointer before reference is true, then: - */ - if (nodeIterator._pointerBeforeReference) { - /** - * 2.1. Let next be toBeRemovedNode’s first following node that is an - * inclusive descendant of nodeIterator’s root and is not an inclusive - * descendant of toBeRemovedNode, and null if there is no such node. - */ - while (true) { - var nextNode = TreeAlgorithm_1.tree_getFollowingNode(nodeIterator._root, toBeRemovedNode); - if (nextNode !== null && - TreeAlgorithm_1.tree_isDescendantOf(nodeIterator._root, nextNode, true) && - !TreeAlgorithm_1.tree_isDescendantOf(toBeRemovedNode, nextNode, true)) { - /** - * 2.2. If next is non-null, then set nodeIterator’s reference to next - * and return. - */ - nodeIterator._reference = nextNode; - return; - } - else if (nextNode === null) { - /** - * 2.3. Otherwise, set nodeIterator’s pointer before reference to false. - */ - nodeIterator._pointerBeforeReference = false; - return; - } + } 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. +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 + } } - } - /** - * 3. Set nodeIterator’s reference to toBeRemovedNode’s parent, if - * toBeRemovedNode’s previous sibling is null, and to the inclusive - * descendant of toBeRemovedNode’s previous sibling that appears last in - * tree order otherwise. - */ - if (toBeRemovedNode._previousSibling === null) { - if (toBeRemovedNode._parent !== null) { - nodeIterator._reference = toBeRemovedNode._parent; + if (i === -1) { + // didn't increment anything + this.prerelease.push(0) } - } - else { - var referenceNode = toBeRemovedNode._previousSibling; - var childNode = TreeAlgorithm_1.tree_getFirstDescendantNode(toBeRemovedNode._previousSibling, true, false); - while (childNode !== null) { - if (childNode !== null) { - referenceNode = childNode; - } - // loop through to get the last descendant node - childNode = TreeAlgorithm_1.tree_getNextDescendantNode(toBeRemovedNode._previousSibling, childNode, true, false); + } + 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] } - nodeIterator._reference = referenceNode; - } + } + break + + default: + throw new Error('invalid increment argument: ' + release) + } + this.format() + this.raw = this.version + return this } -/** - * Defines attribute change steps to update a slot’s name. - */ -function updateASlotsName(element, localName, oldValue, value, namespace) { - /** - * 1. If element is a slot, localName is name, and namespace is null, then: - * 1.1. If value is oldValue, then return. - * 1.2. If value is null and oldValue is the empty string, then return. - * 1.3. If value is the empty string and oldValue is null, then return. - * 1.4. If value is null or the empty string, then set element’s name to the - * empty string. - * 1.5. Otherwise, set element’s name to value. - * 1.6. Run assign slotables for a tree with element’s root. - */ - if (util_1.Guard.isSlot(element) && localName === "name" && namespace === null) { - if (value === oldValue) - return; - if (value === null && oldValue === '') - return; - if (value === '' && oldValue === null) - return; - if ((value === null || value === '')) { - element._name = ''; - } - else { - element._name = value; - } - ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(element)); - } + +exports.inc = inc +function inc (version, release, loose, identifier) { + if (typeof (loose) === 'string') { + identifier = loose + loose = undefined + } + + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } } -/** - * Defines attribute change steps to update a slotable’s name. - */ -function updateASlotablesName(element, localName, oldValue, value, namespace) { - /** - * 1. If localName is slot and namespace is null, then: - * 1.1. If value is oldValue, then return. - * 1.2. If value is null and oldValue is the empty string, then return. - * 1.3. If value is the empty string and oldValue is null, then return. - * 1.4. If value is null or the empty string, then set element’s name to - * the empty string. - * 1.5. Otherwise, set element’s name to value. - * 1.6. If element is assigned, then run assign slotables for element’s - * assigned slot. - * 1.7. Run assign a slot for element. - */ - if (util_1.Guard.isSlotable(element) && localName === "slot" && namespace === null) { - if (value === oldValue) - return; - if (value === null && oldValue === '') - return; - if (value === '' && oldValue === null) - return; - if ((value === null || value === '')) { - element._name = ''; - } - else { - element._name = value; - } - if (ShadowTreeAlgorithm_1.shadowTree_isAssigned(element)) { - ShadowTreeAlgorithm_1.shadowTree_assignSlotables(element._assignedSlot); + +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 } - ShadowTreeAlgorithm_1.shadowTree_assignASlot(element); + } } + return defaultResult // may be undefined + } } -/** - * Defines attribute change steps to update an element's ID. - */ -function updateAnElementID(element, localName, value, namespace) { - /** - * 1. If localName is id, namespace is null, and value is null or the empty - * string, then unset element’s ID. - * 2. Otherwise, if localName is id, namespace is null, then set element’s - * ID to value. - */ - if (localName === "id" && namespace === null) { - if (!value) - element._uniqueIdentifier = undefined; - else - element._uniqueIdentifier = value; - } + +exports.compareIdentifiers = compareIdentifiers + +var numeric = /^[0-9]+$/ +function compareIdentifiers (a, b) { + var anum = numeric.test(a) + var 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 } -//# sourceMappingURL=DOMAlgorithm.js.map -/***/ }), -/* 305 */ -/***/ (function(__unusedmodule, exports) { +exports.rcompareIdentifiers = rcompareIdentifiers +function rcompareIdentifiers (a, b) { + return compareIdentifiers(b, a) +} -"use strict"; +exports.major = major +function major (a, loose) { + return new SemVer(a, loose).major +} -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Pre-serializes XML nodes. - */ -var BaseReader = /** @class */ (function () { - /** - * Initializes a new instance of `BaseReader`. - * - * @param builderOptions - XML builder options - */ - function BaseReader(builderOptions) { - this._builderOptions = builderOptions; - if (builderOptions.parser) { - Object.assign(this, builderOptions.parser); - } - } - BaseReader.prototype._docType = function (parent, name, publicId, systemId) { - return parent.dtd({ name: name, pubID: publicId, sysID: systemId }); - }; - BaseReader.prototype._comment = function (parent, data) { - return parent.com(data); - }; - BaseReader.prototype._text = function (parent, data) { - return parent.txt(data); - }; - BaseReader.prototype._instruction = function (parent, target, data) { - return parent.ins(target, data); - }; - BaseReader.prototype._cdata = function (parent, data) { - return parent.dat(data); - }; - BaseReader.prototype._element = function (parent, namespace, name) { - return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name)); - }; - BaseReader.prototype._attribute = function (parent, namespace, name, value) { - return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value)); - }; - /** - * Main parser function which parses the given object and returns an XMLBuilder. - * - * @param node - node to recieve parsed content - * @param obj - object to parse - */ - BaseReader.prototype.parse = function (node, obj) { - return this._parse(node, obj); - }; - /** - * Creates a DocType node. - * The node will be skipped if the function returns `undefined`. - * - * @param name - node name - * @param publicId - public identifier - * @param systemId - system identifier - */ - BaseReader.prototype.docType = function (parent, name, publicId, systemId) { - return this._docType(parent, name, publicId, systemId); - }; - /** - * Creates a comment node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.comment = function (parent, data) { - return this._comment(parent, data); - }; - /** - * Creates a text node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.text = function (parent, data) { - return this._text(parent, data); - }; - /** - * Creates a processing instruction node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param target - instruction target - * @param data - node data - */ - BaseReader.prototype.instruction = function (parent, target, data) { - return this._instruction(parent, target, data); - }; - /** - * Creates a CData section node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.cdata = function (parent, data) { - return this._cdata(parent, data); - }; - /** - * Creates an element node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param namespace - node namespace - * @param name - node name - */ - BaseReader.prototype.element = function (parent, namespace, name) { - return this._element(parent, namespace, name); - }; - /** - * Creates an attribute or namespace declaration. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param namespace - node namespace - * @param name - node name - * @param value - node value - */ - BaseReader.prototype.attribute = function (parent, namespace, name, value) { - return this._attribute(parent, namespace, name, value); - }; - return BaseReader; -}()); -exports.BaseReader = BaseReader; -//# sourceMappingURL=BaseReader.js.map +exports.minor = minor +function minor (a, loose) { + return new SemVer(a, loose).minor +} -/***/ }), -/* 306 */, -/* 307 */, -/* 308 */, -/* 309 */, -/* 310 */ -/***/ (function(module, __unusedexports, __webpack_require__) { +exports.patch = patch +function patch (a, loose) { + return new SemVer(a, loose).patch +} -const Range = __webpack_require__(124) -const satisfies = (version, range, options) => { - try { - range = new Range(range, options) - } catch (er) { - return false - } - return range.test(version) +exports.compare = compare +function compare (a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) } -module.exports = satisfies +exports.compareLoose = compareLoose +function compareLoose (a, b) { + return compare(a, b, true) +} -/***/ }), -/* 311 */, -/* 312 */, -/* 313 */, -/* 314 */, -/* 315 */, -/* 316 */, -/* 317 */, -/* 318 */, -/* 319 */, -/* 320 */, -/* 321 */, -/* 322 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +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) +} -"use strict"; +exports.rcompare = rcompare +function rcompare (a, b, loose) { + return compare(b, a, loose) +} -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 (k !== "default" && Object.prototype.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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; -const os_1 = __importDefault(__webpack_require__(87)); -const path_1 = __importDefault(__webpack_require__(622)); -const fs = __importStar(__webpack_require__(747)); -const semver = __importStar(__webpack_require__(876)); -const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); -function getTempDir() { - let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); - return tempDirectory; +exports.sort = sort +function sort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(a, b, loose) + }) } -exports.getTempDir = getTempDir; -function getBooleanInput(inputName, defaultValue = false) { - return (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'; + +exports.rsort = rsort +function rsort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(b, a, loose) + }) } -exports.getBooleanInput = getBooleanInput; -function getVersionFromToolcachePath(toolPath) { - if (toolPath) { - return path_1.default.basename(path_1.default.dirname(toolPath)); + +exports.gt = gt +function gt (a, b, loose) { + return compare(a, b, loose) > 0 +} + +exports.lt = lt +function lt (a, b, loose) { + return compare(a, b, loose) < 0 +} + +exports.eq = eq +function eq (a, b, loose) { + return compare(a, b, loose) === 0 +} + +exports.neq = neq +function neq (a, b, loose) { + return compare(a, b, loose) !== 0 +} + +exports.gte = gte +function gte (a, b, loose) { + return compare(a, b, loose) >= 0 +} + +exports.lte = lte +function lte (a, b, loose) { + return compare(a, b, loose) <= 0 +} + +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) + + default: + throw new TypeError('Invalid operator: ' + op) + } +} + +exports.Comparator = Comparator +function Comparator (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } - return toolPath; + } + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value + } + } + + 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 + } + + debug('comp', this) } -exports.getVersionFromToolcachePath = getVersionFromToolcachePath; -function extractJdkFile(toolPath, extension) { - return __awaiter(this, void 0, void 0, function* () { - if (!extension) { - extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); - if (extension.startsWith('.')) { - extension = extension.substring(1); - } - } - switch (extension) { - case 'tar.gz': - case 'tar': - return yield tc.extractTar(toolPath); - case 'zip': - return yield tc.extractZip(toolPath); - default: - return yield tc.extract7z(toolPath); - } - }); + +var ANY = {} +Comparator.prototype.parse = function (comp) { + var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var 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) + } } -exports.extractJdkFile = extractJdkFile; -function getDownloadArchiveExtension() { - return process.platform === 'win32' ? 'zip' : 'tar.gz'; + +Comparator.prototype.toString = function () { + return this.value } -exports.getDownloadArchiveExtension = getDownloadArchiveExtension; -function isVersionSatisfies(range, version) { - var _a; - if (semver.valid(range)) { - // if full version with build digit is provided as a range (such as '1.2.3+4') - // we should check for exact equal via compareBuild - // since semver.satisfies doesn't handle 4th digit - const semRange = semver.parse(range); - if (semRange && ((_a = semRange.build) === null || _a === void 0 ? void 0 : _a.length) > 0) { - return semver.compareBuild(range, version) === 0; - } + +Comparator.prototype.test = function (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 semver.satisfies(version, range); + } + + return cmp(version, this.operator, this.semver, this.options) } -exports.isVersionSatisfies = isVersionSatisfies; -function getToolcachePath(toolName, version, architecture) { - var _a; - const toolcacheRoot = (_a = process.env['RUNNER_TOOL_CACHE']) !== null && _a !== void 0 ? _a : ''; - const fullPath = path_1.default.join(toolcacheRoot, toolName, version, architecture); - if (fs.existsSync(fullPath)) { - return fullPath; + +Comparator.prototype.intersects = function (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } - return null; + } + + var rangeTmp + + 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) + } + + 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 } -exports.getToolcachePath = getToolcachePath; +exports.Range = Range +function Range (range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } -/***/ }), -/* 323 */ -/***/ (function(module, __unusedexports, __webpack_require__) { + if (range instanceof Range) { + if (range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease) { + return range + } else { + return new Range(range.raw, options) + } + } -const outside = __webpack_require__(881) -// 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 + if (range instanceof Comparator) { + return new Range(range.value, options) + } + if (!(this instanceof Range)) { + return new Range(range, options) + } -/***/ }), -/* 324 */, -/* 325 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { + this.options = options + this.loose = !!options.loose + this.includePrerelease = !!options.includePrerelease -"use strict"; + // 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 + }) -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var ObjectWriter_1 = __webpack_require__(419); -var util_1 = __webpack_require__(592); -var BaseWriter_1 = __webpack_require__(462); -/** - * Serializes XML nodes into a YAML string. - */ -var YAMLWriter = /** @class */ (function (_super) { - __extends(YAMLWriter, _super); - /** - * Initializes a new instance of `YAMLWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function YAMLWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - wellFormed: false, - noDoubleEncoding: false, - indent: ' ', - newline: '\n', - offset: 0, - group: false, - verbose: false - }); - if (_this._writerOptions.indent.length < 2) { - throw new Error("YAML indententation string must be at least two characters long."); - } - if (_this._writerOptions.offset < 0) { - throw new Error("YAML offset should be zero or a positive number."); - } - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - * @param writerOptions - serialization options - */ - YAMLWriter.prototype.serialize = function (node) { - // convert to object - var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - }); - var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); - var val = objectWriter.serialize(node); - var markup = this._beginLine(this._writerOptions, 0) + '---' + this._endLine(this._writerOptions) + - this._convertObject(val, this._writerOptions, 0); - // remove trailing newline - /* istanbul ignore else */ - if (markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { - markup = markup.slice(0, -this._writerOptions.newline.length); - } - return markup; - }; - /** - * Produces an XML serialization of the given object. - * - * @param obj - object to serialize - * @param options - serialization options - * @param level - depth of the XML tree - * @param indentLeaf - indents leaf nodes - */ - YAMLWriter.prototype._convertObject = function (obj, options, level, suppressIndent) { - var e_1, _a; - var _this = this; - if (suppressIndent === void 0) { suppressIndent = false; } - var markup = ''; - if (util_1.isArray(obj)) { - try { - for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { - var val = obj_1_1.value; - markup += this._beginLine(options, level, true); - if (!util_1.isObject(val)) { - markup += this._val(val) + this._endLine(options); - } - else if (util_1.isEmpty(val)) { - markup += '""' + this._endLine(options); - } - else { - markup += this._convertObject(val, options, level, true); - } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); - } - finally { if (e_1) throw e_1.error; } - } - } - else /* if (isObject(obj)) */ { - util_1.forEachObject(obj, function (key, val) { - if (suppressIndent) { - markup += _this._key(key); - suppressIndent = false; - } - else { - markup += _this._beginLine(options, level) + _this._key(key); - } - if (!util_1.isObject(val)) { - markup += ' ' + _this._val(val) + _this._endLine(options); - } - else if (util_1.isEmpty(val)) { - markup += ' ""' + _this._endLine(options); - } - else { - markup += _this._endLine(options) + - _this._convertObject(val, options, level + 1); - } - }, this); - } - return markup; - }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - * @param level - current depth of the XML tree - * @param isArray - whether this line is an array item - */ - YAMLWriter.prototype._beginLine = function (options, level, isArray) { - if (isArray === void 0) { isArray = false; } - var indentLevel = options.offset + level + 1; - var chars = new Array(indentLevel).join(options.indent); - if (isArray) { - return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); - } - else { - return chars; - } - }; - /** - * Produces characters to be appended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - */ - YAMLWriter.prototype._endLine = function (options) { - return options.newline; - }; - /** - * Produces a YAML key string delimited with double quotes. - */ - YAMLWriter.prototype._key = function (key) { - return "\"" + key + "\":"; - }; - /** - * Produces a YAML value string delimited with double quotes. - */ - YAMLWriter.prototype._val = function (val) { - return JSON.stringify(val); - }; - return YAMLWriter; -}(BaseWriter_1.BaseWriter)); -exports.YAMLWriter = YAMLWriter; -//# sourceMappingURL=YAMLWriter.js.map - -/***/ }), -/* 326 */, -/* 327 */, -/* 328 */, -/* 329 */, -/* 330 */, -/* 331 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range) + } -"use strict"; + this.format() +} -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 (k !== "default" && Object.prototype.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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.generate = exports.createAuthenticationSettings = exports.configureAuthentication = exports.SETTINGS_FILE = exports.M2_DIR = void 0; -const path = __importStar(__webpack_require__(622)); -const core = __importStar(__webpack_require__(470)); -const io = __importStar(__webpack_require__(1)); -const fs = __importStar(__webpack_require__(747)); -const os = __importStar(__webpack_require__(87)); -const xmlbuilder2_1 = __webpack_require__(255); -const constants = __importStar(__webpack_require__(211)); -const gpg = __importStar(__webpack_require__(884)); -const util_1 = __webpack_require__(322); -exports.M2_DIR = '.m2'; -exports.SETTINGS_FILE = 'settings.xml'; -function configureAuthentication() { - return __awaiter(this, void 0, void 0, function* () { - const id = core.getInput(constants.INPUT_SERVER_ID); - const username = core.getInput(constants.INPUT_SERVER_USERNAME); - const password = core.getInput(constants.INPUT_SERVER_PASSWORD); - const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) || path.join(os.homedir(), exports.M2_DIR); - const overwriteSettings = util_1.getBooleanInput(constants.INPUT_OVERWRITE_SETTINGS, true); - const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY) || constants.INPUT_DEFAULT_GPG_PRIVATE_KEY; - const gpgPassphrase = core.getInput(constants.INPUT_GPG_PASSPHRASE) || - (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined); - if (gpgPrivateKey) { - core.setSecret(gpgPrivateKey); - } - yield createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase); - if (gpgPrivateKey) { - core.info('Importing private gpg key'); - const keyFingerprint = (yield gpg.importKey(gpgPrivateKey)) || ''; - core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); - } - }); +Range.prototype.format = function () { + this.range = this.set.map(function (comps) { + return comps.join(' ').trim() + }).join('||').trim() + return this.range } -exports.configureAuthentication = configureAuthentication; -function createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase = undefined) { - return __awaiter(this, void 0, void 0, function* () { - core.info(`Creating ${exports.SETTINGS_FILE} with server-id: ${id}`); - // when an alternate m2 location is specified use only that location (no .m2 directory) - // otherwise use the home/.m2/ path - yield io.mkdirP(settingsDirectory); - yield write(settingsDirectory, generate(id, username, password, gpgPassphrase), overwriteSettings); - }); + +Range.prototype.toString = function () { + return this.range } -exports.createAuthenticationSettings = createAuthenticationSettings; -// only exported for testing purposes -function generate(id, username, password, gpgPassphrase) { - const xmlObj = { - settings: { - '@xmlns': 'http://maven.apache.org/SETTINGS/1.0.0', - '@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', - '@xsi:schemaLocation': 'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd', - servers: { - server: [ - { - id: id, - username: `\${env.${username}}`, - password: `\${env.${password}}` - } - ] - } - } - }; - if (gpgPassphrase) { - const gpgServer = { - id: 'gpg.passphrase', - passphrase: `\${env.${gpgPassphrase}}` - }; - xmlObj.settings.servers.server.push(gpgServer); - } - return xmlbuilder2_1.create(xmlObj).end({ - headless: true, - prettyPrint: true, - width: 80 - }); + +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]) + + // `~ 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. + + 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) + + return set } -exports.generate = generate; -function write(directory, settings, overwriteSettings) { - return __awaiter(this, void 0, void 0, function* () { - const location = path.join(directory, exports.SETTINGS_FILE); - const settingsExists = fs.existsSync(location); - if (settingsExists && overwriteSettings) { - core.info(`Overwriting existing file ${location}`); - } - else if (!settingsExists) { - core.info(`Writing to ${location}`); - } - else { - core.info(`Skipping generation ${location} because file already exists and overwriting is not required`); - return; - } - return fs.writeFileSync(location, settings, { - encoding: 'utf-8', - flag: 'w' - }); - }); + +Range.prototype.intersects = function (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + 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() -/***/ }), -/* 332 */, -/* 333 */, -/* 334 */, -/* 335 */, -/* 336 */, -/* 337 */, -/* 338 */, -/* 339 */, -/* 340 */, -/* 341 */, -/* 342 */, -/* 343 */, -/* 344 */ -/***/ (function(__unusedmodule, exports) { + while (result && remainingComparators.length) { + result = remainingComparators.every(function (otherComparator) { + return testComparator.intersects(otherComparator, options) + }) -"use strict"; + testComparator = remainingComparators.pop() + } -Object.defineProperty(exports, "__esModule", { value: true }); -var PotentialCustomElementName = /[a-z]([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*-([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*/; -var NamesWithHyphen = new Set(['annotation-xml', 'color-profile', - 'font-face', 'font-face-src', 'font-face-uri', 'font-face-format', - 'font-face-name', 'missing-glyph']); -var ElementNames = new Set(['article', 'aside', 'blockquote', - 'body', 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', - 'header', 'main', 'nav', 'p', 'section', 'span']); -var VoidElementNames = new Set(['area', 'base', 'basefont', - 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', - 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); -var ShadowHostNames = new Set(['article', 'aside', 'blockquote', 'body', - 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'main', - 'nav', 'p', 'section', 'span']); -/** - * Determines if the given string is a valid custom element name. - * - * @param name - a name string - */ -function customElement_isValidCustomElementName(name) { - if (!PotentialCustomElementName.test(name)) - return false; - if (NamesWithHyphen.has(name)) - return false; - return true; + return result } -exports.customElement_isValidCustomElementName = customElement_isValidCustomElementName; -/** - * Determines if the given string is a valid element name. - * - * @param name - a name string - */ -function customElement_isValidElementName(name) { - return (ElementNames.has(name)); + +// 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(' ') + }) } -exports.customElement_isValidElementName = customElement_isValidElementName; -/** - * Determines if the given string is a void element name. - * - * @param name - a name string - */ -function customElement_isVoidElementName(name) { - return (VoidElementNames.has(name)); + +// 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 } -exports.customElement_isVoidElementName = customElement_isVoidElementName; -/** - * Determines if the given string is a valid shadow host element name. - * - * @param name - a name string - */ -function customElement_isValidShadowHostName(name) { - return (ShadowHostNames.has(name)); + +function isX (id) { + return !id || id.toLowerCase() === 'x' || id === '*' } -exports.customElement_isValidShadowHostName = customElement_isValidShadowHostName; -/** - * Enqueues an upgrade reaction for a custom element. - * - * @param element - a custom element - * @param definition - a custom element definition - */ -function customElement_enqueueACustomElementUpgradeReaction(element, definition) { - // TODO: Implement in HTML DOM + +// ~, ~> --> * (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(' ') } -exports.customElement_enqueueACustomElementUpgradeReaction = customElement_enqueueACustomElementUpgradeReaction; -/** - * Enqueues a callback reaction for a custom element. - * - * @param element - a custom element - * @param callbackName - name of the callback - * @param args - callback arguments - */ -function customElement_enqueueACustomElementCallbackReaction(element, callbackName, args) { - // TODO: Implement in HTML DOM -} -exports.customElement_enqueueACustomElementCallbackReaction = customElement_enqueueACustomElementCallbackReaction; -/** - * Upgrade a custom element. - * - * @param element - a custom element - */ -function customElement_upgrade(definition, element) { - // TODO: Implement in HTML DOM -} -exports.customElement_upgrade = customElement_upgrade; -/** - * Tries to upgrade a custom element. - * - * @param element - a custom element - */ -function customElement_tryToUpgrade(element) { - // TODO: Implement in HTML DOM -} -exports.customElement_tryToUpgrade = customElement_tryToUpgrade; -/** - * Looks up a custom element definition. - * - * @param document - a document - * @param namespace - element namespace - * @param localName - element local name - * @param is - an `is` value - */ -function customElement_lookUpACustomElementDefinition(document, namespace, localName, is) { - // TODO: Implement in HTML DOM - return null; + +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 + }) } -exports.customElement_lookUpACustomElementDefinition = customElement_lookUpACustomElementDefinition; -//# sourceMappingURL=CustomElementAlgorithm.js.map -/***/ }), -/* 345 */, -/* 346 */, -/* 347 */, -/* 348 */, -/* 349 */, -/* 350 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +// ^ --> * (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(' ') +} -"use strict"; +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 -Object.defineProperty(exports, "__esModule", { value: true }); -var interfaces_1 = __webpack_require__(970); -var TreeAlgorithm_1 = __webpack_require__(873); -/** - * Defines the position of a boundary point relative to another. - * - * @param bp - a boundary point - * @param relativeTo - a boundary point to compare to - */ -function boundaryPoint_position(bp, relativeTo) { - var nodeA = bp[0]; - var offsetA = bp[1]; - var nodeB = relativeTo[0]; - var offsetB = relativeTo[1]; - /** - * 1. Assert: nodeA and nodeB have the same root. - */ - console.assert(TreeAlgorithm_1.tree_rootNode(nodeA) === TreeAlgorithm_1.tree_rootNode(nodeB), "Boundary points must share the same root node."); - /** - * 2. If nodeA is nodeB, then return equal if offsetA is offsetB, before - * if offsetA is less than offsetB, and after if offsetA is greater than - * offsetB. - */ - if (nodeA === nodeB) { - if (offsetA === offsetB) { - return interfaces_1.BoundaryPosition.Equal; - } - else if (offsetA < offsetB) { - return interfaces_1.BoundaryPosition.Before; + 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 { - return interfaces_1.BoundaryPosition.After; + } 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' + } } - /** - * 3. If nodeA is following nodeB, then if the position of (nodeB, offsetB) - * relative to (nodeA, offsetA) is before, return after, and if it is after, - * return before. - */ - if (TreeAlgorithm_1.tree_isFollowing(nodeB, nodeA)) { - var pos = boundaryPoint_position([nodeB, offsetB], [nodeA, offsetA]); - if (pos === interfaces_1.BoundaryPosition.Before) { - return interfaces_1.BoundaryPosition.After; - } - else if (pos === interfaces_1.BoundaryPosition.After) { - return interfaces_1.BoundaryPosition.Before; - } + + 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 = '' } - /** - * 4. If nodeA is an ancestor of nodeB: - */ - if (TreeAlgorithm_1.tree_isAncestorOf(nodeB, nodeA)) { - /** - * 4.1. Let child be nodeB. - * 4.2. While child is not a child of nodeA, set child to its parent. - * 4.3. If child’s index is less than offsetA, then return after. - */ - var child = nodeB; - while (!TreeAlgorithm_1.tree_isChildOf(nodeA, child)) { - /* istanbul ignore else */ - if (child._parent !== null) { - child = child._parent; - } + + // 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 } - if (TreeAlgorithm_1.tree_index(child) < offsetA) { - return interfaces_1.BoundaryPosition.After; + } 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 } - } - /** - * 5. Return before. - */ - return interfaces_1.BoundaryPosition.Before; -} -exports.boundaryPoint_position = boundaryPoint_position; -//# sourceMappingURL=BoundaryPointAlgorithm.js.map - -/***/ }), -/* 351 */, -/* 352 */ -/***/ (function(module, __unusedexports, __webpack_require__) { + } -"use strict"; + 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 + } + debug('xRange return', ret) -var esprima; + return ret + }) +} -// Browserified version does not have esprima -// -// 1. For node.js just require module as deps -// 2. For browser try to require mudule via external AMD system. -// If not found - try to fallback to window.esprima. If not -// found too - then fail to parse. -// -try { - // workaround to exclude package from browserify list. - var _require = require; - esprima = _require('esprima'); -} catch (_) { - /* eslint-disable no-redeclare */ - /* global window */ - if (typeof window !== 'undefined') esprima = window.esprima; +// 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], '') } -var Type = __webpack_require__(945); +// 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 + } -function resolveJavascriptFunction(data) { - if (data === null) return false; + 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 + } - try { - var source = '(' + data + ')', - ast = esprima.parse(source, { range: true }); + return (from + ' ' + to).trim() +} - if (ast.type !== 'Program' || - ast.body.length !== 1 || - ast.body[0].type !== 'ExpressionStatement' || - (ast.body[0].expression.type !== 'ArrowFunctionExpression' && - ast.body[0].expression.type !== 'FunctionExpression')) { - return false; +// if ANY of the sets match ALL of its comparators, then pass +Range.prototype.test = function (version) { + if (!version) { + return false + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false } + } - return true; - } catch (err) { - return false; + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } } + return false } -function constructJavascriptFunction(data) { - /*jslint evil:true*/ +function testSet (set, version, options) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false + } + } - var source = '(' + data + ')', - ast = esprima.parse(source, { range: true }), - params = [], - body; + 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 (ast.type !== 'Program' || - ast.body.length !== 1 || - ast.body[0].type !== 'ExpressionStatement' || - (ast.body[0].expression.type !== 'ArrowFunctionExpression' && - ast.body[0].expression.type !== 'FunctionExpression')) { - throw new Error('Failed to resolve function'); - } + 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 + } + } + } - ast.body[0].expression.params.forEach(function (param) { - params.push(param.name); - }); + // Version has a -pre, but it's not one of the ones we like. + return false + } - body = ast.body[0].expression.body.range; + return true +} - // Esprima's ranges include the first '{' and the last '}' characters on - // function expressions. So cut them out. - if (ast.body[0].expression.body.type === 'BlockStatement') { - /*eslint-disable no-new-func*/ - return new Function(params, source.slice(body[0] + 1, body[1] - 1)); +exports.satisfies = satisfies +function satisfies (version, range, options) { + try { + range = new Range(range, options) + } catch (er) { + return false } - // ES6 arrow functions can omit the BlockStatement. In that case, just return - // the body. - /*eslint-disable no-new-func*/ - return new Function(params, 'return ' + source.slice(body[0], body[1])); + return range.test(version) } -function representJavascriptFunction(object /*, style*/) { - return object.toString(); +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 } -function isFunction(object) { - return Object.prototype.toString.call(object) === '[object Function]'; +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 } -module.exports = new Type('tag:yaml.org,2002:js/function', { - kind: 'scalar', - resolve: resolveJavascriptFunction, - construct: constructJavascriptFunction, - predicate: isFunction, - represent: representJavascriptFunction -}); +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 + } -/***/ }), -/* 353 */, -/* 354 */, -/* 355 */, -/* 356 */, -/* 357 */ -/***/ (function(module) { + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } -module.exports = require("assert"); + minver = null + for (var i = 0; i < range.set.length; ++i) { + var comparators = range.set[i] -/***/ }), -/* 358 */, -/* 359 */, -/* 360 */, -/* 361 */, -/* 362 */, -/* 363 */, -/* 364 */, -/* 365 */, -/* 366 */, -/* 367 */, -/* 368 */, -/* 369 */, -/* 370 */, -/* 371 */, -/* 372 */, -/* 373 */ -/***/ (function(module) { - -module.exports = require("crypto"); + 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) + } + }) + } -/***/ }), -/* 374 */, -/* 375 */, -/* 376 */, -/* 377 */, -/* 378 */, -/* 379 */, -/* 380 */, -/* 381 */, -/* 382 */, -/* 383 */, -/* 384 */, -/* 385 */, -/* 386 */ -/***/ (function(module, __unusedexports, __webpack_require__) { + if (minver && range.test(minver)) { + return minver + } -"use strict"; + return null +} +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 + } +} -var Type = __webpack_require__(945); +// 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) +} -function resolveJavascriptUndefined() { - return true; +// 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) } -function constructJavascriptUndefined() { - /*eslint-disable no-undefined*/ - return 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] + + var high = null + var low = null + + 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 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 } -function representJavascriptUndefined() { - return ''; +exports.prerelease = prerelease +function prerelease (version, options) { + var parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null } -function isUndefined(object) { - return typeof object === 'undefined'; +exports.intersects = intersects +function intersects (r1, r2, options) { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) } -module.exports = new Type('tag:yaml.org,2002:js/undefined', { - kind: 'scalar', - resolve: resolveJavascriptUndefined, - construct: constructJavascriptUndefined, - predicate: isUndefined, - represent: representJavascriptUndefined -}); +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 + } + + options = options || {} + + 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 + } + // 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) +} /***/ }), -/* 387 */, -/* 388 */, -/* 389 */, -/* 390 */, -/* 391 */, -/* 392 */ +/* 281 */, +/* 282 */, +/* 283 */, +/* 284 */, +/* 285 */, +/* 286 */ /***/ (function(__unusedmodule, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** - * A namespace prefix map is a map that associates namespaceURI and namespace - * prefix lists, where namespaceURI values are the map's unique keys (which can - * include the null value representing no namespace), and ordered lists of - * associated prefix values are the map's key values. The namespace prefix map - * will be populated by previously seen namespaceURIs and all their previously - * encountered prefix associations for a given node and its ancestors. + * Represents the state of the URL parser. + */ +var ParserState; +(function (ParserState) { + ParserState[ParserState["SchemeStart"] = 0] = "SchemeStart"; + ParserState[ParserState["Scheme"] = 1] = "Scheme"; + ParserState[ParserState["NoScheme"] = 2] = "NoScheme"; + ParserState[ParserState["SpecialRelativeOrAuthority"] = 3] = "SpecialRelativeOrAuthority"; + ParserState[ParserState["PathOrAuthority"] = 4] = "PathOrAuthority"; + ParserState[ParserState["Relative"] = 5] = "Relative"; + ParserState[ParserState["RelativeSlash"] = 6] = "RelativeSlash"; + ParserState[ParserState["SpecialAuthoritySlashes"] = 7] = "SpecialAuthoritySlashes"; + ParserState[ParserState["SpecialAuthorityIgnoreSlashes"] = 8] = "SpecialAuthorityIgnoreSlashes"; + ParserState[ParserState["Authority"] = 9] = "Authority"; + ParserState[ParserState["Host"] = 10] = "Host"; + ParserState[ParserState["Hostname"] = 11] = "Hostname"; + ParserState[ParserState["Port"] = 12] = "Port"; + ParserState[ParserState["File"] = 13] = "File"; + ParserState[ParserState["FileSlash"] = 14] = "FileSlash"; + ParserState[ParserState["FileHost"] = 15] = "FileHost"; + ParserState[ParserState["PathStart"] = 16] = "PathStart"; + ParserState[ParserState["Path"] = 17] = "Path"; + ParserState[ParserState["CannotBeABaseURLPath"] = 18] = "CannotBeABaseURLPath"; + ParserState[ParserState["Query"] = 19] = "Query"; + ParserState[ParserState["Fragment"] = 20] = "Fragment"; +})(ParserState = exports.ParserState || (exports.ParserState = {})); +exports.OpaqueOrigin = ["", "", null, null]; +//# sourceMappingURL=interfaces.js.map + +/***/ }), +/* 287 */, +/* 288 */, +/* 289 */, +/* 290 */, +/* 291 */, +/* 292 */, +/* 293 */, +/* 294 */, +/* 295 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var _1 = __webpack_require__(535); +/** + * Creates an XML builder which serializes the document in chunks. * - * _Note:_ The last seen prefix for a given namespaceURI is at the end of its - * respective list. The list is searched to find potentially matching prefixes, - * and if no matches are found for the given namespaceURI, then the last prefix - * in the list is used. See copy a namespace prefix map and retrieve a preferred - * prefix string for additional details. + * @param options - callback builder options * - * See: https://w3c.github.io/DOM-Parsing/#the-namespace-prefix-map + * @returns callback builder */ -var NamespacePrefixMap = /** @class */ (function () { - function NamespacePrefixMap() { - this._items = {}; - this._nullItems = []; - } - /** - * Creates a copy of the map. - */ - NamespacePrefixMap.prototype.copy = function () { - /** - * To copy a namespace prefix map map means to copy the map's keys into a - * new empty namespace prefix map, and to copy each of the values in the - * namespace prefix list associated with each keys' value into a new list - * which should be associated with the respective key in the new map. - */ - var mapCopy = new NamespacePrefixMap(); - for (var key in this._items) { - mapCopy._items[key] = this._items[key].slice(0); - } - mapCopy._nullItems = this._nullItems.slice(0); - return mapCopy; - }; - /** - * Retrieves a preferred prefix string from the namespace prefix map. - * - * @param preferredPrefix - preferred prefix string - * @param ns - namespace - */ - NamespacePrefixMap.prototype.get = function (preferredPrefix, ns) { - /** - * 1. Let candidates list be the result of retrieving a list from map where - * there exists a key in map that matches the value of ns or if there is no - * such key, then stop running these steps, and return the null value. - */ - var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); - if (candidatesList === null) { - return null; - } - /** - * 2. Otherwise, for each prefix value prefix in candidates list, iterating - * from beginning to end: - * - * _Note:_ There will always be at least one prefix value in the list. - */ - var prefix = null; - for (var i = 0; i < candidatesList.length; i++) { - prefix = candidatesList[i]; - /** - * 2.1. If prefix matches preferred prefix, then stop running these steps - * and return prefix. - */ - if (prefix === preferredPrefix) { - return prefix; - } - } - /** - * 2.2. If prefix is the last item in the candidates list, then stop - * running these steps and return prefix. - */ - return prefix; - }; - /** - * Checks if a prefix string is found in the namespace prefix map associated - * with the given namespace. - * - * @param prefix - prefix string - * @param ns - namespace - */ - NamespacePrefixMap.prototype.has = function (prefix, ns) { - /** - * 1. Let candidates list be the result of retrieving a list from map where - * there exists a key in map that matches the value of ns or if there is - * no such key, then stop running these steps, and return false. - */ - var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); - if (candidatesList === null) { - return false; - } - /** - * 2. If the value of prefix occurs at least once in candidates list, - * return true, otherwise return false. - */ - return (candidatesList.indexOf(prefix) !== -1); - }; - /** - * Checks if a prefix string is found in the namespace prefix map. - * - * @param prefix - prefix string - */ - NamespacePrefixMap.prototype.hasPrefix = function (prefix) { - if (this._nullItems.indexOf(prefix) !== -1) - return true; - for (var key in this._items) { - if (this._items[key].indexOf(prefix) !== -1) - return true; - } - return false; - }; - /** - * Adds a prefix string associated with a namespace to the prefix map. - * - * @param prefix - prefix string - * @param ns - namespace - */ - NamespacePrefixMap.prototype.set = function (prefix, ns) { - /** - * 1. Let candidates list be the result of retrieving a list from map where - * there exists a key in map that matches the value of ns or if there is - * no such key, then let candidates list be null. - */ - var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); - /** - * 2. If candidates list is null, then create a new list with prefix as the - * only item in the list, and associate that list with a new key ns in map. - * 3. Otherwise, append prefix to the end of candidates list. - * - * _Note:_ The steps in retrieve a preferred prefix string use the list to - * track the most recently used (MRU) prefix associated with a given - * namespace, which will be the prefix at the end of the list. This list - * may contain duplicates of the same prefix value seen earlier - * (and that's OK). - */ - if (ns !== null && candidatesList === null) { - this._items[ns] = [prefix]; - } - else { - candidatesList.push(prefix); - } - }; - return NamespacePrefixMap; -}()); -exports.NamespacePrefixMap = NamespacePrefixMap; -//# sourceMappingURL=NamespacePrefixMap.js.map +function createCB(options) { + return new _1.XMLBuilderCBImpl(options); +} +exports.createCB = createCB; +/** + * Creates an XML builder which serializes the fragment in chunks. + * + * @param options - callback builder options + * + * @returns callback builder + */ +function fragmentCB(options) { + return new _1.XMLBuilderCBImpl(options, true); +} +exports.fragmentCB = fragmentCB; +//# sourceMappingURL=BuilderFunctionsCB.js.map /***/ }), -/* 393 */ +/* 296 */, +/* 297 */, +/* 298 */, +/* 299 */, +/* 300 */, +/* 301 */, +/* 302 */, +/* 303 */, +/* 304 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "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 (k !== "default" && Object.prototype.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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.ZuluDistribution = void 0; -const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); -const path_1 = __importDefault(__webpack_require__(622)); -const fs_1 = __importDefault(__webpack_require__(747)); -const semver_1 = __importDefault(__webpack_require__(876)); -const base_installer_1 = __webpack_require__(83); -const util_1 = __webpack_require__(322); -class ZuluDistribution extends base_installer_1.JavaBase { - constructor(installerOptions) { - super('Zulu', installerOptions); - } - findPackageForDownload(version) { - return __awaiter(this, void 0, void 0, function* () { - const availableVersionsRaw = yield this.getAvailableVersions(); - const availableVersions = availableVersionsRaw.map(item => { - return { - version: this.convertVersionToSemver(item.jdk_version), - url: item.url, - zuluVersion: this.convertVersionToSemver(item.zulu_version) - }; - }); - const satisfiedVersions = availableVersions - .filter(item => util_1.isVersionSatisfies(version, item.version)) - .sort((a, b) => { - // Azul provides two versions: jdk_version and azul_version - // we should sort by both fields by descending - return (-semver_1.default.compareBuild(a.version, b.version) || - -semver_1.default.compareBuild(a.zuluVersion, b.zuluVersion)); - }) - .map(item => { - return { - version: item.version, - url: item.url - }; - }); - const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; - if (!resolvedFullVersion) { - const availableOptions = availableVersions.map(item => item.version).join(', '); - const availableOptionsMessage = availableOptions - ? `\nAvailable versions: ${availableOptions}` - : ''; - throw new Error(`Could not find satisfied version for semver ${version}. ${availableOptionsMessage}`); - } - return resolvedFullVersion; - }); +var DOMImpl_1 = __webpack_require__(648); +var TreeAlgorithm_1 = __webpack_require__(873); +var util_1 = __webpack_require__(918); +var ShadowTreeAlgorithm_1 = __webpack_require__(180); +var supportedTokens = new Map(); +/** + * Runs removing steps for node. + * + * @param removedNode - removed node + * @param oldParent - old parent node + */ +function dom_runRemovingSteps(removedNode, oldParent) { + // No steps defined +} +exports.dom_runRemovingSteps = dom_runRemovingSteps; +/** + * Runs cloning steps for node. + * + * @param copy - node clone + * @param node - node + * @param document - document to own the cloned node + * @param cloneChildrenFlag - whether child nodes are cloned + */ +function dom_runCloningSteps(copy, node, document, cloneChildrenFlag) { + // No steps defined +} +exports.dom_runCloningSteps = dom_runCloningSteps; +/** + * Runs adopting steps for node. + * + * @param node - node + * @param oldDocument - old document + */ +function dom_runAdoptingSteps(node, oldDocument) { + // No steps defined +} +exports.dom_runAdoptingSteps = dom_runAdoptingSteps; +/** + * Runs attribute change steps for an element node. + * + * @param element - element node owning the attribute + * @param localName - attribute's local name + * @param oldValue - attribute's old value + * @param value - attribute's new value + * @param namespace - attribute's namespace + */ +function dom_runAttributeChangeSteps(element, localName, oldValue, value, namespace) { + var e_1, _a; + // run default steps + if (DOMImpl_1.dom.features.slots) { + updateASlotablesName.call(element, element, localName, oldValue, value, namespace); + updateASlotsName.call(element, element, localName, oldValue, value, namespace); } - downloadTool(javaRelease) { - return __awaiter(this, void 0, void 0, function* () { - let extractedJavaPath; - core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); - core.info(`Extracting Java archive...`); - let extension = util_1.getDownloadArchiveExtension(); - extractedJavaPath = yield util_1.extractJdkFile(javaArchivePath, extension); - const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; - const archivePath = path_1.default.join(extractedJavaPath, archiveName); - const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture); - return { version: javaRelease.version, path: javaPath }; - }); + updateAnElementID.call(element, element, localName, value, namespace); + try { + // run custom steps + for (var _b = __values(element._attributeChangeSteps), _c = _b.next(); !_c.done; _c = _b.next()) { + var step = _c.value; + step.call(element, element, localName, oldValue, value, namespace); + } } - getAvailableVersions() { - var _a, _b; - return __awaiter(this, void 0, void 0, function* () { - const { arch, hw_bitness, abi } = this.getArchitectureOptions(); - const [bundleType, features] = this.packageType.split('+'); - const platform = this.getPlatformOption(); - const extension = util_1.getDownloadArchiveExtension(); - const javafx = (_a = features === null || features === void 0 ? void 0 : features.includes('fx')) !== null && _a !== void 0 ? _a : false; - const releaseStatus = this.stable ? 'ga' : 'ea'; - console.time('azul-retrieve-available-versions'); - const requestArguments = [ - `os=${platform}`, - `ext=${extension}`, - `bundle_type=${bundleType}`, - `javafx=${javafx}`, - `arch=${arch}`, - `hw_bitness=${hw_bitness}`, - `release_status=${releaseStatus}`, - abi ? `abi=${abi}` : null, - features ? `features=${features}` : null - ] - .filter(Boolean) - .join('&'); - const availableVersionsUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?${requestArguments}`; - if (core.isDebug()) { - core.debug(`Gathering available versions from '${availableVersionsUrl}'`); + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +exports.dom_runAttributeChangeSteps = dom_runAttributeChangeSteps; +/** + * Runs insertion steps for a node. + * + * @param insertedNode - inserted node + */ +function dom_runInsertionSteps(insertedNode) { + // No steps defined +} +exports.dom_runInsertionSteps = dom_runInsertionSteps; +/** + * Runs pre-removing steps for a node iterator and node. + * + * @param nodeIterator - a node iterator + * @param toBeRemoved - node to be removed + */ +function dom_runNodeIteratorPreRemovingSteps(nodeIterator, toBeRemoved) { + removeNodeIterator.call(nodeIterator, nodeIterator, toBeRemoved); +} +exports.dom_runNodeIteratorPreRemovingSteps = dom_runNodeIteratorPreRemovingSteps; +/** + * Determines if there are any supported tokens defined for the given + * attribute name. + * + * @param attributeName - an attribute name + */ +function dom_hasSupportedTokens(attributeName) { + return supportedTokens.has(attributeName); +} +exports.dom_hasSupportedTokens = dom_hasSupportedTokens; +/** + * Returns the set of supported tokens defined for the given attribute name. + * + * @param attributeName - an attribute name + */ +function dom_getSupportedTokens(attributeName) { + return supportedTokens.get(attributeName) || new Set(); +} +exports.dom_getSupportedTokens = dom_getSupportedTokens; +/** + * Runs event construction steps. + * + * @param event - an event + */ +function dom_runEventConstructingSteps(event) { + // No steps defined +} +exports.dom_runEventConstructingSteps = dom_runEventConstructingSteps; +/** + * Runs child text content change steps for a parent node. + * + * @param parent - parent node with text node child nodes + */ +function dom_runChildTextContentChangeSteps(parent) { + // No steps defined +} +exports.dom_runChildTextContentChangeSteps = dom_runChildTextContentChangeSteps; +/** + * Defines pre-removing steps for a node iterator. + */ +function removeNodeIterator(nodeIterator, toBeRemovedNode) { + /** + * 1. If toBeRemovedNode is not an inclusive ancestor of nodeIterator’s + * reference, or toBeRemovedNode is nodeIterator’s root, then return. + */ + if (toBeRemovedNode === nodeIterator._root || + !TreeAlgorithm_1.tree_isAncestorOf(nodeIterator._reference, toBeRemovedNode, true)) { + return; + } + /** + * 2. If nodeIterator’s pointer before reference is true, then: + */ + if (nodeIterator._pointerBeforeReference) { + /** + * 2.1. Let next be toBeRemovedNode’s first following node that is an + * inclusive descendant of nodeIterator’s root and is not an inclusive + * descendant of toBeRemovedNode, and null if there is no such node. + */ + while (true) { + var nextNode = TreeAlgorithm_1.tree_getFollowingNode(nodeIterator._root, toBeRemovedNode); + if (nextNode !== null && + TreeAlgorithm_1.tree_isDescendantOf(nodeIterator._root, nextNode, true) && + !TreeAlgorithm_1.tree_isDescendantOf(toBeRemovedNode, nextNode, true)) { + /** + * 2.2. If next is non-null, then set nodeIterator’s reference to next + * and return. + */ + nodeIterator._reference = nextNode; + return; } - const availableVersions = (_b = (yield this.http.getJson(availableVersionsUrl)).result) !== null && _b !== void 0 ? _b : []; - if (core.isDebug()) { - core.startGroup('Print information about available versions'); - console.timeEnd('azul-retrieve-available-versions'); - console.log(`Available versions: [${availableVersions.length}]`); - console.log(availableVersions.map(item => item.jdk_version.join('.')).join(', ')); - core.endGroup(); + else if (nextNode === null) { + /** + * 2.3. Otherwise, set nodeIterator’s pointer before reference to false. + */ + nodeIterator._pointerBeforeReference = false; + return; } - return availableVersions; - }); + } } - getArchitectureOptions() { - if (this.architecture == 'x64') { - return { arch: 'x86', hw_bitness: '64', abi: '' }; + /** + * 3. Set nodeIterator’s reference to toBeRemovedNode’s parent, if + * toBeRemovedNode’s previous sibling is null, and to the inclusive + * descendant of toBeRemovedNode’s previous sibling that appears last in + * tree order otherwise. + */ + if (toBeRemovedNode._previousSibling === null) { + if (toBeRemovedNode._parent !== null) { + nodeIterator._reference = toBeRemovedNode._parent; } - else if (this.architecture == 'x86') { - return { arch: 'x86', hw_bitness: '32', abi: '' }; + } + else { + var referenceNode = toBeRemovedNode._previousSibling; + var childNode = TreeAlgorithm_1.tree_getFirstDescendantNode(toBeRemovedNode._previousSibling, true, false); + while (childNode !== null) { + if (childNode !== null) { + referenceNode = childNode; + } + // loop through to get the last descendant node + childNode = TreeAlgorithm_1.tree_getNextDescendantNode(toBeRemovedNode._previousSibling, childNode, true, false); + } + nodeIterator._reference = referenceNode; + } +} +/** + * Defines attribute change steps to update a slot’s name. + */ +function updateASlotsName(element, localName, oldValue, value, namespace) { + /** + * 1. If element is a slot, localName is name, and namespace is null, then: + * 1.1. If value is oldValue, then return. + * 1.2. If value is null and oldValue is the empty string, then return. + * 1.3. If value is the empty string and oldValue is null, then return. + * 1.4. If value is null or the empty string, then set element’s name to the + * empty string. + * 1.5. Otherwise, set element’s name to value. + * 1.6. Run assign slotables for a tree with element’s root. + */ + if (util_1.Guard.isSlot(element) && localName === "name" && namespace === null) { + if (value === oldValue) + return; + if (value === null && oldValue === '') + return; + if (value === '' && oldValue === null) + return; + if ((value === null || value === '')) { + element._name = ''; } else { - return { arch: this.architecture, hw_bitness: '', abi: '' }; + element._name = value; } + ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(element)); } - getPlatformOption() { - // Azul has own platform names so need to map them - switch (process.platform) { - case 'darwin': - return 'macos'; - case 'win32': - return 'windows'; - default: - return process.platform; +} +/** + * Defines attribute change steps to update a slotable’s name. + */ +function updateASlotablesName(element, localName, oldValue, value, namespace) { + /** + * 1. If localName is slot and namespace is null, then: + * 1.1. If value is oldValue, then return. + * 1.2. If value is null and oldValue is the empty string, then return. + * 1.3. If value is the empty string and oldValue is null, then return. + * 1.4. If value is null or the empty string, then set element’s name to + * the empty string. + * 1.5. Otherwise, set element’s name to value. + * 1.6. If element is assigned, then run assign slotables for element’s + * assigned slot. + * 1.7. Run assign a slot for element. + */ + if (util_1.Guard.isSlotable(element) && localName === "slot" && namespace === null) { + if (value === oldValue) + return; + if (value === null && oldValue === '') + return; + if (value === '' && oldValue === null) + return; + if ((value === null || value === '')) { + element._name = ''; } - } - // Azul API returns jdk_version as array of digits like [11, 0, 2, 1] - convertVersionToSemver(version_array) { - const mainVersion = version_array.slice(0, 3).join('.'); - if (version_array.length > 3) { - // intentionally ignore more than 4 numbers because it is invalid semver - return `${mainVersion}+${version_array[3]}`; + else { + element._name = value; } - return mainVersion; + if (ShadowTreeAlgorithm_1.shadowTree_isAssigned(element)) { + ShadowTreeAlgorithm_1.shadowTree_assignSlotables(element._assignedSlot); + } + ShadowTreeAlgorithm_1.shadowTree_assignASlot(element); } } -exports.ZuluDistribution = ZuluDistribution; - - -/***/ }), -/* 394 */, -/* 395 */, -/* 396 */ -/***/ (function(module) { - -"use strict"; - -module.exports = function (Yallist) { - Yallist.prototype[Symbol.iterator] = function* () { - for (let walker = this.head; walker; walker = walker.next) { - yield walker.value +/** + * Defines attribute change steps to update an element's ID. + */ +function updateAnElementID(element, localName, value, namespace) { + /** + * 1. If localName is id, namespace is null, and value is null or the empty + * string, then unset element’s ID. + * 2. Otherwise, if localName is id, namespace is null, then set element’s + * ID to value. + */ + if (localName === "id" && namespace === null) { + if (!value) + element._uniqueIdentifier = undefined; + else + element._uniqueIdentifier = value; } - } } - +//# sourceMappingURL=DOMAlgorithm.js.map /***/ }), -/* 397 */, -/* 398 */, -/* 399 */, -/* 400 */, -/* 401 */, -/* 402 */, -/* 403 */, -/* 404 */, -/* 405 */, -/* 406 */, -/* 407 */, -/* 408 */, -/* 409 */, -/* 410 */, -/* 411 */, -/* 412 */, -/* 413 */ +/* 305 */ /***/ (function(__unusedmodule, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** - * Represents an abstract range with a start and end boundary point. + * Pre-serializes XML nodes. */ -var AbstractRangeImpl = /** @class */ (function () { - function AbstractRangeImpl() { +var BaseReader = /** @class */ (function () { + /** + * Initializes a new instance of `BaseReader`. + * + * @param builderOptions - XML builder options + */ + function BaseReader(builderOptions) { + this._builderOptions = builderOptions; + if (builderOptions.parser) { + Object.assign(this, builderOptions.parser); + } } - Object.defineProperty(AbstractRangeImpl.prototype, "_startNode", { - get: function () { return this._start[0]; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "_startOffset", { - get: function () { return this._start[1]; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "_endNode", { - get: function () { return this._end[0]; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "_endOffset", { - get: function () { return this._end[1]; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "_collapsed", { - get: function () { - return (this._start[0] === this._end[0] && - this._start[1] === this._end[1]); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "startContainer", { - /** @inheritdoc */ - get: function () { return this._startNode; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "startOffset", { - /** @inheritdoc */ - get: function () { return this._startOffset; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "endContainer", { - /** @inheritdoc */ - get: function () { return this._endNode; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "endOffset", { - /** @inheritdoc */ - get: function () { return this._endOffset; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "collapsed", { - /** @inheritdoc */ - get: function () { return this._collapsed; }, - enumerable: true, - configurable: true - }); - return AbstractRangeImpl; -}()); -exports.AbstractRangeImpl = AbstractRangeImpl; -//# sourceMappingURL=AbstractRangeImpl.js.map - -/***/ }), -/* 414 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - - -var yaml = __webpack_require__(9); - - -module.exports = yaml; - - -/***/ }), -/* 415 */, -/* 416 */, -/* 417 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -var common = __webpack_require__(740); -var Type = __webpack_require__(945); - -var YAML_FLOAT_PATTERN = new RegExp( - // 2.5e4, 2.5 and integers - '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + - // .2e4, .2 - // special case, seems not from spec - '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + - // 20:59 - '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + - // .inf - '|[-+]?\\.(?:inf|Inf|INF)' + - // .nan - '|\\.(?:nan|NaN|NAN))$'); - -function resolveYamlFloat(data) { - if (data === null) return false; - - if (!YAML_FLOAT_PATTERN.test(data) || - // Quick hack to not allow integers end with `_` - // Probably should update regexp & check speed - data[data.length - 1] === '_') { - return false; - } - - return true; -} - -function constructYamlFloat(data) { - var value, sign, base, digits; - - value = data.replace(/_/g, '').toLowerCase(); - sign = value[0] === '-' ? -1 : 1; - digits = []; - - if ('+-'.indexOf(value[0]) >= 0) { - value = value.slice(1); - } - - if (value === '.inf') { - return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; - - } else if (value === '.nan') { - return NaN; + BaseReader.prototype._docType = function (parent, name, publicId, systemId) { + return parent.dtd({ name: name, pubID: publicId, sysID: systemId }); + }; + BaseReader.prototype._comment = function (parent, data) { + return parent.com(data); + }; + BaseReader.prototype._text = function (parent, data) { + return parent.txt(data); + }; + BaseReader.prototype._instruction = function (parent, target, data) { + return parent.ins(target, data); + }; + BaseReader.prototype._cdata = function (parent, data) { + return parent.dat(data); + }; + BaseReader.prototype._element = function (parent, namespace, name) { + return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name)); + }; + BaseReader.prototype._attribute = function (parent, namespace, name, value) { + return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value)); + }; + /** + * Main parser function which parses the given object and returns an XMLBuilder. + * + * @param node - node to recieve parsed content + * @param obj - object to parse + */ + BaseReader.prototype.parse = function (node, obj) { + return this._parse(node, obj); + }; + /** + * Creates a DocType node. + * The node will be skipped if the function returns `undefined`. + * + * @param name - node name + * @param publicId - public identifier + * @param systemId - system identifier + */ + BaseReader.prototype.docType = function (parent, name, publicId, systemId) { + return this._docType(parent, name, publicId, systemId); + }; + /** + * Creates a comment node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.comment = function (parent, data) { + return this._comment(parent, data); + }; + /** + * Creates a text node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.text = function (parent, data) { + return this._text(parent, data); + }; + /** + * Creates a processing instruction node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param target - instruction target + * @param data - node data + */ + BaseReader.prototype.instruction = function (parent, target, data) { + return this._instruction(parent, target, data); + }; + /** + * Creates a CData section node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.cdata = function (parent, data) { + return this._cdata(parent, data); + }; + /** + * Creates an element node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param namespace - node namespace + * @param name - node name + */ + BaseReader.prototype.element = function (parent, namespace, name) { + return this._element(parent, namespace, name); + }; + /** + * Creates an attribute or namespace declaration. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param namespace - node namespace + * @param name - node name + * @param value - node value + */ + BaseReader.prototype.attribute = function (parent, namespace, name, value) { + return this._attribute(parent, namespace, name, value); + }; + return BaseReader; +}()); +exports.BaseReader = BaseReader; +//# sourceMappingURL=BaseReader.js.map - } else if (value.indexOf(':') >= 0) { - value.split(':').forEach(function (v) { - digits.unshift(parseFloat(v, 10)); - }); +/***/ }), +/* 306 */, +/* 307 */, +/* 308 */, +/* 309 */, +/* 310 */, +/* 311 */, +/* 312 */, +/* 313 */, +/* 314 */, +/* 315 */, +/* 316 */, +/* 317 */, +/* 318 */, +/* 319 */, +/* 320 */, +/* 321 */, +/* 322 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { - value = 0.0; - base = 1; +"use strict"; - digits.forEach(function (d) { - value += d * base; - base *= 60; +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 (k !== "default" && 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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); }); - - return sign * value; - - } - return sign * parseFloat(value, 10); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +const os_1 = __importDefault(__webpack_require__(87)); +const path_1 = __importDefault(__webpack_require__(622)); +const fs = __importStar(__webpack_require__(747)); +const semver = __importStar(__webpack_require__(280)); +const core = __importStar(__webpack_require__(470)); +const tc = __importStar(__webpack_require__(139)); +function getTempDir() { + let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); + return tempDirectory; } - - -var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; - -function representYamlFloat(object, style) { - var res; - - if (isNaN(object)) { - switch (style) { - case 'lowercase': return '.nan'; - case 'uppercase': return '.NAN'; - case 'camelcase': return '.NaN'; - } - } else if (Number.POSITIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '.inf'; - case 'uppercase': return '.INF'; - case 'camelcase': return '.Inf'; +exports.getTempDir = getTempDir; +function getBooleanInput(inputName, defaultValue = false) { + return (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'; +} +exports.getBooleanInput = getBooleanInput; +function getVersionFromToolcachePath(toolPath) { + if (toolPath) { + return path_1.default.basename(path_1.default.dirname(toolPath)); } - } else if (Number.NEGATIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '-.inf'; - case 'uppercase': return '-.INF'; - case 'camelcase': return '-.Inf'; + return toolPath; +} +exports.getVersionFromToolcachePath = getVersionFromToolcachePath; +function extractJdkFile(toolPath, extension) { + return __awaiter(this, void 0, void 0, function* () { + if (!extension) { + extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); + if (extension.startsWith('.')) { + extension = extension.substring(1); + } + } + switch (extension) { + case 'tar.gz': + case 'tar': + return yield tc.extractTar(toolPath); + case 'zip': + return yield tc.extractZip(toolPath); + default: + return yield tc.extract7z(toolPath); + } + }); +} +exports.extractJdkFile = extractJdkFile; +function getDownloadArchiveExtension() { + return process.platform === 'win32' ? 'zip' : 'tar.gz'; +} +exports.getDownloadArchiveExtension = getDownloadArchiveExtension; +function isVersionSatisfies(range, version) { + var _a; + if (semver.valid(range)) { + // if full version with build digit is provided as a range (such as '1.2.3+4') + // we should check for exact equal via compareBuild + // since semver.satisfies doesn't handle 4th digit + const semRange = semver.parse(range); + if (semRange && ((_a = semRange.build) === null || _a === void 0 ? void 0 : _a.length) > 0) { + return semver.compareBuild(range, version) === 0; + } } - } else if (common.isNegativeZero(object)) { - return '-0.0'; - } - - res = object.toString(10); - - // JS stringifier can build scientific format without dots: 5e-100, - // while YAML requres dot: 5.e-100. Fix it with simple hack - - return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; + return semver.satisfies(version, range); } - -function isFloat(object) { - return (Object.prototype.toString.call(object) === '[object Number]') && - (object % 1 !== 0 || common.isNegativeZero(object)); +exports.isVersionSatisfies = isVersionSatisfies; +function getToolcachePath(toolName, version, architecture) { + var _a; + const toolcacheRoot = (_a = process.env['RUNNER_TOOL_CACHE']) !== null && _a !== void 0 ? _a : ''; + const fullPath = path_1.default.join(toolcacheRoot, toolName, version, architecture); + if (fs.existsSync(fullPath)) { + return fullPath; + } + return null; } - -module.exports = new Type('tag:yaml.org,2002:float', { - kind: 'scalar', - resolve: resolveYamlFloat, - construct: constructYamlFloat, - predicate: isFloat, - represent: representYamlFloat, - defaultStyle: 'lowercase' -}); +exports.getToolcachePath = getToolcachePath; /***/ }), -/* 418 */, -/* 419 */ +/* 323 */, +/* 324 */, +/* 325 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; @@ -14358,7405 +13648,6113 @@ var __values = (this && this.__values) || function(o) { throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); +var ObjectWriter_1 = __webpack_require__(419); var util_1 = __webpack_require__(592); -var interfaces_1 = __webpack_require__(970); var BaseWriter_1 = __webpack_require__(462); /** - * Serializes XML nodes into objects and arrays. + * Serializes XML nodes into a YAML string. */ -var ObjectWriter = /** @class */ (function (_super) { - __extends(ObjectWriter, _super); +var YAMLWriter = /** @class */ (function (_super) { + __extends(YAMLWriter, _super); /** - * Initializes a new instance of `ObjectWriter`. + * Initializes a new instance of `YAMLWriter`. * * @param builderOptions - XML builder options * @param writerOptions - serialization options */ - function ObjectWriter(builderOptions, writerOptions) { + function YAMLWriter(builderOptions, writerOptions) { var _this = _super.call(this, builderOptions) || this; + // provide default options _this._writerOptions = util_1.applyDefaults(writerOptions, { - format: "object", wellFormed: false, noDoubleEncoding: false, + indent: ' ', + newline: '\n', + offset: 0, group: false, verbose: false }); + if (_this._writerOptions.indent.length < 2) { + throw new Error("YAML indententation string must be at least two characters long."); + } + if (_this._writerOptions.offset < 0) { + throw new Error("YAML offset should be zero or a positive number."); + } return _this; } /** * Produces an XML serialization of the given node. * * @param node - node to serialize + * @param writerOptions - serialization options */ - ObjectWriter.prototype.serialize = function (node) { - this._currentList = []; - this._currentIndex = 0; - this._listRegister = [this._currentList]; - /** - * First pass, serialize nodes - * This creates a list of nodes grouped under node types while preserving - * insertion order. For example: - * [ - * root: [ - * node: [ - * { "@" : { "att1": "val1", "att2": "val2" } - * { "#": "node text" } - * { childNode: [] } - * { "#": "more text" } - * ], - * node: [ - * { "@" : { "att": "val" } - * { "#": [ "text line1", "text line2" ] } - * ] - * ] - * ] - */ - this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); - /** - * Second pass, process node lists. Above example becomes: - * { - * root: { - * node: [ - * { - * "@att1": "val1", - * "@att2": "val2", - * "#1": "node text", - * childNode: {}, - * "#2": "more text" - * }, - * { - * "@att": "val", - * "#": [ "text line1", "text line2" ] - * } - * ] - * } - * } - */ - return this._process(this._currentList, this._writerOptions); + YAMLWriter.prototype.serialize = function (node) { + // convert to object + var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + }); + var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); + var val = objectWriter.serialize(node); + var markup = this._beginLine(this._writerOptions, 0) + '---' + this._endLine(this._writerOptions) + + this._convertObject(val, this._writerOptions, 0); + // remove trailing newline + /* istanbul ignore else */ + if (markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { + markup = markup.slice(0, -this._writerOptions.newline.length); + } + return markup; }; - ObjectWriter.prototype._process = function (items, options) { - var _a, _b, _c, _d, _e, _f, _g; - if (items.length === 0) - return {}; - // determine if there are non-unique element names - var namesSeen = {}; - var hasNonUniqueNames = false; - var textCount = 0; - var commentCount = 0; - var instructionCount = 0; - var cdataCount = 0; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - continue; - case "#": - textCount++; - break; - case "!": - commentCount++; - break; - case "?": - instructionCount++; - break; - case "$": - cdataCount++; - break; - default: - if (namesSeen[key]) { - hasNonUniqueNames = true; - } - else { - namesSeen[key] = true; + /** + * Produces an XML serialization of the given object. + * + * @param obj - object to serialize + * @param options - serialization options + * @param level - depth of the XML tree + * @param indentLeaf - indents leaf nodes + */ + YAMLWriter.prototype._convertObject = function (obj, options, level, suppressIndent) { + var e_1, _a; + var _this = this; + if (suppressIndent === void 0) { suppressIndent = false; } + var markup = ''; + if (util_1.isArray(obj)) { + try { + for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { + var val = obj_1_1.value; + markup += this._beginLine(options, level, true); + if (!util_1.isObject(val)) { + markup += this._val(val) + this._endLine(options); } - break; - } - } - var defAttrKey = this._getAttrKey(); - var defTextKey = this._getNodeKey(interfaces_1.NodeType.Text); - var defCommentKey = this._getNodeKey(interfaces_1.NodeType.Comment); - var defInstructionKey = this._getNodeKey(interfaces_1.NodeType.ProcessingInstruction); - var defCdataKey = this._getNodeKey(interfaces_1.NodeType.CData); - if (textCount === 1 && items.length === 1 && util_1.isString(items[0]["#"])) { - // special case of an element node with a single text node - return items[0]["#"]; - } - else if (hasNonUniqueNames) { - var obj = {}; - // process attributes first - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - if (key === "@") { - var attrs = item["@"]; - var attrKeys = Object.keys(attrs); - if (attrKeys.length === 1) { - obj[defAttrKey + attrKeys[0]] = attrs[attrKeys[0]]; + else if (util_1.isEmpty(val)) { + markup += '""' + this._endLine(options); } else { - obj[defAttrKey] = item["@"]; + markup += this._convertObject(val, options, level, true); } } } - // list contains element nodes with non-unique names - // return an array with mixed content notation - var result = []; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - // attributes were processed above - break; - case "#": - result.push((_a = {}, _a[defTextKey] = item["#"], _a)); - break; - case "!": - result.push((_b = {}, _b[defCommentKey] = item["!"], _b)); - break; - case "?": - result.push((_c = {}, _c[defInstructionKey] = item["?"], _c)); - break; - case "$": - result.push((_d = {}, _d[defCdataKey] = item["$"], _d)); - break; - default: - // element node - var ele = item; - if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { - // group of element nodes - var eleGroup = []; - var listOfLists = ele[key]; - for (var i_1 = 0; i_1 < listOfLists.length; i_1++) { - eleGroup.push(this._process(listOfLists[i_1], options)); - } - result.push((_e = {}, _e[key] = eleGroup, _e)); - } - else { - // single element node - if (options.verbose) { - result.push((_f = {}, _f[key] = [this._process(ele[key], options)], _f)); - } - else { - result.push((_g = {}, _g[key] = this._process(ele[key], options), _g)); - } - } - break; - } - } - obj[defTextKey] = result; - return obj; - } - else { - // all element nodes have unique names - // return an object while prefixing data node keys - var textId = 1; - var commentId = 1; - var instructionId = 1; - var cdataId = 1; - var obj = {}; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - var attrs = item["@"]; - var attrKeys = Object.keys(attrs); - if (!options.group || attrKeys.length === 1) { - for (var attrName in attrs) { - obj[defAttrKey + attrName] = attrs[attrName]; - } - } - else { - obj[defAttrKey] = attrs; - } - break; - case "#": - textId = this._processSpecItem(item["#"], obj, options.group, defTextKey, textCount, textId); - break; - case "!": - commentId = this._processSpecItem(item["!"], obj, options.group, defCommentKey, commentCount, commentId); - break; - case "?": - instructionId = this._processSpecItem(item["?"], obj, options.group, defInstructionKey, instructionCount, instructionId); - break; - case "$": - cdataId = this._processSpecItem(item["$"], obj, options.group, defCdataKey, cdataCount, cdataId); - break; - default: - // element node - var ele = item; - if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { - // group of element nodes - var eleGroup = []; - var listOfLists = ele[key]; - for (var i_2 = 0; i_2 < listOfLists.length; i_2++) { - eleGroup.push(this._process(listOfLists[i_2], options)); - } - obj[key] = eleGroup; - } - else { - // single element node - if (options.verbose) { - obj[key] = [this._process(ele[key], options)]; - } - else { - obj[key] = this._process(ele[key], options); - } - } - break; - } - } - return obj; - } - }; - ObjectWriter.prototype._processSpecItem = function (item, obj, group, defKey, count, id) { - var e_1, _a; - if (!group && util_1.isArray(item) && count + item.length > 2) { - try { - for (var item_1 = __values(item), item_1_1 = item_1.next(); !item_1_1.done; item_1_1 = item_1.next()) { - var subItem = item_1_1.value; - var key = defKey + (id++).toString(); - obj[key] = subItem; - } - } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (item_1_1 && !item_1_1.done && (_a = item_1.return)) _a.call(item_1); + if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); } finally { if (e_1) throw e_1.error; } } } - else { - var key = count > 1 ? defKey + (id++).toString() : defKey; - obj[key] = item; - } - return id; - }; - /** @inheritdoc */ - ObjectWriter.prototype.beginElement = function (name) { - var _a, _b; - var childItems = []; - if (this._currentList.length === 0) { - this._currentList.push((_a = {}, _a[name] = childItems, _a)); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isElementNode(lastItem, name)) { - if (lastItem[name].length !== 0 && util_1.isArray(lastItem[name][0])) { - var listOfLists = lastItem[name]; - listOfLists.push(childItems); - } - else { - lastItem[name] = [lastItem[name], childItems]; - } - } - else { - this._currentList.push((_b = {}, _b[name] = childItems, _b)); - } - } - this._currentIndex++; - if (this._listRegister.length > this._currentIndex) { - this._listRegister[this._currentIndex] = childItems; - } - else { - this._listRegister.push(childItems); - } - this._currentList = childItems; - }; - /** @inheritdoc */ - ObjectWriter.prototype.endElement = function () { - this._currentList = this._listRegister[--this._currentIndex]; - }; - /** @inheritdoc */ - ObjectWriter.prototype.attribute = function (name, value) { - var _a, _b; - if (this._currentList.length === 0) { - this._currentList.push({ "@": (_a = {}, _a[name] = value, _a) }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - /* istanbul ignore else */ - if (this._isAttrNode(lastItem)) { - lastItem["@"][name] = value; - } - else { - this._currentList.push({ "@": (_b = {}, _b[name] = value, _b) }); - } - } - }; - /** @inheritdoc */ - ObjectWriter.prototype.comment = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "!": data }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isCommentNode(lastItem)) { - if (util_1.isArray(lastItem["!"])) { - lastItem["!"].push(data); + else /* if (isObject(obj)) */ { + util_1.forEachObject(obj, function (key, val) { + if (suppressIndent) { + markup += _this._key(key); + suppressIndent = false; } else { - lastItem["!"] = [lastItem["!"], data]; - } - } - else { - this._currentList.push({ "!": data }); - } - } - }; - /** @inheritdoc */ - ObjectWriter.prototype.text = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "#": data }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isTextNode(lastItem)) { - if (util_1.isArray(lastItem["#"])) { - lastItem["#"].push(data); + markup += _this._beginLine(options, level) + _this._key(key); } - else { - lastItem["#"] = [lastItem["#"], data]; + if (!util_1.isObject(val)) { + markup += ' ' + _this._val(val) + _this._endLine(options); } - } - else { - this._currentList.push({ "#": data }); - } - } - }; - /** @inheritdoc */ - ObjectWriter.prototype.instruction = function (target, data) { - var value = (data === "" ? target : target + " " + data); - if (this._currentList.length === 0) { - this._currentList.push({ "?": value }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isInstructionNode(lastItem)) { - if (util_1.isArray(lastItem["?"])) { - lastItem["?"].push(value); + else if (util_1.isEmpty(val)) { + markup += ' ""' + _this._endLine(options); } else { - lastItem["?"] = [lastItem["?"], value]; + markup += _this._endLine(options) + + _this._convertObject(val, options, level + 1); } - } - else { - this._currentList.push({ "?": value }); - } + }, this); } + return markup; }; - /** @inheritdoc */ - ObjectWriter.prototype.cdata = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "$": data }); + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + * @param level - current depth of the XML tree + * @param isArray - whether this line is an array item + */ + YAMLWriter.prototype._beginLine = function (options, level, isArray) { + if (isArray === void 0) { isArray = false; } + var indentLevel = options.offset + level + 1; + var chars = new Array(indentLevel).join(options.indent); + if (isArray) { + return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); } else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isCDATANode(lastItem)) { - if (util_1.isArray(lastItem["$"])) { - lastItem["$"].push(data); - } - else { - lastItem["$"] = [lastItem["$"], data]; - } - } - else { - this._currentList.push({ "$": data }); - } + return chars; } }; - ObjectWriter.prototype._isAttrNode = function (x) { - return "@" in x; - }; - ObjectWriter.prototype._isTextNode = function (x) { - return "#" in x; - }; - ObjectWriter.prototype._isCommentNode = function (x) { - return "!" in x; - }; - ObjectWriter.prototype._isInstructionNode = function (x) { - return "?" in x; - }; - ObjectWriter.prototype._isCDATANode = function (x) { - return "$" in x; - }; - ObjectWriter.prototype._isElementNode = function (x, name) { - return name in x; + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + */ + YAMLWriter.prototype._endLine = function (options) { + return options.newline; }; /** - * Returns an object key for an attribute or namespace declaration. + * Produces a YAML key string delimited with double quotes. */ - ObjectWriter.prototype._getAttrKey = function () { - return this._builderOptions.convert.att; + YAMLWriter.prototype._key = function (key) { + return "\"" + key + "\":"; }; /** - * Returns an object key for the given node type. - * - * @param nodeType - node type to get a key for + * Produces a YAML value string delimited with double quotes. */ - ObjectWriter.prototype._getNodeKey = function (nodeType) { - switch (nodeType) { - case interfaces_1.NodeType.Comment: - return this._builderOptions.convert.comment; - case interfaces_1.NodeType.Text: - return this._builderOptions.convert.text; - case interfaces_1.NodeType.ProcessingInstruction: - return this._builderOptions.convert.ins; - case interfaces_1.NodeType.CData: - return this._builderOptions.convert.cdata; - /* istanbul ignore next */ - default: - throw new Error("Invalid node type."); - } + YAMLWriter.prototype._val = function (val) { + return JSON.stringify(val); }; - return ObjectWriter; + return YAMLWriter; }(BaseWriter_1.BaseWriter)); -exports.ObjectWriter = ObjectWriter; -//# sourceMappingURL=ObjectWriter.js.map +exports.YAMLWriter = YAMLWriter; +//# sourceMappingURL=YAMLWriter.js.map /***/ }), -/* 420 */, -/* 421 */, -/* 422 */, -/* 423 */, -/* 424 */, -/* 425 */ +/* 326 */, +/* 327 */, +/* 328 */, +/* 329 */, +/* 330 */, +/* 331 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +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 (k !== "default" && 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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); }; Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var DOMException_1 = __webpack_require__(35); -var infra_1 = __webpack_require__(23); -var algorithm_1 = __webpack_require__(163); -/** - * Represents a token set. - */ -var DOMTokenListImpl = /** @class */ (function () { - /** - * Initializes a new instance of `DOMTokenList`. - * - * @param element - associated element - * @param attribute - associated attribute - */ - function DOMTokenListImpl(element, attribute) { - /** - * 1. Let element be associated element. - * 2. Let localName be associated attribute’s local name. - * 3. Let value be the result of getting an attribute value given element - * and localName. - * 4. Run the attribute change steps for element, localName, value, value, - * and null. - */ - this._element = element; - this._attribute = attribute; - this._tokenSet = new Set(); - var localName = attribute._localName; - var value = algorithm_1.element_getAnAttributeValue(element, localName); - // define a closure to be called when the associated attribute's value changes - var thisObj = this; - function updateTokenSet(element, localName, oldValue, value, namespace) { - /** - * 1. If localName is associated attribute’s local name, namespace is null, - * and value is null, then empty token set. - * 2. Otherwise, if localName is associated attribute’s local name, - * namespace is null, then set token set to value, parsed. - */ - if (localName === thisObj._attribute._localName && namespace === null) { - if (!value) - thisObj._tokenSet.clear(); - else - thisObj._tokenSet = algorithm_1.orderedSet_parse(value); - } +exports.generate = exports.createAuthenticationSettings = exports.configureAuthentication = exports.SETTINGS_FILE = exports.M2_DIR = void 0; +const path = __importStar(__webpack_require__(622)); +const core = __importStar(__webpack_require__(470)); +const io = __importStar(__webpack_require__(1)); +const fs = __importStar(__webpack_require__(747)); +const os = __importStar(__webpack_require__(87)); +const xmlbuilder2_1 = __webpack_require__(255); +const constants = __importStar(__webpack_require__(211)); +const gpg = __importStar(__webpack_require__(884)); +const util_1 = __webpack_require__(322); +exports.M2_DIR = '.m2'; +exports.SETTINGS_FILE = 'settings.xml'; +function configureAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + const id = core.getInput(constants.INPUT_SERVER_ID); + const username = core.getInput(constants.INPUT_SERVER_USERNAME); + const password = core.getInput(constants.INPUT_SERVER_PASSWORD); + const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) || path.join(os.homedir(), exports.M2_DIR); + const overwriteSettings = util_1.getBooleanInput(constants.INPUT_OVERWRITE_SETTINGS, true); + const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY) || constants.INPUT_DEFAULT_GPG_PRIVATE_KEY; + const gpgPassphrase = core.getInput(constants.INPUT_GPG_PASSPHRASE) || + (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined); + if (gpgPrivateKey) { + core.setSecret(gpgPrivateKey); } - // add the closure to the associated element's attribute change steps - this._element._attributeChangeSteps.push(updateTokenSet); - if (DOMImpl_1.dom.features.steps) { - algorithm_1.dom_runAttributeChangeSteps(element, localName, value, value, null); + yield createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase); + if (gpgPrivateKey) { + core.info('Importing private gpg key'); + const keyFingerprint = (yield gpg.importKey(gpgPrivateKey)) || ''; + core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); } - } - Object.defineProperty(DOMTokenListImpl.prototype, "length", { - /** @inheritdoc */ - get: function () { - /** - * The length attribute' getter must return context object’s token set’s - * size. - */ - return this._tokenSet.size; - }, - enumerable: true, - configurable: true }); - /** @inheritdoc */ - DOMTokenListImpl.prototype.item = function (index) { - var e_1, _a; - /** - * 1. If index is equal to or greater than context object’s token set’s - * size, then return null. - * 2. Return context object’s token set[index]. - */ - var i = 0; - try { - for (var _b = __values(this._tokenSet), _c = _b.next(); !_c.done; _c = _b.next()) { - var token = _c.value; - if (i === index) - return token; - i++; - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); +} +exports.configureAuthentication = configureAuthentication; +function createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase = undefined) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Creating ${exports.SETTINGS_FILE} with server-id: ${id}`); + // when an alternate m2 location is specified use only that location (no .m2 directory) + // otherwise use the home/.m2/ path + yield io.mkdirP(settingsDirectory); + yield write(settingsDirectory, generate(id, username, password, gpgPassphrase), overwriteSettings); + }); +} +exports.createAuthenticationSettings = createAuthenticationSettings; +// only exported for testing purposes +function generate(id, username, password, gpgPassphrase) { + const xmlObj = { + settings: { + '@xmlns': 'http://maven.apache.org/SETTINGS/1.0.0', + '@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', + '@xsi:schemaLocation': 'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd', + servers: { + server: [ + { + id: id, + username: `\${env.${username}}`, + password: `\${env.${password}}` + } + ] } - finally { if (e_1) throw e_1.error; } } - return null; - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.contains = function (token) { - /** - * The contains(token) method, when invoked, must return true if context - * object’s token set[token] exists, and false otherwise. - */ - return this._tokenSet.has(token); }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.add = function () { - var e_2, _a; - var tokens = []; - for (var _i = 0; _i < arguments.length; _i++) { - tokens[_i] = arguments[_i]; - } - try { - /** - * 1. For each token in tokens: - * 1.1. If token is the empty string, then throw a "SyntaxError" - * DOMException. - * 1.2. If token contains any ASCII whitespace, then throw an - * "InvalidCharacterError" DOMException. - * 2. For each token in tokens, append token to context object’s token set. - * 3. Run the update steps. - */ - for (var tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) { - var token = tokens_1_1.value; - if (token === '') { - throw new DOMException_1.SyntaxError("Cannot add an empty token."); - } - else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { - throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); - } - else { - this._tokenSet.add(token); - } - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1); - } - finally { if (e_2) throw e_2.error; } - } - algorithm_1.tokenList_updateSteps(this); - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.remove = function () { - var e_3, _a; - var tokens = []; - for (var _i = 0; _i < arguments.length; _i++) { - tokens[_i] = arguments[_i]; - } - try { - /** - * 1. For each token in tokens: - * 1.1. If token is the empty string, then throw a "SyntaxError" - * DOMException. - * 1.2. If token contains any ASCII whitespace, then throw an - * "InvalidCharacterError" DOMException. - * 2. For each token in tokens, remove token from context object’s token set. - * 3. Run the update steps. - */ - for (var tokens_2 = __values(tokens), tokens_2_1 = tokens_2.next(); !tokens_2_1.done; tokens_2_1 = tokens_2.next()) { - var token = tokens_2_1.value; - if (token === '') { - throw new DOMException_1.SyntaxError("Cannot remove an empty token."); - } - else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { - throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); - } - else { - this._tokenSet.delete(token); - } - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2); - } - finally { if (e_3) throw e_3.error; } - } - algorithm_1.tokenList_updateSteps(this); - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.toggle = function (token, force) { - if (force === void 0) { force = undefined; } - /** - * 1. If token is the empty string, then throw a "SyntaxError" DOMException. - * 2. If token contains any ASCII whitespace, then throw an - * "InvalidCharacterError" DOMException. - */ - if (token === '') { - throw new DOMException_1.SyntaxError("Cannot toggle an empty token."); - } - else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { - throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); - } - /** - * 3. If context object’s token set[token] exists, then: - */ - if (this._tokenSet.has(token)) { - /** - * 3.1. If force is either not given or is false, then remove token from - * context object’s token set, run the update steps and return false. - * 3.2. Return true. - */ - if (force === undefined || force === false) { - this._tokenSet.delete(token); - algorithm_1.tokenList_updateSteps(this); - return false; - } - return true; - } - /** - * 4. Otherwise, if force not given or is true, append token to context - * object’s token set, run the update steps, and return true. - */ - if (force === undefined || force === true) { - this._tokenSet.add(token); - algorithm_1.tokenList_updateSteps(this); - return true; + if (gpgPassphrase) { + const gpgServer = { + id: 'gpg.passphrase', + passphrase: `\${env.${gpgPassphrase}}` + }; + xmlObj.settings.servers.server.push(gpgServer); + } + return xmlbuilder2_1.create(xmlObj).end({ + headless: true, + prettyPrint: true, + width: 80 + }); +} +exports.generate = generate; +function write(directory, settings, overwriteSettings) { + return __awaiter(this, void 0, void 0, function* () { + const location = path.join(directory, exports.SETTINGS_FILE); + const settingsExists = fs.existsSync(location); + if (settingsExists && overwriteSettings) { + core.info(`Overwriting existing file ${location}`); } - /** - * 5. Return false. - */ - return false; - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.replace = function (token, newToken) { - /** - * 1. If either token or newToken is the empty string, then throw a - * "SyntaxError" DOMException. - * 2. If either token or newToken contains any ASCII whitespace, then throw - * an "InvalidCharacterError" DOMException. - */ - if (token === '' || newToken === '') { - throw new DOMException_1.SyntaxError("Cannot replace an empty token."); + else if (!settingsExists) { + core.info(`Writing to ${location}`); } - else if (infra_1.codePoint.ASCIIWhiteSpace.test(token) || infra_1.codePoint.ASCIIWhiteSpace.test(newToken)) { - throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); + else { + core.info(`Skipping generation ${location} because file already exists and overwriting is not required`); + return; } - /** - * 3. If context object’s token set does not contain token, then return - * false. - */ - if (!this._tokenSet.has(token)) - return false; - /** - * 4. Replace token in context object’s token set with newToken. - * 5. Run the update steps. - * 6. Return true. - */ - infra_1.set.replace(this._tokenSet, token, newToken); - algorithm_1.tokenList_updateSteps(this); - return true; - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.supports = function (token) { - /** - * 1. Let result be the return value of validation steps called with token. - * 2. Return result. - */ - return algorithm_1.tokenList_validationSteps(this, token); - }; - Object.defineProperty(DOMTokenListImpl.prototype, "value", { - /** @inheritdoc */ - get: function () { - /** - * The value attribute must return the result of running context object’s - * serialize steps. - */ - return algorithm_1.tokenList_serializeSteps(this); - }, - set: function (value) { - /** - * Setting the value attribute must set an attribute value for the - * associated element using associated attribute’s local name and the given - * value. - */ - algorithm_1.element_setAnAttributeValue(this._element, this._attribute._localName, value); - }, - enumerable: true, - configurable: true + return fs.writeFileSync(location, settings, { + encoding: 'utf-8', + flag: 'w' + }); }); - /** - * Returns an iterator for the token set. - */ - DOMTokenListImpl.prototype[Symbol.iterator] = function () { - var it = this._tokenSet[Symbol.iterator](); - return { - next: function () { - return it.next(); - } - }; - }; - /** - * Creates a new `DOMTokenList`. - * - * @param element - associated element - * @param attribute - associated attribute - */ - DOMTokenListImpl._create = function (element, attribute) { - return new DOMTokenListImpl(element, attribute); - }; - return DOMTokenListImpl; -}()); -exports.DOMTokenListImpl = DOMTokenListImpl; -//# sourceMappingURL=DOMTokenListImpl.js.map +} + /***/ }), -/* 426 */, -/* 427 */ +/* 332 */, +/* 333 */, +/* 334 */, +/* 335 */, +/* 336 */, +/* 337 */, +/* 338 */, +/* 339 */, +/* 340 */, +/* 341 */, +/* 342 */, +/* 343 */, +/* 344 */ +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var PotentialCustomElementName = /[a-z]([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*-([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*/; +var NamesWithHyphen = new Set(['annotation-xml', 'color-profile', + 'font-face', 'font-face-src', 'font-face-uri', 'font-face-format', + 'font-face-name', 'missing-glyph']); +var ElementNames = new Set(['article', 'aside', 'blockquote', + 'body', 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', + 'header', 'main', 'nav', 'p', 'section', 'span']); +var VoidElementNames = new Set(['area', 'base', 'basefont', + 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', + 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); +var ShadowHostNames = new Set(['article', 'aside', 'blockquote', 'body', + 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'main', + 'nav', 'p', 'section', 'span']); +/** + * Determines if the given string is a valid custom element name. + * + * @param name - a name string + */ +function customElement_isValidCustomElementName(name) { + if (!PotentialCustomElementName.test(name)) + return false; + if (NamesWithHyphen.has(name)) + return false; + return true; +} +exports.customElement_isValidCustomElementName = customElement_isValidCustomElementName; +/** + * Determines if the given string is a valid element name. + * + * @param name - a name string + */ +function customElement_isValidElementName(name) { + return (ElementNames.has(name)); +} +exports.customElement_isValidElementName = customElement_isValidElementName; +/** + * Determines if the given string is a void element name. + * + * @param name - a name string + */ +function customElement_isVoidElementName(name) { + return (VoidElementNames.has(name)); +} +exports.customElement_isVoidElementName = customElement_isVoidElementName; +/** + * Determines if the given string is a valid shadow host element name. + * + * @param name - a name string + */ +function customElement_isValidShadowHostName(name) { + return (ShadowHostNames.has(name)); +} +exports.customElement_isValidShadowHostName = customElement_isValidShadowHostName; +/** + * Enqueues an upgrade reaction for a custom element. + * + * @param element - a custom element + * @param definition - a custom element definition + */ +function customElement_enqueueACustomElementUpgradeReaction(element, definition) { + // TODO: Implement in HTML DOM +} +exports.customElement_enqueueACustomElementUpgradeReaction = customElement_enqueueACustomElementUpgradeReaction; +/** + * Enqueues a callback reaction for a custom element. + * + * @param element - a custom element + * @param callbackName - name of the callback + * @param args - callback arguments + */ +function customElement_enqueueACustomElementCallbackReaction(element, callbackName, args) { + // TODO: Implement in HTML DOM +} +exports.customElement_enqueueACustomElementCallbackReaction = customElement_enqueueACustomElementCallbackReaction; +/** + * Upgrade a custom element. + * + * @param element - a custom element + */ +function customElement_upgrade(definition, element) { + // TODO: Implement in HTML DOM +} +exports.customElement_upgrade = customElement_upgrade; +/** + * Tries to upgrade a custom element. + * + * @param element - a custom element + */ +function customElement_tryToUpgrade(element) { + // TODO: Implement in HTML DOM +} +exports.customElement_tryToUpgrade = customElement_tryToUpgrade; +/** + * Looks up a custom element definition. + * + * @param document - a document + * @param namespace - element namespace + * @param localName - element local name + * @param is - an `is` value + */ +function customElement_lookUpACustomElementDefinition(document, namespace, localName, is) { + // TODO: Implement in HTML DOM + return null; +} +exports.customElement_lookUpACustomElementDefinition = customElement_lookUpACustomElementDefinition; +//# sourceMappingURL=CustomElementAlgorithm.js.map + +/***/ }), +/* 345 */, +/* 346 */, +/* 347 */, +/* 348 */, +/* 349 */, +/* 350 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var interfaces_1 = __webpack_require__(970); -var algorithm_1 = __webpack_require__(163); -var WebIDLAlgorithm_1 = __webpack_require__(495); +var TreeAlgorithm_1 = __webpack_require__(873); /** - * Represents a DOM event. + * Defines the position of a boundary point relative to another. + * + * @param bp - a boundary point + * @param relativeTo - a boundary point to compare to */ -var EventImpl = /** @class */ (function () { +function boundaryPoint_position(bp, relativeTo) { + var nodeA = bp[0]; + var offsetA = bp[1]; + var nodeB = relativeTo[0]; + var offsetB = relativeTo[1]; /** - * Initializes a new instance of `Event`. + * 1. Assert: nodeA and nodeB have the same root. */ - function EventImpl(type, eventInit) { - this._target = null; - this._relatedTarget = null; - this._touchTargetList = []; - this._path = []; - this._currentTarget = null; - this._eventPhase = interfaces_1.EventPhase.None; - this._stopPropagationFlag = false; - this._stopImmediatePropagationFlag = false; - this._canceledFlag = false; - this._inPassiveListenerFlag = false; - this._composedFlag = false; - this._initializedFlag = false; - this._dispatchFlag = false; - this._isTrusted = false; - this._bubbles = false; - this._cancelable = false; - /** - * When a constructor of the Event interface, or of an interface that - * inherits from the Event interface, is invoked, these steps must be run, - * given the arguments type and eventInitDict: - * 1. Let event be the result of running the inner event creation steps with - * this interface, null, now, and eventInitDict. - * 2. Initialize event’s type attribute to type. - * 3. Return event. - */ - this._type = type; - if (eventInit) { - this._bubbles = eventInit.bubbles || false; - this._cancelable = eventInit.cancelable || false; - this._composedFlag = eventInit.composed || false; + console.assert(TreeAlgorithm_1.tree_rootNode(nodeA) === TreeAlgorithm_1.tree_rootNode(nodeB), "Boundary points must share the same root node."); + /** + * 2. If nodeA is nodeB, then return equal if offsetA is offsetB, before + * if offsetA is less than offsetB, and after if offsetA is greater than + * offsetB. + */ + if (nodeA === nodeB) { + if (offsetA === offsetB) { + return interfaces_1.BoundaryPosition.Equal; + } + else if (offsetA < offsetB) { + return interfaces_1.BoundaryPosition.Before; + } + else { + return interfaces_1.BoundaryPosition.After; } - this._initializedFlag = true; - this._timeStamp = new Date().getTime(); } - Object.defineProperty(EventImpl.prototype, "type", { - /** @inheritdoc */ - get: function () { return this._type; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "target", { - /** @inheritdoc */ - get: function () { return this._target; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "srcElement", { - /** @inheritdoc */ - get: function () { return this._target; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "currentTarget", { - /** @inheritdoc */ - get: function () { return this._currentTarget; }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.composedPath = function () { - /** - * 1. Let composedPath be an empty list. - * 2. Let path be the context object’s path. - * 3. If path is empty, then return composedPath. - * 4. Let currentTarget be the context object’s currentTarget attribute - * value. - * 5. Append currentTarget to composedPath. - * 6. Let currentTargetIndex be 0. - * 7. Let currentTargetHiddenSubtreeLevel be 0. - */ - var composedPath = []; - var path = this._path; - if (path.length === 0) - return composedPath; - var currentTarget = this._currentTarget; - if (currentTarget === null) { - throw new Error("Event currentTarget is null."); + /** + * 3. If nodeA is following nodeB, then if the position of (nodeB, offsetB) + * relative to (nodeA, offsetA) is before, return after, and if it is after, + * return before. + */ + if (TreeAlgorithm_1.tree_isFollowing(nodeB, nodeA)) { + var pos = boundaryPoint_position([nodeB, offsetB], [nodeA, offsetA]); + if (pos === interfaces_1.BoundaryPosition.Before) { + return interfaces_1.BoundaryPosition.After; } - composedPath.push(currentTarget); - var currentTargetIndex = 0; - var currentTargetHiddenSubtreeLevel = 0; + else if (pos === interfaces_1.BoundaryPosition.After) { + return interfaces_1.BoundaryPosition.Before; + } + } + /** + * 4. If nodeA is an ancestor of nodeB: + */ + if (TreeAlgorithm_1.tree_isAncestorOf(nodeB, nodeA)) { /** - * 8. Let index be path’s size − 1. - * 9. While index is greater than or equal to 0: + * 4.1. Let child be nodeB. + * 4.2. While child is not a child of nodeA, set child to its parent. + * 4.3. If child’s index is less than offsetA, then return after. */ - var index = path.length - 1; - while (index >= 0) { - /** - * 9.1. If path[index]'s root-of-closed-tree is true, then increase - * currentTargetHiddenSubtreeLevel by 1. - * 9.2. If path[index]'s invocation target is currentTarget, then set - * currentTargetIndex to index and break. - * 9.3. If path[index]'s slot-in-closed-tree is true, then decrease - * currentTargetHiddenSubtreeLevel by 1. - * 9.4. Decrease index by 1. - */ - if (path[index].rootOfClosedTree) { - currentTargetHiddenSubtreeLevel++; - } - if (path[index].invocationTarget === currentTarget) { - currentTargetIndex = index; - break; - } - if (path[index].slotInClosedTree) { - currentTargetHiddenSubtreeLevel--; + var child = nodeB; + while (!TreeAlgorithm_1.tree_isChildOf(nodeA, child)) { + /* istanbul ignore else */ + if (child._parent !== null) { + child = child._parent; } - index--; } - /** - * 10. Let currentHiddenLevel and maxHiddenLevel be - * currentTargetHiddenSubtreeLevel. - */ - var currentHiddenLevel = currentTargetHiddenSubtreeLevel; - var maxHiddenLevel = currentTargetHiddenSubtreeLevel; - /** - * 11. Set index to currentTargetIndex − 1. - * 12. While index is greater than or equal to 0: - */ - index = currentTargetIndex - 1; - while (index >= 0) { - /** - * 12.1. If path[index]'s root-of-closed-tree is true, then increase - * currentHiddenLevel by 1. - * 12.2. If currentHiddenLevel is less than or equal to maxHiddenLevel, - * then prepend path[index]'s invocation target to composedPath. - */ - if (path[index].rootOfClosedTree) { - currentHiddenLevel++; - } - if (currentHiddenLevel <= maxHiddenLevel) { - composedPath.unshift(path[index].invocationTarget); - } - /** - * 12.3. If path[index]'s slot-in-closed-tree is true, then: - */ - if (path[index].slotInClosedTree) { - /** - * 12.3.1. Decrease currentHiddenLevel by 1. - * 12.3.2. If currentHiddenLevel is less than maxHiddenLevel, then set - * maxHiddenLevel to currentHiddenLevel. - */ - currentHiddenLevel--; - if (currentHiddenLevel < maxHiddenLevel) { - maxHiddenLevel = currentHiddenLevel; - } - } - /** - * 12.4. Decrease index by 1. - */ - index--; - } - /** - * 13. Set currentHiddenLevel and maxHiddenLevel to - * currentTargetHiddenSubtreeLevel. - */ - currentHiddenLevel = currentTargetHiddenSubtreeLevel; - maxHiddenLevel = currentTargetHiddenSubtreeLevel; - /** - * 14. Set index to currentTargetIndex + 1. - * 15. While index is less than path’s size: - */ - index = currentTargetIndex + 1; - while (index < path.length) { - /** - * 15.1. If path[index]'s slot-in-closed-tree is true, then increase - * currentHiddenLevel by 1. - * 15.2. If currentHiddenLevel is less than or equal to maxHiddenLevel, - * then append path[index]'s invocation target to composedPath. - */ - if (path[index].slotInClosedTree) { - currentHiddenLevel++; - } - if (currentHiddenLevel <= maxHiddenLevel) { - composedPath.push(path[index].invocationTarget); - } - /** - * 15.3. If path[index]'s root-of-closed-tree is true, then: - */ - if (path[index].rootOfClosedTree) { - /** - * 15.3.1. Decrease currentHiddenLevel by 1. - * 15.3.2. If currentHiddenLevel is less than maxHiddenLevel, then set - * maxHiddenLevel to currentHiddenLevel. - */ - currentHiddenLevel--; - if (currentHiddenLevel < maxHiddenLevel) { - maxHiddenLevel = currentHiddenLevel; - } - } - /** - * 15.4. Increase index by 1. - */ - index++; + if (TreeAlgorithm_1.tree_index(child) < offsetA) { + return interfaces_1.BoundaryPosition.After; } - /** - * 16. Return composedPath. - */ - return composedPath; - }; - Object.defineProperty(EventImpl.prototype, "eventPhase", { - /** @inheritdoc */ - get: function () { return this._eventPhase; }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.stopPropagation = function () { this._stopPropagationFlag = true; }; - Object.defineProperty(EventImpl.prototype, "cancelBubble", { - /** @inheritdoc */ - get: function () { return this._stopPropagationFlag; }, - set: function (value) { if (value) - this.stopPropagation(); }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.stopImmediatePropagation = function () { - this._stopPropagationFlag = true; - this._stopImmediatePropagationFlag = true; - }; - Object.defineProperty(EventImpl.prototype, "bubbles", { - /** @inheritdoc */ - get: function () { return this._bubbles; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "cancelable", { - /** @inheritdoc */ - get: function () { return this._cancelable; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "returnValue", { - /** @inheritdoc */ - get: function () { return !this._canceledFlag; }, - set: function (value) { - if (!value) { - algorithm_1.event_setTheCanceledFlag(this); - } - }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.preventDefault = function () { - algorithm_1.event_setTheCanceledFlag(this); - }; - Object.defineProperty(EventImpl.prototype, "defaultPrevented", { - /** @inheritdoc */ - get: function () { return this._canceledFlag; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "composed", { - /** @inheritdoc */ - get: function () { return this._composedFlag; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "isTrusted", { - /** @inheritdoc */ - get: function () { return this._isTrusted; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "timeStamp", { - /** @inheritdoc */ - get: function () { return this._timeStamp; }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.initEvent = function (type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - /** - * 1. If the context object’s dispatch flag is set, then return. - */ - if (this._dispatchFlag) - return; - /** - * 2. Initialize the context object with type, bubbles, and cancelable. - */ - algorithm_1.event_initialize(this, type, bubbles, cancelable); - }; - EventImpl.NONE = 0; - EventImpl.CAPTURING_PHASE = 1; - EventImpl.AT_TARGET = 2; - EventImpl.BUBBLING_PHASE = 3; - return EventImpl; -}()); -exports.EventImpl = EventImpl; -/** - * Define constants on prototype. - */ -WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "NONE", 0); -WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "CAPTURING_PHASE", 1); -WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "AT_TARGET", 2); -WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "BUBBLING_PHASE", 3); -//# sourceMappingURL=EventImpl.js.map + } + /** + * 5. Return before. + */ + return interfaces_1.BoundaryPosition.Before; +} +exports.boundaryPoint_position = boundaryPoint_position; +//# sourceMappingURL=BoundaryPointAlgorithm.js.map /***/ }), -/* 428 */, -/* 429 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/* 351 */, +/* 352 */ +/***/ (function(module, __unusedexports, __webpack_require__) { "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var algorithm_1 = __webpack_require__(163); -/** - * Represents a mixin that allows nodes to become the contents of - * a element. This mixin is implemented by {@link Element} and - * {@link Text}. - */ -var SlotableImpl = /** @class */ (function () { - function SlotableImpl() { + +var esprima; + +// Browserified version does not have esprima +// +// 1. For node.js just require module as deps +// 2. For browser try to require mudule via external AMD system. +// If not found - try to fallback to window.esprima. If not +// found too - then fail to parse. +// +try { + // workaround to exclude package from browserify list. + var _require = require; + esprima = _require('esprima'); +} catch (_) { + /* eslint-disable no-redeclare */ + /* global window */ + if (typeof window !== 'undefined') esprima = window.esprima; +} + +var Type = __webpack_require__(945); + +function resolveJavascriptFunction(data) { + if (data === null) return false; + + try { + var source = '(' + data + ')', + ast = esprima.parse(source, { range: true }); + + if (ast.type !== 'Program' || + ast.body.length !== 1 || + ast.body[0].type !== 'ExpressionStatement' || + (ast.body[0].expression.type !== 'ArrowFunctionExpression' && + ast.body[0].expression.type !== 'FunctionExpression')) { + return false; } - Object.defineProperty(SlotableImpl.prototype, "_name", { - get: function () { return this.__name || ''; }, - set: function (val) { this.__name = val; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SlotableImpl.prototype, "_assignedSlot", { - get: function () { return this.__assignedSlot || null; }, - set: function (val) { this.__assignedSlot = val; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SlotableImpl.prototype, "assignedSlot", { - /** @inheritdoc */ - get: function () { - return algorithm_1.shadowTree_findASlot(this, true); - }, - enumerable: true, - configurable: true - }); - return SlotableImpl; -}()); -exports.SlotableImpl = SlotableImpl; -//# sourceMappingURL=SlotableImpl.js.map + + return true; + } catch (err) { + return false; + } +} + +function constructJavascriptFunction(data) { + /*jslint evil:true*/ + + var source = '(' + data + ')', + ast = esprima.parse(source, { range: true }), + params = [], + body; + + if (ast.type !== 'Program' || + ast.body.length !== 1 || + ast.body[0].type !== 'ExpressionStatement' || + (ast.body[0].expression.type !== 'ArrowFunctionExpression' && + ast.body[0].expression.type !== 'FunctionExpression')) { + throw new Error('Failed to resolve function'); + } + + ast.body[0].expression.params.forEach(function (param) { + params.push(param.name); + }); + + body = ast.body[0].expression.body.range; + + // Esprima's ranges include the first '{' and the last '}' characters on + // function expressions. So cut them out. + if (ast.body[0].expression.body.type === 'BlockStatement') { + /*eslint-disable no-new-func*/ + return new Function(params, source.slice(body[0] + 1, body[1] - 1)); + } + // ES6 arrow functions can omit the BlockStatement. In that case, just return + // the body. + /*eslint-disable no-new-func*/ + return new Function(params, 'return ' + source.slice(body[0], body[1])); +} + +function representJavascriptFunction(object /*, style*/) { + return object.toString(); +} + +function isFunction(object) { + return Object.prototype.toString.call(object) === '[object Function]'; +} + +module.exports = new Type('tag:yaml.org,2002:js/function', { + kind: 'scalar', + resolve: resolveJavascriptFunction, + construct: constructJavascriptFunction, + predicate: isFunction, + represent: representJavascriptFunction +}); + /***/ }), -/* 430 */, -/* 431 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/* 353 */, +/* 354 */, +/* 355 */, +/* 356 */, +/* 357 */ +/***/ (function(module) { + +module.exports = require("assert"); + +/***/ }), +/* 358 */, +/* 359 */, +/* 360 */, +/* 361 */, +/* 362 */, +/* 363 */, +/* 364 */, +/* 365 */, +/* 366 */, +/* 367 */, +/* 368 */, +/* 369 */, +/* 370 */, +/* 371 */, +/* 372 */, +/* 373 */ +/***/ (function(module) { + +module.exports = require("crypto"); + +/***/ }), +/* 374 */, +/* 375 */, +/* 376 */, +/* 377 */, +/* 378 */, +/* 379 */, +/* 380 */, +/* 381 */, +/* 382 */, +/* 383 */, +/* 384 */, +/* 385 */, +/* 386 */ +/***/ (function(module, __unusedexports, __webpack_require__) { "use strict"; -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; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const os = __importStar(__webpack_require__(87)); -const utils_1 = __webpack_require__(82); -/** - * Commands - * - * Command Format: - * ::name key=value,key=value::message - * - * Examples: - * ::warning::This is the message - * ::set-env name=MY_VAR::some value - */ -function issueCommand(command, properties, message) { - const cmd = new Command(command, properties, message); - process.stdout.write(cmd.toString() + os.EOL); -} -exports.issueCommand = issueCommand; -function issue(name, message = '') { - issueCommand(name, {}, message); + +var Type = __webpack_require__(945); + +function resolveJavascriptUndefined() { + return true; } -exports.issue = issue; -const CMD_STRING = '::'; -class Command { - constructor(command, properties, message) { - if (!command) { - command = 'missing.command'; - } - this.command = command; - this.properties = properties; - this.message = message; - } - toString() { - let cmdStr = CMD_STRING + this.command; - if (this.properties && Object.keys(this.properties).length > 0) { - cmdStr += ' '; - let first = true; - for (const key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - const val = this.properties[key]; - if (val) { - if (first) { - first = false; - } - else { - cmdStr += ','; - } - cmdStr += `${key}=${escapeProperty(val)}`; - } - } - } - } - cmdStr += `${CMD_STRING}${escapeData(this.message)}`; - return cmdStr; - } + +function constructJavascriptUndefined() { + /*eslint-disable no-undefined*/ + return undefined; } -function escapeData(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A'); + +function representJavascriptUndefined() { + return ''; } -function escapeProperty(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A') - .replace(/:/g, '%3A') - .replace(/,/g, '%2C'); + +function isUndefined(object) { + return typeof object === 'undefined'; } -//# sourceMappingURL=command.js.map + +module.exports = new Type('tag:yaml.org,2002:js/undefined', { + kind: 'scalar', + resolve: resolveJavascriptUndefined, + construct: constructJavascriptUndefined, + predicate: isUndefined, + represent: representJavascriptUndefined +}); + /***/ }), -/* 432 */, -/* 433 */, -/* 434 */, -/* 435 */, -/* 436 */, -/* 437 */, -/* 438 */, -/* 439 */, -/* 440 */, -/* 441 */, -/* 442 */ +/* 387 */, +/* 388 */, +/* 389 */, +/* 390 */, +/* 391 */, +/* 392 */ /***/ (function(__unusedmodule, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** - * Determines if the given string is valid for a `"Name"` construct. + * A namespace prefix map is a map that associates namespaceURI and namespace + * prefix lists, where namespaceURI values are the map's unique keys (which can + * include the null value representing no namespace), and ordered lists of + * associated prefix values are the map's key values. The namespace prefix map + * will be populated by previously seen namespaceURIs and all their previously + * encountered prefix associations for a given node and its ancestors. * - * @param name - name string to test + * _Note:_ The last seen prefix for a given namespaceURI is at the end of its + * respective list. The list is searched to find potentially matching prefixes, + * and if no matches are found for the given namespaceURI, then the last prefix + * in the list is used. See copy a namespace prefix map and retrieve a preferred + * prefix string for additional details. + * + * See: https://w3c.github.io/DOM-Parsing/#the-namespace-prefix-map */ -function xml_isName(name) { - for (var i = 0; i < name.length; i++) { - var n = name.charCodeAt(i); - // NameStartChar - if ((n >= 97 && n <= 122) || // [a-z] - (n >= 65 && n <= 90) || // [A-Z] - n === 58 || n === 95 || // ':' or '_' - (n >= 0xC0 && n <= 0xD6) || - (n >= 0xD8 && n <= 0xF6) || - (n >= 0xF8 && n <= 0x2FF) || - (n >= 0x370 && n <= 0x37D) || - (n >= 0x37F && n <= 0x1FFF) || - (n >= 0x200C && n <= 0x200D) || - (n >= 0x2070 && n <= 0x218F) || - (n >= 0x2C00 && n <= 0x2FEF) || - (n >= 0x3001 && n <= 0xD7FF) || - (n >= 0xF900 && n <= 0xFDCF) || - (n >= 0xFDF0 && n <= 0xFFFD)) { - continue; - } - else if (i !== 0 && - (n === 45 || n === 46 || // '-' or '.' - (n >= 48 && n <= 57) || // [0-9] - (n === 0xB7) || - (n >= 0x0300 && n <= 0x036F) || - (n >= 0x203F && n <= 0x2040))) { - continue; - } - if (n >= 0xD800 && n <= 0xDBFF && i < name.length - 1) { - var n2 = name.charCodeAt(i + 1); - if (n2 >= 0xDC00 && n2 <= 0xDFFF) { - n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; - i++; - if (n >= 0x10000 && n <= 0xEFFFF) { - continue; - } - } - } - return false; +var NamespacePrefixMap = /** @class */ (function () { + function NamespacePrefixMap() { + this._items = {}; + this._nullItems = []; } - return true; -} -exports.xml_isName = xml_isName; -/** - * Determines if the given string is valid for a `"QName"` construct. - * - * @param name - name string to test - */ -function xml_isQName(name) { - var colonFound = false; - for (var i = 0; i < name.length; i++) { - var n = name.charCodeAt(i); - // NameStartChar - if ((n >= 97 && n <= 122) || // [a-z] - (n >= 65 && n <= 90) || // [A-Z] - n === 95 || // '_' - (n >= 0xC0 && n <= 0xD6) || - (n >= 0xD8 && n <= 0xF6) || - (n >= 0xF8 && n <= 0x2FF) || - (n >= 0x370 && n <= 0x37D) || - (n >= 0x37F && n <= 0x1FFF) || - (n >= 0x200C && n <= 0x200D) || - (n >= 0x2070 && n <= 0x218F) || - (n >= 0x2C00 && n <= 0x2FEF) || - (n >= 0x3001 && n <= 0xD7FF) || - (n >= 0xF900 && n <= 0xFDCF) || - (n >= 0xFDF0 && n <= 0xFFFD)) { - continue; - } - else if (i !== 0 && - (n === 45 || n === 46 || // '-' or '.' - (n >= 48 && n <= 57) || // [0-9] - (n === 0xB7) || - (n >= 0x0300 && n <= 0x036F) || - (n >= 0x203F && n <= 0x2040))) { - continue; + /** + * Creates a copy of the map. + */ + NamespacePrefixMap.prototype.copy = function () { + /** + * To copy a namespace prefix map map means to copy the map's keys into a + * new empty namespace prefix map, and to copy each of the values in the + * namespace prefix list associated with each keys' value into a new list + * which should be associated with the respective key in the new map. + */ + var mapCopy = new NamespacePrefixMap(); + for (var key in this._items) { + mapCopy._items[key] = this._items[key].slice(0); } - else if (i !== 0 && n === 58) { // : - if (colonFound) - return false; // multiple colons in qname - if (i === name.length - 1) - return false; // colon at the end of qname - colonFound = true; - continue; + mapCopy._nullItems = this._nullItems.slice(0); + return mapCopy; + }; + /** + * Retrieves a preferred prefix string from the namespace prefix map. + * + * @param preferredPrefix - preferred prefix string + * @param ns - namespace + */ + NamespacePrefixMap.prototype.get = function (preferredPrefix, ns) { + /** + * 1. Let candidates list be the result of retrieving a list from map where + * there exists a key in map that matches the value of ns or if there is no + * such key, then stop running these steps, and return the null value. + */ + var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); + if (candidatesList === null) { + return null; } - if (n >= 0xD800 && n <= 0xDBFF && i < name.length - 1) { - var n2 = name.charCodeAt(i + 1); - if (n2 >= 0xDC00 && n2 <= 0xDFFF) { - n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; - i++; - if (n >= 0x10000 && n <= 0xEFFFF) { - continue; - } + /** + * 2. Otherwise, for each prefix value prefix in candidates list, iterating + * from beginning to end: + * + * _Note:_ There will always be at least one prefix value in the list. + */ + var prefix = null; + for (var i = 0; i < candidatesList.length; i++) { + prefix = candidatesList[i]; + /** + * 2.1. If prefix matches preferred prefix, then stop running these steps + * and return prefix. + */ + if (prefix === preferredPrefix) { + return prefix; } } - return false; - } - return true; -} -exports.xml_isQName = xml_isQName; -/** - * Determines if the given string contains legal characters. - * - * @param chars - sequence of characters to test - */ -function xml_isLegalChar(chars) { - for (var i = 0; i < chars.length; i++) { - var n = chars.charCodeAt(i); - // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] - if (n === 0x9 || n === 0xA || n === 0xD || - (n >= 0x20 && n <= 0xD7FF) || - (n >= 0xE000 && n <= 0xFFFD)) { - continue; + /** + * 2.2. If prefix is the last item in the candidates list, then stop + * running these steps and return prefix. + */ + return prefix; + }; + /** + * Checks if a prefix string is found in the namespace prefix map associated + * with the given namespace. + * + * @param prefix - prefix string + * @param ns - namespace + */ + NamespacePrefixMap.prototype.has = function (prefix, ns) { + /** + * 1. Let candidates list be the result of retrieving a list from map where + * there exists a key in map that matches the value of ns or if there is + * no such key, then stop running these steps, and return false. + */ + var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); + if (candidatesList === null) { + return false; } - if (n >= 0xD800 && n <= 0xDBFF && i < chars.length - 1) { - var n2 = chars.charCodeAt(i + 1); - if (n2 >= 0xDC00 && n2 <= 0xDFFF) { - n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; - i++; - if (n >= 0x10000 && n <= 0x10FFFF) { - continue; - } - } + /** + * 2. If the value of prefix occurs at least once in candidates list, + * return true, otherwise return false. + */ + return (candidatesList.indexOf(prefix) !== -1); + }; + /** + * Checks if a prefix string is found in the namespace prefix map. + * + * @param prefix - prefix string + */ + NamespacePrefixMap.prototype.hasPrefix = function (prefix) { + if (this._nullItems.indexOf(prefix) !== -1) + return true; + for (var key in this._items) { + if (this._items[key].indexOf(prefix) !== -1) + return true; } return false; - } - return true; -} -exports.xml_isLegalChar = xml_isLegalChar; -/** - * Determines if the given string contains legal characters for a public - * identifier. - * - * @param chars - sequence of characters to test - */ -function xml_isPubidChar(chars) { - for (var i = 0; i < chars.length; i++) { - // PubId chars are all in the ASCII range, no need to check surrogates - var n = chars.charCodeAt(i); - // #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] - if ((n >= 97 && n <= 122) || // [a-z] - (n >= 65 && n <= 90) || // [A-Z] - (n >= 39 && n <= 59) || // ['()*+,-./] | [0-9] | [:;] - n === 0x20 || n === 0xD || n === 0xA || // #x20 | #xD | #xA - (n >= 35 && n <= 37) || // [#$%] - n === 33 || // ! - n === 61 || n === 63 || n === 64 || n === 95) { // [=?@_] - continue; + }; + /** + * Adds a prefix string associated with a namespace to the prefix map. + * + * @param prefix - prefix string + * @param ns - namespace + */ + NamespacePrefixMap.prototype.set = function (prefix, ns) { + /** + * 1. Let candidates list be the result of retrieving a list from map where + * there exists a key in map that matches the value of ns or if there is + * no such key, then let candidates list be null. + */ + var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); + /** + * 2. If candidates list is null, then create a new list with prefix as the + * only item in the list, and associate that list with a new key ns in map. + * 3. Otherwise, append prefix to the end of candidates list. + * + * _Note:_ The steps in retrieve a preferred prefix string use the list to + * track the most recently used (MRU) prefix associated with a given + * namespace, which will be the prefix at the end of the list. This list + * may contain duplicates of the same prefix value seen earlier + * (and that's OK). + */ + if (ns !== null && candidatesList === null) { + this._items[ns] = [prefix]; } else { - return false; + candidatesList.push(prefix); } - } - return true; -} -exports.xml_isPubidChar = xml_isPubidChar; -//# sourceMappingURL=XMLAlgorithm.js.map + }; + return NamespacePrefixMap; +}()); +exports.NamespacePrefixMap = NamespacePrefixMap; +//# sourceMappingURL=NamespacePrefixMap.js.map /***/ }), -/* 443 */, -/* 444 */, -/* 445 */, -/* 446 */, -/* 447 */, -/* 448 */, -/* 449 */, -/* 450 */ -/***/ (function(module, __unusedexports, __webpack_require__) { +/* 393 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; - -var Type = __webpack_require__(945); - -module.exports = new Type('tag:yaml.org,2002:str', { - kind: 'scalar', - construct: function (data) { return data !== null ? data : ''; } +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 (k !== "default" && 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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ZuluDistribution = void 0; +const core = __importStar(__webpack_require__(470)); +const tc = __importStar(__webpack_require__(139)); +const path_1 = __importDefault(__webpack_require__(622)); +const fs_1 = __importDefault(__webpack_require__(747)); +const semver_1 = __importDefault(__webpack_require__(280)); +const base_installer_1 = __webpack_require__(83); +const util_1 = __webpack_require__(322); +class ZuluDistribution extends base_installer_1.JavaBase { + constructor(installerOptions) { + super('Zulu', installerOptions); + } + findPackageForDownload(version) { + return __awaiter(this, void 0, void 0, function* () { + const availableVersionsRaw = yield this.getAvailableVersions(); + const availableVersions = availableVersionsRaw.map(item => { + return { + version: this.convertVersionToSemver(item.jdk_version), + url: item.url, + zuluVersion: this.convertVersionToSemver(item.zulu_version) + }; + }); + const satisfiedVersions = availableVersions + .filter(item => util_1.isVersionSatisfies(version, item.version)) + .sort((a, b) => { + // Azul provides two versions: jdk_version and azul_version + // we should sort by both fields by descending + return (-semver_1.default.compareBuild(a.version, b.version) || + -semver_1.default.compareBuild(a.zuluVersion, b.zuluVersion)); + }) + .map(item => { + return { + version: item.version, + url: item.url + }; + }); + const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; + if (!resolvedFullVersion) { + const availableOptions = availableVersions.map(item => item.version).join(', '); + const availableOptionsMessage = availableOptions + ? `\nAvailable versions: ${availableOptions}` + : ''; + throw new Error(`Could not find satisfied version for semver ${version}. ${availableOptionsMessage}`); + } + return resolvedFullVersion; + }); + } + downloadTool(javaRelease) { + return __awaiter(this, void 0, void 0, function* () { + let extractedJavaPath; + core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); + const javaArchivePath = yield tc.downloadTool(javaRelease.url); + core.info(`Extracting Java archive...`); + let extension = util_1.getDownloadArchiveExtension(); + extractedJavaPath = yield util_1.extractJdkFile(javaArchivePath, extension); + const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; + const archivePath = path_1.default.join(extractedJavaPath, archiveName); + const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture); + return { version: javaRelease.version, path: javaPath }; + }); + } + getAvailableVersions() { + var _a, _b; + return __awaiter(this, void 0, void 0, function* () { + const { arch, hw_bitness, abi } = this.getArchitectureOptions(); + const [bundleType, features] = this.packageType.split('+'); + const platform = this.getPlatformOption(); + const extension = util_1.getDownloadArchiveExtension(); + const javafx = (_a = features === null || features === void 0 ? void 0 : features.includes('fx')) !== null && _a !== void 0 ? _a : false; + const releaseStatus = this.stable ? 'ga' : 'ea'; + console.time('azul-retrieve-available-versions'); + const requestArguments = [ + `os=${platform}`, + `ext=${extension}`, + `bundle_type=${bundleType}`, + `javafx=${javafx}`, + `arch=${arch}`, + `hw_bitness=${hw_bitness}`, + `release_status=${releaseStatus}`, + abi ? `abi=${abi}` : null, + features ? `features=${features}` : null + ] + .filter(Boolean) + .join('&'); + const availableVersionsUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?${requestArguments}`; + if (core.isDebug()) { + core.debug(`Gathering available versions from '${availableVersionsUrl}'`); + } + const availableVersions = (_b = (yield this.http.getJson(availableVersionsUrl)).result) !== null && _b !== void 0 ? _b : []; + if (core.isDebug()) { + core.startGroup('Print information about available versions'); + console.timeEnd('azul-retrieve-available-versions'); + console.log(`Available versions: [${availableVersions.length}]`); + console.log(availableVersions.map(item => item.jdk_version.join('.')).join(', ')); + core.endGroup(); + } + return availableVersions; + }); + } + getArchitectureOptions() { + if (this.architecture == 'x64') { + return { arch: 'x86', hw_bitness: '64', abi: '' }; + } + else if (this.architecture == 'x86') { + return { arch: 'x86', hw_bitness: '32', abi: '' }; + } + else { + return { arch: this.architecture, hw_bitness: '', abi: '' }; + } + } + getPlatformOption() { + // Azul has own platform names so need to map them + switch (process.platform) { + case 'darwin': + return 'macos'; + case 'win32': + return 'windows'; + default: + return process.platform; + } + } + // Azul API returns jdk_version as array of digits like [11, 0, 2, 1] + convertVersionToSemver(version_array) { + const mainVersion = version_array.slice(0, 3).join('.'); + if (version_array.length > 3) { + // intentionally ignore more than 4 numbers because it is invalid semver + return `${mainVersion}+${version_array[3]}`; + } + return mainVersion; + } +} +exports.ZuluDistribution = ZuluDistribution; /***/ }), -/* 451 */, -/* 452 */, -/* 453 */, -/* 454 */, -/* 455 */, -/* 456 */, -/* 457 */ -/***/ (function(module, __unusedexports, __webpack_require__) { +/* 394 */, +/* 395 */, +/* 396 */, +/* 397 */, +/* 398 */, +/* 399 */, +/* 400 */, +/* 401 */, +/* 402 */, +/* 403 */, +/* 404 */, +/* 405 */, +/* 406 */, +/* 407 */, +/* 408 */, +/* 409 */, +/* 410 */, +/* 411 */, +/* 412 */, +/* 413 */ +/***/ (function(__unusedmodule, exports) { "use strict"; - -/*eslint-disable max-len,no-use-before-define*/ - -var common = __webpack_require__(740); -var YAMLException = __webpack_require__(556); -var Mark = __webpack_require__(93); -var DEFAULT_SAFE_SCHEMA = __webpack_require__(723); -var DEFAULT_FULL_SCHEMA = __webpack_require__(910); - - -var _hasOwnProperty = Object.prototype.hasOwnProperty; - - -var CONTEXT_FLOW_IN = 1; -var CONTEXT_FLOW_OUT = 2; -var CONTEXT_BLOCK_IN = 3; -var CONTEXT_BLOCK_OUT = 4; - - -var CHOMPING_CLIP = 1; -var CHOMPING_STRIP = 2; -var CHOMPING_KEEP = 3; - - -var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; -var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; -var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; -var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; -var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; - - -function _class(obj) { return Object.prototype.toString.call(obj); } - -function is_EOL(c) { - return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); -} - -function is_WHITE_SPACE(c) { - return (c === 0x09/* Tab */) || (c === 0x20/* Space */); -} - -function is_WS_OR_EOL(c) { - return (c === 0x09/* Tab */) || - (c === 0x20/* Space */) || - (c === 0x0A/* LF */) || - (c === 0x0D/* CR */); -} - -function is_FLOW_INDICATOR(c) { - return c === 0x2C/* , */ || - c === 0x5B/* [ */ || - c === 0x5D/* ] */ || - c === 0x7B/* { */ || - c === 0x7D/* } */; -} - -function fromHexCode(c) { - var lc; - - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } - - /*eslint-disable no-bitwise*/ - lc = c | 0x20; - - if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { - return lc - 0x61 + 10; - } - - return -1; -} - -function escapedHexLen(c) { - if (c === 0x78/* x */) { return 2; } - if (c === 0x75/* u */) { return 4; } - if (c === 0x55/* U */) { return 8; } - return 0; -} - -function fromDecimalCode(c) { - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } - - return -1; -} - -function simpleEscapeSequence(c) { - /* eslint-disable indent */ - return (c === 0x30/* 0 */) ? '\x00' : - (c === 0x61/* a */) ? '\x07' : - (c === 0x62/* b */) ? '\x08' : - (c === 0x74/* t */) ? '\x09' : - (c === 0x09/* Tab */) ? '\x09' : - (c === 0x6E/* n */) ? '\x0A' : - (c === 0x76/* v */) ? '\x0B' : - (c === 0x66/* f */) ? '\x0C' : - (c === 0x72/* r */) ? '\x0D' : - (c === 0x65/* e */) ? '\x1B' : - (c === 0x20/* Space */) ? ' ' : - (c === 0x22/* " */) ? '\x22' : - (c === 0x2F/* / */) ? '/' : - (c === 0x5C/* \ */) ? '\x5C' : - (c === 0x4E/* N */) ? '\x85' : - (c === 0x5F/* _ */) ? '\xA0' : - (c === 0x4C/* L */) ? '\u2028' : - (c === 0x50/* P */) ? '\u2029' : ''; -} - -function charFromCodepoint(c) { - if (c <= 0xFFFF) { - return String.fromCharCode(c); - } - // Encode UTF-16 surrogate pair - // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF - return String.fromCharCode( - ((c - 0x010000) >> 10) + 0xD800, - ((c - 0x010000) & 0x03FF) + 0xDC00 - ); -} - -var simpleEscapeCheck = new Array(256); // integer, for fast access -var simpleEscapeMap = new Array(256); -for (var i = 0; i < 256; i++) { - simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; - simpleEscapeMap[i] = simpleEscapeSequence(i); -} - - -function State(input, options) { - this.input = input; - - this.filename = options['filename'] || null; - this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; - this.onWarning = options['onWarning'] || null; - this.legacy = options['legacy'] || false; - this.json = options['json'] || false; - this.listener = options['listener'] || null; - - this.implicitTypes = this.schema.compiledImplicit; - this.typeMap = this.schema.compiledTypeMap; - - this.length = input.length; - this.position = 0; - this.line = 0; - this.lineStart = 0; - this.lineIndent = 0; - - this.documents = []; - - /* - this.version; - this.checkLineBreaks; - this.tagMap; - this.anchorMap; - this.tag; - this.anchor; - this.kind; - this.result;*/ - -} - - -function generateError(state, message) { - return new YAMLException( - message, - new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart))); -} - -function throwError(state, message) { - throw generateError(state, message); -} - -function throwWarning(state, message) { - if (state.onWarning) { - state.onWarning.call(null, generateError(state, message)); - } -} - - -var directiveHandlers = { - - YAML: function handleYamlDirective(state, name, args) { - - var match, major, minor; - - if (state.version !== null) { - throwError(state, 'duplication of %YAML directive'); +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Represents an abstract range with a start and end boundary point. + */ +var AbstractRangeImpl = /** @class */ (function () { + function AbstractRangeImpl() { } + Object.defineProperty(AbstractRangeImpl.prototype, "_startNode", { + get: function () { return this._start[0]; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "_startOffset", { + get: function () { return this._start[1]; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "_endNode", { + get: function () { return this._end[0]; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "_endOffset", { + get: function () { return this._end[1]; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "_collapsed", { + get: function () { + return (this._start[0] === this._end[0] && + this._start[1] === this._end[1]); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "startContainer", { + /** @inheritdoc */ + get: function () { return this._startNode; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "startOffset", { + /** @inheritdoc */ + get: function () { return this._startOffset; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "endContainer", { + /** @inheritdoc */ + get: function () { return this._endNode; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "endOffset", { + /** @inheritdoc */ + get: function () { return this._endOffset; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "collapsed", { + /** @inheritdoc */ + get: function () { return this._collapsed; }, + enumerable: true, + configurable: true + }); + return AbstractRangeImpl; +}()); +exports.AbstractRangeImpl = AbstractRangeImpl; +//# sourceMappingURL=AbstractRangeImpl.js.map - if (args.length !== 1) { - throwError(state, 'YAML directive accepts exactly one argument'); - } +/***/ }), +/* 414 */ +/***/ (function(module, __unusedexports, __webpack_require__) { - match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); +"use strict"; - if (match === null) { - throwError(state, 'ill-formed argument of the YAML directive'); - } - major = parseInt(match[1], 10); - minor = parseInt(match[2], 10); - if (major !== 1) { - throwError(state, 'unacceptable YAML version of the document'); - } +var yaml = __webpack_require__(9); - state.version = args[0]; - state.checkLineBreaks = (minor < 2); - if (minor !== 1 && minor !== 2) { - throwWarning(state, 'unsupported YAML version of the document'); - } - }, +module.exports = yaml; - TAG: function handleTagDirective(state, name, args) { - var handle, prefix; +/***/ }), +/* 415 */, +/* 416 */, +/* 417 */ +/***/ (function(module, __unusedexports, __webpack_require__) { - if (args.length !== 2) { - throwError(state, 'TAG directive accepts exactly two arguments'); - } +"use strict"; - handle = args[0]; - prefix = args[1]; - if (!PATTERN_TAG_HANDLE.test(handle)) { - throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); - } +var common = __webpack_require__(740); +var Type = __webpack_require__(945); - if (_hasOwnProperty.call(state.tagMap, handle)) { - throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); - } +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + + // .2e4, .2 + // special case, seems not from spec + '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + + // 20:59 + '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + + // .inf + '|[-+]?\\.(?:inf|Inf|INF)' + + // .nan + '|\\.(?:nan|NaN|NAN))$'); - if (!PATTERN_TAG_URI.test(prefix)) { - throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); - } +function resolveYamlFloat(data) { + if (data === null) return false; - state.tagMap[handle] = prefix; + if (!YAML_FLOAT_PATTERN.test(data) || + // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === '_') { + return false; } -}; - - -function captureSegment(state, start, end, checkJson) { - var _position, _length, _character, _result; - - if (start < end) { - _result = state.input.slice(start, end); - - if (checkJson) { - for (_position = 0, _length = _result.length; _position < _length; _position += 1) { - _character = _result.charCodeAt(_position); - if (!(_character === 0x09 || - (0x20 <= _character && _character <= 0x10FFFF))) { - throwError(state, 'expected valid JSON character'); - } - } - } else if (PATTERN_NON_PRINTABLE.test(_result)) { - throwError(state, 'the stream contains non-printable characters'); - } - state.result += _result; - } + return true; } -function mergeMappings(state, destination, source, overridableKeys) { - var sourceKeys, key, index, quantity; - - if (!common.isObject(source)) { - throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); - } - - sourceKeys = Object.keys(source); +function constructYamlFloat(data) { + var value, sign, base, digits; - for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { - key = sourceKeys[index]; + value = data.replace(/_/g, '').toLowerCase(); + sign = value[0] === '-' ? -1 : 1; + digits = []; - if (!_hasOwnProperty.call(destination, key)) { - destination[key] = source[key]; - overridableKeys[key] = true; - } + if ('+-'.indexOf(value[0]) >= 0) { + value = value.slice(1); } -} - -function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) { - var index, quantity; - - // The output is a plain object here, so keys can only be strings. - // We need to convert keyNode to a string, but doing so can hang the process - // (deeply nested arrays that explode exponentially using aliases). - if (Array.isArray(keyNode)) { - keyNode = Array.prototype.slice.call(keyNode); - for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { - if (Array.isArray(keyNode[index])) { - throwError(state, 'nested arrays are not supported inside keys'); - } + if (value === '.inf') { + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; - if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { - keyNode[index] = '[object Object]'; - } - } - } + } else if (value === '.nan') { + return NaN; - // Avoid code execution in load() via toString property - // (still use its own toString for arrays, timestamps, - // and whatever user schema extensions happen to have @@toStringTag) - if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { - keyNode = '[object Object]'; - } + } else if (value.indexOf(':') >= 0) { + value.split(':').forEach(function (v) { + digits.unshift(parseFloat(v, 10)); + }); + value = 0.0; + base = 1; - keyNode = String(keyNode); + digits.forEach(function (d) { + value += d * base; + base *= 60; + }); - if (_result === null) { - _result = {}; - } + return sign * value; - if (keyTag === 'tag:yaml.org,2002:merge') { - if (Array.isArray(valueNode)) { - for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { - mergeMappings(state, _result, valueNode[index], overridableKeys); - } - } else { - mergeMappings(state, _result, valueNode, overridableKeys); - } - } else { - if (!state.json && - !_hasOwnProperty.call(overridableKeys, keyNode) && - _hasOwnProperty.call(_result, keyNode)) { - state.line = startLine || state.line; - state.position = startPos || state.position; - throwError(state, 'duplicated mapping key'); - } - _result[keyNode] = valueNode; - delete overridableKeys[keyNode]; } - - return _result; + return sign * parseFloat(value, 10); } -function readLineBreak(state) { - var ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x0A/* LF */) { - state.position++; - } else if (ch === 0x0D/* CR */) { - state.position++; - if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { - state.position++; - } - } else { - throwError(state, 'a line break is expected'); - } - state.line += 1; - state.lineStart = state.position; -} +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; -function skipSeparationSpace(state, allowComments, checkIndent) { - var lineBreaks = 0, - ch = state.input.charCodeAt(state.position); +function representYamlFloat(object, style) { + var res; - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); + if (isNaN(object)) { + switch (style) { + case 'lowercase': return '.nan'; + case 'uppercase': return '.NAN'; + case 'camelcase': return '.NaN'; } - - if (allowComments && ch === 0x23/* # */) { - do { - ch = state.input.charCodeAt(++state.position); - } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '.inf'; + case 'uppercase': return '.INF'; + case 'camelcase': return '.Inf'; } - - if (is_EOL(ch)) { - readLineBreak(state); - - ch = state.input.charCodeAt(state.position); - lineBreaks++; - state.lineIndent = 0; - - while (ch === 0x20/* Space */) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } - } else { - break; + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '-.inf'; + case 'uppercase': return '-.INF'; + case 'camelcase': return '-.Inf'; } + } else if (common.isNegativeZero(object)) { + return '-0.0'; } - if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { - throwWarning(state, 'deficient indentation'); - } - - return lineBreaks; -} - -function testDocumentSeparator(state) { - var _position = state.position, - ch; - - ch = state.input.charCodeAt(_position); - - // Condition state.position === state.lineStart is tested - // in parent on each call, for efficiency. No needs to test here again. - if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && - ch === state.input.charCodeAt(_position + 1) && - ch === state.input.charCodeAt(_position + 2)) { - - _position += 3; - - ch = state.input.charCodeAt(_position); + res = object.toString(10); - if (ch === 0 || is_WS_OR_EOL(ch)) { - return true; - } - } + // JS stringifier can build scientific format without dots: 5e-100, + // while YAML requres dot: 5.e-100. Fix it with simple hack - return false; + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; } -function writeFoldedLines(state, count) { - if (count === 1) { - state.result += ' '; - } else if (count > 1) { - state.result += common.repeat('\n', count - 1); - } +function isFloat(object) { + return (Object.prototype.toString.call(object) === '[object Number]') && + (object % 1 !== 0 || common.isNegativeZero(object)); } - -function readPlainScalar(state, nodeIndent, withinFlowCollection) { - var preceding, - following, - captureStart, - captureEnd, - hasPendingContent, - _line, - _lineStart, - _lineIndent, - _kind = state.kind, - _result = state.result, - ch; - - ch = state.input.charCodeAt(state.position); - - if (is_WS_OR_EOL(ch) || - is_FLOW_INDICATOR(ch) || - ch === 0x23/* # */ || - ch === 0x26/* & */ || - ch === 0x2A/* * */ || - ch === 0x21/* ! */ || - ch === 0x7C/* | */ || - ch === 0x3E/* > */ || - ch === 0x27/* ' */ || - ch === 0x22/* " */ || - ch === 0x25/* % */ || - ch === 0x40/* @ */ || - ch === 0x60/* ` */) { - return false; - } - - if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { - following = state.input.charCodeAt(state.position + 1); - - if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - return false; - } - } - - state.kind = 'scalar'; - state.result = ''; - captureStart = captureEnd = state.position; - hasPendingContent = false; - - while (ch !== 0) { - if (ch === 0x3A/* : */) { - following = state.input.charCodeAt(state.position + 1); - - if (is_WS_OR_EOL(following) || - withinFlowCollection && is_FLOW_INDICATOR(following)) { - break; - } - - } else if (ch === 0x23/* # */) { - preceding = state.input.charCodeAt(state.position - 1); - - if (is_WS_OR_EOL(preceding)) { - break; - } - - } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || - withinFlowCollection && is_FLOW_INDICATOR(ch)) { - break; - - } else if (is_EOL(ch)) { - _line = state.line; - _lineStart = state.lineStart; - _lineIndent = state.lineIndent; - skipSeparationSpace(state, false, -1); - - if (state.lineIndent >= nodeIndent) { - hasPendingContent = true; - ch = state.input.charCodeAt(state.position); - continue; - } else { - state.position = captureEnd; - state.line = _line; - state.lineStart = _lineStart; - state.lineIndent = _lineIndent; - break; - } - } - - if (hasPendingContent) { - captureSegment(state, captureStart, captureEnd, false); - writeFoldedLines(state, state.line - _line); - captureStart = captureEnd = state.position; - hasPendingContent = false; - } - - if (!is_WHITE_SPACE(ch)) { - captureEnd = state.position + 1; - } - - ch = state.input.charCodeAt(++state.position); - } - - captureSegment(state, captureStart, captureEnd, false); - - if (state.result) { - return true; - } - - state.kind = _kind; - state.result = _result; - return false; -} - -function readSingleQuotedScalar(state, nodeIndent) { - var ch, - captureStart, captureEnd; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x27/* ' */) { - return false; - } - - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; - - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x27/* ' */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x27/* ' */) { - captureStart = state.position; - state.position++; - captureEnd = state.position; - } else { - return true; - } - - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a single quoted scalar'); - - } else { - state.position++; - captureEnd = state.position; - } - } - - throwError(state, 'unexpected end of the stream within a single quoted scalar'); -} - -function readDoubleQuotedScalar(state, nodeIndent) { - var captureStart, - captureEnd, - hexLength, - hexResult, - tmp, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x22/* " */) { - return false; - } - - state.kind = 'scalar'; - state.result = ''; - state.position++; - captureStart = captureEnd = state.position; - - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - if (ch === 0x22/* " */) { - captureSegment(state, captureStart, state.position, true); - state.position++; - return true; - - } else if (ch === 0x5C/* \ */) { - captureSegment(state, captureStart, state.position, true); - ch = state.input.charCodeAt(++state.position); - - if (is_EOL(ch)) { - skipSeparationSpace(state, false, nodeIndent); - - // TODO: rework to inline fn with no type cast? - } else if (ch < 256 && simpleEscapeCheck[ch]) { - state.result += simpleEscapeMap[ch]; - state.position++; - - } else if ((tmp = escapedHexLen(ch)) > 0) { - hexLength = tmp; - hexResult = 0; - - for (; hexLength > 0; hexLength--) { - ch = state.input.charCodeAt(++state.position); - - if ((tmp = fromHexCode(ch)) >= 0) { - hexResult = (hexResult << 4) + tmp; - - } else { - throwError(state, 'expected hexadecimal character'); - } - } - - state.result += charFromCodepoint(hexResult); - - state.position++; - - } else { - throwError(state, 'unknown escape sequence'); - } - - captureStart = captureEnd = state.position; - - } else if (is_EOL(ch)) { - captureSegment(state, captureStart, captureEnd, true); - writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); - captureStart = captureEnd = state.position; - - } else if (state.position === state.lineStart && testDocumentSeparator(state)) { - throwError(state, 'unexpected end of the document within a double quoted scalar'); - - } else { - state.position++; - captureEnd = state.position; - } - } - - throwError(state, 'unexpected end of the stream within a double quoted scalar'); -} - -function readFlowCollection(state, nodeIndent) { - var readNext = true, - _line, - _tag = state.tag, - _result, - _anchor = state.anchor, - following, - terminator, - isPair, - isExplicitPair, - isMapping, - overridableKeys = {}, - keyNode, - keyTag, - valueNode, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x5B/* [ */) { - terminator = 0x5D;/* ] */ - isMapping = false; - _result = []; - } else if (ch === 0x7B/* { */) { - terminator = 0x7D;/* } */ - isMapping = true; - _result = {}; - } else { - return false; - } - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(++state.position); - - while (ch !== 0) { - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if (ch === terminator) { - state.position++; - state.tag = _tag; - state.anchor = _anchor; - state.kind = isMapping ? 'mapping' : 'sequence'; - state.result = _result; - return true; - } else if (!readNext) { - throwError(state, 'missed comma between flow collection entries'); - } - - keyTag = keyNode = valueNode = null; - isPair = isExplicitPair = false; - - if (ch === 0x3F/* ? */) { - following = state.input.charCodeAt(state.position + 1); - - if (is_WS_OR_EOL(following)) { - isPair = isExplicitPair = true; - state.position++; - skipSeparationSpace(state, true, nodeIndent); - } - } - - _line = state.line; - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - keyTag = state.tag; - keyNode = state.result; - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { - isPair = true; - ch = state.input.charCodeAt(++state.position); - skipSeparationSpace(state, true, nodeIndent); - composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); - valueNode = state.result; - } - - if (isMapping) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); - } else if (isPair) { - _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode)); - } else { - _result.push(keyNode); - } - - skipSeparationSpace(state, true, nodeIndent); - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x2C/* , */) { - readNext = true; - ch = state.input.charCodeAt(++state.position); - } else { - readNext = false; - } - } - - throwError(state, 'unexpected end of the stream within a flow collection'); -} - -function readBlockScalar(state, nodeIndent) { - var captureStart, - folding, - chomping = CHOMPING_CLIP, - didReadContent = false, - detectedIndent = false, - textIndent = nodeIndent, - emptyLines = 0, - atMoreIndented = false, - tmp, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch === 0x7C/* | */) { - folding = false; - } else if (ch === 0x3E/* > */) { - folding = true; - } else { - return false; - } - - state.kind = 'scalar'; - state.result = ''; - - while (ch !== 0) { - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { - if (CHOMPING_CLIP === chomping) { - chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; - } else { - throwError(state, 'repeat of a chomping mode identifier'); - } - - } else if ((tmp = fromDecimalCode(ch)) >= 0) { - if (tmp === 0) { - throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); - } else if (!detectedIndent) { - textIndent = nodeIndent + tmp - 1; - detectedIndent = true; - } else { - throwError(state, 'repeat of an indentation width identifier'); - } - - } else { - break; - } - } - - if (is_WHITE_SPACE(ch)) { - do { ch = state.input.charCodeAt(++state.position); } - while (is_WHITE_SPACE(ch)); - - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (!is_EOL(ch) && (ch !== 0)); - } - } - - while (ch !== 0) { - readLineBreak(state); - state.lineIndent = 0; - - ch = state.input.charCodeAt(state.position); - - while ((!detectedIndent || state.lineIndent < textIndent) && - (ch === 0x20/* Space */)) { - state.lineIndent++; - ch = state.input.charCodeAt(++state.position); - } - - if (!detectedIndent && state.lineIndent > textIndent) { - textIndent = state.lineIndent; - } - - if (is_EOL(ch)) { - emptyLines++; - continue; - } - - // End of the scalar. - if (state.lineIndent < textIndent) { - - // Perform the chomping. - if (chomping === CHOMPING_KEEP) { - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - } else if (chomping === CHOMPING_CLIP) { - if (didReadContent) { // i.e. only if the scalar is not empty. - state.result += '\n'; - } - } - - // Break this `while` cycle and go to the funciton's epilogue. - break; - } - - // Folded style: use fancy rules to handle line breaks. - if (folding) { - - // Lines starting with white space characters (more-indented lines) are not folded. - if (is_WHITE_SPACE(ch)) { - atMoreIndented = true; - // except for the first content line (cf. Example 8.1) - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - - // End of more-indented block. - } else if (atMoreIndented) { - atMoreIndented = false; - state.result += common.repeat('\n', emptyLines + 1); - - // Just one line break - perceive as the same line. - } else if (emptyLines === 0) { - if (didReadContent) { // i.e. only if we have already read some scalar content. - state.result += ' '; - } - - // Several line breaks - perceive as different lines. - } else { - state.result += common.repeat('\n', emptyLines); - } - - // Literal style: just add exact number of line breaks between content lines. - } else { - // Keep all line breaks except the header line break. - state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); - } - - didReadContent = true; - detectedIndent = true; - emptyLines = 0; - captureStart = state.position; - - while (!is_EOL(ch) && (ch !== 0)) { - ch = state.input.charCodeAt(++state.position); - } - - captureSegment(state, captureStart, state.position, false); - } - - return true; -} - -function readBlockSequence(state, nodeIndent) { - var _line, - _tag = state.tag, - _anchor = state.anchor, - _result = [], - following, - detected = false, - ch; - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(state.position); - - while (ch !== 0) { - - if (ch !== 0x2D/* - */) { - break; - } - - following = state.input.charCodeAt(state.position + 1); - - if (!is_WS_OR_EOL(following)) { - break; - } - - detected = true; - state.position++; - - if (skipSeparationSpace(state, true, -1)) { - if (state.lineIndent <= nodeIndent) { - _result.push(null); - ch = state.input.charCodeAt(state.position); - continue; - } - } - - _line = state.line; - composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); - _result.push(state.result); - skipSeparationSpace(state, true, -1); - - ch = state.input.charCodeAt(state.position); - - if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { - throwError(state, 'bad indentation of a sequence entry'); - } else if (state.lineIndent < nodeIndent) { - break; - } - } - - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'sequence'; - state.result = _result; - return true; - } - return false; -} - -function readBlockMapping(state, nodeIndent, flowIndent) { - var following, - allowCompact, - _line, - _pos, - _tag = state.tag, - _anchor = state.anchor, - _result = {}, - overridableKeys = {}, - keyTag = null, - keyNode = null, - valueNode = null, - atExplicitKey = false, - detected = false, - ch; - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = _result; - } - - ch = state.input.charCodeAt(state.position); - - while (ch !== 0) { - following = state.input.charCodeAt(state.position + 1); - _line = state.line; // Save the current line. - _pos = state.position; - - // - // Explicit notation case. There are two separate blocks: - // first for the key (denoted by "?") and second for the value (denoted by ":") - // - if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { - - if (ch === 0x3F/* ? */) { - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); - keyTag = keyNode = valueNode = null; - } - - detected = true; - atExplicitKey = true; - allowCompact = true; - - } else if (atExplicitKey) { - // i.e. 0x3A/* : */ === character after the explicit key. - atExplicitKey = false; - allowCompact = true; - - } else { - throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); - } - - state.position += 1; - ch = following; - - // - // Implicit notation case. Flow-style node as the key first, then ":", and the value. - // - } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { - - if (state.line === _line) { - ch = state.input.charCodeAt(state.position); - - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (ch === 0x3A/* : */) { - ch = state.input.charCodeAt(++state.position); - - if (!is_WS_OR_EOL(ch)) { - throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); - } - - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); - keyTag = keyNode = valueNode = null; - } - - detected = true; - atExplicitKey = false; - allowCompact = false; - keyTag = state.tag; - keyNode = state.result; - - } else if (detected) { - throwError(state, 'can not read an implicit mapping pair; a colon is missed'); - - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. - } - - } else if (detected) { - throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); - - } else { - state.tag = _tag; - state.anchor = _anchor; - return true; // Keep the result of `composeNode`. - } - - } else { - break; // Reading is done. Go to the epilogue. - } - - // - // Common reading code for both explicit and implicit notations. - // - if (state.line === _line || state.lineIndent > nodeIndent) { - if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { - if (atExplicitKey) { - keyNode = state.result; - } else { - valueNode = state.result; - } - } - - if (!atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos); - keyTag = keyNode = valueNode = null; - } - - skipSeparationSpace(state, true, -1); - ch = state.input.charCodeAt(state.position); - } - - if (state.lineIndent > nodeIndent && (ch !== 0)) { - throwError(state, 'bad indentation of a mapping entry'); - } else if (state.lineIndent < nodeIndent) { - break; - } - } - - // - // Epilogue. - // - - // Special case: last mapping's node contains only the key in explicit notation. - if (atExplicitKey) { - storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); - } - - // Expose the resulting mapping. - if (detected) { - state.tag = _tag; - state.anchor = _anchor; - state.kind = 'mapping'; - state.result = _result; - } - - return detected; -} - -function readTagProperty(state) { - var _position, - isVerbatim = false, - isNamed = false, - tagHandle, - tagName, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x21/* ! */) return false; - - if (state.tag !== null) { - throwError(state, 'duplication of a tag property'); - } - - ch = state.input.charCodeAt(++state.position); - - if (ch === 0x3C/* < */) { - isVerbatim = true; - ch = state.input.charCodeAt(++state.position); - - } else if (ch === 0x21/* ! */) { - isNamed = true; - tagHandle = '!!'; - ch = state.input.charCodeAt(++state.position); - - } else { - tagHandle = '!'; - } - - _position = state.position; - - if (isVerbatim) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && ch !== 0x3E/* > */); - - if (state.position < state.length) { - tagName = state.input.slice(_position, state.position); - ch = state.input.charCodeAt(++state.position); - } else { - throwError(state, 'unexpected end of the stream within a verbatim tag'); - } - } else { - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - - if (ch === 0x21/* ! */) { - if (!isNamed) { - tagHandle = state.input.slice(_position - 1, state.position + 1); - - if (!PATTERN_TAG_HANDLE.test(tagHandle)) { - throwError(state, 'named tag handle cannot contain such characters'); - } - - isNamed = true; - _position = state.position + 1; - } else { - throwError(state, 'tag suffix cannot contain exclamation marks'); - } - } - - ch = state.input.charCodeAt(++state.position); - } - - tagName = state.input.slice(_position, state.position); - - if (PATTERN_FLOW_INDICATORS.test(tagName)) { - throwError(state, 'tag suffix cannot contain flow indicator characters'); - } - } - - if (tagName && !PATTERN_TAG_URI.test(tagName)) { - throwError(state, 'tag name cannot contain such characters: ' + tagName); - } - - if (isVerbatim) { - state.tag = tagName; - - } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { - state.tag = state.tagMap[tagHandle] + tagName; - - } else if (tagHandle === '!') { - state.tag = '!' + tagName; - - } else if (tagHandle === '!!') { - state.tag = 'tag:yaml.org,2002:' + tagName; - - } else { - throwError(state, 'undeclared tag handle "' + tagHandle + '"'); - } - - return true; -} - -function readAnchorProperty(state) { - var _position, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x26/* & */) return false; - - if (state.anchor !== null) { - throwError(state, 'duplication of an anchor property'); - } - - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (state.position === _position) { - throwError(state, 'name of an anchor node must contain at least one character'); - } - - state.anchor = state.input.slice(_position, state.position); - return true; -} - -function readAlias(state) { - var _position, alias, - ch; - - ch = state.input.charCodeAt(state.position); - - if (ch !== 0x2A/* * */) return false; - - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (state.position === _position) { - throwError(state, 'name of an alias node must contain at least one character'); - } - - alias = state.input.slice(_position, state.position); - - if (!state.anchorMap.hasOwnProperty(alias)) { - throwError(state, 'unidentified alias "' + alias + '"'); - } - - state.result = state.anchorMap[alias]; - skipSeparationSpace(state, true, -1); - return true; -} - -function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { - var allowBlockStyles, - allowBlockScalars, - allowBlockCollections, - indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; - } - } - } - - if (indentStatus === 1) { - while (readTagProperty(state) || readAnchorProperty(state)) { - if (skipSeparationSpace(state, true, -1)) { - atNewLine = true; - allowBlockCollections = allowBlockStyles; - - if (state.lineIndent > parentIndent) { - indentStatus = 1; - } else if (state.lineIndent === parentIndent) { - indentStatus = 0; - } else if (state.lineIndent < parentIndent) { - indentStatus = -1; - } - } else { - allowBlockCollections = false; - } - } - } - - if (allowBlockCollections) { - allowBlockCollections = atNewLine || allowCompact; - } - - if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { - if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { - flowIndent = parentIndent; - } else { - flowIndent = parentIndent + 1; - } - - blockIndent = state.position - state.lineStart; - - if (indentStatus === 1) { - if (allowBlockCollections && - (readBlockSequence(state, blockIndent) || - readBlockMapping(state, blockIndent, flowIndent)) || - readFlowCollection(state, flowIndent)) { - hasContent = true; - } else { - if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || - readSingleQuotedScalar(state, flowIndent) || - readDoubleQuotedScalar(state, flowIndent)) { - hasContent = true; - - } else if (readAlias(state)) { - hasContent = true; - - if (state.tag !== null || state.anchor !== null) { - throwError(state, 'alias node should not have any properties'); - } - - } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { - hasContent = true; - - if (state.tag === null) { - state.tag = '?'; - } - } - - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - } - } else if (indentStatus === 0) { - // Special case: block sequences are allowed to have same indentation level as the parent. - // http://www.yaml.org/spec/1.2/spec.html#id2799784 - hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); - } - } - - if (state.tag !== null && state.tag !== '!') { - if (state.tag === '?') { - // Implicit resolving is not allowed for non-scalar types, and '?' - // non-specific tag is only automatically assigned to plain scalars. - // - // We only need to check kind conformity in case user explicitly assigns '?' - // tag, for example like this: "! [0]" - // - if (state.result !== null && state.kind !== 'scalar') { - throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); - } - - for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { - type = state.implicitTypes[typeIndex]; - - if (type.resolve(state.result)) { // `state.result` updated in resolver if matched - state.result = type.construct(state.result); - state.tag = type.tag; - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - break; - } - } - } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { - type = state.typeMap[state.kind || 'fallback'][state.tag]; - - if (state.result !== null && type.kind !== state.kind) { - throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); - } - - if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched - throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); - } else { - state.result = type.construct(state.result); - if (state.anchor !== null) { - state.anchorMap[state.anchor] = state.result; - } - } - } else { - throwError(state, 'unknown tag !<' + state.tag + '>'); - } - } - - if (state.listener !== null) { - state.listener('close', state); - } - return state.tag !== null || state.anchor !== null || hasContent; -} - -function readDocument(state) { - var documentStart = state.position, - _position, - directiveName, - directiveArgs, - hasDirectives = false, - ch; - - state.version = null; - state.checkLineBreaks = state.legacy; - state.tagMap = {}; - state.anchorMap = {}; - - while ((ch = state.input.charCodeAt(state.position)) !== 0) { - skipSeparationSpace(state, true, -1); - - ch = state.input.charCodeAt(state.position); - - if (state.lineIndent > 0 || ch !== 0x25/* % */) { - break; - } - - hasDirectives = true; - ch = state.input.charCodeAt(++state.position); - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - directiveName = state.input.slice(_position, state.position); - directiveArgs = []; - - if (directiveName.length < 1) { - throwError(state, 'directive name must not be less than one character in length'); - } - - while (ch !== 0) { - while (is_WHITE_SPACE(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - if (ch === 0x23/* # */) { - do { ch = state.input.charCodeAt(++state.position); } - while (ch !== 0 && !is_EOL(ch)); - break; - } - - if (is_EOL(ch)) break; - - _position = state.position; - - while (ch !== 0 && !is_WS_OR_EOL(ch)) { - ch = state.input.charCodeAt(++state.position); - } - - directiveArgs.push(state.input.slice(_position, state.position)); - } - - if (ch !== 0) readLineBreak(state); - - if (_hasOwnProperty.call(directiveHandlers, directiveName)) { - directiveHandlers[directiveName](state, directiveName, directiveArgs); - } else { - throwWarning(state, 'unknown document directive "' + directiveName + '"'); - } - } - - skipSeparationSpace(state, true, -1); - - if (state.lineIndent === 0 && - state.input.charCodeAt(state.position) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && - state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { - state.position += 3; - skipSeparationSpace(state, true, -1); - - } else if (hasDirectives) { - throwError(state, 'directives end mark is expected'); - } - - composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); - skipSeparationSpace(state, true, -1); - - if (state.checkLineBreaks && - PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { - throwWarning(state, 'non-ASCII line breaks are interpreted as content'); - } - - state.documents.push(state.result); - - if (state.position === state.lineStart && testDocumentSeparator(state)) { - - if (state.input.charCodeAt(state.position) === 0x2E/* . */) { - state.position += 3; - skipSeparationSpace(state, true, -1); - } - return; - } - - if (state.position < (state.length - 1)) { - throwError(state, 'end of the stream or a document separator is expected'); - } else { - return; - } -} - - -function loadDocuments(input, options) { - input = String(input); - options = options || {}; - - if (input.length !== 0) { - - // Add tailing `\n` if not exists - if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && - input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { - input += '\n'; - } - - // Strip BOM - if (input.charCodeAt(0) === 0xFEFF) { - input = input.slice(1); - } - } - - var state = new State(input, options); - - var nullpos = input.indexOf('\0'); - - if (nullpos !== -1) { - state.position = nullpos; - throwError(state, 'null byte is not allowed in input'); - } - - // Use 0 as string terminator. That significantly simplifies bounds check. - state.input += '\0'; - - while (state.input.charCodeAt(state.position) === 0x20/* Space */) { - state.lineIndent += 1; - state.position += 1; - } - - while (state.position < (state.length - 1)) { - readDocument(state); - } - - return state.documents; -} - - -function loadAll(input, iterator, options) { - if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { - options = iterator; - iterator = null; - } - - var documents = loadDocuments(input, options); - - if (typeof iterator !== 'function') { - return documents; - } - - for (var index = 0, length = documents.length; index < length; index += 1) { - iterator(documents[index]); - } -} - - -function load(input, options) { - var documents = loadDocuments(input, options); - - if (documents.length === 0) { - /*eslint-disable no-undefined*/ - return undefined; - } else if (documents.length === 1) { - return documents[0]; - } - throw new YAMLException('expected a single document in the stream, but found more'); -} - - -function safeLoadAll(input, iterator, options) { - if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') { - options = iterator; - iterator = null; - } - - return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); -} - - -function safeLoad(input, options) { - return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); -} - - -module.exports.loadAll = loadAll; -module.exports.load = load; -module.exports.safeLoadAll = safeLoadAll; -module.exports.safeLoad = safeLoad; +module.exports = new Type('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: 'lowercase' +}); /***/ }), -/* 458 */, -/* 459 */, -/* 460 */, -/* 461 */, -/* 462 */ +/* 418 */, +/* 419 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (this && this.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); +var util_1 = __webpack_require__(592); var interfaces_1 = __webpack_require__(970); -var LocalNameSet_1 = __webpack_require__(575); -var NamespacePrefixMap_1 = __webpack_require__(392); -var infra_1 = __webpack_require__(23); -var algorithm_1 = __webpack_require__(163); +var BaseWriter_1 = __webpack_require__(462); /** - * Pre-serializes XML nodes. + * Serializes XML nodes into objects and arrays. */ -var BaseWriter = /** @class */ (function () { +var ObjectWriter = /** @class */ (function (_super) { + __extends(ObjectWriter, _super); /** - * Initializes a new instance of `BaseWriter`. + * Initializes a new instance of `ObjectWriter`. * * @param builderOptions - XML builder options + * @param writerOptions - serialization options */ - function BaseWriter(builderOptions) { - /** - * Gets the current depth of the XML tree. - */ - this.level = 0; - this._builderOptions = builderOptions; + function ObjectWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._writerOptions = util_1.applyDefaults(writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + group: false, + verbose: false + }); + return _this; } /** - * Used by derived classes to serialize the XML declaration. - * - * @param version - a version number string - * @param encoding - encoding declaration - * @param standalone - standalone document declaration - */ - BaseWriter.prototype.declaration = function (version, encoding, standalone) { }; - /** - * Used by derived classes to serialize a DocType node. - * - * @param name - node name - * @param publicId - public identifier - * @param systemId - system identifier - */ - BaseWriter.prototype.docType = function (name, publicId, systemId) { }; - /** - * Used by derived classes to serialize a comment node. - * - * @param data - node data - */ - BaseWriter.prototype.comment = function (data) { }; - /** - * Used by derived classes to serialize a text node. - * - * @param data - node data - */ - BaseWriter.prototype.text = function (data) { }; - /** - * Used by derived classes to serialize a processing instruction node. - * - * @param target - instruction target - * @param data - node data - */ - BaseWriter.prototype.instruction = function (target, data) { }; - /** - * Used by derived classes to serialize a CData section node. - * - * @param data - node data - */ - BaseWriter.prototype.cdata = function (data) { }; - /** - * Used by derived classes to serialize the beginning of the opening tag of an - * element node. - * - * @param name - node name - */ - BaseWriter.prototype.openTagBegin = function (name) { }; - /** - * Used by derived classes to serialize the ending of the opening tag of an - * element node. - * - * @param name - node name - * @param selfClosing - whether the element node is self closing - * @param voidElement - whether the element node is a HTML void element - */ - BaseWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { }; - /** - * Used by derived classes to serialize the closing tag of an element node. - * - * @param name - node name - */ - BaseWriter.prototype.closeTag = function (name) { }; - /** - * Used by derived classes to serialize attributes or namespace declarations. - * - * @param attributes - attribute array - */ - BaseWriter.prototype.attributes = function (attributes) { - var e_1, _a; - try { - for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) { - var attr = attributes_1_1.value; - this.attribute(attr[1] === null ? attr[2] : attr[1] + ':' + attr[2], attr[3]); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1); - } - finally { if (e_1) throw e_1.error; } - } - }; - /** - * Used by derived classes to serialize an attribute or namespace declaration. - * - * @param name - node name - * @param value - node value - */ - BaseWriter.prototype.attribute = function (name, value) { }; - /** - * Used by derived classes to perform any pre-processing steps before starting - * serializing an element node. - * - * @param name - node name - */ - BaseWriter.prototype.beginElement = function (name) { }; - /** - * Used by derived classes to perform any post-processing steps after - * completing serializing an element node. - * - * @param name - node name - */ - BaseWriter.prototype.endElement = function (name) { }; - /** - * Produces an XML serialization of the given node. The pre-serializer inserts - * namespace declarations where necessary and produces qualified names for - * nodes and attributes. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype.serializeNode = function (node, requireWellFormed, noDoubleEncoding) { - var hasNamespaces = (node._nodeDocument !== undefined && node._nodeDocument._hasNamespaces); - this.level = 0; - this.currentNode = node; - if (hasNamespaces) { - /** From: https://w3c.github.io/DOM-Parsing/#xml-serialization - * - * 1. Let namespace be a context namespace with value null. - * The context namespace tracks the XML serialization algorithm's current - * default namespace. The context namespace is changed when either an Element - * Node has a default namespace declaration, or the algorithm generates a - * default namespace declaration for the Element Node to match its own - * namespace. The algorithm assumes no namespace (null) to start. - * 2. Let prefix map be a new namespace prefix map. - * 3. Add the XML namespace with prefix value "xml" to prefix map. - * 4. Let prefix index be a generated namespace prefix index with value 1. - * The generated namespace prefix index is used to generate a new unique - * prefix value when no suitable existing namespace prefix is available to - * serialize a node's namespaceURI (or the namespaceURI of one of node's - * attributes). See the generate a prefix algorithm. - */ - var namespace = null; - var prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); - prefixMap.set("xml", infra_1.namespace.XML); - var prefixIndex = { value: 1 }; - /** - * 5. Return the result of running the XML serialization algorithm on node - * passing the context namespace namespace, namespace prefix map prefix map, - * generated namespace prefix index reference to prefix index, and the - * flag require well-formed. If an exception occurs during the execution - * of the algorithm, then catch that exception and throw an - * "InvalidStateError" DOMException. - */ - this._serializeNodeNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - } - else { - this._serializeNode(node, requireWellFormed, noDoubleEncoding); - } - }; - /** - * Produces an XML serialization of a node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeNodeNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - this.currentNode = node; - switch (node.nodeType) { - case interfaces_1.NodeType.Element: - this._serializeElementNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Document: - this._serializeDocumentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Comment: - this._serializeComment(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Text: - this._serializeText(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentFragment: - this._serializeDocumentFragmentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentType: - this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.ProcessingInstruction: - this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.CData: - this._serializeCData(node, requireWellFormed, noDoubleEncoding); - break; - default: - throw new Error("Unknown node type: " + node.nodeType); - } - }; - /** - * Produces an XML serialization of a node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeNode = function (node, requireWellFormed, noDoubleEncoding) { - this.currentNode = node; - switch (node.nodeType) { - case interfaces_1.NodeType.Element: - this._serializeElement(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Document: - this._serializeDocument(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Comment: - this._serializeComment(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.Text: - this._serializeText(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentFragment: - this._serializeDocumentFragment(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.DocumentType: - this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.ProcessingInstruction: - this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); - break; - case interfaces_1.NodeType.CData: - this._serializeCData(node, requireWellFormed, noDoubleEncoding); - break; - default: - throw new Error("Unknown node type: " + node.nodeType); - } - }; - /** - * Produces an XML serialization of an element node. + * Produces an XML serialization of the given node. * * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance */ - BaseWriter.prototype._serializeElementNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - var e_2, _a; - var attributes = []; + ObjectWriter.prototype.serialize = function (node) { + this._currentList = []; + this._currentIndex = 0; + this._listRegister = [this._currentList]; /** - * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node - * - * 1. If the require well-formed flag is set (its value is true), and this - * node's localName attribute contains the character ":" (U+003A COLON) or - * does not match the XML Name production, then throw an exception; the - * serialization of this node would not be a well-formed element. + * First pass, serialize nodes + * This creates a list of nodes grouped under node types while preserving + * insertion order. For example: + * [ + * root: [ + * node: [ + * { "@" : { "att1": "val1", "att2": "val2" } + * { "#": "node text" } + * { childNode: [] } + * { "#": "more text" } + * ], + * node: [ + * { "@" : { "att": "val" } + * { "#": [ "text line1", "text line2" ] } + * ] + * ] + * ] */ - if (requireWellFormed && (node.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(node.localName))) { - throw new Error("Node local name contains invalid characters (well-formed required)."); - } + this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); /** - * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). - * 3. Let qualified name be an empty string. - * 4. Let skip end tag be a boolean flag with value false. - * 5. Let ignore namespace definition attribute be a boolean flag with value - * false. - * 6. Given prefix map, copy a namespace prefix map and let map be the - * result. - * 7. Let local prefixes map be an empty map. The map has unique Node prefix - * strings as its keys, with corresponding namespaceURI Node values as the - * map's key values (in this map, the null namespace is represented by the - * empty string). - * - * _Note:_ This map is local to each element. It is used to ensure there - * are no conflicting prefixes should a new namespace prefix attribute need - * to be generated. It is also used to enable skipping of duplicate prefix - * definitions when writing an element's attributes: the map allows the - * algorithm to distinguish between a prefix in the namespace prefix map - * that might be locally-defined (to the current Element) and one that is - * not. - * 8. Let local default namespace be the result of recording the namespace - * information for node given map and local prefixes map. - * - * _Note:_ The above step will update map with any found namespace prefix - * definitions, add the found prefix definitions to the local prefixes map - * and return a local default namespace value defined by a default namespace - * attribute if one exists. Otherwise it returns null. - * 9. Let inherited ns be a copy of namespace. - * 10. Let ns be the value of node's namespaceURI attribute. + * Second pass, process node lists. Above example becomes: + * { + * root: { + * node: [ + * { + * "@att1": "val1", + * "@att2": "val2", + * "#1": "node text", + * childNode: {}, + * "#2": "more text" + * }, + * { + * "@att": "val", + * "#": [ "text line1", "text line2" ] + * } + * ] + * } + * } */ - var qualifiedName = ''; - var skipEndTag = false; - var ignoreNamespaceDefinitionAttribute = false; - var map = prefixMap.copy(); - var localPrefixesMap = {}; - var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); - var inheritedNS = namespace; - var ns = node.namespaceURI; - /** 11. If inherited ns is equal to ns, then: */ - if (inheritedNS === ns) { - /** - * 11.1. If local default namespace is not null, then set ignore - * namespace definition attribute to true. - */ - if (localDefaultNamespace !== null) { - ignoreNamespaceDefinitionAttribute = true; + return this._process(this._currentList, this._writerOptions); + }; + ObjectWriter.prototype._process = function (items, options) { + var _a, _b, _c, _d, _e, _f, _g; + if (items.length === 0) + return {}; + // determine if there are non-unique element names + var namesSeen = {}; + var hasNonUniqueNames = false; + var textCount = 0; + var commentCount = 0; + var instructionCount = 0; + var cdataCount = 0; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + continue; + case "#": + textCount++; + break; + case "!": + commentCount++; + break; + case "?": + instructionCount++; + break; + case "$": + cdataCount++; + break; + default: + if (namesSeen[key]) { + hasNonUniqueNames = true; + } + else { + namesSeen[key] = true; + } + break; } - /** - * 11.2. If ns is the XML namespace, then append to qualified name the - * concatenation of the string "xml:" and the value of node's localName. - * 11.3. Otherwise, append to qualified name the value of node's - * localName. The node's prefix if it exists, is dropped. - */ - if (ns === infra_1.namespace.XML) { - qualifiedName = 'xml:' + node.localName; + } + var defAttrKey = this._getAttrKey(); + var defTextKey = this._getNodeKey(interfaces_1.NodeType.Text); + var defCommentKey = this._getNodeKey(interfaces_1.NodeType.Comment); + var defInstructionKey = this._getNodeKey(interfaces_1.NodeType.ProcessingInstruction); + var defCdataKey = this._getNodeKey(interfaces_1.NodeType.CData); + if (textCount === 1 && items.length === 1 && util_1.isString(items[0]["#"])) { + // special case of an element node with a single text node + return items[0]["#"]; + } + else if (hasNonUniqueNames) { + var obj = {}; + // process attributes first + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + if (key === "@") { + var attrs = item["@"]; + var attrKeys = Object.keys(attrs); + if (attrKeys.length === 1) { + obj[defAttrKey + attrKeys[0]] = attrs[attrKeys[0]]; + } + else { + obj[defAttrKey] = item["@"]; + } + } } - else { - qualifiedName = node.localName; + // list contains element nodes with non-unique names + // return an array with mixed content notation + var result = []; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + // attributes were processed above + break; + case "#": + result.push((_a = {}, _a[defTextKey] = item["#"], _a)); + break; + case "!": + result.push((_b = {}, _b[defCommentKey] = item["!"], _b)); + break; + case "?": + result.push((_c = {}, _c[defInstructionKey] = item["?"], _c)); + break; + case "$": + result.push((_d = {}, _d[defCdataKey] = item["$"], _d)); + break; + default: + // element node + var ele = item; + if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { + // group of element nodes + var eleGroup = []; + var listOfLists = ele[key]; + for (var i_1 = 0; i_1 < listOfLists.length; i_1++) { + eleGroup.push(this._process(listOfLists[i_1], options)); + } + result.push((_e = {}, _e[key] = eleGroup, _e)); + } + else { + // single element node + if (options.verbose) { + result.push((_f = {}, _f[key] = [this._process(ele[key], options)], _f)); + } + else { + result.push((_g = {}, _g[key] = this._process(ele[key], options), _g)); + } + } + break; + } + } + obj[defTextKey] = result; + return obj; + } + else { + // all element nodes have unique names + // return an object while prefixing data node keys + var textId = 1; + var commentId = 1; + var instructionId = 1; + var cdataId = 1; + var obj = {}; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + var attrs = item["@"]; + var attrKeys = Object.keys(attrs); + if (!options.group || attrKeys.length === 1) { + for (var attrName in attrs) { + obj[defAttrKey + attrName] = attrs[attrName]; + } + } + else { + obj[defAttrKey] = attrs; + } + break; + case "#": + textId = this._processSpecItem(item["#"], obj, options.group, defTextKey, textCount, textId); + break; + case "!": + commentId = this._processSpecItem(item["!"], obj, options.group, defCommentKey, commentCount, commentId); + break; + case "?": + instructionId = this._processSpecItem(item["?"], obj, options.group, defInstructionKey, instructionCount, instructionId); + break; + case "$": + cdataId = this._processSpecItem(item["$"], obj, options.group, defCdataKey, cdataCount, cdataId); + break; + default: + // element node + var ele = item; + if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { + // group of element nodes + var eleGroup = []; + var listOfLists = ele[key]; + for (var i_2 = 0; i_2 < listOfLists.length; i_2++) { + eleGroup.push(this._process(listOfLists[i_2], options)); + } + obj[key] = eleGroup; + } + else { + // single element node + if (options.verbose) { + obj[key] = [this._process(ele[key], options)]; + } + else { + obj[key] = this._process(ele[key], options); + } + } + break; + } } - /** 11.4. Append the value of qualified name to markup. */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); + return obj; } - else { - /** - * 12. Otherwise, inherited ns is not equal to ns (the node's own - * namespace is different from the context namespace of its parent). - * Run these sub-steps: - * - * 12.1. Let prefix be the value of node's prefix attribute. - * 12.2. Let candidate prefix be the result of retrieving a preferred - * prefix string prefix from map given namespace ns. The above may return - * null if no namespace key ns exists in map. - */ - var prefix = node.prefix; - /** - * We don't need to run "retrieving a preferred prefix string" algorithm if - * the element has no prefix and its namespace matches to the default - * namespace. - * See: https://github.com/web-platform-tests/wpt/pull/16703 - */ - var candidatePrefix = null; - if (prefix !== null || ns !== localDefaultNamespace) { - candidatePrefix = map.get(prefix, ns); - } - /** - * 12.3. If the value of prefix matches "xmlns", then run the following - * steps: - */ - if (prefix === "xmlns") { - /** - * 12.3.1. If the require well-formed flag is set, then throw an error. - * An Element with prefix "xmlns" will not legally round-trip in a - * conforming XML parser. - */ - if (requireWellFormed) { - throw new Error("An element cannot have the 'xmlns' prefix (well-formed required)."); + }; + ObjectWriter.prototype._processSpecItem = function (item, obj, group, defKey, count, id) { + var e_1, _a; + if (!group && util_1.isArray(item) && count + item.length > 2) { + try { + for (var item_1 = __values(item), item_1_1 = item_1.next(); !item_1_1.done; item_1_1 = item_1.next()) { + var subItem = item_1_1.value; + var key = defKey + (id++).toString(); + obj[key] = subItem; } - /** - * 12.3.2. Let candidate prefix be the value of prefix. - */ - candidatePrefix = prefix; } - /** - * 12.4.Found a suitable namespace prefix: if candidate prefix is not - * null (a namespace prefix is defined which maps to ns), then: - */ - if (candidatePrefix !== null) { - /** - * The following may serialize a different prefix than the Element's - * existing prefix if it already had one. However, the retrieving a - * preferred prefix string algorithm already tried to match the - * existing prefix if possible. - * - * 12.4.1. Append to qualified name the concatenation of candidate - * prefix, ":" (U+003A COLON), and node's localName. There exists on - * this node or the node's ancestry a namespace prefix definition that - * defines the node's namespace. - * 12.4.2. If the local default namespace is not null (there exists a - * locally-defined default namespace declaration attribute) and its - * value is not the XML namespace, then let inherited ns get the value - * of local default namespace unless the local default namespace is the - * empty string in which case let it get null (the context namespace - * is changed to the declared default, rather than this node's own - * namespace). - * - * _Note:_ Any default namespace definitions or namespace prefixes that - * define the XML namespace are omitted when serializing this node's - * attributes. - */ - qualifiedName = candidatePrefix + ':' + node.localName; - if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { - inheritedNS = localDefaultNamespace || null; + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (item_1_1 && !item_1_1.done && (_a = item_1.return)) _a.call(item_1); } - /** - * 12.4.3. Append the value of qualified name to markup. - */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** 12.5. Otherwise, if prefix is not null, then: */ + finally { if (e_1) throw e_1.error; } } - else if (prefix !== null) { - /** - * _Note:_ By this step, there is no namespace or prefix mapping - * declaration in this node (or any parent node visited by this - * algorithm) that defines prefix otherwise the step labelled Found - * a suitable namespace prefix would have been followed. The sub-steps - * that follow will create a new namespace prefix declaration for prefix - * and ensure that prefix does not conflict with an existing namespace - * prefix declaration of the same localName in node's attribute list. - * - * 12.5.1. If the local prefixes map contains a key matching prefix, - * then let prefix be the result of generating a prefix providing as - * input map, ns, and prefix index. - */ - if (prefix in localPrefixesMap) { - prefix = this._generatePrefix(ns, map, prefixIndex); + } + else { + var key = count > 1 ? defKey + (id++).toString() : defKey; + obj[key] = item; + } + return id; + }; + /** @inheritdoc */ + ObjectWriter.prototype.beginElement = function (name) { + var _a, _b; + var childItems = []; + if (this._currentList.length === 0) { + this._currentList.push((_a = {}, _a[name] = childItems, _a)); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isElementNode(lastItem, name)) { + if (lastItem[name].length !== 0 && util_1.isArray(lastItem[name][0])) { + var listOfLists = lastItem[name]; + listOfLists.push(childItems); } - /** - * 12.5.2. Add prefix to map given namespace ns. - * 12.5.3. Append to qualified name the concatenation of prefix, ":" - * (U+003A COLON), and node's localName. - * 12.5.4. Append the value of qualified name to markup. - */ - map.set(prefix, ns); - qualifiedName += prefix + ':' + node.localName; - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** - * 12.5.5. Append the following to markup, in the order listed: - * - * _Note:_ The following serializes a namespace prefix declaration for - * prefix which was just added to the map. - * - * 12.5.5.1. " " (U+0020 SPACE); - * 12.5.5.2. The string "xmlns:"; - * 12.5.5.3. The value of prefix; - * 12.5.5.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 12.5.5.5. The result of serializing an attribute value given ns and - * the require well-formed flag as input; - * 12.5.5.6. """ (U+0022 QUOTATION MARK). - */ - attributes.push([null, 'xmlns', prefix, - this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); - /** - * 12.5.5.7. If local default namespace is not null (there exists a - * locally-defined default namespace declaration attribute), then - * let inherited ns get the value of local default namespace unless the - * local default namespace is the empty string in which case let it get - * null. - */ - if (localDefaultNamespace !== null) { - inheritedNS = localDefaultNamespace || null; + else { + lastItem[name] = [lastItem[name], childItems]; } - /** - * 12.6. Otherwise, if local default namespace is null, or local - * default namespace is not null and its value is not equal to ns, then: - */ - } - else if (localDefaultNamespace === null || - (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { - /** - * _Note:_ At this point, the namespace for this node still needs to be - * serialized, but there's no prefix (or candidate prefix) available; the - * following uses the default namespace declaration to define the - * namespace--optionally replacing an existing default declaration - * if present. - * - * 12.6.1. Set the ignore namespace definition attribute flag to true. - * 12.6.2. Append to qualified name the value of node's localName. - * 12.6.3. Let the value of inherited ns be ns. - * - * _Note:_ The new default namespace will be used in the serialization - * to define this node's namespace and act as the context namespace for - * its children. - */ - ignoreNamespaceDefinitionAttribute = true; - qualifiedName += node.localName; - inheritedNS = ns; - /** - * 12.6.4. Append the value of qualified name to markup. - */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** - * 12.6.5. Append the following to markup, in the order listed: - * - * _Note:_ The following serializes the new (or replacement) default - * namespace definition. - * - * 12.6.5.1. " " (U+0020 SPACE); - * 12.6.5.2. The string "xmlns"; - * 12.6.5.3. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 12.6.5.4. The result of serializing an attribute value given ns - * and the require well-formed flag as input; - * 12.6.5.5. """ (U+0022 QUOTATION MARK). - */ - attributes.push([null, null, 'xmlns', - this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); - /** - * 12.7. Otherwise, the node has a local default namespace that matches - * ns. Append to qualified name the value of node's localName, let the - * value of inherited ns be ns, and append the value of qualified name - * to markup. - */ } else { - qualifiedName += node.localName; - inheritedNS = ns; - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); + this._currentList.push((_b = {}, _b[name] = childItems, _b)); } } - /** - * 13. Append to markup the result of the XML serialization of node's - * attributes given map, prefix index, local prefixes map, ignore namespace - * definition attribute flag, and require well-formed flag. - */ - attributes.push.apply(attributes, __spread(this._serializeAttributesNS(node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding))); - this.attributes(attributes); - /** - * 14. If ns is the HTML namespace, and the node's list of children is - * empty, and the node's localName matches any one of the following void - * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", - * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", - * "param", "source", "track", "wbr"; then append the following to markup, - * in the order listed: - * 14.1. " " (U+0020 SPACE); - * 14.2. "/" (U+002F SOLIDUS). - * and set the skip end tag flag to true. - * 15. If ns is not the HTML namespace, and the node's list of children is - * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end - * tag flag to true. - * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. - */ - var isHTML = (ns === infra_1.namespace.HTML); - if (isHTML && node.childNodes.length === 0 && - BaseWriter._VoidElementNames.has(node.localName)) { - this.openTagEnd(qualifiedName, true, true); - this.endElement(qualifiedName); - skipEndTag = true; + this._currentIndex++; + if (this._listRegister.length > this._currentIndex) { + this._listRegister[this._currentIndex] = childItems; } - else if (!isHTML && node.childNodes.length === 0) { - this.openTagEnd(qualifiedName, true, false); - this.endElement(qualifiedName); - skipEndTag = true; + else { + this._listRegister.push(childItems); + } + this._currentList = childItems; + }; + /** @inheritdoc */ + ObjectWriter.prototype.endElement = function () { + this._currentList = this._listRegister[--this._currentIndex]; + }; + /** @inheritdoc */ + ObjectWriter.prototype.attribute = function (name, value) { + var _a, _b; + if (this._currentList.length === 0) { + this._currentList.push({ "@": (_a = {}, _a[name] = value, _a) }); } else { - this.openTagEnd(qualifiedName, false, false); + var lastItem = this._currentList[this._currentList.length - 1]; + /* istanbul ignore else */ + if (this._isAttrNode(lastItem)) { + lastItem["@"][name] = value; + } + else { + this._currentList.push({ "@": (_b = {}, _b[name] = value, _b) }); + } } - /** - * 17. If the value of skip end tag is true, then return the value of markup - * and skip the remaining steps. The node is a leaf-node. - */ - if (skipEndTag) - return; - /** - * 18. If ns is the HTML namespace, and the node's localName matches the - * string "template", then this is a template element. Append to markup the - * result of XML serializing a DocumentFragment node given the template - * element's template contents (a DocumentFragment), providing inherited - * ns, map, prefix index, and the require well-formed flag. - * - * _Note:_ This allows template content to round-trip, given the rules for - * parsing XHTML documents. - * - * 19. Otherwise, append to markup the result of running the XML - * serialization algorithm on each of node's children, in tree order, - * providing inherited ns, map, prefix index, and the require well-formed - * flag. - */ - if (isHTML && node.localName === "template") { - // TODO: serialize template contents + }; + /** @inheritdoc */ + ObjectWriter.prototype.comment = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "!": data }); } else { - try { - for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this.level++; - this._serializeNodeNS(childNode, inheritedNS, map, prefixIndex, requireWellFormed, noDoubleEncoding); - this.level--; + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isCommentNode(lastItem)) { + if (util_1.isArray(lastItem["!"])) { + lastItem["!"].push(data); } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + else { + lastItem["!"] = [lastItem["!"], data]; } - finally { if (e_2) throw e_2.error; } + } + else { + this._currentList.push({ "!": data }); } } - /** - * 20. Append the following to markup, in the order listed: - * 20.1. "" (U+003E GREATER-THAN SIGN). - * 21. Return the value of markup. - */ - this.closeTag(qualifiedName); - this.endElement(qualifiedName); }; - /** - * Produces an XML serialization of an element node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeElement = function (node, requireWellFormed, noDoubleEncoding) { - var e_3, _a; - /** - * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node - * - * 1. If the require well-formed flag is set (its value is true), and this - * node's localName attribute contains the character ":" (U+003A COLON) or - * does not match the XML Name production, then throw an exception; the - * serialization of this node would not be a well-formed element. - */ - if (requireWellFormed && (node.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(node.localName))) { - throw new Error("Node local name contains invalid characters (well-formed required)."); - } - /** - * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). - * 3. Let qualified name be an empty string. - * 4. Let skip end tag be a boolean flag with value false. - * 5. Let ignore namespace definition attribute be a boolean flag with value - * false. - * 6. Given prefix map, copy a namespace prefix map and let map be the - * result. - * 7. Let local prefixes map be an empty map. The map has unique Node prefix - * strings as its keys, with corresponding namespaceURI Node values as the - * map's key values (in this map, the null namespace is represented by the - * empty string). - * - * _Note:_ This map is local to each element. It is used to ensure there - * are no conflicting prefixes should a new namespace prefix attribute need - * to be generated. It is also used to enable skipping of duplicate prefix - * definitions when writing an element's attributes: the map allows the - * algorithm to distinguish between a prefix in the namespace prefix map - * that might be locally-defined (to the current Element) and one that is - * not. - * 8. Let local default namespace be the result of recording the namespace - * information for node given map and local prefixes map. - * - * _Note:_ The above step will update map with any found namespace prefix - * definitions, add the found prefix definitions to the local prefixes map - * and return a local default namespace value defined by a default namespace - * attribute if one exists. Otherwise it returns null. - * 9. Let inherited ns be a copy of namespace. - * 10. Let ns be the value of node's namespaceURI attribute. - */ - var skipEndTag = false; - /** 11. If inherited ns is equal to ns, then: */ - /** - * 11.1. If local default namespace is not null, then set ignore - * namespace definition attribute to true. - */ - /** - * 11.2. If ns is the XML namespace, then append to qualified name the - * concatenation of the string "xml:" and the value of node's localName. - * 11.3. Otherwise, append to qualified name the value of node's - * localName. The node's prefix if it exists, is dropped. - */ - var qualifiedName = node.localName; - /** 11.4. Append the value of qualified name to markup. */ - this.beginElement(qualifiedName); - this.openTagBegin(qualifiedName); - /** - * 13. Append to markup the result of the XML serialization of node's - * attributes given map, prefix index, local prefixes map, ignore namespace - * definition attribute flag, and require well-formed flag. - */ - var attributes = this._serializeAttributes(node, requireWellFormed, noDoubleEncoding); - this.attributes(attributes); - /** - * 14. If ns is the HTML namespace, and the node's list of children is - * empty, and the node's localName matches any one of the following void - * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", - * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", - * "param", "source", "track", "wbr"; then append the following to markup, - * in the order listed: - * 14.1. " " (U+0020 SPACE); - * 14.2. "/" (U+002F SOLIDUS). - * and set the skip end tag flag to true. - * 15. If ns is not the HTML namespace, and the node's list of children is - * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end - * tag flag to true. - * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. - */ - if (!node.hasChildNodes()) { - this.openTagEnd(qualifiedName, true, false); - this.endElement(qualifiedName); - skipEndTag = true; + /** @inheritdoc */ + ObjectWriter.prototype.text = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "#": data }); } else { - this.openTagEnd(qualifiedName, false, false); - } - /** - * 17. If the value of skip end tag is true, then return the value of markup - * and skip the remaining steps. The node is a leaf-node. - */ - if (skipEndTag) - return; - try { - /** - * 18. If ns is the HTML namespace, and the node's localName matches the - * string "template", then this is a template element. Append to markup the - * result of XML serializing a DocumentFragment node given the template - * element's template contents (a DocumentFragment), providing inherited - * ns, map, prefix index, and the require well-formed flag. - * - * _Note:_ This allows template content to round-trip, given the rules for - * parsing XHTML documents. - * - * 19. Otherwise, append to markup the result of running the XML - * serialization algorithm on each of node's children, in tree order, - * providing inherited ns, map, prefix index, and the require well-formed - * flag. - */ - for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this.level++; - this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); - this.level--; + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isTextNode(lastItem)) { + if (util_1.isArray(lastItem["#"])) { + lastItem["#"].push(data); + } + else { + lastItem["#"] = [lastItem["#"], data]; + } } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + else { + this._currentList.push({ "#": data }); } - finally { if (e_3) throw e_3.error; } } - /** - * 20. Append the following to markup, in the order listed: - * 20.1. "" (U+003E GREATER-THAN SIGN). - * 21. Return the value of markup. - */ - this.closeTag(qualifiedName); - this.endElement(qualifiedName); }; - /** - * Produces an XML serialization of a document node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - var e_4, _a; - /** - * If the require well-formed flag is set (its value is true), and this node - * has no documentElement (the documentElement attribute's value is null), - * then throw an exception; the serialization of this node would not be a - * well-formed document. - */ - if (requireWellFormed && node.documentElement === null) { - throw new Error("Missing document element (well-formed required)."); + /** @inheritdoc */ + ObjectWriter.prototype.instruction = function (target, data) { + var value = (data === "" ? target : target + " " + data); + if (this._currentList.length === 0) { + this._currentList.push({ "?": value }); } - try { - /** - * Otherwise, run the following steps: - * 1. Let serialized document be an empty string. - * 2. For each child child of node, in tree order, run the XML - * serialization algorithm on the child passing along the provided - * arguments, and append the result to serialized document. - * - * _Note:_ This will serialize any number of ProcessingInstruction and - * Comment nodes both before and after the Document's documentElement node, - * including at most one DocumentType node. (Text nodes are not allowed as - * children of the Document.) - * - * 3. Return the value of serialized document. - */ - for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isInstructionNode(lastItem)) { + if (util_1.isArray(lastItem["?"])) { + lastItem["?"].push(value); + } + else { + lastItem["?"] = [lastItem["?"], value]; + } } - } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + else { + this._currentList.push({ "?": value }); } - finally { if (e_4) throw e_4.error; } } }; - /** - * Produces an XML serialization of a document node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocument = function (node, requireWellFormed, noDoubleEncoding) { - var e_5, _a; - /** - * If the require well-formed flag is set (its value is true), and this node - * has no documentElement (the documentElement attribute's value is null), - * then throw an exception; the serialization of this node would not be a - * well-formed document. - */ - if (requireWellFormed && node.documentElement === null) { - throw new Error("Missing document element (well-formed required)."); + /** @inheritdoc */ + ObjectWriter.prototype.cdata = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "$": data }); } - try { - /** - * Otherwise, run the following steps: - * 1. Let serialized document be an empty string. - * 2. For each child child of node, in tree order, run the XML - * serialization algorithm on the child passing along the provided - * arguments, and append the result to serialized document. - * - * _Note:_ This will serialize any number of ProcessingInstruction and - * Comment nodes both before and after the Document's documentElement node, - * including at most one DocumentType node. (Text nodes are not allowed as - * children of the Document.) - * - * 3. Return the value of serialized document. - */ - for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isCDATANode(lastItem)) { + if (util_1.isArray(lastItem["$"])) { + lastItem["$"].push(data); + } + else { + lastItem["$"] = [lastItem["$"], data]; + } } - } - catch (e_5_1) { e_5 = { error: e_5_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + else { + this._currentList.push({ "$": data }); } - finally { if (e_5) throw e_5.error; } } }; + ObjectWriter.prototype._isAttrNode = function (x) { + return "@" in x; + }; + ObjectWriter.prototype._isTextNode = function (x) { + return "#" in x; + }; + ObjectWriter.prototype._isCommentNode = function (x) { + return "!" in x; + }; + ObjectWriter.prototype._isInstructionNode = function (x) { + return "?" in x; + }; + ObjectWriter.prototype._isCDATANode = function (x) { + return "$" in x; + }; + ObjectWriter.prototype._isElementNode = function (x, name) { + return name in x; + }; /** - * Produces an XML serialization of a comment node. + * Returns an object key for an attribute or namespace declaration. + */ + ObjectWriter.prototype._getAttrKey = function () { + return this._builderOptions.convert.att; + }; + /** + * Returns an object key for the given node type. * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance + * @param nodeType - node type to get a key for */ - BaseWriter.prototype._serializeComment = function (node, requireWellFormed, noDoubleEncoding) { - /** - * If the require well-formed flag is set (its value is true), and node's - * data contains characters that are not matched by the XML Char production - * or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or that - * ends with a "-" (U+002D HYPHEN-MINUS) character, then throw an exception; - * the serialization of this node's data would not be well-formed. - */ - if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || - node.data.indexOf("--") !== -1 || node.data.endsWith("-"))) { - throw new Error("Comment data contains invalid characters (well-formed required)."); + ObjectWriter.prototype._getNodeKey = function (nodeType) { + switch (nodeType) { + case interfaces_1.NodeType.Comment: + return this._builderOptions.convert.comment; + case interfaces_1.NodeType.Text: + return this._builderOptions.convert.text; + case interfaces_1.NodeType.ProcessingInstruction: + return this._builderOptions.convert.ins; + case interfaces_1.NodeType.CData: + return this._builderOptions.convert.cdata; + /* istanbul ignore next */ + default: + throw new Error("Invalid node type."); + } + }; + return ObjectWriter; +}(BaseWriter_1.BaseWriter)); +exports.ObjectWriter = ObjectWriter; +//# sourceMappingURL=ObjectWriter.js.map + +/***/ }), +/* 420 */, +/* 421 */, +/* 422 */, +/* 423 */, +/* 424 */, +/* 425 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; } - /** - * Otherwise, return the concatenation of "". - */ - this.comment(node.data); }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var DOMImpl_1 = __webpack_require__(648); +var DOMException_1 = __webpack_require__(35); +var infra_1 = __webpack_require__(23); +var algorithm_1 = __webpack_require__(163); +/** + * Represents a token set. + */ +var DOMTokenListImpl = /** @class */ (function () { /** - * Produces an XML serialization of a text node. + * Initializes a new instance of `DOMTokenList`. * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - * @param level - current depth of the XML tree + * @param element - associated element + * @param attribute - associated attribute */ - BaseWriter.prototype._serializeText = function (node, requireWellFormed, noDoubleEncoding) { + function DOMTokenListImpl(element, attribute) { /** - * 1. If the require well-formed flag is set (its value is true), and - * node's data contains characters that are not matched by the XML Char - * production, then throw an exception; the serialization of this node's - * data would not be well-formed. + * 1. Let element be associated element. + * 2. Let localName be associated attribute’s local name. + * 3. Let value be the result of getting an attribute value given element + * and localName. + * 4. Run the attribute change steps for element, localName, value, value, + * and null. */ - if (requireWellFormed && !algorithm_1.xml_isLegalChar(node.data)) { - throw new Error("Text data contains invalid characters (well-formed required)."); + this._element = element; + this._attribute = attribute; + this._tokenSet = new Set(); + var localName = attribute._localName; + var value = algorithm_1.element_getAnAttributeValue(element, localName); + // define a closure to be called when the associated attribute's value changes + var thisObj = this; + function updateTokenSet(element, localName, oldValue, value, namespace) { + /** + * 1. If localName is associated attribute’s local name, namespace is null, + * and value is null, then empty token set. + * 2. Otherwise, if localName is associated attribute’s local name, + * namespace is null, then set token set to value, parsed. + */ + if (localName === thisObj._attribute._localName && namespace === null) { + if (!value) + thisObj._tokenSet.clear(); + else + thisObj._tokenSet = algorithm_1.orderedSet_parse(value); + } + } + // add the closure to the associated element's attribute change steps + this._element._attributeChangeSteps.push(updateTokenSet); + if (DOMImpl_1.dom.features.steps) { + algorithm_1.dom_runAttributeChangeSteps(element, localName, value, value, null); } + } + Object.defineProperty(DOMTokenListImpl.prototype, "length", { + /** @inheritdoc */ + get: function () { + /** + * The length attribute' getter must return context object’s token set’s + * size. + */ + return this._tokenSet.size; + }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + DOMTokenListImpl.prototype.item = function (index) { + var e_1, _a; /** - * 2. Let markup be the value of node's data. - * 3. Replace any occurrences of "&" in markup by "&". - * 4. Replace any occurrences of "<" in markup by "<". - * 5. Replace any occurrences of ">" in markup by ">". - * 6. Return the value of markup. + * 1. If index is equal to or greater than context object’s token set’s + * size, then return null. + * 2. Return context object’s token set[index]. */ - var markup = ""; - if (noDoubleEncoding) { - markup = node.data.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>'); + var i = 0; + try { + for (var _b = __values(this._tokenSet), _c = _b.next(); !_c.done; _c = _b.next()) { + var token = _c.value; + if (i === index) + return token; + i++; + } } - else { - for (var i = 0; i < node.data.length; i++) { - var c = node.data[i]; - if (c === "&") - markup += "&"; - else if (c === "<") - markup += "<"; - else if (c === ">") - markup += ">"; - else - markup += c; + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } + finally { if (e_1) throw e_1.error; } } - this.text(markup); + return null; }; - /** - * Produces an XML serialization of a document fragment node. - * - * @param node - node to serialize - * @param namespace - context namespace - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentFragmentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { - var e_6, _a; + /** @inheritdoc */ + DOMTokenListImpl.prototype.contains = function (token) { + /** + * The contains(token) method, when invoked, must return true if context + * object’s token set[token] exists, and false otherwise. + */ + return this._tokenSet.has(token); + }; + /** @inheritdoc */ + DOMTokenListImpl.prototype.add = function () { + var e_2, _a; + var tokens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tokens[_i] = arguments[_i]; + } try { /** - * 1. Let markup the empty string. - * 2. For each child child of node, in tree order, run the XML serialization - * algorithm on the child given namespace, prefix map, a reference to prefix - * index, and flag require well-formed. Concatenate the result to markup. - * 3. Return the value of markup. + * 1. For each token in tokens: + * 1.1. If token is the empty string, then throw a "SyntaxError" + * DOMException. + * 1.2. If token contains any ASCII whitespace, then throw an + * "InvalidCharacterError" DOMException. + * 2. For each token in tokens, append token to context object’s token set. + * 3. Run the update steps. */ - for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + for (var tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) { + var token = tokens_1_1.value; + if (token === '') { + throw new DOMException_1.SyntaxError("Cannot add an empty token."); + } + else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { + throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); + } + else { + this._tokenSet.add(token); + } } } - catch (e_6_1) { e_6 = { error: e_6_1 }; } + catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1); } - finally { if (e_6) throw e_6.error; } + finally { if (e_2) throw e_2.error; } } + algorithm_1.tokenList_updateSteps(this); }; - /** - * Produces an XML serialization of a document fragment node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentFragment = function (node, requireWellFormed, noDoubleEncoding) { - var e_7, _a; + /** @inheritdoc */ + DOMTokenListImpl.prototype.remove = function () { + var e_3, _a; + var tokens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tokens[_i] = arguments[_i]; + } try { /** - * 1. Let markup the empty string. - * 2. For each child child of node, in tree order, run the XML serialization - * algorithm on the child given namespace, prefix map, a reference to prefix - * index, and flag require well-formed. Concatenate the result to markup. - * 3. Return the value of markup. + * 1. For each token in tokens: + * 1.1. If token is the empty string, then throw a "SyntaxError" + * DOMException. + * 1.2. If token contains any ASCII whitespace, then throw an + * "InvalidCharacterError" DOMException. + * 2. For each token in tokens, remove token from context object’s token set. + * 3. Run the update steps. */ - for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var childNode = _c.value; - this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + for (var tokens_2 = __values(tokens), tokens_2_1 = tokens_2.next(); !tokens_2_1.done; tokens_2_1 = tokens_2.next()) { + var token = tokens_2_1.value; + if (token === '') { + throw new DOMException_1.SyntaxError("Cannot remove an empty token."); + } + else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { + throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); + } + else { + this._tokenSet.delete(token); + } } } - catch (e_7_1) { e_7 = { error: e_7_1 }; } + catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2); } - finally { if (e_7) throw e_7.error; } + finally { if (e_3) throw e_3.error; } } + algorithm_1.tokenList_updateSteps(this); }; - /** - * Produces an XML serialization of a document type node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeDocumentType = function (node, requireWellFormed, noDoubleEncoding) { + /** @inheritdoc */ + DOMTokenListImpl.prototype.toggle = function (token, force) { + if (force === void 0) { force = undefined; } /** - * 1. If the require well-formed flag is true and the node's publicId - * attribute contains characters that are not matched by the XML PubidChar - * production, then throw an exception; the serialization of this node - * would not be a well-formed document type declaration. + * 1. If token is the empty string, then throw a "SyntaxError" DOMException. + * 2. If token contains any ASCII whitespace, then throw an + * "InvalidCharacterError" DOMException. */ - if (requireWellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { - throw new Error("DocType public identifier does not match PubidChar construct (well-formed required)."); + if (token === '') { + throw new DOMException_1.SyntaxError("Cannot toggle an empty token."); + } + else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { + throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); } /** - * 2. If the require well-formed flag is true and the node's systemId - * attribute contains characters that are not matched by the XML Char - * production or that contains both a """ (U+0022 QUOTATION MARK) and a - * "'" (U+0027 APOSTROPHE), then throw an exception; the serialization - * of this node would not be a well-formed document type declaration. + * 3. If context object’s token set[token] exists, then: */ - if (requireWellFormed && - (!algorithm_1.xml_isLegalChar(node.systemId) || - (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { - throw new Error("DocType system identifier contains invalid characters (well-formed required)."); + if (this._tokenSet.has(token)) { + /** + * 3.1. If force is either not given or is false, then remove token from + * context object’s token set, run the update steps and return false. + * 3.2. Return true. + */ + if (force === undefined || force === false) { + this._tokenSet.delete(token); + algorithm_1.tokenList_updateSteps(this); + return false; + } + return true; } /** - * 3. Let markup be an empty string. - * 4. Append the string "" (U+003E GREATER-THAN SIGN) to markup. - * 11. Return the value of markup. + * 4. Otherwise, if force not given or is true, append token to context + * object’s token set, run the update steps, and return true. + */ + if (force === undefined || force === true) { + this._tokenSet.add(token); + algorithm_1.tokenList_updateSteps(this); + return true; + } + /** + * 5. Return false. */ - this.docType(node.name, node.publicId, node.systemId); + return false; }; - /** - * Produces an XML serialization of a processing instruction node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeProcessingInstruction = function (node, requireWellFormed, noDoubleEncoding) { + /** @inheritdoc */ + DOMTokenListImpl.prototype.replace = function (token, newToken) { /** - * 1. If the require well-formed flag is set (its value is true), and node's - * target contains a ":" (U+003A COLON) character or is an ASCII - * case-insensitive match for the string "xml", then throw an exception; - * the serialization of this node's target would not be well-formed. + * 1. If either token or newToken is the empty string, then throw a + * "SyntaxError" DOMException. + * 2. If either token or newToken contains any ASCII whitespace, then throw + * an "InvalidCharacterError" DOMException. */ - if (requireWellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { - throw new Error("Processing instruction target contains invalid characters (well-formed required)."); + if (token === '' || newToken === '') { + throw new DOMException_1.SyntaxError("Cannot replace an empty token."); + } + else if (infra_1.codePoint.ASCIIWhiteSpace.test(token) || infra_1.codePoint.ASCIIWhiteSpace.test(newToken)) { + throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); } /** - * 2. If the require well-formed flag is set (its value is true), and node's - * data contains characters that are not matched by the XML Char production - * or contains the string "?>" (U+003F QUESTION MARK, - * U+003E GREATER-THAN SIGN), then throw an exception; the serialization of - * this node's data would not be well-formed. + * 3. If context object’s token set does not contain token, then return + * false. */ - if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || - node.data.indexOf("?>") !== -1)) { - throw new Error("Processing instruction data contains invalid characters (well-formed required)."); - } + if (!this._tokenSet.has(token)) + return false; /** - * 3. Let markup be the concatenation of the following, in the order listed: - * 3.1. "" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN). - * 4. Return the value of markup. + * 4. Replace token in context object’s token set with newToken. + * 5. Run the update steps. + * 6. Return true. */ - this.instruction(node.target, node.data); + infra_1.set.replace(this._tokenSet, token, newToken); + algorithm_1.tokenList_updateSteps(this); + return true; + }; + /** @inheritdoc */ + DOMTokenListImpl.prototype.supports = function (token) { + /** + * 1. Let result be the return value of validation steps called with token. + * 2. Return result. + */ + return algorithm_1.tokenList_validationSteps(this, token); }; + Object.defineProperty(DOMTokenListImpl.prototype, "value", { + /** @inheritdoc */ + get: function () { + /** + * The value attribute must return the result of running context object’s + * serialize steps. + */ + return algorithm_1.tokenList_serializeSteps(this); + }, + set: function (value) { + /** + * Setting the value attribute must set an attribute value for the + * associated element using associated attribute’s local name and the given + * value. + */ + algorithm_1.element_setAnAttributeValue(this._element, this._attribute._localName, value); + }, + enumerable: true, + configurable: true + }); /** - * Produces an XML serialization of a CDATA node. + * Returns an iterator for the token set. + */ + DOMTokenListImpl.prototype[Symbol.iterator] = function () { + var it = this._tokenSet[Symbol.iterator](); + return { + next: function () { + return it.next(); + } + }; + }; + /** + * Creates a new `DOMTokenList`. * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance + * @param element - associated element + * @param attribute - associated attribute */ - BaseWriter.prototype._serializeCData = function (node, requireWellFormed, noDoubleEncoding) { - if (requireWellFormed && (node.data.indexOf("]]>") !== -1)) { - throw new Error("CDATA contains invalid characters (well-formed required)."); - } - this.cdata(node.data); + DOMTokenListImpl._create = function (element, attribute) { + return new DOMTokenListImpl(element, attribute); }; + return DOMTokenListImpl; +}()); +exports.DOMTokenListImpl = DOMTokenListImpl; +//# sourceMappingURL=DOMTokenListImpl.js.map + +/***/ }), +/* 426 */, +/* 427 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var interfaces_1 = __webpack_require__(970); +var algorithm_1 = __webpack_require__(163); +var WebIDLAlgorithm_1 = __webpack_require__(495); +/** + * Represents a DOM event. + */ +var EventImpl = /** @class */ (function () { /** - * Produces an XML serialization of the attributes of an element node. - * - * @param node - node to serialize - * @param map - namespace prefix map - * @param prefixIndex - generated namespace prefix index - * @param localPrefixesMap - local prefixes map - * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace - * attributes - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeAttributesNS = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding) { - var e_8, _a; + * Initializes a new instance of `Event`. + */ + function EventImpl(type, eventInit) { + this._target = null; + this._relatedTarget = null; + this._touchTargetList = []; + this._path = []; + this._currentTarget = null; + this._eventPhase = interfaces_1.EventPhase.None; + this._stopPropagationFlag = false; + this._stopImmediatePropagationFlag = false; + this._canceledFlag = false; + this._inPassiveListenerFlag = false; + this._composedFlag = false; + this._initializedFlag = false; + this._dispatchFlag = false; + this._isTrusted = false; + this._bubbles = false; + this._cancelable = false; /** - * 1. Let result be the empty string. - * 2. Let localname set be a new empty namespace localname set. This - * localname set will contain tuples of unique attribute namespaceURI and - * localName pairs, and is populated as each attr is processed. This set is - * used to [optionally] enforce the well-formed constraint that an element - * cannot have two attributes with the same namespaceURI and localName. - * This can occur when two otherwise identical attributes on the same - * element differ only by their prefix values. + * When a constructor of the Event interface, or of an interface that + * inherits from the Event interface, is invoked, these steps must be run, + * given the arguments type and eventInitDict: + * 1. Let event be the result of running the inner event creation steps with + * this interface, null, now, and eventInitDict. + * 2. Initialize event’s type attribute to type. + * 3. Return event. */ - var result = []; - var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; - try { - /** - * 3. Loop: For each attribute attr in element's attributes, in the order - * they are specified in the element's attribute list: - */ - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - // Optimize common case - if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { - result.push([null, null, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - continue; - } - /** - * 3.1. If the require well-formed flag is set (its value is true), and the - * localname set contains a tuple whose values match those of a new tuple - * consisting of attr's namespaceURI attribute and localName attribute, - * then throw an exception; the serialization of this attr would fail to - * produce a well-formed element serialization. - */ - if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { - throw new Error("Element contains duplicate attributes (well-formed required)."); - } - /** - * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and - * localName attribute, and add it to the localname set. - * 3.3. Let attribute namespace be the value of attr's namespaceURI value. - * 3.4. Let candidate prefix be null. - */ - if (requireWellFormed && localNameSet) - localNameSet.set(attr.namespaceURI, attr.localName); - var attributeNamespace = attr.namespaceURI; - var candidatePrefix = null; - /** 3.5. If attribute namespace is not null, then run these sub-steps: */ - if (attributeNamespace !== null) { - /** - * 3.5.1. Let candidate prefix be the result of retrieving a preferred - * prefix string from map given namespace attribute namespace with - * preferred prefix being attr's prefix value. - */ - candidatePrefix = map.get(attr.prefix, attributeNamespace); - /** - * 3.5.2. If the value of attribute namespace is the XMLNS namespace, - * then run these steps: - */ - if (attributeNamespace === infra_1.namespace.XMLNS) { - /** - * 3.5.2.1. If any of the following are true, then stop running these - * steps and goto Loop to visit the next attribute: - * - the attr's value is the XML namespace; - * _Note:_ The XML namespace cannot be redeclared and survive - * round-tripping (unless it defines the prefix "xml"). To avoid this - * problem, this algorithm always prefixes elements in the XML - * namespace with "xml" and drops any related definitions as seen - * in the above condition. - * - the attr's prefix is null and the ignore namespace definition - * attribute flag is true (the Element's default namespace attribute - * should be skipped); - * - the attr's prefix is not null and either - * * the attr's localName is not a key contained in the local - * prefixes map, or - * * the attr's localName is present in the local prefixes map but - * the value of the key does not match attr's value - * and furthermore that the attr's localName (as the prefix to find) - * is found in the namespace prefix map given the namespace consisting - * of the attr's value (the current namespace prefix definition was - * exactly defined previously--on an ancestor element not the current - * element whose attributes are being processed). - */ - if (attr.value === infra_1.namespace.XML || - (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || - (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || - localPrefixesMap[attr.localName] !== attr.value) && - map.has(attr.localName, attr.value))) - continue; - /** - * 3.5.2.2. If the require well-formed flag is set (its value is true), - * and the value of attr's value attribute matches the XMLNS - * namespace, then throw an exception; the serialization of this - * attribute would produce invalid XML because the XMLNS namespace - * is reserved and cannot be applied as an element's namespace via - * XML parsing. - * - * _Note:_ DOM APIs do allow creation of elements in the XMLNS - * namespace but with strict qualifications. - */ - if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { - throw new Error("XMLNS namespace is reserved (well-formed required)."); - } - /** - * 3.5.2.3. If the require well-formed flag is set (its value is true), - * and the value of attr's value attribute is the empty string, then - * throw an exception; namespace prefix declarations cannot be used - * to undeclare a namespace (use a default namespace declaration - * instead). - */ - if (requireWellFormed && attr.value === '') { - throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required)."); - } - /** - * 3.5.2.4. the attr's prefix matches the string "xmlns", then let - * candidate prefix be the string "xmlns". - */ - if (attr.prefix === 'xmlns') - candidatePrefix = 'xmlns'; - /** - * 3.5.3. Otherwise, the attribute namespace is not the XMLNS namespace. - * Run these steps: - * - * _Note:_ The (candidatePrefix === null) check is not in the spec. - * We deviate from the spec here. Otherwise a prefix is generated for - * all attributes with namespaces. - */ - } - else if (candidatePrefix === null) { - if (attr.prefix !== null && - (!map.hasPrefix(attr.prefix) || - map.has(attr.prefix, attributeNamespace))) { - /** - * Check if we can use the attribute's own prefix. - * We deviate from the spec here. - * TODO: This is not an efficient way of searching for prefixes. - * Follow developments to the spec. - */ - candidatePrefix = attr.prefix; - } - else { - /** - * 3.5.3.1. Let candidate prefix be the result of generating a prefix - * providing map, attribute namespace, and prefix index as input. - */ - candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); - } - /** - * 3.5.3.2. Append the following to result, in the order listed: - * 3.5.3.2.1. " " (U+0020 SPACE); - * 3.5.3.2.2. The string "xmlns:"; - * 3.5.3.2.3. The value of candidate prefix; - * 3.5.3.2.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 3.5.3.2.5. The result of serializing an attribute value given - * attribute namespace and the require well-formed flag as input; - * 3.5.3.2.6. """ (U+0022 QUOTATION MARK). - */ - result.push([null, "xmlns", candidatePrefix, - this._serializeAttributeValue(attributeNamespace, requireWellFormed, noDoubleEncoding)]); - } - } - /** - * 3.6. Append a " " (U+0020 SPACE) to result. - * 3.7. If candidate prefix is not null, then append to result the - * concatenation of candidate prefix with ":" (U+003A COLON). - */ - var attrName = ''; - if (candidatePrefix !== null) { - attrName = candidatePrefix; - } - /** - * 3.8. If the require well-formed flag is set (its value is true), and - * this attr's localName attribute contains the character - * ":" (U+003A COLON) or does not match the XML Name production or - * equals "xmlns" and attribute namespace is null, then throw an - * exception; the serialization of this attr would not be a - * well-formed attribute. - */ - if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(attr.localName) || - (attr.localName === "xmlns" && attributeNamespace === null))) { - throw new Error("Attribute local name contains invalid characters (well-formed required)."); - } - /** - * 3.9. Append the following strings to result, in the order listed: - * 3.9.1. The value of attr's localName; - * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 3.9.3. The result of serializing an attribute value given attr's value - * attribute and the require well-formed flag as input; - * 3.9.4. """ (U+0022 QUOTATION MARK). - */ - result.push([attributeNamespace, candidatePrefix, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - } - } - catch (e_8_1) { e_8 = { error: e_8_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_8) throw e_8.error; } + this._type = type; + if (eventInit) { + this._bubbles = eventInit.bubbles || false; + this._cancelable = eventInit.cancelable || false; + this._composedFlag = eventInit.composed || false; } + this._initializedFlag = true; + this._timeStamp = new Date().getTime(); + } + Object.defineProperty(EventImpl.prototype, "type", { + /** @inheritdoc */ + get: function () { return this._type; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "target", { + /** @inheritdoc */ + get: function () { return this._target; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "srcElement", { + /** @inheritdoc */ + get: function () { return this._target; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "currentTarget", { + /** @inheritdoc */ + get: function () { return this._currentTarget; }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.composedPath = function () { /** - * 4. Return the value of result. + * 1. Let composedPath be an empty list. + * 2. Let path be the context object’s path. + * 3. If path is empty, then return composedPath. + * 4. Let currentTarget be the context object’s currentTarget attribute + * value. + * 5. Append currentTarget to composedPath. + * 6. Let currentTargetIndex be 0. + * 7. Let currentTargetHiddenSubtreeLevel be 0. */ - return result; - }; - /** - * Produces an XML serialization of the attributes of an element node. - * - * @param node - node to serialize - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeAttributes = function (node, requireWellFormed, noDoubleEncoding) { - var e_9, _a; + var composedPath = []; + var path = this._path; + if (path.length === 0) + return composedPath; + var currentTarget = this._currentTarget; + if (currentTarget === null) { + throw new Error("Event currentTarget is null."); + } + composedPath.push(currentTarget); + var currentTargetIndex = 0; + var currentTargetHiddenSubtreeLevel = 0; /** - * 1. Let result be the empty string. - * 2. Let localname set be a new empty namespace localname set. This - * localname set will contain tuples of unique attribute namespaceURI and - * localName pairs, and is populated as each attr is processed. This set is - * used to [optionally] enforce the well-formed constraint that an element - * cannot have two attributes with the same namespaceURI and localName. - * This can occur when two otherwise identical attributes on the same - * element differ only by their prefix values. + * 8. Let index be path’s size − 1. + * 9. While index is greater than or equal to 0: */ - var result = []; - var localNameSet = requireWellFormed ? {} : undefined; - try { + var index = path.length - 1; + while (index >= 0) { /** - * 3. Loop: For each attribute attr in element's attributes, in the order - * they are specified in the element's attribute list: + * 9.1. If path[index]'s root-of-closed-tree is true, then increase + * currentTargetHiddenSubtreeLevel by 1. + * 9.2. If path[index]'s invocation target is currentTarget, then set + * currentTargetIndex to index and break. + * 9.3. If path[index]'s slot-in-closed-tree is true, then decrease + * currentTargetHiddenSubtreeLevel by 1. + * 9.4. Decrease index by 1. */ - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - // Optimize common case - if (!requireWellFormed) { - result.push([null, null, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); - continue; - } - /** - * 3.1. If the require well-formed flag is set (its value is true), and the - * localname set contains a tuple whose values match those of a new tuple - * consisting of attr's namespaceURI attribute and localName attribute, - * then throw an exception; the serialization of this attr would fail to - * produce a well-formed element serialization. - */ - if (requireWellFormed && localNameSet && (attr.localName in localNameSet)) { - throw new Error("Element contains duplicate attributes (well-formed required)."); - } - /** - * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and - * localName attribute, and add it to the localname set. - * 3.3. Let attribute namespace be the value of attr's namespaceURI value. - * 3.4. Let candidate prefix be null. - */ - /* istanbul ignore else */ - if (requireWellFormed && localNameSet) - localNameSet[attr.localName] = true; - /** 3.5. If attribute namespace is not null, then run these sub-steps: */ - /** - * 3.6. Append a " " (U+0020 SPACE) to result. - * 3.7. If candidate prefix is not null, then append to result the - * concatenation of candidate prefix with ":" (U+003A COLON). - */ - /** - * 3.8. If the require well-formed flag is set (its value is true), and - * this attr's localName attribute contains the character - * ":" (U+003A COLON) or does not match the XML Name production or - * equals "xmlns" and attribute namespace is null, then throw an - * exception; the serialization of this attr would not be a - * well-formed attribute. - */ - if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(attr.localName))) { - throw new Error("Attribute local name contains invalid characters (well-formed required)."); - } - /** - * 3.9. Append the following strings to result, in the order listed: - * 3.9.1. The value of attr's localName; - * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); - * 3.9.3. The result of serializing an attribute value given attr's value - * attribute and the require well-formed flag as input; - * 3.9.4. """ (U+0022 QUOTATION MARK). - */ - result.push([null, null, attr.localName, - this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + if (path[index].rootOfClosedTree) { + currentTargetHiddenSubtreeLevel++; } - } - catch (e_9_1) { e_9 = { error: e_9_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + if (path[index].invocationTarget === currentTarget) { + currentTargetIndex = index; + break; } - finally { if (e_9) throw e_9.error; } + if (path[index].slotInClosedTree) { + currentTargetHiddenSubtreeLevel--; + } + index--; } /** - * 4. Return the value of result. + * 10. Let currentHiddenLevel and maxHiddenLevel be + * currentTargetHiddenSubtreeLevel. */ - return result; - }; - /** - * Records namespace information for the given element and returns the - * default namespace attribute value. - * - * @param node - element node to process - * @param map - namespace prefix map - * @param localPrefixesMap - local prefixes map - */ - BaseWriter.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { - var e_10, _a; + var currentHiddenLevel = currentTargetHiddenSubtreeLevel; + var maxHiddenLevel = currentTargetHiddenSubtreeLevel; /** - * 1. Let default namespace attr value be null. + * 11. Set index to currentTargetIndex − 1. + * 12. While index is greater than or equal to 0: */ - var defaultNamespaceAttrValue = null; - try { + index = currentTargetIndex - 1; + while (index >= 0) { /** - * 2. Main: For each attribute attr in element's attributes, in the order - * they are specified in the element's attribute list: + * 12.1. If path[index]'s root-of-closed-tree is true, then increase + * currentHiddenLevel by 1. + * 12.2. If currentHiddenLevel is less than or equal to maxHiddenLevel, + * then prepend path[index]'s invocation target to composedPath. */ - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; + if (path[index].rootOfClosedTree) { + currentHiddenLevel++; + } + if (currentHiddenLevel <= maxHiddenLevel) { + composedPath.unshift(path[index].invocationTarget); + } + /** + * 12.3. If path[index]'s slot-in-closed-tree is true, then: + */ + if (path[index].slotInClosedTree) { /** - * _Note:_ The following conditional steps find namespace prefixes. Only - * attributes in the XMLNS namespace are considered (e.g., attributes made - * to look like namespace declarations via - * setAttribute("xmlns:pretend-prefix", "pretend-namespace") are not - * included). + * 12.3.1. Decrease currentHiddenLevel by 1. + * 12.3.2. If currentHiddenLevel is less than maxHiddenLevel, then set + * maxHiddenLevel to currentHiddenLevel. */ - /** 2.1. Let attribute namespace be the value of attr's namespaceURI value. */ - var attributeNamespace = attr.namespaceURI; - /** 2.2. Let attribute prefix be the value of attr's prefix. */ - var attributePrefix = attr.prefix; - /** 2.3. If the attribute namespace is the XMLNS namespace, then: */ - if (attributeNamespace === infra_1.namespace.XMLNS) { - /** - * 2.3.1. If attribute prefix is null, then attr is a default namespace - * declaration. Set the default namespace attr value to attr's value and - * stop running these steps, returning to Main to visit the next - * attribute. - */ - if (attributePrefix === null) { - defaultNamespaceAttrValue = attr.value; - continue; - /** - * 2.3.2. Otherwise, the attribute prefix is not null and attr is a - * namespace prefix definition. Run the following steps: - */ - } - else { - /** 2.3.2.1. Let prefix definition be the value of attr's localName. */ - var prefixDefinition = attr.localName; - /** 2.3.2.2. Let namespace definition be the value of attr's value. */ - var namespaceDefinition = attr.value; - /** - * 2.3.2.3. If namespace definition is the XML namespace, then stop - * running these steps, and return to Main to visit the next - * attribute. - * - * _Note:_ XML namespace definitions in prefixes are completely - * ignored (in order to avoid unnecessary work when there might be - * prefix conflicts). XML namespaced elements are always handled - * uniformly by prefixing (and overriding if necessary) the element's - * localname with the reserved "xml" prefix. - */ - if (namespaceDefinition === infra_1.namespace.XML) { - continue; - } - /** - * 2.3.2.4. If namespace definition is the empty string (the - * declarative form of having no namespace), then let namespace - * definition be null instead. - */ - if (namespaceDefinition === '') { - namespaceDefinition = null; - } - /** - * 2.3.2.5. If prefix definition is found in map given the namespace - * namespace definition, then stop running these steps, and return to - * Main to visit the next attribute. - * - * _Note:_ This step avoids adding duplicate prefix definitions for - * the same namespace in the map. This has the side-effect of avoiding - * later serialization of duplicate namespace prefix declarations in - * any descendant nodes. - */ - if (map.has(prefixDefinition, namespaceDefinition)) { - continue; - } - /** - * 2.3.2.6. Add the prefix prefix definition to map given namespace - * namespace definition. - */ - map.set(prefixDefinition, namespaceDefinition); - /** - * 2.3.2.7. Add the value of prefix definition as a new key to the - * local prefixes map, with the namespace definition as the key's - * value replacing the value of null with the empty string if - * applicable. - */ - localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; - } + currentHiddenLevel--; + if (currentHiddenLevel < maxHiddenLevel) { + maxHiddenLevel = currentHiddenLevel; } } - } - catch (e_10_1) { e_10 = { error: e_10_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_10) throw e_10.error; } + /** + * 12.4. Decrease index by 1. + */ + index--; } /** - * 3. Return the value of default namespace attr value. - * - * _Note:_ The empty string is a legitimate return value and is not - * converted to null. + * 13. Set currentHiddenLevel and maxHiddenLevel to + * currentTargetHiddenSubtreeLevel. */ - return defaultNamespaceAttrValue; - }; - /** - * Generates a new prefix for the given namespace. - * - * @param newNamespace - a namespace to generate prefix for - * @param prefixMap - namespace prefix map - * @param prefixIndex - generated namespace prefix index - */ - BaseWriter.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { + currentHiddenLevel = currentTargetHiddenSubtreeLevel; + maxHiddenLevel = currentTargetHiddenSubtreeLevel; /** - * 1. Let generated prefix be the concatenation of the string "ns" and the - * current numerical value of prefix index. - * 2. Let the value of prefix index be incremented by one. - * 3. Add to map the generated prefix given the new namespace namespace. - * 4. Return the value of generated prefix. + * 14. Set index to currentTargetIndex + 1. + * 15. While index is less than path’s size: */ - var generatedPrefix = "ns" + prefixIndex.value.toString(); - prefixIndex.value++; - prefixMap.set(generatedPrefix, newNamespace); - return generatedPrefix; - }; - /** - * Produces an XML serialization of an attribute value. - * - * @param value - attribute value - * @param requireWellFormed - whether to check conformance - */ - BaseWriter.prototype._serializeAttributeValue = function (value, requireWellFormed, noDoubleEncoding) { + index = currentTargetIndex + 1; + while (index < path.length) { + /** + * 15.1. If path[index]'s slot-in-closed-tree is true, then increase + * currentHiddenLevel by 1. + * 15.2. If currentHiddenLevel is less than or equal to maxHiddenLevel, + * then append path[index]'s invocation target to composedPath. + */ + if (path[index].slotInClosedTree) { + currentHiddenLevel++; + } + if (currentHiddenLevel <= maxHiddenLevel) { + composedPath.push(path[index].invocationTarget); + } + /** + * 15.3. If path[index]'s root-of-closed-tree is true, then: + */ + if (path[index].rootOfClosedTree) { + /** + * 15.3.1. Decrease currentHiddenLevel by 1. + * 15.3.2. If currentHiddenLevel is less than maxHiddenLevel, then set + * maxHiddenLevel to currentHiddenLevel. + */ + currentHiddenLevel--; + if (currentHiddenLevel < maxHiddenLevel) { + maxHiddenLevel = currentHiddenLevel; + } + } + /** + * 15.4. Increase index by 1. + */ + index++; + } /** - * From: https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value - * - * 1. If the require well-formed flag is set (its value is true), and - * attribute value contains characters that are not matched by the XML Char - * production, then throw an exception; the serialization of this attribute - * value would fail to produce a well-formed element serialization. + * 16. Return composedPath. */ - if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { - throw new Error("Invalid characters in attribute value."); - } + return composedPath; + }; + Object.defineProperty(EventImpl.prototype, "eventPhase", { + /** @inheritdoc */ + get: function () { return this._eventPhase; }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.stopPropagation = function () { this._stopPropagationFlag = true; }; + Object.defineProperty(EventImpl.prototype, "cancelBubble", { + /** @inheritdoc */ + get: function () { return this._stopPropagationFlag; }, + set: function (value) { if (value) + this.stopPropagation(); }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.stopImmediatePropagation = function () { + this._stopPropagationFlag = true; + this._stopImmediatePropagationFlag = true; + }; + Object.defineProperty(EventImpl.prototype, "bubbles", { + /** @inheritdoc */ + get: function () { return this._bubbles; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "cancelable", { + /** @inheritdoc */ + get: function () { return this._cancelable; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "returnValue", { + /** @inheritdoc */ + get: function () { return !this._canceledFlag; }, + set: function (value) { + if (!value) { + algorithm_1.event_setTheCanceledFlag(this); + } + }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.preventDefault = function () { + algorithm_1.event_setTheCanceledFlag(this); + }; + Object.defineProperty(EventImpl.prototype, "defaultPrevented", { + /** @inheritdoc */ + get: function () { return this._canceledFlag; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "composed", { + /** @inheritdoc */ + get: function () { return this._composedFlag; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "isTrusted", { + /** @inheritdoc */ + get: function () { return this._isTrusted; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "timeStamp", { + /** @inheritdoc */ + get: function () { return this._timeStamp; }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.initEvent = function (type, bubbles, cancelable) { + if (bubbles === void 0) { bubbles = false; } + if (cancelable === void 0) { cancelable = false; } /** - * 2. If attribute value is null, then return the empty string. + * 1. If the context object’s dispatch flag is set, then return. */ - if (value === null) - return ""; + if (this._dispatchFlag) + return; /** - * 3. Otherwise, attribute value is a string. Return the value of attribute - * value, first replacing any occurrences of the following: - * - "&" with "&" - * - """ with """ - * - "<" with "<" - * - ">" with ">" - * NOTE - * This matches behavior present in browsers, and goes above and beyond the - * grammar requirement in the XML specification's AttValue production by - * also replacing ">" characters. + * 2. Initialize the context object with type, bubbles, and cancelable. */ - if (noDoubleEncoding) { - return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); - } - else { - var result = ""; - for (var i = 0; i < value.length; i++) { - var c = value[i]; - if (c === "\"") - result += """; - else if (c === "&") - result += "&"; - else if (c === "<") - result += "<"; - else if (c === ">") - result += ">"; - else - result += c; - } - return result; - } + algorithm_1.event_initialize(this, type, bubbles, cancelable); }; - BaseWriter._VoidElementNames = new Set(['area', 'base', 'basefont', - 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', - 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); - return BaseWriter; + EventImpl.NONE = 0; + EventImpl.CAPTURING_PHASE = 1; + EventImpl.AT_TARGET = 2; + EventImpl.BUBBLING_PHASE = 3; + return EventImpl; }()); -exports.BaseWriter = BaseWriter; -//# sourceMappingURL=BaseWriter.js.map +exports.EventImpl = EventImpl; +/** + * Define constants on prototype. + */ +WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "NONE", 0); +WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "CAPTURING_PHASE", 1); +WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "AT_TARGET", 2); +WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "BUBBLING_PHASE", 3); +//# sourceMappingURL=EventImpl.js.map /***/ }), -/* 463 */, -/* 464 */ +/* 428 */, +/* 429 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var interfaces_1 = __webpack_require__(970); -var DOMException_1 = __webpack_require__(35); +var algorithm_1 = __webpack_require__(163); /** - * Applies the filter to the given node and returns the result. - * - * @param traverser - the `NodeIterator` or `TreeWalker` instance - * @param node - the node to filter + * Represents a mixin that allows nodes to become the contents of + * a element. This mixin is implemented by {@link Element} and + * {@link Text}. */ -function traversal_filter(traverser, node) { - /** - * 1. If traverser’s active flag is set, then throw an "InvalidStateError" - * DOMException. - */ - if (traverser._activeFlag) { - throw new DOMException_1.InvalidStateError(); - } - /** - * 2. Let n be node’s nodeType attribute value − 1. - */ - var n = node._nodeType - 1; - /** - * 3. If the nth bit (where 0 is the least significant bit) of traverser’s - * whatToShow is not set, then return FILTER_SKIP. - */ - var mask = 1 << n; - if ((traverser.whatToShow & mask) === 0) { - return interfaces_1.FilterResult.Skip; - } - /** - * 4. If traverser’s filter is null, then return FILTER_ACCEPT. - */ - if (!traverser.filter) { - return interfaces_1.FilterResult.Accept; +var SlotableImpl = /** @class */ (function () { + function SlotableImpl() { } - /** - * 5. Set traverser’s active flag. - */ - traverser._activeFlag = true; - /** - * 6. Let result be the return value of call a user object’s operation with - * traverser’s filter, "acceptNode", and « node ». If this throws an - * exception, then unset traverser’s active flag and rethrow the exception. - */ - var result = interfaces_1.FilterResult.Reject; - try { - result = traverser.filter.acceptNode(node); + Object.defineProperty(SlotableImpl.prototype, "_name", { + get: function () { return this.__name || ''; }, + set: function (val) { this.__name = val; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SlotableImpl.prototype, "_assignedSlot", { + get: function () { return this.__assignedSlot || null; }, + set: function (val) { this.__assignedSlot = val; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(SlotableImpl.prototype, "assignedSlot", { + /** @inheritdoc */ + get: function () { + return algorithm_1.shadowTree_findASlot(this, true); + }, + enumerable: true, + configurable: true + }); + return SlotableImpl; +}()); +exports.SlotableImpl = SlotableImpl; +//# sourceMappingURL=SlotableImpl.js.map + +/***/ }), +/* 430 */, +/* 431 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +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; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); +/** + * Commands + * + * Command Format: + * ::name key=value,key=value::message + * + * Examples: + * ::warning::This is the message + * ::set-env name=MY_VAR::some value + */ +function issueCommand(command, properties, message) { + const cmd = new Command(command, properties, message); + process.stdout.write(cmd.toString() + os.EOL); +} +exports.issueCommand = issueCommand; +function issue(name, message = '') { + issueCommand(name, {}, message); +} +exports.issue = issue; +const CMD_STRING = '::'; +class Command { + constructor(command, properties, message) { + if (!command) { + command = 'missing.command'; + } + this.command = command; + this.properties = properties; + this.message = message; } - catch (err) { - traverser._activeFlag = false; - throw err; + toString() { + let cmdStr = CMD_STRING + this.command; + if (this.properties && Object.keys(this.properties).length > 0) { + cmdStr += ' '; + let first = true; + for (const key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + const val = this.properties[key]; + if (val) { + if (first) { + first = false; + } + else { + cmdStr += ','; + } + cmdStr += `${key}=${escapeProperty(val)}`; + } + } + } + } + cmdStr += `${CMD_STRING}${escapeData(this.message)}`; + return cmdStr; } - /** - * 7. Unset traverser’s active flag. - * 8. Return result. - */ - traverser._activeFlag = false; - return result; } -exports.traversal_filter = traversal_filter; -//# sourceMappingURL=TraversalAlgorithm.js.map +function escapeData(s) { + return utils_1.toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A'); +} +function escapeProperty(s) { + return utils_1.toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A') + .replace(/:/g, '%3A') + .replace(/,/g, '%2C'); +} +//# sourceMappingURL=command.js.map /***/ }), -/* 465 */, -/* 466 */, -/* 467 */, -/* 468 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/* 432 */, +/* 433 */, +/* 434 */, +/* 435 */, +/* 436 */, +/* 437 */, +/* 438 */, +/* 439 */, +/* 440 */, +/* 441 */, +/* 442 */ +/***/ (function(__unusedmodule, exports) { "use strict"; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Determines if the given string is valid for a `"Name"` construct. + * + * @param name - name string to test + */ +function xml_isName(name) { + for (var i = 0; i < name.length; i++) { + var n = name.charCodeAt(i); + // NameStartChar + if ((n >= 97 && n <= 122) || // [a-z] + (n >= 65 && n <= 90) || // [A-Z] + n === 58 || n === 95 || // ':' or '_' + (n >= 0xC0 && n <= 0xD6) || + (n >= 0xD8 && n <= 0xF6) || + (n >= 0xF8 && n <= 0x2FF) || + (n >= 0x370 && n <= 0x37D) || + (n >= 0x37F && n <= 0x1FFF) || + (n >= 0x200C && n <= 0x200D) || + (n >= 0x2070 && n <= 0x218F) || + (n >= 0x2C00 && n <= 0x2FEF) || + (n >= 0x3001 && n <= 0xD7FF) || + (n >= 0xF900 && n <= 0xFDCF) || + (n >= 0xFDF0 && n <= 0xFFFD)) { + continue; } - finally { if (e) throw e.error; } - } - return ar; -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; + else if (i !== 0 && + (n === 45 || n === 46 || // '-' or '.' + (n >= 48 && n <= 57) || // [0-9] + (n === 0xB7) || + (n >= 0x0300 && n <= 0x036F) || + (n >= 0x203F && n <= 0x2040))) { + continue; } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var XMLStringLexer_1 = __webpack_require__(911); -var interfaces_1 = __webpack_require__(172); -var infra_1 = __webpack_require__(23); -var algorithm_1 = __webpack_require__(163); -var LocalNameSet_1 = __webpack_require__(575); + if (n >= 0xD800 && n <= 0xDBFF && i < name.length - 1) { + var n2 = name.charCodeAt(i + 1); + if (n2 >= 0xDC00 && n2 <= 0xDFFF) { + n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; + i++; + if (n >= 0x10000 && n <= 0xEFFFF) { + continue; + } + } + } + return false; + } + return true; +} +exports.xml_isName = xml_isName; /** - * Represents a parser for XML content. + * Determines if the given string is valid for a `"QName"` construct. * - * See: https://html.spec.whatwg.org/#xml-parser + * @param name - name string to test */ -var XMLParserImpl = /** @class */ (function () { - function XMLParserImpl() { +function xml_isQName(name) { + var colonFound = false; + for (var i = 0; i < name.length; i++) { + var n = name.charCodeAt(i); + // NameStartChar + if ((n >= 97 && n <= 122) || // [a-z] + (n >= 65 && n <= 90) || // [A-Z] + n === 95 || // '_' + (n >= 0xC0 && n <= 0xD6) || + (n >= 0xD8 && n <= 0xF6) || + (n >= 0xF8 && n <= 0x2FF) || + (n >= 0x370 && n <= 0x37D) || + (n >= 0x37F && n <= 0x1FFF) || + (n >= 0x200C && n <= 0x200D) || + (n >= 0x2070 && n <= 0x218F) || + (n >= 0x2C00 && n <= 0x2FEF) || + (n >= 0x3001 && n <= 0xD7FF) || + (n >= 0xF900 && n <= 0xFDCF) || + (n >= 0xFDF0 && n <= 0xFFFD)) { + continue; + } + else if (i !== 0 && + (n === 45 || n === 46 || // '-' or '.' + (n >= 48 && n <= 57) || // [0-9] + (n === 0xB7) || + (n >= 0x0300 && n <= 0x036F) || + (n >= 0x203F && n <= 0x2040))) { + continue; + } + else if (i !== 0 && n === 58) { // : + if (colonFound) + return false; // multiple colons in qname + if (i === name.length - 1) + return false; // colon at the end of qname + colonFound = true; + continue; + } + if (n >= 0xD800 && n <= 0xDBFF && i < name.length - 1) { + var n2 = name.charCodeAt(i + 1); + if (n2 >= 0xDC00 && n2 <= 0xDFFF) { + n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; + i++; + if (n >= 0x10000 && n <= 0xEFFFF) { + continue; + } + } + } + return false; } - /** - * Parses XML content. - * - * @param source - a string containing XML content - */ - XMLParserImpl.prototype.parse = function (source) { - var e_1, _a, e_2, _b; - var lexer = new XMLStringLexer_1.XMLStringLexer(source, { skipWhitespaceOnlyText: true }); - var doc = algorithm_1.create_document(); - var context = doc; - var token = lexer.nextToken(); - while (token.type !== interfaces_1.TokenType.EOF) { - switch (token.type) { - case interfaces_1.TokenType.Declaration: - var declaration = token; - if (declaration.version !== "1.0") { - throw new Error("Invalid xml version: " + declaration.version); - } - break; - case interfaces_1.TokenType.DocType: - var doctype = token; - if (!algorithm_1.xml_isPubidChar(doctype.pubId)) { - throw new Error("DocType public identifier does not match PubidChar construct."); - } - if (!algorithm_1.xml_isLegalChar(doctype.sysId) || - (doctype.sysId.indexOf('"') !== -1 && doctype.sysId.indexOf("'") !== -1)) { - throw new Error("DocType system identifier contains invalid characters."); - } - context.appendChild(doc.implementation.createDocumentType(doctype.name, doctype.pubId, doctype.sysId)); - break; - case interfaces_1.TokenType.CDATA: - var cdata = token; - if (!algorithm_1.xml_isLegalChar(cdata.data) || - cdata.data.indexOf("]]>") !== -1) { - throw new Error("CDATA contains invalid characters."); - } - context.appendChild(doc.createCDATASection(cdata.data)); - break; - case interfaces_1.TokenType.Comment: - var comment = token; - if (!algorithm_1.xml_isLegalChar(comment.data) || - comment.data.indexOf("--") !== -1 || comment.data.endsWith("-")) { - throw new Error("Comment data contains invalid characters."); - } - context.appendChild(doc.createComment(comment.data)); - break; - case interfaces_1.TokenType.PI: - var pi = token; - if (pi.target.indexOf(":") !== -1 || (/^xml$/i).test(pi.target)) { - throw new Error("Processing instruction target contains invalid characters."); - } - if (!algorithm_1.xml_isLegalChar(pi.data) || pi.data.indexOf("?>") !== -1) { - throw new Error("Processing instruction data contains invalid characters."); - } - context.appendChild(doc.createProcessingInstruction(pi.target, pi.data)); - break; - case interfaces_1.TokenType.Text: - var text = token; - if (!algorithm_1.xml_isLegalChar(text.data)) { - throw new Error("Text data contains invalid characters."); - } - context.appendChild(doc.createTextNode(text.data)); - break; - case interfaces_1.TokenType.Element: - var element = token; - // inherit namespace from parent - var _c = __read(algorithm_1.namespace_extractQName(element.name), 2), prefix = _c[0], localName = _c[1]; - if (localName.indexOf(":") !== -1 || !algorithm_1.xml_isName(localName)) { - throw new Error("Node local name contains invalid characters."); - } - if (prefix === "xmlns") { - throw new Error("An element cannot have the 'xmlns' prefix."); - } - var namespace = context.lookupNamespaceURI(prefix); - // override namespace if there is a namespace declaration - // attribute - // also lookup namespace declaration attributes - var nsDeclarations = {}; - try { - for (var _d = (e_1 = void 0, __values(element.attributes)), _e = _d.next(); !_e.done; _e = _d.next()) { - var _f = __read(_e.value, 2), attName = _f[0], attValue = _f[1]; - if (attName === "xmlns") { - namespace = attValue; - } - else { - var _g = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _g[0], attLocalName = _g[1]; - if (attPrefix === "xmlns") { - if (attLocalName === prefix) { - namespace = attValue; - } - nsDeclarations[attLocalName] = attValue; - } - } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_e && !_e.done && (_a = _d.return)) _a.call(_d); - } - finally { if (e_1) throw e_1.error; } - } - // create the DOM element node - var elementNode = (namespace !== null ? - doc.createElementNS(namespace, element.name) : - doc.createElement(element.name)); - context.appendChild(elementNode); - // assign attributes - var localNameSet = new LocalNameSet_1.LocalNameSet(); - try { - for (var _h = (e_2 = void 0, __values(element.attributes)), _j = _h.next(); !_j.done; _j = _h.next()) { - var _k = __read(_j.value, 2), attName = _k[0], attValue = _k[1]; - var _l = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _l[0], attLocalName = _l[1]; - var attNamespace = null; - if (attPrefix === "xmlns" || (attPrefix === null && attLocalName === "xmlns")) { - // namespace declaration attribute - attNamespace = infra_1.namespace.XMLNS; - } - else { - attNamespace = elementNode.lookupNamespaceURI(attPrefix); - if (attNamespace !== null && elementNode.isDefaultNamespace(attNamespace)) { - attNamespace = null; - } - else if (attNamespace === null && attPrefix !== null) { - attNamespace = nsDeclarations[attPrefix] || null; - } - } - if (localNameSet.has(attNamespace, attLocalName)) { - throw new Error("Element contains duplicate attributes."); - } - localNameSet.set(attNamespace, attLocalName); - if (attNamespace === infra_1.namespace.XMLNS) { - if (attValue === infra_1.namespace.XMLNS) { - throw new Error("XMLNS namespace is reserved."); - } - } - if (attLocalName.indexOf(":") !== -1 || !algorithm_1.xml_isName(attLocalName)) { - throw new Error("Attribute local name contains invalid characters."); - } - if (attPrefix === "xmlns" && attValue === "") { - throw new Error("Empty XML namespace is not allowed."); - } - if (attNamespace !== null) - elementNode.setAttributeNS(attNamespace, attName, attValue); - else - elementNode.setAttribute(attName, attValue); - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_j && !_j.done && (_b = _h.return)) _b.call(_h); - } - finally { if (e_2) throw e_2.error; } - } - if (!element.selfClosing) { - context = elementNode; - } - break; - case interfaces_1.TokenType.ClosingTag: - var closingTag = token; - if (closingTag.name !== context.nodeName) { - throw new Error('Closing tag name does not match opening tag name.'); - } - /* istanbul ignore else */ - if (context._parent) { - context = context._parent; - } - break; + return true; +} +exports.xml_isQName = xml_isQName; +/** + * Determines if the given string contains legal characters. + * + * @param chars - sequence of characters to test + */ +function xml_isLegalChar(chars) { + for (var i = 0; i < chars.length; i++) { + var n = chars.charCodeAt(i); + // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] + if (n === 0x9 || n === 0xA || n === 0xD || + (n >= 0x20 && n <= 0xD7FF) || + (n >= 0xE000 && n <= 0xFFFD)) { + continue; + } + if (n >= 0xD800 && n <= 0xDBFF && i < chars.length - 1) { + var n2 = chars.charCodeAt(i + 1); + if (n2 >= 0xDC00 && n2 <= 0xDFFF) { + n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; + i++; + if (n >= 0x10000 && n <= 0x10FFFF) { + continue; + } } - token = lexer.nextToken(); } - return doc; - }; - return XMLParserImpl; -}()); -exports.XMLParserImpl = XMLParserImpl; -//# sourceMappingURL=XMLParserImpl.js.map + return false; + } + return true; +} +exports.xml_isLegalChar = xml_isLegalChar; +/** + * Determines if the given string contains legal characters for a public + * identifier. + * + * @param chars - sequence of characters to test + */ +function xml_isPubidChar(chars) { + for (var i = 0; i < chars.length; i++) { + // PubId chars are all in the ASCII range, no need to check surrogates + var n = chars.charCodeAt(i); + // #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] + if ((n >= 97 && n <= 122) || // [a-z] + (n >= 65 && n <= 90) || // [A-Z] + (n >= 39 && n <= 59) || // ['()*+,-./] | [0-9] | [:;] + n === 0x20 || n === 0xD || n === 0xA || // #x20 | #xD | #xA + (n >= 35 && n <= 37) || // [#$%] + n === 33 || // ! + n === 61 || n === 63 || n === 64 || n === 95) { // [=?@_] + continue; + } + else { + return false; + } + } + return true; +} +exports.xml_isPubidChar = xml_isPubidChar; +//# sourceMappingURL=XMLAlgorithm.js.map /***/ }), -/* 469 */, -/* 470 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/* 443 */, +/* 444 */, +/* 445 */, +/* 446 */, +/* 447 */, +/* 448 */, +/* 449 */, +/* 450 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + + +var Type = __webpack_require__(945); + +module.exports = new Type('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function (data) { return data !== null ? data : ''; } +}); + + +/***/ }), +/* 451 */, +/* 452 */, +/* 453 */, +/* 454 */, +/* 455 */, +/* 456 */, +/* 457 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + + +/*eslint-disable max-len,no-use-before-define*/ + +var common = __webpack_require__(740); +var YAMLException = __webpack_require__(556); +var Mark = __webpack_require__(93); +var DEFAULT_SAFE_SCHEMA = __webpack_require__(723); +var DEFAULT_FULL_SCHEMA = __webpack_require__(910); + + +var _hasOwnProperty = Object.prototype.hasOwnProperty; + + +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; + + +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; + + +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; + + +function _class(obj) { return Object.prototype.toString.call(obj); } + +function is_EOL(c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); +} + +function is_WHITE_SPACE(c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */); +} + +function is_WS_OR_EOL(c) { + return (c === 0x09/* Tab */) || + (c === 0x20/* Space */) || + (c === 0x0A/* LF */) || + (c === 0x0D/* CR */); +} + +function is_FLOW_INDICATOR(c) { + return c === 0x2C/* , */ || + c === 0x5B/* [ */ || + c === 0x5D/* ] */ || + c === 0x7B/* { */ || + c === 0x7D/* } */; +} + +function fromHexCode(c) { + var lc; + + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + /*eslint-disable no-bitwise*/ + lc = c | 0x20; -"use strict"; + if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10; + } -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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - 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; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const command_1 = __webpack_require__(431); -const file_command_1 = __webpack_require__(102); -const utils_1 = __webpack_require__(82); -const os = __importStar(__webpack_require__(87)); -const path = __importStar(__webpack_require__(622)); -/** - * The code to exit an action - */ -var ExitCode; -(function (ExitCode) { - /** - * A code indicating that the action was successful - */ - ExitCode[ExitCode["Success"] = 0] = "Success"; - /** - * A code indicating that the action was a failure - */ - ExitCode[ExitCode["Failure"] = 1] = "Failure"; -})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); -//----------------------------------------------------------------------- -// Variables -//----------------------------------------------------------------------- -/** - * Sets env variable for this action and future actions in the job - * @param name the name of the variable to set - * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function exportVariable(name, val) { - const convertedVal = utils_1.toCommandValue(val); - process.env[name] = convertedVal; - const filePath = process.env['GITHUB_ENV'] || ''; - if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); - } + return -1; } -exports.exportVariable = exportVariable; -/** - * Registers a secret which will get masked from logs - * @param secret value of the secret - */ -function setSecret(secret) { - command_1.issueCommand('add-mask', {}, secret); + +function escapedHexLen(c) { + if (c === 0x78/* x */) { return 2; } + if (c === 0x75/* u */) { return 4; } + if (c === 0x55/* U */) { return 8; } + return 0; } -exports.setSecret = setSecret; -/** - * Prepends inputPath to the PATH (for this action and future actions) - * @param inputPath - */ -function addPath(inputPath) { - const filePath = process.env['GITHUB_PATH'] || ''; - if (filePath) { - file_command_1.issueCommand('PATH', inputPath); - } - else { - command_1.issueCommand('add-path', {}, inputPath); - } - process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; + +function fromDecimalCode(c) { + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + return -1; } -exports.addPath = addPath; -/** - * Gets the value of an input. The value is also trimmed. - * - * @param name name of the input to get - * @param options optional. See InputOptions. - * @returns string - */ -function getInput(name, options) { - const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; - if (options && options.required && !val) { - throw new Error(`Input required and not supplied: ${name}`); - } - return val.trim(); + +function simpleEscapeSequence(c) { + /* eslint-disable indent */ + return (c === 0x30/* 0 */) ? '\x00' : + (c === 0x61/* a */) ? '\x07' : + (c === 0x62/* b */) ? '\x08' : + (c === 0x74/* t */) ? '\x09' : + (c === 0x09/* Tab */) ? '\x09' : + (c === 0x6E/* n */) ? '\x0A' : + (c === 0x76/* v */) ? '\x0B' : + (c === 0x66/* f */) ? '\x0C' : + (c === 0x72/* r */) ? '\x0D' : + (c === 0x65/* e */) ? '\x1B' : + (c === 0x20/* Space */) ? ' ' : + (c === 0x22/* " */) ? '\x22' : + (c === 0x2F/* / */) ? '/' : + (c === 0x5C/* \ */) ? '\x5C' : + (c === 0x4E/* N */) ? '\x85' : + (c === 0x5F/* _ */) ? '\xA0' : + (c === 0x4C/* L */) ? '\u2028' : + (c === 0x50/* P */) ? '\u2029' : ''; } -exports.getInput = getInput; -/** - * Sets the value of an output. - * - * @param name name of the output to set - * @param value value to store. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function setOutput(name, value) { - command_1.issueCommand('set-output', { name }, value); + +function charFromCodepoint(c) { + if (c <= 0xFFFF) { + return String.fromCharCode(c); + } + // Encode UTF-16 surrogate pair + // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF + return String.fromCharCode( + ((c - 0x010000) >> 10) + 0xD800, + ((c - 0x010000) & 0x03FF) + 0xDC00 + ); } -exports.setOutput = setOutput; -/** - * Enables or disables the echoing of commands into stdout for the rest of the step. - * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. - * - */ -function setCommandEcho(enabled) { - command_1.issue('echo', enabled ? 'on' : 'off'); + +var simpleEscapeCheck = new Array(256); // integer, for fast access +var simpleEscapeMap = new Array(256); +for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); } -exports.setCommandEcho = setCommandEcho; -//----------------------------------------------------------------------- -// Results -//----------------------------------------------------------------------- -/** - * Sets the action status to failed. - * When the action exits it will be with an exit code of 1 - * @param message add error issue message - */ -function setFailed(message) { - process.exitCode = ExitCode.Failure; - error(message); + + +function State(input, options) { + this.input = input; + + this.filename = options['filename'] || null; + this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; + this.onWarning = options['onWarning'] || null; + this.legacy = options['legacy'] || false; + this.json = options['json'] || false; + this.listener = options['listener'] || null; + + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + + this.documents = []; + + /* + this.version; + this.checkLineBreaks; + this.tagMap; + this.anchorMap; + this.tag; + this.anchor; + this.kind; + this.result;*/ + } -exports.setFailed = setFailed; -//----------------------------------------------------------------------- -// Logging Commands -//----------------------------------------------------------------------- -/** - * Gets whether Actions Step Debug is on or not - */ -function isDebug() { - return process.env['RUNNER_DEBUG'] === '1'; + + +function generateError(state, message) { + return new YAMLException( + message, + new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart))); } -exports.isDebug = isDebug; -/** - * Writes debug message to user log - * @param message debug message - */ -function debug(message) { - command_1.issueCommand('debug', {}, message); + +function throwError(state, message) { + throw generateError(state, message); } -exports.debug = debug; -/** - * Adds an error issue - * @param message error issue message. Errors will be converted to string via toString() - */ -function error(message) { - command_1.issue('error', message instanceof Error ? message.toString() : message); + +function throwWarning(state, message) { + if (state.onWarning) { + state.onWarning.call(null, generateError(state, message)); + } } -exports.error = error; -/** - * Adds an warning issue - * @param message warning issue message. Errors will be converted to string via toString() - */ -function warning(message) { - command_1.issue('warning', message instanceof Error ? message.toString() : message); + + +var directiveHandlers = { + + YAML: function handleYamlDirective(state, name, args) { + + var match, major, minor; + + if (state.version !== null) { + throwError(state, 'duplication of %YAML directive'); + } + + if (args.length !== 1) { + throwError(state, 'YAML directive accepts exactly one argument'); + } + + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + + if (match === null) { + throwError(state, 'ill-formed argument of the YAML directive'); + } + + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + + if (major !== 1) { + throwError(state, 'unacceptable YAML version of the document'); + } + + state.version = args[0]; + state.checkLineBreaks = (minor < 2); + + if (minor !== 1 && minor !== 2) { + throwWarning(state, 'unsupported YAML version of the document'); + } + }, + + TAG: function handleTagDirective(state, name, args) { + + var handle, prefix; + + if (args.length !== 2) { + throwError(state, 'TAG directive accepts exactly two arguments'); + } + + handle = args[0]; + prefix = args[1]; + + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); + } + + if (_hasOwnProperty.call(state.tagMap, handle)) { + throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } + + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + } + + state.tagMap[handle] = prefix; + } +}; + + +function captureSegment(state, start, end, checkJson) { + var _position, _length, _character, _result; + + if (start < end) { + _result = state.input.slice(start, end); + + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 0x09 || + (0x20 <= _character && _character <= 0x10FFFF))) { + throwError(state, 'expected valid JSON character'); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state, 'the stream contains non-printable characters'); + } + + state.result += _result; + } } -exports.warning = warning; -/** - * Writes info to log with console.log. - * @param message info message - */ -function info(message) { - process.stdout.write(message + os.EOL); + +function mergeMappings(state, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; + + if (!common.isObject(source)) { + throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); + } + + sourceKeys = Object.keys(source); + + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + + if (!_hasOwnProperty.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } } -exports.info = info; -/** - * Begin an output group. - * - * Output until the next `groupEnd` will be foldable in this group - * - * @param name The name of the output group - */ -function startGroup(name) { - command_1.issue('group', name); + +function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) { + var index, quantity; + + // The output is a plain object here, so keys can only be strings. + // We need to convert keyNode to a string, but doing so can hang the process + // (deeply nested arrays that explode exponentially using aliases). + if (Array.isArray(keyNode)) { + keyNode = Array.prototype.slice.call(keyNode); + + for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { + if (Array.isArray(keyNode[index])) { + throwError(state, 'nested arrays are not supported inside keys'); + } + + if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { + keyNode[index] = '[object Object]'; + } + } + } + + // Avoid code execution in load() via toString property + // (still use its own toString for arrays, timestamps, + // and whatever user schema extensions happen to have @@toStringTag) + if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { + keyNode = '[object Object]'; + } + + + keyNode = String(keyNode); + + if (_result === null) { + _result = {}; + } + + if (keyTag === 'tag:yaml.org,2002:merge') { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state, _result, valueNode, overridableKeys); + } + } else { + if (!state.json && + !_hasOwnProperty.call(overridableKeys, keyNode) && + _hasOwnProperty.call(_result, keyNode)) { + state.line = startLine || state.line; + state.position = startPos || state.position; + throwError(state, 'duplicated mapping key'); + } + _result[keyNode] = valueNode; + delete overridableKeys[keyNode]; + } + + return _result; } -exports.startGroup = startGroup; -/** - * End an output group. - */ -function endGroup() { - command_1.issue('endgroup'); + +function readLineBreak(state) { + var ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x0A/* LF */) { + state.position++; + } else if (ch === 0x0D/* CR */) { + state.position++; + if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { + state.position++; + } + } else { + throwError(state, 'a line break is expected'); + } + + state.line += 1; + state.lineStart = state.position; } -exports.endGroup = endGroup; -/** - * Wrap an asynchronous function call in a group. - * - * Returns the same type as the function itself. - * - * @param name The name of the group - * @param fn The function to wrap in the group - */ -function group(name, fn) { - return __awaiter(this, void 0, void 0, function* () { - startGroup(name); - let result; - try { - result = yield fn(); - } - finally { - endGroup(); - } - return result; - }); + +function skipSeparationSpace(state, allowComments, checkIndent) { + var lineBreaks = 0, + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (allowComments && ch === 0x23/* # */) { + do { + ch = state.input.charCodeAt(++state.position); + } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + } + + if (is_EOL(ch)) { + readLineBreak(state); + + ch = state.input.charCodeAt(state.position); + lineBreaks++; + state.lineIndent = 0; + + while (ch === 0x20/* Space */) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + } else { + break; + } + } + + if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { + throwWarning(state, 'deficient indentation'); + } + + return lineBreaks; } -exports.group = group; -//----------------------------------------------------------------------- -// Wrapper action state -//----------------------------------------------------------------------- -/** - * Saves state for current action, the state can only be retrieved by this action's post job execution. - * - * @param name name of the state to store - * @param value value to store. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + +function testDocumentSeparator(state) { + var _position = state.position, + ch; + + ch = state.input.charCodeAt(_position); + + // Condition state.position === state.lineStart is tested + // in parent on each call, for efficiency. No needs to test here again. + if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && + ch === state.input.charCodeAt(_position + 1) && + ch === state.input.charCodeAt(_position + 2)) { + + _position += 3; + + ch = state.input.charCodeAt(_position); + + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + + return false; } -exports.saveState = saveState; -/** - * Gets the value of an state set by this action's main execution. - * - * @param name name of the state to get - * @returns string - */ -function getState(name) { - return process.env[`STATE_${name}`] || ''; + +function writeFoldedLines(state, count) { + if (count === 1) { + state.result += ' '; + } else if (count > 1) { + state.result += common.repeat('\n', count - 1); + } } -exports.getState = getState; -//# sourceMappingURL=core.js.map -/***/ }), -/* 471 */, -/* 472 */, -/* 473 */, -/* 474 */, -/* 475 */, -/* 476 */, -/* 477 */, -/* 478 */, -/* 479 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { -"use strict"; +function readPlainScalar(state, nodeIndent, withinFlowCollection) { + var preceding, + following, + captureStart, + captureEnd, + hasPendingContent, + _line, + _lineStart, + _lineIndent, + _kind = state.kind, + _result = state.result, + ch; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + ch = state.input.charCodeAt(state.position); + + if (is_WS_OR_EOL(ch) || + is_FLOW_INDICATOR(ch) || + ch === 0x23/* # */ || + ch === 0x26/* & */ || + ch === 0x2A/* * */ || + ch === 0x21/* ! */ || + ch === 0x7C/* | */ || + ch === 0x3E/* > */ || + ch === 0x27/* ' */ || + ch === 0x22/* " */ || + ch === 0x25/* % */ || + ch === 0x40/* @ */ || + ch === 0x60/* ` */) { + return false; + } + + if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } + } + + state.kind = 'scalar'; + state.result = ''; + captureStart = captureEnd = state.position; + hasPendingContent = false; + + while (ch !== 0) { + if (ch === 0x3A/* : */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + + } else if (ch === 0x23/* # */) { + preceding = state.input.charCodeAt(state.position - 1); + + if (is_WS_OR_EOL(preceding)) { + break; + } + + } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || + withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + + } else if (is_EOL(ch)) { + _line = state.line; + _lineStart = state.lineStart; + _lineIndent = state.lineIndent; + skipSeparationSpace(state, false, -1); + + if (state.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state.input.charCodeAt(state.position); + continue; + } else { + state.position = captureEnd; + state.line = _line; + state.lineStart = _lineStart; + state.lineIndent = _lineIndent; + break; + } } - return ar; -}; -var __spread = (this && this.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var DOMException_1 = __webpack_require__(35); -var interfaces_1 = __webpack_require__(970); -var util_1 = __webpack_require__(918); -var util_2 = __webpack_require__(592); -var infra_1 = __webpack_require__(23); -var CustomElementAlgorithm_1 = __webpack_require__(344); -var TreeAlgorithm_1 = __webpack_require__(873); -var NodeIteratorAlgorithm_1 = __webpack_require__(272); -var ShadowTreeAlgorithm_1 = __webpack_require__(180); -var MutationObserverAlgorithm_1 = __webpack_require__(151); -var DOMAlgorithm_1 = __webpack_require__(304); -var DocumentAlgorithm_1 = __webpack_require__(493); -/** - * Ensures pre-insertion validity of a node into a parent before a - * child. - * - * @param node - node to insert - * @param parent - parent node to receive node - * @param child - child node to insert node before - */ -function mutation_ensurePreInsertionValidity(node, parent, child) { - var e_1, _a, e_2, _b, e_3, _c, e_4, _d; - var parentNodeType = parent._nodeType; - var nodeNodeType = node._nodeType; - var childNodeType = child ? child._nodeType : null; - /** - * 1. If parent is not a Document, DocumentFragment, or Element node, - * throw a "HierarchyRequestError" DOMException. - */ - if (parentNodeType !== interfaces_1.NodeType.Document && - parentNodeType !== interfaces_1.NodeType.DocumentFragment && - parentNodeType !== interfaces_1.NodeType.Element) - throw new DOMException_1.HierarchyRequestError("Only document, document fragment and element nodes can contain child nodes. Parent node is " + parent.nodeName + "."); - /** - * 2. If node is a host-including inclusive ancestor of parent, throw a - * "HierarchyRequestError" DOMException. - */ - if (TreeAlgorithm_1.tree_isHostIncludingAncestorOf(parent, node, true)) - throw new DOMException_1.HierarchyRequestError("The node to be inserted cannot be an inclusive ancestor of parent node. Node is " + node.nodeName + ", parent node is " + parent.nodeName + "."); - /** - * 3. If child is not null and its parent is not parent, then throw a - * "NotFoundError" DOMException. - */ - if (child !== null && child._parent !== parent) - throw new DOMException_1.NotFoundError("The reference child node cannot be found under parent node. Child node is " + child.nodeName + ", parent node is " + parent.nodeName + "."); - /** - * 4. If node is not a DocumentFragment, DocumentType, Element, Text, - * ProcessingInstruction, or Comment node, throw a "HierarchyRequestError" - * DOMException. - */ - if (nodeNodeType !== interfaces_1.NodeType.DocumentFragment && - nodeNodeType !== interfaces_1.NodeType.DocumentType && - nodeNodeType !== interfaces_1.NodeType.Element && - nodeNodeType !== interfaces_1.NodeType.Text && - nodeNodeType !== interfaces_1.NodeType.ProcessingInstruction && - nodeNodeType !== interfaces_1.NodeType.CData && - nodeNodeType !== interfaces_1.NodeType.Comment) - throw new DOMException_1.HierarchyRequestError("Only document fragment, document type, element, text, processing instruction, cdata section or comment nodes can be inserted. Node is " + node.nodeName + "."); - /** - * 5. If either node is a Text node and parent is a document, or node is a - * doctype and parent is not a document, throw a "HierarchyRequestError" - * DOMException. - */ - if (nodeNodeType === interfaces_1.NodeType.Text && - parentNodeType === interfaces_1.NodeType.Document) - throw new DOMException_1.HierarchyRequestError("Cannot insert a text node as a child of a document node. Node is " + node.nodeName + "."); - if (nodeNodeType === interfaces_1.NodeType.DocumentType && - parentNodeType !== interfaces_1.NodeType.Document) - throw new DOMException_1.HierarchyRequestError("A document type node can only be inserted under a document node. Parent node is " + parent.nodeName + "."); - /** - * 6. If parent is a document, and any of the statements below, switched on - * node, are true, throw a "HierarchyRequestError" DOMException. - * - DocumentFragment node - * If node has more than one element child or has a Text node child. - * Otherwise, if node has one element child and either parent has an element - * child, child is a doctype, or child is not null and a doctype is - * following child. - * - element - * parent has an element child, child is a doctype, or child is not null and - * a doctype is following child. - * - doctype - * parent has a doctype child, child is non-null and an element is preceding - * child, or child is null and parent has an element child. - */ - if (parentNodeType === interfaces_1.NodeType.Document) { - if (nodeNodeType === interfaces_1.NodeType.DocumentFragment) { - var eleCount = 0; - try { - for (var _e = __values(node._children), _f = _e.next(); !_f.done; _f = _e.next()) { - var childNode = _f.value; - if (childNode._nodeType === interfaces_1.NodeType.Element) - eleCount++; - else if (childNode._nodeType === interfaces_1.NodeType.Text) - throw new DOMException_1.HierarchyRequestError("Cannot insert text a node as a child of a document node. Node is " + childNode.nodeName + "."); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_f && !_f.done && (_a = _e.return)) _a.call(_e); - } - finally { if (e_1) throw e_1.error; } - } - if (eleCount > 1) { - throw new DOMException_1.HierarchyRequestError("A document node can only have one document element node. Document fragment to be inserted has " + eleCount + " element nodes."); - } - else if (eleCount === 1) { - try { - for (var _g = __values(parent._children), _h = _g.next(); !_h.done; _h = _g.next()) { - var ele = _h.value; - if (ele._nodeType === interfaces_1.NodeType.Element) - throw new DOMException_1.HierarchyRequestError("The document node already has a document element node."); - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_h && !_h.done && (_b = _g.return)) _b.call(_g); - } - finally { if (e_2) throw e_2.error; } - } - if (child) { - if (childNodeType === interfaces_1.NodeType.DocumentType) - throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node."); - var doctypeChild = child._nextSibling; - while (doctypeChild) { - if (doctypeChild._nodeType === interfaces_1.NodeType.DocumentType) - throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node."); - doctypeChild = doctypeChild._nextSibling; - } - } - } - } - else if (nodeNodeType === interfaces_1.NodeType.Element) { - try { - for (var _j = __values(parent._children), _k = _j.next(); !_k.done; _k = _j.next()) { - var ele = _k.value; - if (ele._nodeType === interfaces_1.NodeType.Element) - throw new DOMException_1.HierarchyRequestError("Document already has a document element node. Node is " + node.nodeName + "."); - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_k && !_k.done && (_c = _j.return)) _c.call(_j); - } - finally { if (e_3) throw e_3.error; } - } - if (child) { - if (childNodeType === interfaces_1.NodeType.DocumentType) - throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node. Node is " + node.nodeName + "."); - var doctypeChild = child._nextSibling; - while (doctypeChild) { - if (doctypeChild._nodeType === interfaces_1.NodeType.DocumentType) - throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node. Node is " + node.nodeName + "."); - doctypeChild = doctypeChild._nextSibling; - } - } - } - else if (nodeNodeType === interfaces_1.NodeType.DocumentType) { - try { - for (var _l = __values(parent._children), _m = _l.next(); !_m.done; _m = _l.next()) { - var ele = _m.value; - if (ele._nodeType === interfaces_1.NodeType.DocumentType) - throw new DOMException_1.HierarchyRequestError("Document already has a document type node. Node is " + node.nodeName + "."); - } - } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (_m && !_m.done && (_d = _l.return)) _d.call(_l); - } - finally { if (e_4) throw e_4.error; } - } - if (child) { - var elementChild = child._previousSibling; - while (elementChild) { - if (elementChild._nodeType === interfaces_1.NodeType.Element) - throw new DOMException_1.HierarchyRequestError("Cannot insert a document type node before an element node. Node is " + node.nodeName + "."); - elementChild = elementChild._previousSibling; - } - } - else { - var elementChild = parent._firstChild; - while (elementChild) { - if (elementChild._nodeType === interfaces_1.NodeType.Element) - throw new DOMException_1.HierarchyRequestError("Cannot insert a document type node before an element node. Node is " + node.nodeName + "."); - elementChild = elementChild._nextSibling; - } - } + + if (hasPendingContent) { + captureSegment(state, captureStart, captureEnd, false); + writeFoldedLines(state, state.line - _line); + captureStart = captureEnd = state.position; + hasPendingContent = false; + } + + if (!is_WHITE_SPACE(ch)) { + captureEnd = state.position + 1; + } + + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, captureEnd, false); + + if (state.result) { + return true; + } + + state.kind = _kind; + state.result = _result; + return false; +} + +function readSingleQuotedScalar(state, nodeIndent) { + var ch, + captureStart, captureEnd; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x27/* ' */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x27/* ' */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x27/* ' */) { + captureStart = state.position; + state.position++; + captureEnd = state.position; + } else { + return true; + } + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a single quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a single quoted scalar'); +} + +function readDoubleQuotedScalar(state, nodeIndent) { + var captureStart, + captureEnd, + hexLength, + hexResult, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x22/* " */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x22/* " */) { + captureSegment(state, captureStart, state.position, true); + state.position++; + return true; + + } else if (ch === 0x5C/* \ */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (is_EOL(ch)) { + skipSeparationSpace(state, false, nodeIndent); + + // TODO: rework to inline fn with no type cast? + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state.result += simpleEscapeMap[ch]; + state.position++; + + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; + + for (; hexLength > 0; hexLength--) { + ch = state.input.charCodeAt(++state.position); + + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; + + } else { + throwError(state, 'expected hexadecimal character'); + } } + + state.result += charFromCodepoint(hexResult); + + state.position++; + + } else { + throwError(state, 'unknown escape sequence'); + } + + captureStart = captureEnd = state.position; + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a double quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; } + } + + throwError(state, 'unexpected end of the stream within a double quoted scalar'); } -exports.mutation_ensurePreInsertionValidity = mutation_ensurePreInsertionValidity; -/** - * Ensures pre-insertion validity of a node into a parent before a - * child, then adopts the node to the tree and inserts it. - * - * @param node - node to insert - * @param parent - parent node to receive node - * @param child - child node to insert node before - */ -function mutation_preInsert(node, parent, child) { - /** - * 1. Ensure pre-insertion validity of node into parent before child. - * 2. Let reference child be child. - * 3. If reference child is node, set it to node’s next sibling. - * 4. Adopt node into parent’s node document. - * 5. Insert node into parent before reference child. - * 6. Return node. - */ - mutation_ensurePreInsertionValidity(node, parent, child); - var referenceChild = child; - if (referenceChild === node) - referenceChild = node._nextSibling; - DocumentAlgorithm_1.document_adopt(node, parent._nodeDocument); - mutation_insert(node, parent, referenceChild); - return node; + +function readFlowCollection(state, nodeIndent) { + var readNext = true, + _line, + _tag = state.tag, + _result, + _anchor = state.anchor, + following, + terminator, + isPair, + isExplicitPair, + isMapping, + overridableKeys = {}, + keyNode, + keyTag, + valueNode, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x5B/* [ */) { + terminator = 0x5D;/* ] */ + isMapping = false; + _result = []; + } else if (ch === 0x7B/* { */) { + terminator = 0x7D;/* } */ + isMapping = true; + _result = {}; + } else { + return false; + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(++state.position); + + while (ch !== 0) { + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === terminator) { + state.position++; + state.tag = _tag; + state.anchor = _anchor; + state.kind = isMapping ? 'mapping' : 'sequence'; + state.result = _result; + return true; + } else if (!readNext) { + throwError(state, 'missed comma between flow collection entries'); + } + + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; + + if (ch === 0x3F/* ? */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state.position++; + skipSeparationSpace(state, true, nodeIndent); + } + } + + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state.tag; + keyNode = state.result; + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { + isPair = true; + ch = state.input.charCodeAt(++state.position); + skipSeparationSpace(state, true, nodeIndent); + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state.result; + } + + if (isMapping) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode); + } else if (isPair) { + _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode)); + } else { + _result.push(keyNode); + } + + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x2C/* , */) { + readNext = true; + ch = state.input.charCodeAt(++state.position); + } else { + readNext = false; + } + } + + throwError(state, 'unexpected end of the stream within a flow collection'); } -exports.mutation_preInsert = mutation_preInsert; -/** - * Inserts a node into a parent node before the given child node. - * - * @param node - node to insert - * @param parent - parent node to receive node - * @param child - child node to insert node before - * @param suppressObservers - whether to notify observers - */ -function mutation_insert(node, parent, child, suppressObservers) { - var e_5, _a; - // Optimized common case - if (child === null && node._nodeType !== interfaces_1.NodeType.DocumentFragment) { - mutation_insert_single(node, parent, suppressObservers); - return; + +function readBlockScalar(state, nodeIndent) { + var captureStart, + folding, + chomping = CHOMPING_CLIP, + didReadContent = false, + detectedIndent = false, + textIndent = nodeIndent, + emptyLines = 0, + atMoreIndented = false, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x7C/* | */) { + folding = false; + } else if (ch === 0x3E/* > */) { + folding = true; + } else { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + + while (ch !== 0) { + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { + if (CHOMPING_CLIP === chomping) { + chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state, 'repeat of a chomping mode identifier'); + } + + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state, 'repeat of an indentation width identifier'); + } + + } else { + break; } - /** - * 1. Let count be the number of children of node if it is a - * DocumentFragment node, and one otherwise. - */ - var count = (node._nodeType === interfaces_1.NodeType.DocumentFragment ? - node._children.size : 1); - /** - * 2. If child is non-null, then: - */ - if (child !== null) { - /** - * 2.1. For each live range whose start node is parent and start - * offset is greater than child's index, increase its start - * offset by count. - * 2.2. For each live range whose end node is parent and end - * offset is greater than child's index, increase its end - * offset by count. - */ - if (DOMImpl_1.dom.rangeList.size !== 0) { - var index_1 = TreeAlgorithm_1.tree_index(child); - try { - for (var _b = __values(DOMImpl_1.dom.rangeList), _c = _b.next(); !_c.done; _c = _b.next()) { - var range = _c.value; - if (range._start[0] === parent && range._start[1] > index_1) { - range._start[1] += count; - } - if (range._end[0] === parent && range._end[1] > index_1) { - range._end[1] += count; - } - } - } - catch (e_5_1) { e_5 = { error: e_5_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_5) throw e_5.error; } - } - } + } + + if (is_WHITE_SPACE(ch)) { + do { ch = state.input.charCodeAt(++state.position); } + while (is_WHITE_SPACE(ch)); + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (!is_EOL(ch) && (ch !== 0)); } - /** - * 3. Let nodes be node’s children, if node is a DocumentFragment node; - * otherwise « node ». - */ - var nodes = node._nodeType === interfaces_1.NodeType.DocumentFragment ? new (Array.bind.apply(Array, __spread([void 0], node._children)))() : [node]; - /** - * 4. If node is a DocumentFragment node, remove its children with the - * suppress observers flag set. - */ - if (node._nodeType === interfaces_1.NodeType.DocumentFragment) { - while (node._firstChild) { - mutation_remove(node._firstChild, node, true); - } + } + + while (ch !== 0) { + readLineBreak(state); + state.lineIndent = 0; + + ch = state.input.charCodeAt(state.position); + + while ((!detectedIndent || state.lineIndent < textIndent) && + (ch === 0x20/* Space */)) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); } - /** - * 5. If node is a DocumentFragment node, then queue a tree mutation record - * for node with « », nodes, null, and null. - */ - if (DOMImpl_1.dom.features.mutationObservers) { - if (node._nodeType === interfaces_1.NodeType.DocumentFragment) { - MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(node, [], nodes, null, null); - } + + if (!detectedIndent && state.lineIndent > textIndent) { + textIndent = state.lineIndent; } - /** - * 6. Let previousSibling be child’s previous sibling or parent’s last - * child if child is null. - */ - var previousSibling = (child ? child._previousSibling : parent._lastChild); - var index = child === null ? -1 : TreeAlgorithm_1.tree_index(child); - /** - * 7. For each node in nodes, in tree order: - */ - for (var i = 0; i < nodes.length; i++) { - var node_1 = nodes[i]; - if (util_1.Guard.isElementNode(node_1)) { - // set document element node - if (util_1.Guard.isDocumentNode(parent)) { - parent._documentElement = node_1; - } - // mark that the document has namespaces - if (!node_1._nodeDocument._hasNamespaces && (node_1._namespace !== null || - node_1._namespacePrefix !== null)) { - node_1._nodeDocument._hasNamespaces = true; - } - } - /** - * 7.1. If child is null, then append node to parent’s children. - * 7.2. Otherwise, insert node into parent’s children before child’s - * index. - */ - node_1._parent = parent; - if (child === null) { - infra_1.set.append(parent._children, node_1); - } - else { - infra_1.set.insert(parent._children, node_1, index); - index++; - } - // assign siblings and children for quick lookups - if (parent._firstChild === null) { - node_1._previousSibling = null; - node_1._nextSibling = null; - parent._firstChild = node_1; - parent._lastChild = node_1; - } - else { - var prev = (child ? child._previousSibling : parent._lastChild); - var next = (child ? child : null); - node_1._previousSibling = prev; - node_1._nextSibling = next; - if (prev) - prev._nextSibling = node_1; - if (next) - next._previousSibling = node_1; - if (!prev) - parent._firstChild = node_1; - if (!next) - parent._lastChild = node_1; - } - /** - * 7.3. If parent is a shadow host and node is a slotable, then - * assign a slot for node. - */ - if (DOMImpl_1.dom.features.slots) { - if (parent._shadowRoot !== null && util_1.Guard.isSlotable(node_1)) { - ShadowTreeAlgorithm_1.shadowTree_assignASlot(node_1); - } - } - /** - * 7.4. If node is a Text node, run the child text content change - * steps for parent. - */ - if (DOMImpl_1.dom.features.steps) { - if (util_1.Guard.isTextNode(node_1)) { - DOMAlgorithm_1.dom_runChildTextContentChangeSteps(parent); - } - } - /** - * 7.5. If parent's root is a shadow root, and parent is a slot - * whose assigned nodes is the empty list, then run signal - * a slot change for parent. - */ - if (DOMImpl_1.dom.features.slots) { - if (util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(parent)) && - util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { - ShadowTreeAlgorithm_1.shadowTree_signalASlotChange(parent); - } - } - /** - * 7.6. Run assign slotables for a tree with node's root. - */ - if (DOMImpl_1.dom.features.slots) { - ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(node_1)); - } - /** - * 7.7. For each shadow-including inclusive descendant - * inclusiveDescendant of node, in shadow-including tree - * order: - */ - var inclusiveDescendant = TreeAlgorithm_1.tree_getFirstDescendantNode(node_1, true, true); - while (inclusiveDescendant !== null) { - /** - * 7.7.1. Run the insertion steps with inclusiveDescendant. - */ - if (DOMImpl_1.dom.features.steps) { - DOMAlgorithm_1.dom_runInsertionSteps(inclusiveDescendant); - } - if (DOMImpl_1.dom.features.customElements) { - /** - * 7.7.2. If inclusiveDescendant is connected, then: - */ - if (util_1.Guard.isElementNode(inclusiveDescendant) && - ShadowTreeAlgorithm_1.shadowTree_isConnected(inclusiveDescendant)) { - if (util_1.Guard.isCustomElementNode(inclusiveDescendant)) { - /** - * 7.7.2.1. If inclusiveDescendant is custom, then enqueue a custom - * element callback reaction with inclusiveDescendant, callback name - * "connectedCallback", and an empty argument list. - */ - CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(inclusiveDescendant, "connectedCallback", []); - } - else { - /** - * 7.7.2.2. Otherwise, try to upgrade inclusiveDescendant. - */ - CustomElementAlgorithm_1.customElement_tryToUpgrade(inclusiveDescendant); - } - } - } - inclusiveDescendant = TreeAlgorithm_1.tree_getNextDescendantNode(node_1, inclusiveDescendant, true, true); + + if (is_EOL(ch)) { + emptyLines++; + continue; + } + + // End of the scalar. + if (state.lineIndent < textIndent) { + + // Perform the chomping. + if (chomping === CHOMPING_KEEP) { + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { // i.e. only if the scalar is not empty. + state.result += '\n'; } + } + + // Break this `while` cycle and go to the funciton's epilogue. + break; } - /** - * 8. If suppress observers flag is unset, then queue a tree mutation record - * for parent with nodes, « », previousSibling, and child. - */ - if (DOMImpl_1.dom.features.mutationObservers) { - if (!suppressObservers) { - MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, nodes, [], previousSibling, child); + + // Folded style: use fancy rules to handle line breaks. + if (folding) { + + // Lines starting with white space characters (more-indented lines) are not folded. + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + // except for the first content line (cf. Example 8.1) + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + + // End of more-indented block. + } else if (atMoreIndented) { + atMoreIndented = false; + state.result += common.repeat('\n', emptyLines + 1); + + // Just one line break - perceive as the same line. + } else if (emptyLines === 0) { + if (didReadContent) { // i.e. only if we have already read some scalar content. + state.result += ' '; } + + // Several line breaks - perceive as different lines. + } else { + state.result += common.repeat('\n', emptyLines); + } + + // Literal style: just add exact number of line breaks between content lines. + } else { + // Keep all line breaks except the header line break. + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } + + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state.position; + + while (!is_EOL(ch) && (ch !== 0)) { + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, state.position, false); + } + + return true; +} + +function readBlockSequence(state, nodeIndent) { + var _line, + _tag = state.tag, + _anchor = state.anchor, + _result = [], + following, + detected = false, + ch; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + + if (ch !== 0x2D/* - */) { + break; + } + + following = state.input.charCodeAt(state.position + 1); + + if (!is_WS_OR_EOL(following)) { + break; + } + + detected = true; + state.position++; + + if (skipSeparationSpace(state, true, -1)) { + if (state.lineIndent <= nodeIndent) { + _result.push(null); + ch = state.input.charCodeAt(state.position); + continue; + } + } + + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state.result); + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a sequence entry'); + } else if (state.lineIndent < nodeIndent) { + break; } + } + + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'sequence'; + state.result = _result; + return true; + } + return false; } -exports.mutation_insert = mutation_insert; -/** - * Inserts a node into a parent node. Optimized routine for the common case where - * node is not a document fragment node and it has no child nodes. - * - * @param node - node to insert - * @param parent - parent node to receive node - * @param suppressObservers - whether to notify observers - */ -function mutation_insert_single(node, parent, suppressObservers) { - /** - * 1. Let count be the number of children of node if it is a - * DocumentFragment node, and one otherwise. - * 2. If child is non-null, then: - * 2.1. For each live range whose start node is parent and start - * offset is greater than child's index, increase its start - * offset by count. - * 2.2. For each live range whose end node is parent and end - * offset is greater than child's index, increase its end - * offset by count. - * 3. Let nodes be node’s children, if node is a DocumentFragment node; - * otherwise « node ». - * 4. If node is a DocumentFragment node, remove its children with the - * suppress observers flag set. - * 5. If node is a DocumentFragment node, then queue a tree mutation record - * for node with « », nodes, null, and null. - */ - /** - * 6. Let previousSibling be child’s previous sibling or parent’s last - * child if child is null. - */ - var previousSibling = parent._lastChild; - // set document element node - if (util_1.Guard.isElementNode(node)) { - // set document element node - if (util_1.Guard.isDocumentNode(parent)) { - parent._documentElement = node; + +function readBlockMapping(state, nodeIndent, flowIndent) { + var following, + allowCompact, + _line, + _pos, + _tag = state.tag, + _anchor = state.anchor, + _result = {}, + overridableKeys = {}, + keyTag = null, + keyNode = null, + valueNode = null, + atExplicitKey = false, + detected = false, + ch; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + following = state.input.charCodeAt(state.position + 1); + _line = state.line; // Save the current line. + _pos = state.position; + + // + // Explicit notation case. There are two separate blocks: + // first for the key (denoted by "?") and second for the value (denoted by ":") + // + if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { + + if (ch === 0x3F/* ? */) { + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); + keyTag = keyNode = valueNode = null; } - // mark that the document has namespaces - if (!node._nodeDocument._hasNamespaces && (node._namespace !== null || - node._namespacePrefix !== null)) { - node._nodeDocument._hasNamespaces = true; + + detected = true; + atExplicitKey = true; + allowCompact = true; + + } else if (atExplicitKey) { + // i.e. 0x3A/* : */ === character after the explicit key. + atExplicitKey = false; + allowCompact = true; + + } else { + throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + } + + state.position += 1; + ch = following; + + // + // Implicit notation case. Flow-style node as the key first, then ":", and the value. + // + } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + + if (state.line === _line) { + ch = state.input.charCodeAt(state.position); + + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); } - } - /** - * 7. For each node in nodes, in tree order: - * 7.1. If child is null, then append node to parent’s children. - * 7.2. Otherwise, insert node into parent’s children before child’s - * index. - */ - node._parent = parent; - parent._children.add(node); - // assign siblings and children for quick lookups - if (parent._firstChild === null) { - node._previousSibling = null; - node._nextSibling = null; - parent._firstChild = node; - parent._lastChild = node; - } - else { - var prev = parent._lastChild; - node._previousSibling = prev; - node._nextSibling = null; - if (prev) - prev._nextSibling = node; - if (!prev) - parent._firstChild = node; - parent._lastChild = node; - } - /** - * 7.3. If parent is a shadow host and node is a slotable, then - * assign a slot for node. - */ - if (DOMImpl_1.dom.features.slots) { - if (parent._shadowRoot !== null && util_1.Guard.isSlotable(node)) { - ShadowTreeAlgorithm_1.shadowTree_assignASlot(node); + + if (ch === 0x3A/* : */) { + ch = state.input.charCodeAt(++state.position); + + if (!is_WS_OR_EOL(ch)) { + throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); + } + + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state.tag; + keyNode = state.result; + + } else if (detected) { + throwError(state, 'can not read an implicit mapping pair; a colon is missed'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. } + + } else if (detected) { + throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + + } else { + break; // Reading is done. Go to the epilogue. } - /** - * 7.4. If node is a Text node, run the child text content change - * steps for parent. - */ - if (DOMImpl_1.dom.features.steps) { - if (util_1.Guard.isTextNode(node)) { - DOMAlgorithm_1.dom_runChildTextContentChangeSteps(parent); + + // + // Common reading code for both explicit and implicit notations. + // + if (state.line === _line || state.lineIndent > nodeIndent) { + if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state.result; + } else { + valueNode = state.result; } + } + + if (!atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos); + keyTag = keyNode = valueNode = null; + } + + skipSeparationSpace(state, true, -1); + ch = state.input.charCodeAt(state.position); } - /** - * 7.5. If parent's root is a shadow root, and parent is a slot - * whose assigned nodes is the empty list, then run signal - * a slot change for parent. - */ - if (DOMImpl_1.dom.features.slots) { - if (util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(parent)) && - util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { - ShadowTreeAlgorithm_1.shadowTree_signalASlotChange(parent); + + if (state.lineIndent > nodeIndent && (ch !== 0)) { + throwError(state, 'bad indentation of a mapping entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + // + // Epilogue. + // + + // Special case: last mapping's node contains only the key in explicit notation. + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null); + } + + // Expose the resulting mapping. + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'mapping'; + state.result = _result; + } + + return detected; +} + +function readTagProperty(state) { + var _position, + isVerbatim = false, + isNamed = false, + tagHandle, + tagName, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x21/* ! */) return false; + + if (state.tag !== null) { + throwError(state, 'duplication of a tag property'); + } + + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x3C/* < */) { + isVerbatim = true; + ch = state.input.charCodeAt(++state.position); + + } else if (ch === 0x21/* ! */) { + isNamed = true; + tagHandle = '!!'; + ch = state.input.charCodeAt(++state.position); + + } else { + tagHandle = '!'; + } + + _position = state.position; + + if (isVerbatim) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && ch !== 0x3E/* > */); + + if (state.position < state.length) { + tagName = state.input.slice(_position, state.position); + ch = state.input.charCodeAt(++state.position); + } else { + throwError(state, 'unexpected end of the stream within a verbatim tag'); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + + if (ch === 0x21/* ! */) { + if (!isNamed) { + tagHandle = state.input.slice(_position - 1, state.position + 1); + + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state, 'named tag handle cannot contain such characters'); + } + + isNamed = true; + _position = state.position + 1; + } else { + throwError(state, 'tag suffix cannot contain exclamation marks'); } + } + + ch = state.input.charCodeAt(++state.position); } - /** - * 7.6. Run assign slotables for a tree with node's root. - */ - if (DOMImpl_1.dom.features.slots) { - ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(node)); + + tagName = state.input.slice(_position, state.position); + + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state, 'tag suffix cannot contain flow indicator characters'); } - /** - * 7.7. For each shadow-including inclusive descendant - * inclusiveDescendant of node, in shadow-including tree - * order: - * 7.7.1. Run the insertion steps with inclusiveDescendant. - */ - if (DOMImpl_1.dom.features.steps) { - DOMAlgorithm_1.dom_runInsertionSteps(node); + } + + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state, 'tag name cannot contain such characters: ' + tagName); + } + + if (isVerbatim) { + state.tag = tagName; + + } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { + state.tag = state.tagMap[tagHandle] + tagName; + + } else if (tagHandle === '!') { + state.tag = '!' + tagName; + + } else if (tagHandle === '!!') { + state.tag = 'tag:yaml.org,2002:' + tagName; + + } else { + throwError(state, 'undeclared tag handle "' + tagHandle + '"'); + } + + return true; +} + +function readAnchorProperty(state) { + var _position, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x26/* & */) return false; + + if (state.anchor !== null) { + throwError(state, 'duplication of an anchor property'); + } + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an anchor node must contain at least one character'); + } + + state.anchor = state.input.slice(_position, state.position); + return true; +} + +function readAlias(state) { + var _position, alias, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x2A/* * */) return false; + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an alias node must contain at least one character'); + } + + alias = state.input.slice(_position, state.position); + + if (!state.anchorMap.hasOwnProperty(alias)) { + throwError(state, 'unidentified alias "' + alias + '"'); + } + + state.result = state.anchorMap[alias]; + skipSeparationSpace(state, true, -1); + return true; +} + +function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, + allowBlockScalars, + allowBlockCollections, + indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } } - if (DOMImpl_1.dom.features.customElements) { - /** - * 7.7.2. If inclusiveDescendant is connected, then: - */ - if (util_1.Guard.isElementNode(node) && - ShadowTreeAlgorithm_1.shadowTree_isConnected(node)) { - if (util_1.Guard.isCustomElementNode(node)) { - /** - * 7.7.2.1. If inclusiveDescendant is custom, then enqueue a custom - * element callback reaction with inclusiveDescendant, callback name - * "connectedCallback", and an empty argument list. - */ - CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(node, "connectedCallback", []); - } - else { - /** - * 7.7.2.2. Otherwise, try to upgrade inclusiveDescendant. - */ - CustomElementAlgorithm_1.customElement_tryToUpgrade(node); - } + } + + if (indentStatus === 1) { + while (readTagProperty(state) || readAnchorProperty(state)) { + if (skipSeparationSpace(state, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + + if (state.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; } + } else { + allowBlockCollections = false; + } + } + } + + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } + + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; } - /** - * 8. If suppress observers flag is unset, then queue a tree mutation record - * for parent with nodes, « », previousSibling, and child. - */ - if (DOMImpl_1.dom.features.mutationObservers) { - if (!suppressObservers) { - MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, [node], [], previousSibling, null); + + blockIndent = state.position - state.lineStart; + + if (indentStatus === 1) { + if (allowBlockCollections && + (readBlockSequence(state, blockIndent) || + readBlockMapping(state, blockIndent, flowIndent)) || + readFlowCollection(state, flowIndent)) { + hasContent = true; + } else { + if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || + readSingleQuotedScalar(state, flowIndent) || + readDoubleQuotedScalar(state, flowIndent)) { + hasContent = true; + + } else if (readAlias(state)) { + hasContent = true; + + if (state.tag !== null || state.anchor !== null) { + throwError(state, 'alias node should not have any properties'); + } + + } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + + if (state.tag === null) { + state.tag = '?'; + } } - } -} -/** - * Appends a node to the children of a parent node. - * - * @param node - a node - * @param parent - the parent to receive node - */ -function mutation_append(node, parent) { - /** - * To append a node to a parent, pre-insert node into parent before null. - */ - return mutation_preInsert(node, parent, null); -} -exports.mutation_append = mutation_append; -/** - * Replaces a node with another node. - * - * @param child - child node to remove - * @param node - node to insert - * @param parent - parent node to receive node - */ -function mutation_replace(child, node, parent) { - var e_6, _a, e_7, _b, e_8, _c, e_9, _d; - /** - * 1. If parent is not a Document, DocumentFragment, or Element node, - * throw a "HierarchyRequestError" DOMException. - */ - if (parent._nodeType !== interfaces_1.NodeType.Document && - parent._nodeType !== interfaces_1.NodeType.DocumentFragment && - parent._nodeType !== interfaces_1.NodeType.Element) - throw new DOMException_1.HierarchyRequestError("Only document, document fragment and element nodes can contain child nodes. Parent node is " + parent.nodeName + "."); - /** - * 2. If node is a host-including inclusive ancestor of parent, throw a - * "HierarchyRequestError" DOMException. - */ - if (TreeAlgorithm_1.tree_isHostIncludingAncestorOf(parent, node, true)) - throw new DOMException_1.HierarchyRequestError("The node to be inserted cannot be an ancestor of parent node. Node is " + node.nodeName + ", parent node is " + parent.nodeName + "."); - /** - * 3. If child’s parent is not parent, then throw a "NotFoundError" - * DOMException. - */ - if (child._parent !== parent) - throw new DOMException_1.NotFoundError("The reference child node cannot be found under parent node. Child node is " + child.nodeName + ", parent node is " + parent.nodeName + "."); - /** - * 4. If node is not a DocumentFragment, DocumentType, Element, Text, - * ProcessingInstruction, or Comment node, throw a "HierarchyRequestError" - * DOMException. - */ - if (node._nodeType !== interfaces_1.NodeType.DocumentFragment && - node._nodeType !== interfaces_1.NodeType.DocumentType && - node._nodeType !== interfaces_1.NodeType.Element && - node._nodeType !== interfaces_1.NodeType.Text && - node._nodeType !== interfaces_1.NodeType.ProcessingInstruction && - node._nodeType !== interfaces_1.NodeType.CData && - node._nodeType !== interfaces_1.NodeType.Comment) - throw new DOMException_1.HierarchyRequestError("Only document fragment, document type, element, text, processing instruction, cdata section or comment nodes can be inserted. Node is " + node.nodeName + "."); - /** - * 5. If either node is a Text node and parent is a document, or node is a - * doctype and parent is not a document, throw a "HierarchyRequestError" - * DOMException. - */ - if (node._nodeType === interfaces_1.NodeType.Text && - parent._nodeType === interfaces_1.NodeType.Document) - throw new DOMException_1.HierarchyRequestError("Cannot insert a text node as a child of a document node. Node is " + node.nodeName + "."); - if (node._nodeType === interfaces_1.NodeType.DocumentType && - parent._nodeType !== interfaces_1.NodeType.Document) - throw new DOMException_1.HierarchyRequestError("A document type node can only be inserted under a document node. Parent node is " + parent.nodeName + "."); - /** - * 6. If parent is a document, and any of the statements below, switched on - * node, are true, throw a "HierarchyRequestError" DOMException. - * - DocumentFragment node - * If node has more than one element child or has a Text node child. - * Otherwise, if node has one element child and either parent has an element - * child that is not child or a doctype is following child. - * - element - * parent has an element child that is not child or a doctype is - * following child. - * - doctype - * parent has a doctype child that is not child, or an element is - * preceding child. - */ - if (parent._nodeType === interfaces_1.NodeType.Document) { - if (node._nodeType === interfaces_1.NodeType.DocumentFragment) { - var eleCount = 0; - try { - for (var _e = __values(node._children), _f = _e.next(); !_f.done; _f = _e.next()) { - var childNode = _f.value; - if (childNode._nodeType === interfaces_1.NodeType.Element) - eleCount++; - else if (childNode._nodeType === interfaces_1.NodeType.Text) - throw new DOMException_1.HierarchyRequestError("Cannot insert text a node as a child of a document node. Node is " + childNode.nodeName + "."); - } - } - catch (e_6_1) { e_6 = { error: e_6_1 }; } - finally { - try { - if (_f && !_f.done && (_a = _e.return)) _a.call(_e); - } - finally { if (e_6) throw e_6.error; } - } - if (eleCount > 1) { - throw new DOMException_1.HierarchyRequestError("A document node can only have one document element node. Document fragment to be inserted has " + eleCount + " element nodes."); - } - else if (eleCount === 1) { - try { - for (var _g = __values(parent._children), _h = _g.next(); !_h.done; _h = _g.next()) { - var ele = _h.value; - if (ele._nodeType === interfaces_1.NodeType.Element && ele !== child) - throw new DOMException_1.HierarchyRequestError("The document node already has a document element node."); - } - } - catch (e_7_1) { e_7 = { error: e_7_1 }; } - finally { - try { - if (_h && !_h.done && (_b = _g.return)) _b.call(_g); - } - finally { if (e_7) throw e_7.error; } - } - var doctypeChild = child._nextSibling; - while (doctypeChild) { - if (doctypeChild._nodeType === interfaces_1.NodeType.DocumentType) - throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node."); - doctypeChild = doctypeChild._nextSibling; - } - } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; } - else if (node._nodeType === interfaces_1.NodeType.Element) { - try { - for (var _j = __values(parent._children), _k = _j.next(); !_k.done; _k = _j.next()) { - var ele = _k.value; - if (ele._nodeType === interfaces_1.NodeType.Element && ele !== child) - throw new DOMException_1.HierarchyRequestError("Document already has a document element node. Node is " + node.nodeName + "."); - } - } - catch (e_8_1) { e_8 = { error: e_8_1 }; } - finally { - try { - if (_k && !_k.done && (_c = _j.return)) _c.call(_j); - } - finally { if (e_8) throw e_8.error; } - } - var doctypeChild = child._nextSibling; - while (doctypeChild) { - if (doctypeChild._nodeType === interfaces_1.NodeType.DocumentType) - throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node. Node is " + node.nodeName + "."); - doctypeChild = doctypeChild._nextSibling; - } + } + } else if (indentStatus === 0) { + // Special case: block sequences are allowed to have same indentation level as the parent. + // http://www.yaml.org/spec/1.2/spec.html#id2799784 + hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); + } + } + + if (state.tag !== null && state.tag !== '!') { + if (state.tag === '?') { + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only automatically assigned to plain scalars. + // + // We only need to check kind conformity in case user explicitly assigns '?' + // tag, for example like this: "! [0]" + // + if (state.result !== null && state.kind !== 'scalar') { + throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + } + + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type = state.implicitTypes[typeIndex]; + + if (type.resolve(state.result)) { // `state.result` updated in resolver if matched + state.result = type.construct(state.result); + state.tag = type.tag; + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + break; } - else if (node._nodeType === interfaces_1.NodeType.DocumentType) { - try { - for (var _l = __values(parent._children), _m = _l.next(); !_m.done; _m = _l.next()) { - var ele = _m.value; - if (ele._nodeType === interfaces_1.NodeType.DocumentType && ele !== child) - throw new DOMException_1.HierarchyRequestError("Document already has a document type node. Node is " + node.nodeName + "."); - } - } - catch (e_9_1) { e_9 = { error: e_9_1 }; } - finally { - try { - if (_m && !_m.done && (_d = _l.return)) _d.call(_l); - } - finally { if (e_9) throw e_9.error; } - } - var elementChild = child._previousSibling; - while (elementChild) { - if (elementChild._nodeType === interfaces_1.NodeType.Element) - throw new DOMException_1.HierarchyRequestError("Cannot insert a document type node before an element node. Node is " + node.nodeName + "."); - elementChild = elementChild._previousSibling; - } + } + } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { + type = state.typeMap[state.kind || 'fallback'][state.tag]; + + if (state.result !== null && type.kind !== state.kind) { + throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + } + + if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched + throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); + } else { + state.result = type.construct(state.result); + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; } + } + } else { + throwError(state, 'unknown tag !<' + state.tag + '>'); } - /** - * 7. Let reference child be child’s next sibling. - * 8. If reference child is node, set it to node’s next sibling. - * 8. Let previousSibling be child’s previous sibling. - */ - var referenceChild = child._nextSibling; - if (referenceChild === node) - referenceChild = node._nextSibling; - var previousSibling = child._previousSibling; - /** - * 10. Adopt node into parent’s node document. - * 11. Let removedNodes be the empty list. - */ - DocumentAlgorithm_1.document_adopt(node, parent._nodeDocument); - var removedNodes = []; - /** - * 12. If child’s parent is not null, then: - */ - if (child._parent !== null) { - /** - * 12.1. Set removedNodes to [child]. - * 12.2. Remove child from its parent with the suppress observers flag - * set. - */ - removedNodes.push(child); - mutation_remove(child, child._parent, true); + } + + if (state.listener !== null) { + state.listener('close', state); + } + return state.tag !== null || state.anchor !== null || hasContent; +} + +function readDocument(state) { + var documentStart = state.position, + _position, + directiveName, + directiveArgs, + hasDirectives = false, + ch; + + state.version = null; + state.checkLineBreaks = state.legacy; + state.tagMap = {}; + state.anchorMap = {}; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if (state.lineIndent > 0 || ch !== 0x25/* % */) { + break; } - /** - * 13. Let nodes be node’s children if node is a DocumentFragment node; - * otherwise [node]. - */ - var nodes = []; - if (node._nodeType === interfaces_1.NodeType.DocumentFragment) { - nodes = Array.from(node._children); + + hasDirectives = true; + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); } - else { - nodes.push(node); + + directiveName = state.input.slice(_position, state.position); + directiveArgs = []; + + if (directiveName.length < 1) { + throwError(state, 'directive name must not be less than one character in length'); } - /** - * 14. Insert node into parent before reference child with the suppress - * observers flag set. - */ - mutation_insert(node, parent, referenceChild, true); - /** - * 15. Queue a tree mutation record for parent with nodes, removedNodes, - * previousSibling, and reference child. - */ - if (DOMImpl_1.dom.features.mutationObservers) { - MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, nodes, removedNodes, previousSibling, referenceChild); + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && !is_EOL(ch)); + break; + } + + if (is_EOL(ch)) break; + + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveArgs.push(state.input.slice(_position, state.position)); } - /** - * 16. Return child. - */ - return child; -} -exports.mutation_replace = mutation_replace; -/** - * Replaces all nodes of a parent with the given node. - * - * @param node - node to insert - * @param parent - parent node to receive node - */ -function mutation_replaceAll(node, parent) { - var e_10, _a; - /** - * 1. If node is not null, adopt node into parent’s node document. - */ - if (node !== null) { - DocumentAlgorithm_1.document_adopt(node, parent._nodeDocument); + + if (ch !== 0) readLineBreak(state); + + if (_hasOwnProperty.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state, directiveName, directiveArgs); + } else { + throwWarning(state, 'unknown document directive "' + directiveName + '"'); } - /** - * 2. Let removedNodes be parent’s children. - */ - var removedNodes = Array.from(parent._children); - /** - * 3. Let addedNodes be the empty list. - * 4. If node is DocumentFragment node, then set addedNodes to node’s - * children. - * 5. Otherwise, if node is non-null, set addedNodes to [node]. - */ - var addedNodes = []; - if (node && node._nodeType === interfaces_1.NodeType.DocumentFragment) { - addedNodes = Array.from(node._children); + } + + skipSeparationSpace(state, true, -1); + + if (state.lineIndent === 0 && + state.input.charCodeAt(state.position) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + + } else if (hasDirectives) { + throwError(state, 'directives end mark is expected'); + } + + composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state, true, -1); + + if (state.checkLineBreaks && + PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { + throwWarning(state, 'non-ASCII line breaks are interpreted as content'); + } + + state.documents.push(state.result); + + if (state.position === state.lineStart && testDocumentSeparator(state)) { + + if (state.input.charCodeAt(state.position) === 0x2E/* . */) { + state.position += 3; + skipSeparationSpace(state, true, -1); } - else if (node !== null) { - addedNodes.push(node); + return; + } + + if (state.position < (state.length - 1)) { + throwError(state, 'end of the stream or a document separator is expected'); + } else { + return; + } +} + + +function loadDocuments(input, options) { + input = String(input); + options = options || {}; + + if (input.length !== 0) { + + // Add tailing `\n` if not exists + if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && + input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { + input += '\n'; } - try { - /** - * 6. Remove all parent’s children, in tree order, with the suppress - * observers flag set. - */ - for (var removedNodes_1 = __values(removedNodes), removedNodes_1_1 = removedNodes_1.next(); !removedNodes_1_1.done; removedNodes_1_1 = removedNodes_1.next()) { - var childNode = removedNodes_1_1.value; - mutation_remove(childNode, parent, true); + + // Strip BOM + if (input.charCodeAt(0) === 0xFEFF) { + input = input.slice(1); + } + } + + var state = new State(input, options); + + var nullpos = input.indexOf('\0'); + + if (nullpos !== -1) { + state.position = nullpos; + throwError(state, 'null byte is not allowed in input'); + } + + // Use 0 as string terminator. That significantly simplifies bounds check. + state.input += '\0'; + + while (state.input.charCodeAt(state.position) === 0x20/* Space */) { + state.lineIndent += 1; + state.position += 1; + } + + while (state.position < (state.length - 1)) { + readDocument(state); + } + + return state.documents; +} + + +function loadAll(input, iterator, options) { + if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { + options = iterator; + iterator = null; + } + + var documents = loadDocuments(input, options); + + if (typeof iterator !== 'function') { + return documents; + } + + for (var index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} + + +function load(input, options) { + var documents = loadDocuments(input, options); + + if (documents.length === 0) { + /*eslint-disable no-undefined*/ + return undefined; + } else if (documents.length === 1) { + return documents[0]; + } + throw new YAMLException('expected a single document in the stream, but found more'); +} + + +function safeLoadAll(input, iterator, options) { + if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') { + options = iterator; + iterator = null; + } + + return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +} + + +function safeLoad(input, options) { + return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +} + + +module.exports.loadAll = loadAll; +module.exports.load = load; +module.exports.safeLoadAll = safeLoadAll; +module.exports.safeLoad = safeLoad; + + +/***/ }), +/* 458 */, +/* 459 */, +/* 460 */, +/* 461 */, +/* 462 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } - catch (e_10_1) { e_10 = { error: e_10_1 }; } + catch (error) { e = { error: error }; } finally { try { - if (removedNodes_1_1 && !removedNodes_1_1.done && (_a = removedNodes_1.return)) _a.call(removedNodes_1); + if (r && !r.done && (m = i["return"])) m.call(i); } - finally { if (e_10) throw e_10.error; } - } - /** - * 7. If node is not null, then insert node into parent before null with the - * suppress observers flag set. - */ - if (node !== null) { - mutation_insert(node, parent, null, true); - } - /** - * 8. Queue a tree mutation record for parent with addedNodes, removedNodes, - * null, and null. - */ - if (DOMImpl_1.dom.features.mutationObservers) { - MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, addedNodes, removedNodes, null, null); + finally { if (e) throw e.error; } } -} -exports.mutation_replaceAll = mutation_replaceAll; + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var interfaces_1 = __webpack_require__(970); +var LocalNameSet_1 = __webpack_require__(575); +var NamespacePrefixMap_1 = __webpack_require__(392); +var infra_1 = __webpack_require__(23); +var algorithm_1 = __webpack_require__(163); /** - * Ensures pre-removal validity of a child node from a parent, then - * removes it. - * - * @param child - child node to remove - * @param parent - parent node + * Pre-serializes XML nodes. */ -function mutation_preRemove(child, parent) { +var BaseWriter = /** @class */ (function () { /** - * 1. If child’s parent is not parent, then throw a "NotFoundError" - * DOMException. - * 2. Remove child from parent. - * 3. Return child. + * Initializes a new instance of `BaseWriter`. + * + * @param builderOptions - XML builder options */ - if (child._parent !== parent) - throw new DOMException_1.NotFoundError("The child node cannot be found under parent node. Child node is " + child.nodeName + ", parent node is " + parent.nodeName + "."); - mutation_remove(child, parent); - return child; -} -exports.mutation_preRemove = mutation_preRemove; -/** - * Removes a child node from its parent. - * - * @param node - node to remove - * @param parent - parent node - * @param suppressObservers - whether to notify observers - */ -function mutation_remove(node, parent, suppressObservers) { - var e_11, _a, e_12, _b, e_13, _c, e_14, _d; - if (DOMImpl_1.dom.rangeList.size !== 0) { + function BaseWriter(builderOptions) { /** - * 1. Let index be node’s index. + * Gets the current depth of the XML tree. */ - var index = TreeAlgorithm_1.tree_index(node); - try { - /** - * 2. For each live range whose start node is an inclusive descendant of - * node, set its start to (parent, index). - * 3. For each live range whose end node is an inclusive descendant of - * node, set its end to (parent, index). - */ - for (var _e = __values(DOMImpl_1.dom.rangeList), _f = _e.next(); !_f.done; _f = _e.next()) { - var range = _f.value; - if (TreeAlgorithm_1.tree_isDescendantOf(node, range._start[0], true)) { - range._start = [parent, index]; - } - if (TreeAlgorithm_1.tree_isDescendantOf(node, range._end[0], true)) { - range._end = [parent, index]; - } - if (range._start[0] === parent && range._start[1] > index) { - range._start[1]--; - } - if (range._end[0] === parent && range._end[1] > index) { - range._end[1]--; - } - } - } - catch (e_11_1) { e_11 = { error: e_11_1 }; } - finally { - try { - if (_f && !_f.done && (_a = _e.return)) _a.call(_e); - } - finally { if (e_11) throw e_11.error; } - } - try { - /** - * 4. For each live range whose start node is parent and start offset is - * greater than index, decrease its start offset by 1. - * 5. For each live range whose end node is parent and end offset is greater - * than index, decrease its end offset by 1. - */ - for (var _g = __values(DOMImpl_1.dom.rangeList), _h = _g.next(); !_h.done; _h = _g.next()) { - var range = _h.value; - if (range._start[0] === parent && range._start[1] > index) { - range._start[1] -= 1; - } - if (range._end[0] === parent && range._end[1] > index) { - range._end[1] -= 1; - } - } - } - catch (e_12_1) { e_12 = { error: e_12_1 }; } - finally { - try { - if (_h && !_h.done && (_b = _g.return)) _b.call(_g); - } - finally { if (e_12) throw e_12.error; } - } + this.level = 0; + this._builderOptions = builderOptions; } /** - * 6. For each NodeIterator object iterator whose root’s node document is - * node’s node document, run the NodeIterator pre-removing steps given node - * and iterator. + * Used by derived classes to serialize the XML declaration. + * + * @param version - a version number string + * @param encoding - encoding declaration + * @param standalone - standalone document declaration */ - if (DOMImpl_1.dom.features.steps) { - try { - for (var _j = __values(NodeIteratorAlgorithm_1.nodeIterator_iteratorList()), _k = _j.next(); !_k.done; _k = _j.next()) { - var iterator = _k.value; - if (iterator._root._nodeDocument === node._nodeDocument) { - DOMAlgorithm_1.dom_runNodeIteratorPreRemovingSteps(iterator, node); - } - } - } - catch (e_13_1) { e_13 = { error: e_13_1 }; } - finally { - try { - if (_k && !_k.done && (_c = _j.return)) _c.call(_j); - } - finally { if (e_13) throw e_13.error; } - } - } + BaseWriter.prototype.declaration = function (version, encoding, standalone) { }; /** - * 7. Let oldPreviousSibling be node’s previous sibling. - * 8. Let oldNextSibling be node’s next sibling. + * Used by derived classes to serialize a DocType node. + * + * @param name - node name + * @param publicId - public identifier + * @param systemId - system identifier */ - var oldPreviousSibling = node._previousSibling; - var oldNextSibling = node._nextSibling; - // set document element node - if (util_1.Guard.isDocumentNode(parent) && util_1.Guard.isElementNode(node)) { - parent._documentElement = null; - } + BaseWriter.prototype.docType = function (name, publicId, systemId) { }; /** - * 9. Remove node from its parent’s children. + * Used by derived classes to serialize a comment node. + * + * @param data - node data */ - node._parent = null; - parent._children.delete(node); - // assign siblings and children for quick lookups - var prev = node._previousSibling; - var next = node._nextSibling; - node._previousSibling = null; - node._nextSibling = null; - if (prev) - prev._nextSibling = next; - if (next) - next._previousSibling = prev; - if (!prev) - parent._firstChild = next; - if (!next) - parent._lastChild = prev; + BaseWriter.prototype.comment = function (data) { }; /** - * 10. If node is assigned, then run assign slotables for node’s assigned - * slot. + * Used by derived classes to serialize a text node. + * + * @param data - node data */ - if (DOMImpl_1.dom.features.slots) { - if (util_1.Guard.isSlotable(node) && node._assignedSlot !== null && ShadowTreeAlgorithm_1.shadowTree_isAssigned(node)) { - ShadowTreeAlgorithm_1.shadowTree_assignSlotables(node._assignedSlot); - } - } + BaseWriter.prototype.text = function (data) { }; /** - * 11. If parent’s root is a shadow root, and parent is a slot whose - * assigned nodes is the empty list, then run signal a slot change for - * parent. + * Used by derived classes to serialize a processing instruction node. + * + * @param target - instruction target + * @param data - node data */ - if (DOMImpl_1.dom.features.slots) { - if (util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(parent)) && - util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { - ShadowTreeAlgorithm_1.shadowTree_signalASlotChange(parent); - } - } + BaseWriter.prototype.instruction = function (target, data) { }; /** - * 12. If node has an inclusive descendant that is a slot, then: - * 12.1. Run assign slotables for a tree with parent's root. - * 12.2. Run assign slotables for a tree with node. + * Used by derived classes to serialize a CData section node. + * + * @param data - node data */ - if (DOMImpl_1.dom.features.slots) { - var descendant_1 = TreeAlgorithm_1.tree_getFirstDescendantNode(node, true, false, function (e) { return util_1.Guard.isSlot(e); }); - if (descendant_1 !== null) { - ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(parent)); - ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(node); - } - } + BaseWriter.prototype.cdata = function (data) { }; /** - * 13. Run the removing steps with node and parent. + * Used by derived classes to serialize the beginning of the opening tag of an + * element node. + * + * @param name - node name */ - if (DOMImpl_1.dom.features.steps) { - DOMAlgorithm_1.dom_runRemovingSteps(node, parent); - } + BaseWriter.prototype.openTagBegin = function (name) { }; /** - * 14. If node is custom, then enqueue a custom element callback - * reaction with node, callback name "disconnectedCallback", - * and an empty argument list. + * Used by derived classes to serialize the ending of the opening tag of an + * element node. + * + * @param name - node name + * @param selfClosing - whether the element node is self closing + * @param voidElement - whether the element node is a HTML void element */ - if (DOMImpl_1.dom.features.customElements) { - if (util_1.Guard.isCustomElementNode(node)) { - CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(node, "disconnectedCallback", []); - } - } + BaseWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { }; /** - * 15. For each shadow-including descendant descendant of node, - * in shadow-including tree order, then: + * Used by derived classes to serialize the closing tag of an element node. + * + * @param name - node name */ - var descendant = TreeAlgorithm_1.tree_getFirstDescendantNode(node, false, true); - while (descendant !== null) { - /** - * 15.1. Run the removing steps with descendant. - */ - if (DOMImpl_1.dom.features.steps) { - DOMAlgorithm_1.dom_runRemovingSteps(descendant, node); - } - /** - * 15.2. If descendant is custom, then enqueue a custom element - * callback reaction with descendant, callback name - * "disconnectedCallback", and an empty argument list. - */ - if (DOMImpl_1.dom.features.customElements) { - if (util_1.Guard.isCustomElementNode(descendant)) { - CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(descendant, "disconnectedCallback", []); - } - } - descendant = TreeAlgorithm_1.tree_getNextDescendantNode(node, descendant, false, true); - } + BaseWriter.prototype.closeTag = function (name) { }; /** - * 16. For each inclusive ancestor inclusiveAncestor of parent, and - * then for each registered of inclusiveAncestor's registered - * observer list, if registered's options's subtree is true, - * then append a new transient registered observer whose - * observer is registered's observer, options is registered's - * options, and source is registered to node's registered - * observer list. + * Used by derived classes to serialize attributes or namespace declarations. + * + * @param attributes - attribute array */ - if (DOMImpl_1.dom.features.mutationObservers) { - var inclusiveAncestor = TreeAlgorithm_1.tree_getFirstAncestorNode(parent, true); - while (inclusiveAncestor !== null) { - try { - for (var _l = (e_14 = void 0, __values(inclusiveAncestor._registeredObserverList)), _m = _l.next(); !_m.done; _m = _l.next()) { - var registered = _m.value; - if (registered.options.subtree) { - node._registeredObserverList.push({ - observer: registered.observer, - options: registered.options, - source: registered - }); - } - } + BaseWriter.prototype.attributes = function (attributes) { + var e_1, _a; + try { + for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) { + var attr = attributes_1_1.value; + this.attribute(attr[1] === null ? attr[2] : attr[1] + ':' + attr[2], attr[3]); } - catch (e_14_1) { e_14 = { error: e_14_1 }; } - finally { - try { - if (_m && !_m.done && (_d = _l.return)) _d.call(_l); - } - finally { if (e_14) throw e_14.error; } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1); } - inclusiveAncestor = TreeAlgorithm_1.tree_getNextAncestorNode(parent, inclusiveAncestor, true); + finally { if (e_1) throw e_1.error; } } - } + }; /** - * 17. If suppress observers flag is unset, then queue a tree mutation - * record for parent with « », « node », oldPreviousSibling, and - * oldNextSibling. + * Used by derived classes to serialize an attribute or namespace declaration. + * + * @param name - node name + * @param value - node value */ - if (DOMImpl_1.dom.features.mutationObservers) { - if (!suppressObservers) { - MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, [], [node], oldPreviousSibling, oldNextSibling); - } - } + BaseWriter.prototype.attribute = function (name, value) { }; /** - * 18. If node is a Text node, then run the child text content change steps - * for parent. + * Used by derived classes to perform any pre-processing steps before starting + * serializing an element node. + * + * @param name - node name */ - if (DOMImpl_1.dom.features.steps) { - if (util_1.Guard.isTextNode(node)) { - DOMAlgorithm_1.dom_runChildTextContentChangeSteps(parent); - } - } -} -exports.mutation_remove = mutation_remove; -//# sourceMappingURL=MutationAlgorithm.js.map - -/***/ }), -/* 480 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const Range = __webpack_require__(124) -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 - - -/***/ }), -/* 481 */, -/* 482 */, -/* 483 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMException_1 = __webpack_require__(35); -/** - * Matches elements with the given selectors. - * - * @param selectors - selectors - * @param node - the node to match against - */ -function selectors_scopeMatchASelectorsString(selectors, node) { + BaseWriter.prototype.beginElement = function (name) { }; /** - * TODO: Selectors - * 1. Let s be the result of parse a selector selectors. [SELECTORS4] - * 2. If s is failure, then throw a "SyntaxError" DOMException. - * 3. Return the result of match a selector against a tree with s and node’s - * root using scoping root node. [SELECTORS4]. + * Used by derived classes to perform any post-processing steps after + * completing serializing an element node. + * + * @param name - node name */ - throw new DOMException_1.NotSupportedError(); -} -exports.selectors_scopeMatchASelectorsString = selectors_scopeMatchASelectorsString; -//# sourceMappingURL=SelectorsAlgorithm.js.map - -/***/ }), -/* 484 */, -/* 485 */, -/* 486 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const gt = (a, b, loose) => compare(a, b, loose) > 0 -module.exports = gt - - -/***/ }), -/* 487 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var interfaces_1 = __webpack_require__(970); -/** - * Represents an object which can be used to iterate through the nodes - * of a subtree. - */ -var TraverserImpl = /** @class */ (function () { + BaseWriter.prototype.endElement = function (name) { }; + /** + * Produces an XML serialization of the given node. The pre-serializer inserts + * namespace declarations where necessary and produces qualified names for + * nodes and attributes. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype.serializeNode = function (node, requireWellFormed, noDoubleEncoding) { + var hasNamespaces = (node._nodeDocument !== undefined && node._nodeDocument._hasNamespaces); + this.level = 0; + this.currentNode = node; + if (hasNamespaces) { + /** From: https://w3c.github.io/DOM-Parsing/#xml-serialization + * + * 1. Let namespace be a context namespace with value null. + * The context namespace tracks the XML serialization algorithm's current + * default namespace. The context namespace is changed when either an Element + * Node has a default namespace declaration, or the algorithm generates a + * default namespace declaration for the Element Node to match its own + * namespace. The algorithm assumes no namespace (null) to start. + * 2. Let prefix map be a new namespace prefix map. + * 3. Add the XML namespace with prefix value "xml" to prefix map. + * 4. Let prefix index be a generated namespace prefix index with value 1. + * The generated namespace prefix index is used to generate a new unique + * prefix value when no suitable existing namespace prefix is available to + * serialize a node's namespaceURI (or the namespaceURI of one of node's + * attributes). See the generate a prefix algorithm. + */ + var namespace = null; + var prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); + prefixMap.set("xml", infra_1.namespace.XML); + var prefixIndex = { value: 1 }; + /** + * 5. Return the result of running the XML serialization algorithm on node + * passing the context namespace namespace, namespace prefix map prefix map, + * generated namespace prefix index reference to prefix index, and the + * flag require well-formed. If an exception occurs during the execution + * of the algorithm, then catch that exception and throw an + * "InvalidStateError" DOMException. + */ + this._serializeNodeNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + } + else { + this._serializeNode(node, requireWellFormed, noDoubleEncoding); + } + }; /** - * Initializes a new instance of `Traverser`. + * Produces an XML serialization of a node. * - * @param root - root node + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance */ - function TraverserImpl(root) { - this._activeFlag = false; - this._root = root; - this._whatToShow = interfaces_1.WhatToShow.All; - this._filter = null; - } - Object.defineProperty(TraverserImpl.prototype, "root", { - /** @inheritdoc */ - get: function () { return this._root; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TraverserImpl.prototype, "whatToShow", { - /** @inheritdoc */ - get: function () { return this._whatToShow; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TraverserImpl.prototype, "filter", { - /** @inheritdoc */ - get: function () { return this._filter; }, - enumerable: true, - configurable: true - }); - return TraverserImpl; -}()); -exports.TraverserImpl = TraverserImpl; -//# sourceMappingURL=TraverserImpl.js.map - -/***/ }), -/* 488 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; + BaseWriter.prototype._serializeNodeNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + this.currentNode = node; + switch (node.nodeType) { + case interfaces_1.NodeType.Element: + this._serializeElementNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Document: + this._serializeDocumentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Comment: + this._serializeComment(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Text: + this._serializeText(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentFragment: + this._serializeDocumentFragmentNS(node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentType: + this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.ProcessingInstruction: + this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.CData: + this._serializeCData(node, requireWellFormed, noDoubleEncoding); + break; + default: + throw new Error("Unknown node type: " + node.nodeType); } }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); + /** + * Produces an XML serialization of a node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeNode = function (node, requireWellFormed, noDoubleEncoding) { + this.currentNode = node; + switch (node.nodeType) { + case interfaces_1.NodeType.Element: + this._serializeElement(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Document: + this._serializeDocument(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Comment: + this._serializeComment(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.Text: + this._serializeText(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentFragment: + this._serializeDocumentFragment(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.DocumentType: + this._serializeDocumentType(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.ProcessingInstruction: + this._serializeProcessingInstruction(node, requireWellFormed, noDoubleEncoding); + break; + case interfaces_1.NodeType.CData: + this._serializeCData(node, requireWellFormed, noDoubleEncoding); + break; + default: + throw new Error("Unknown node type: " + node.nodeType); } - finally { if (e) throw e.error; } - } - return ar; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var interfaces_1 = __webpack_require__(970); -var DOMException_1 = __webpack_require__(35); -var NodeImpl_1 = __webpack_require__(935); -var util_1 = __webpack_require__(918); -var util_2 = __webpack_require__(592); -var infra_1 = __webpack_require__(23); -var URLAlgorithm_1 = __webpack_require__(813); -var algorithm_1 = __webpack_require__(163); -var WebIDLAlgorithm_1 = __webpack_require__(495); -/** - * Represents a document node. - */ -var DocumentImpl = /** @class */ (function (_super) { - __extends(DocumentImpl, _super); + }; /** - * Initializes a new instance of `Document`. + * Produces an XML serialization of an element node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance */ - function DocumentImpl() { - var _this = _super.call(this) || this; - _this._children = new Set(); - _this._encoding = { - name: "UTF-8", - labels: ["unicode-1-1-utf-8", "utf-8", "utf8"] - }; - _this._contentType = 'application/xml'; - _this._URL = { - scheme: "about", - username: "", - password: "", - host: null, - port: null, - path: ["blank"], - query: null, - fragment: null, - _cannotBeABaseURLFlag: true, - _blobURLEntry: null - }; - _this._origin = null; - _this._type = "xml"; - _this._mode = "no-quirks"; - _this._documentElement = null; - _this._hasNamespaces = false; - _this._nodeDocumentOverwrite = null; - return _this; - } - Object.defineProperty(DocumentImpl.prototype, "_nodeDocument", { - get: function () { return this._nodeDocumentOverwrite || this; }, - set: function (val) { this._nodeDocumentOverwrite = val; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "implementation", { - /** @inheritdoc */ - get: function () { + BaseWriter.prototype._serializeElementNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + var e_2, _a; + var attributes = []; + /** + * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node + * + * 1. If the require well-formed flag is set (its value is true), and this + * node's localName attribute contains the character ":" (U+003A COLON) or + * does not match the XML Name production, then throw an exception; the + * serialization of this node would not be a well-formed element. + */ + if (requireWellFormed && (node.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(node.localName))) { + throw new Error("Node local name contains invalid characters (well-formed required)."); + } + /** + * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). + * 3. Let qualified name be an empty string. + * 4. Let skip end tag be a boolean flag with value false. + * 5. Let ignore namespace definition attribute be a boolean flag with value + * false. + * 6. Given prefix map, copy a namespace prefix map and let map be the + * result. + * 7. Let local prefixes map be an empty map. The map has unique Node prefix + * strings as its keys, with corresponding namespaceURI Node values as the + * map's key values (in this map, the null namespace is represented by the + * empty string). + * + * _Note:_ This map is local to each element. It is used to ensure there + * are no conflicting prefixes should a new namespace prefix attribute need + * to be generated. It is also used to enable skipping of duplicate prefix + * definitions when writing an element's attributes: the map allows the + * algorithm to distinguish between a prefix in the namespace prefix map + * that might be locally-defined (to the current Element) and one that is + * not. + * 8. Let local default namespace be the result of recording the namespace + * information for node given map and local prefixes map. + * + * _Note:_ The above step will update map with any found namespace prefix + * definitions, add the found prefix definitions to the local prefixes map + * and return a local default namespace value defined by a default namespace + * attribute if one exists. Otherwise it returns null. + * 9. Let inherited ns be a copy of namespace. + * 10. Let ns be the value of node's namespaceURI attribute. + */ + var qualifiedName = ''; + var skipEndTag = false; + var ignoreNamespaceDefinitionAttribute = false; + var map = prefixMap.copy(); + var localPrefixesMap = {}; + var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); + var inheritedNS = namespace; + var ns = node.namespaceURI; + /** 11. If inherited ns is equal to ns, then: */ + if (inheritedNS === ns) { /** - * The implementation attribute’s getter must return the DOMImplementation - * object that is associated with the document. + * 11.1. If local default namespace is not null, then set ignore + * namespace definition attribute to true. */ - return this._implementation || (this._implementation = algorithm_1.create_domImplementation(this)); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "URL", { - /** @inheritdoc */ - get: function () { + if (localDefaultNamespace !== null) { + ignoreNamespaceDefinitionAttribute = true; + } /** - * The URL attribute’s getter and documentURI attribute’s getter must return - * the URL, serialized. - * See: https://url.spec.whatwg.org/#concept-url-serializer + * 11.2. If ns is the XML namespace, then append to qualified name the + * concatenation of the string "xml:" and the value of node's localName. + * 11.3. Otherwise, append to qualified name the value of node's + * localName. The node's prefix if it exists, is dropped. */ - return URLAlgorithm_1.urlSerializer(this._URL); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "documentURI", { - /** @inheritdoc */ - get: function () { return this.URL; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "origin", { - /** @inheritdoc */ - get: function () { - return "null"; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "compatMode", { - /** @inheritdoc */ - get: function () { + if (ns === infra_1.namespace.XML) { + qualifiedName = 'xml:' + node.localName; + } + else { + qualifiedName = node.localName; + } + /** 11.4. Append the value of qualified name to markup. */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + } + else { /** - * The compatMode attribute’s getter must return "BackCompat" if context - * object’s mode is "quirks", and "CSS1Compat" otherwise. + * 12. Otherwise, inherited ns is not equal to ns (the node's own + * namespace is different from the context namespace of its parent). + * Run these sub-steps: + * + * 12.1. Let prefix be the value of node's prefix attribute. + * 12.2. Let candidate prefix be the result of retrieving a preferred + * prefix string prefix from map given namespace ns. The above may return + * null if no namespace key ns exists in map. */ - return this._mode === "quirks" ? "BackCompat" : "CSS1Compat"; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "characterSet", { - /** @inheritdoc */ - get: function () { + var prefix = node.prefix; /** - * The characterSet attribute’s getter, charset attribute’s getter, and - * inputEncoding attribute’s getter, must return context object’s - * encoding’s name. + * We don't need to run "retrieving a preferred prefix string" algorithm if + * the element has no prefix and its namespace matches to the default + * namespace. + * See: https://github.com/web-platform-tests/wpt/pull/16703 */ - return this._encoding.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "charset", { - /** @inheritdoc */ - get: function () { return this._encoding.name; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "inputEncoding", { - /** @inheritdoc */ - get: function () { return this._encoding.name; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "contentType", { - /** @inheritdoc */ - get: function () { + var candidatePrefix = null; + if (prefix !== null || ns !== localDefaultNamespace) { + candidatePrefix = map.get(prefix, ns); + } /** - * The contentType attribute’s getter must return the content type. + * 12.3. If the value of prefix matches "xmlns", then run the following + * steps: */ - return this._contentType; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "doctype", { - /** @inheritdoc */ - get: function () { - var e_1, _a; - try { + if (prefix === "xmlns") { + /** + * 12.3.1. If the require well-formed flag is set, then throw an error. + * An Element with prefix "xmlns" will not legally round-trip in a + * conforming XML parser. + */ + if (requireWellFormed) { + throw new Error("An element cannot have the 'xmlns' prefix (well-formed required)."); + } + /** + * 12.3.2. Let candidate prefix be the value of prefix. + */ + candidatePrefix = prefix; + } + /** + * 12.4.Found a suitable namespace prefix: if candidate prefix is not + * null (a namespace prefix is defined which maps to ns), then: + */ + if (candidatePrefix !== null) { + /** + * The following may serialize a different prefix than the Element's + * existing prefix if it already had one. However, the retrieving a + * preferred prefix string algorithm already tried to match the + * existing prefix if possible. + * + * 12.4.1. Append to qualified name the concatenation of candidate + * prefix, ":" (U+003A COLON), and node's localName. There exists on + * this node or the node's ancestry a namespace prefix definition that + * defines the node's namespace. + * 12.4.2. If the local default namespace is not null (there exists a + * locally-defined default namespace declaration attribute) and its + * value is not the XML namespace, then let inherited ns get the value + * of local default namespace unless the local default namespace is the + * empty string in which case let it get null (the context namespace + * is changed to the declared default, rather than this node's own + * namespace). + * + * _Note:_ Any default namespace definitions or namespace prefixes that + * define the XML namespace are omitted when serializing this node's + * attributes. + */ + qualifiedName = candidatePrefix + ':' + node.localName; + if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { + inheritedNS = localDefaultNamespace || null; + } + /** + * 12.4.3. Append the value of qualified name to markup. + */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** 12.5. Otherwise, if prefix is not null, then: */ + } + else if (prefix !== null) { + /** + * _Note:_ By this step, there is no namespace or prefix mapping + * declaration in this node (or any parent node visited by this + * algorithm) that defines prefix otherwise the step labelled Found + * a suitable namespace prefix would have been followed. The sub-steps + * that follow will create a new namespace prefix declaration for prefix + * and ensure that prefix does not conflict with an existing namespace + * prefix declaration of the same localName in node's attribute list. + * + * 12.5.1. If the local prefixes map contains a key matching prefix, + * then let prefix be the result of generating a prefix providing as + * input map, ns, and prefix index. + */ + if (prefix in localPrefixesMap) { + prefix = this._generatePrefix(ns, map, prefixIndex); + } + /** + * 12.5.2. Add prefix to map given namespace ns. + * 12.5.3. Append to qualified name the concatenation of prefix, ":" + * (U+003A COLON), and node's localName. + * 12.5.4. Append the value of qualified name to markup. + */ + map.set(prefix, ns); + qualifiedName += prefix + ':' + node.localName; + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** + * 12.5.5. Append the following to markup, in the order listed: + * + * _Note:_ The following serializes a namespace prefix declaration for + * prefix which was just added to the map. + * + * 12.5.5.1. " " (U+0020 SPACE); + * 12.5.5.2. The string "xmlns:"; + * 12.5.5.3. The value of prefix; + * 12.5.5.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 12.5.5.5. The result of serializing an attribute value given ns and + * the require well-formed flag as input; + * 12.5.5.6. """ (U+0022 QUOTATION MARK). + */ + attributes.push([null, 'xmlns', prefix, + this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); + /** + * 12.5.5.7. If local default namespace is not null (there exists a + * locally-defined default namespace declaration attribute), then + * let inherited ns get the value of local default namespace unless the + * local default namespace is the empty string in which case let it get + * null. + */ + if (localDefaultNamespace !== null) { + inheritedNS = localDefaultNamespace || null; + } + /** + * 12.6. Otherwise, if local default namespace is null, or local + * default namespace is not null and its value is not equal to ns, then: + */ + } + else if (localDefaultNamespace === null || + (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { + /** + * _Note:_ At this point, the namespace for this node still needs to be + * serialized, but there's no prefix (or candidate prefix) available; the + * following uses the default namespace declaration to define the + * namespace--optionally replacing an existing default declaration + * if present. + * + * 12.6.1. Set the ignore namespace definition attribute flag to true. + * 12.6.2. Append to qualified name the value of node's localName. + * 12.6.3. Let the value of inherited ns be ns. + * + * _Note:_ The new default namespace will be used in the serialization + * to define this node's namespace and act as the context namespace for + * its children. + */ + ignoreNamespaceDefinitionAttribute = true; + qualifiedName += node.localName; + inheritedNS = ns; /** - * The doctype attribute’s getter must return the child of the document - * that is a doctype, and null otherwise. + * 12.6.4. Append the value of qualified name to markup. */ - for (var _b = __values(this._children), _c = _b.next(); !_c.done; _c = _b.next()) { - var child = _c.value; - if (util_1.Guard.isDocumentTypeNode(child)) - return child; + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** + * 12.6.5. Append the following to markup, in the order listed: + * + * _Note:_ The following serializes the new (or replacement) default + * namespace definition. + * + * 12.6.5.1. " " (U+0020 SPACE); + * 12.6.5.2. The string "xmlns"; + * 12.6.5.3. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 12.6.5.4. The result of serializing an attribute value given ns + * and the require well-formed flag as input; + * 12.6.5.5. """ (U+0022 QUOTATION MARK). + */ + attributes.push([null, null, 'xmlns', + this._serializeAttributeValue(ns, requireWellFormed, noDoubleEncoding)]); + /** + * 12.7. Otherwise, the node has a local default namespace that matches + * ns. Append to qualified name the value of node's localName, let the + * value of inherited ns be ns, and append the value of qualified name + * to markup. + */ + } + else { + qualifiedName += node.localName; + inheritedNS = ns; + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + } + } + /** + * 13. Append to markup the result of the XML serialization of node's + * attributes given map, prefix index, local prefixes map, ignore namespace + * definition attribute flag, and require well-formed flag. + */ + attributes.push.apply(attributes, __spread(this._serializeAttributesNS(node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding))); + this.attributes(attributes); + /** + * 14. If ns is the HTML namespace, and the node's list of children is + * empty, and the node's localName matches any one of the following void + * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", + * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", + * "param", "source", "track", "wbr"; then append the following to markup, + * in the order listed: + * 14.1. " " (U+0020 SPACE); + * 14.2. "/" (U+002F SOLIDUS). + * and set the skip end tag flag to true. + * 15. If ns is not the HTML namespace, and the node's list of children is + * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end + * tag flag to true. + * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. + */ + var isHTML = (ns === infra_1.namespace.HTML); + if (isHTML && node.childNodes.length === 0 && + BaseWriter._VoidElementNames.has(node.localName)) { + this.openTagEnd(qualifiedName, true, true); + this.endElement(qualifiedName); + skipEndTag = true; + } + else if (!isHTML && node.childNodes.length === 0) { + this.openTagEnd(qualifiedName, true, false); + this.endElement(qualifiedName); + skipEndTag = true; + } + else { + this.openTagEnd(qualifiedName, false, false); + } + /** + * 17. If the value of skip end tag is true, then return the value of markup + * and skip the remaining steps. The node is a leaf-node. + */ + if (skipEndTag) + return; + /** + * 18. If ns is the HTML namespace, and the node's localName matches the + * string "template", then this is a template element. Append to markup the + * result of XML serializing a DocumentFragment node given the template + * element's template contents (a DocumentFragment), providing inherited + * ns, map, prefix index, and the require well-formed flag. + * + * _Note:_ This allows template content to round-trip, given the rules for + * parsing XHTML documents. + * + * 19. Otherwise, append to markup the result of running the XML + * serialization algorithm on each of node's children, in tree order, + * providing inherited ns, map, prefix index, and the require well-formed + * flag. + */ + if (isHTML && node.localName === "template") { + // TODO: serialize template contents + } + else { + try { + for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this.level++; + this._serializeNodeNS(childNode, inheritedNS, map, prefixIndex, requireWellFormed, noDoubleEncoding); + this.level--; } } - catch (e_1_1) { e_1 = { error: e_1_1 }; } + catch (e_2_1) { e_2 = { error: e_2_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } - finally { if (e_1) throw e_1.error; } + finally { if (e_2) throw e_2.error; } } - return null; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "documentElement", { - /** @inheritdoc */ - get: function () { - /** - * The documentElement attribute’s getter must return the document element. - */ - return this._documentElement; - }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - DocumentImpl.prototype.getElementsByTagName = function (qualifiedName) { + } /** - * The getElementsByTagName(qualifiedName) method, when invoked, must return - * the list of elements with qualified name qualifiedName for the context object. + * 20. Append the following to markup, in the order listed: + * 20.1. "" (U+003E GREATER-THAN SIGN). + * 21. Return the value of markup. */ - return algorithm_1.node_listOfElementsWithQualifiedName(qualifiedName, this); + this.closeTag(qualifiedName); + this.endElement(qualifiedName); }; - /** @inheritdoc */ - DocumentImpl.prototype.getElementsByTagNameNS = function (namespace, localName) { + /** + * Produces an XML serialization of an element node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeElement = function (node, requireWellFormed, noDoubleEncoding) { + var e_3, _a; /** - * The getElementsByTagNameNS(namespace, localName) method, when invoked, - * must return the list of elements with namespace namespace and local name - * localName for the context object. + * From: https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node + * + * 1. If the require well-formed flag is set (its value is true), and this + * node's localName attribute contains the character ":" (U+003A COLON) or + * does not match the XML Name production, then throw an exception; the + * serialization of this node would not be a well-formed element. */ - return algorithm_1.node_listOfElementsWithNamespace(namespace, localName, this); - }; - /** @inheritdoc */ - DocumentImpl.prototype.getElementsByClassName = function (classNames) { + if (requireWellFormed && (node.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(node.localName))) { + throw new Error("Node local name contains invalid characters (well-formed required)."); + } /** - * The getElementsByClassName(classNames) method, when invoked, must return - * the list of elements with class names classNames for the context object. + * 2. Let markup be the string "<" (U+003C LESS-THAN SIGN). + * 3. Let qualified name be an empty string. + * 4. Let skip end tag be a boolean flag with value false. + * 5. Let ignore namespace definition attribute be a boolean flag with value + * false. + * 6. Given prefix map, copy a namespace prefix map and let map be the + * result. + * 7. Let local prefixes map be an empty map. The map has unique Node prefix + * strings as its keys, with corresponding namespaceURI Node values as the + * map's key values (in this map, the null namespace is represented by the + * empty string). + * + * _Note:_ This map is local to each element. It is used to ensure there + * are no conflicting prefixes should a new namespace prefix attribute need + * to be generated. It is also used to enable skipping of duplicate prefix + * definitions when writing an element's attributes: the map allows the + * algorithm to distinguish between a prefix in the namespace prefix map + * that might be locally-defined (to the current Element) and one that is + * not. + * 8. Let local default namespace be the result of recording the namespace + * information for node given map and local prefixes map. + * + * _Note:_ The above step will update map with any found namespace prefix + * definitions, add the found prefix definitions to the local prefixes map + * and return a local default namespace value defined by a default namespace + * attribute if one exists. Otherwise it returns null. + * 9. Let inherited ns be a copy of namespace. + * 10. Let ns be the value of node's namespaceURI attribute. */ - return algorithm_1.node_listOfElementsWithClassNames(classNames, this); - }; - /** @inheritdoc */ - DocumentImpl.prototype.createElement = function (localName, options) { + var skipEndTag = false; + /** 11. If inherited ns is equal to ns, then: */ /** - * 1. If localName does not match the Name production, then throw an - * "InvalidCharacterError" DOMException. - * 2. If the context object is an HTML document, then set localName to - * localName in ASCII lowercase. - * 3. Let is be null. - * 4. If options is a dictionary and options’s is is present, then set is - * to it. - * 5. Let namespace be the HTML namespace, if the context object is an - * HTML document or context object’s content type is - * "application/xhtml+xml", and null otherwise. - * 6. Return the result of creating an element given the context object, - * localName, namespace, null, is, and with the synchronous custom elements - * flag set. + * 11.1. If local default namespace is not null, then set ignore + * namespace definition attribute to true. */ - if (!algorithm_1.xml_isName(localName)) - throw new DOMException_1.InvalidCharacterError(); - if (this._type === "html") - localName = localName.toLowerCase(); - var is = null; - if (options !== undefined) { - if (util_2.isString(options)) { - is = options; + /** + * 11.2. If ns is the XML namespace, then append to qualified name the + * concatenation of the string "xml:" and the value of node's localName. + * 11.3. Otherwise, append to qualified name the value of node's + * localName. The node's prefix if it exists, is dropped. + */ + var qualifiedName = node.localName; + /** 11.4. Append the value of qualified name to markup. */ + this.beginElement(qualifiedName); + this.openTagBegin(qualifiedName); + /** + * 13. Append to markup the result of the XML serialization of node's + * attributes given map, prefix index, local prefixes map, ignore namespace + * definition attribute flag, and require well-formed flag. + */ + var attributes = this._serializeAttributes(node, requireWellFormed, noDoubleEncoding); + this.attributes(attributes); + /** + * 14. If ns is the HTML namespace, and the node's list of children is + * empty, and the node's localName matches any one of the following void + * elements: "area", "base", "basefont", "bgsound", "br", "col", "embed", + * "frame", "hr", "img", "input", "keygen", "link", "menuitem", "meta", + * "param", "source", "track", "wbr"; then append the following to markup, + * in the order listed: + * 14.1. " " (U+0020 SPACE); + * 14.2. "/" (U+002F SOLIDUS). + * and set the skip end tag flag to true. + * 15. If ns is not the HTML namespace, and the node's list of children is + * empty, then append "/" (U+002F SOLIDUS) to markup and set the skip end + * tag flag to true. + * 16. Append ">" (U+003E GREATER-THAN SIGN) to markup. + */ + if (!node.hasChildNodes()) { + this.openTagEnd(qualifiedName, true, false); + this.endElement(qualifiedName); + skipEndTag = true; + } + else { + this.openTagEnd(qualifiedName, false, false); + } + /** + * 17. If the value of skip end tag is true, then return the value of markup + * and skip the remaining steps. The node is a leaf-node. + */ + if (skipEndTag) + return; + try { + /** + * 18. If ns is the HTML namespace, and the node's localName matches the + * string "template", then this is a template element. Append to markup the + * result of XML serializing a DocumentFragment node given the template + * element's template contents (a DocumentFragment), providing inherited + * ns, map, prefix index, and the require well-formed flag. + * + * _Note:_ This allows template content to round-trip, given the rules for + * parsing XHTML documents. + * + * 19. Otherwise, append to markup the result of running the XML + * serialization algorithm on each of node's children, in tree order, + * providing inherited ns, map, prefix index, and the require well-formed + * flag. + */ + for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this.level++; + this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + this.level--; } - else { - is = options.is; + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } + finally { if (e_3) throw e_3.error; } } - var namespace = (this._type === "html" || this._contentType === "application/xhtml+xml") ? - infra_1.namespace.HTML : null; - return algorithm_1.element_createAnElement(this, localName, namespace, null, is, true); + /** + * 20. Append the following to markup, in the order listed: + * 20.1. "" (U+003E GREATER-THAN SIGN). + * 21. Return the value of markup. + */ + this.closeTag(qualifiedName); + this.endElement(qualifiedName); }; - /** @inheritdoc */ - DocumentImpl.prototype.createElementNS = function (namespace, qualifiedName, options) { + /** + * Produces an XML serialization of a document node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + var e_4, _a; /** - * The createElementNS(namespace, qualifiedName, options) method, when - * invoked, must return the result of running the internal createElementNS - * steps, given context object, namespace, qualifiedName, and options. + * If the require well-formed flag is set (its value is true), and this node + * has no documentElement (the documentElement attribute's value is null), + * then throw an exception; the serialization of this node would not be a + * well-formed document. */ - return algorithm_1.document_internalCreateElementNS(this, namespace, qualifiedName, options); + if (requireWellFormed && node.documentElement === null) { + throw new Error("Missing document element (well-formed required)."); + } + try { + /** + * Otherwise, run the following steps: + * 1. Let serialized document be an empty string. + * 2. For each child child of node, in tree order, run the XML + * serialization algorithm on the child passing along the provided + * arguments, and append the result to serialized document. + * + * _Note:_ This will serialize any number of ProcessingInstruction and + * Comment nodes both before and after the Document's documentElement node, + * including at most one DocumentType node. (Text nodes are not allowed as + * children of the Document.) + * + * 3. Return the value of serialized document. + */ + for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_4) throw e_4.error; } + } }; - /** @inheritdoc */ - DocumentImpl.prototype.createDocumentFragment = function () { + /** + * Produces an XML serialization of a document node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocument = function (node, requireWellFormed, noDoubleEncoding) { + var e_5, _a; /** - * The createDocumentFragment() method, when invoked, must return a new - * DocumentFragment node with its node document set to the context object. + * If the require well-formed flag is set (its value is true), and this node + * has no documentElement (the documentElement attribute's value is null), + * then throw an exception; the serialization of this node would not be a + * well-formed document. */ - return algorithm_1.create_documentFragment(this); + if (requireWellFormed && node.documentElement === null) { + throw new Error("Missing document element (well-formed required)."); + } + try { + /** + * Otherwise, run the following steps: + * 1. Let serialized document be an empty string. + * 2. For each child child of node, in tree order, run the XML + * serialization algorithm on the child passing along the provided + * arguments, and append the result to serialized document. + * + * _Note:_ This will serialize any number of ProcessingInstruction and + * Comment nodes both before and after the Document's documentElement node, + * including at most one DocumentType node. (Text nodes are not allowed as + * children of the Document.) + * + * 3. Return the value of serialized document. + */ + for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_5) throw e_5.error; } + } }; - /** @inheritdoc */ - DocumentImpl.prototype.createTextNode = function (data) { + /** + * Produces an XML serialization of a comment node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeComment = function (node, requireWellFormed, noDoubleEncoding) { /** - * The createTextNode(data) method, when invoked, must return a new Text - * node with its data set to data and node document set to the context object. + * If the require well-formed flag is set (its value is true), and node's + * data contains characters that are not matched by the XML Char production + * or contains "--" (two adjacent U+002D HYPHEN-MINUS characters) or that + * ends with a "-" (U+002D HYPHEN-MINUS) character, then throw an exception; + * the serialization of this node's data would not be well-formed. */ - return algorithm_1.create_text(this, data); + if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || + node.data.indexOf("--") !== -1 || node.data.endsWith("-"))) { + throw new Error("Comment data contains invalid characters (well-formed required)."); + } + /** + * Otherwise, return the concatenation of "". + */ + this.comment(node.data); }; - /** @inheritdoc */ - DocumentImpl.prototype.createCDATASection = function (data) { + /** + * Produces an XML serialization of a text node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + * @param level - current depth of the XML tree + */ + BaseWriter.prototype._serializeText = function (node, requireWellFormed, noDoubleEncoding) { /** - * 1. If context object is an HTML document, then throw a - * "NotSupportedError" DOMException. - * 2. If data contains the string "]]>", then throw an - * "InvalidCharacterError" DOMException. - * 3. Return a new CDATASection node with its data set to data and node - * document set to the context object. + * 1. If the require well-formed flag is set (its value is true), and + * node's data contains characters that are not matched by the XML Char + * production, then throw an exception; the serialization of this node's + * data would not be well-formed. */ - if (this._type === "html") - throw new DOMException_1.NotSupportedError(); - if (data.indexOf(']]>') !== -1) - throw new DOMException_1.InvalidCharacterError(); - return algorithm_1.create_cdataSection(this, data); + if (requireWellFormed && !algorithm_1.xml_isLegalChar(node.data)) { + throw new Error("Text data contains invalid characters (well-formed required)."); + } + /** + * 2. Let markup be the value of node's data. + * 3. Replace any occurrences of "&" in markup by "&". + * 4. Replace any occurrences of "<" in markup by "<". + * 5. Replace any occurrences of ">" in markup by ">". + * 6. Return the value of markup. + */ + var markup = ""; + if (noDoubleEncoding) { + markup = node.data.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') + .replace(//g, '>'); + } + else { + for (var i = 0; i < node.data.length; i++) { + var c = node.data[i]; + if (c === "&") + markup += "&"; + else if (c === "<") + markup += "<"; + else if (c === ">") + markup += ">"; + else + markup += c; + } + } + this.text(markup); + }; + /** + * Produces an XML serialization of a document fragment node. + * + * @param node - node to serialize + * @param namespace - context namespace + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentFragmentNS = function (node, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding) { + var e_6, _a; + try { + /** + * 1. Let markup the empty string. + * 2. For each child child of node, in tree order, run the XML serialization + * algorithm on the child given namespace, prefix map, a reference to prefix + * index, and flag require well-formed. Concatenate the result to markup. + * 3. Return the value of markup. + */ + for (var _b = __values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNodeNS(childNode, namespace, prefixMap, prefixIndex, requireWellFormed, noDoubleEncoding); + } + } + catch (e_6_1) { e_6 = { error: e_6_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_6) throw e_6.error; } + } }; - /** @inheritdoc */ - DocumentImpl.prototype.createComment = function (data) { - /** - * The createComment(data) method, when invoked, must return a new Comment - * node with its data set to data and node document set to the context object. - */ - return algorithm_1.create_comment(this, data); + /** + * Produces an XML serialization of a document fragment node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentFragment = function (node, requireWellFormed, noDoubleEncoding) { + var e_7, _a; + try { + /** + * 1. Let markup the empty string. + * 2. For each child child of node, in tree order, run the XML serialization + * algorithm on the child given namespace, prefix map, a reference to prefix + * index, and flag require well-formed. Concatenate the result to markup. + * 3. Return the value of markup. + */ + for (var _b = __values(node._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var childNode = _c.value; + this._serializeNode(childNode, requireWellFormed, noDoubleEncoding); + } + } + catch (e_7_1) { e_7 = { error: e_7_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_7) throw e_7.error; } + } }; - /** @inheritdoc */ - DocumentImpl.prototype.createProcessingInstruction = function (target, data) { + /** + * Produces an XML serialization of a document type node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeDocumentType = function (node, requireWellFormed, noDoubleEncoding) { /** - * 1. If target does not match the Name production, then throw an - * "InvalidCharacterError" DOMException. - * 2. If data contains the string "?>", then throw an - * "InvalidCharacterError" DOMException. - * 3. Return a new ProcessingInstruction node, with target set to target, - * data set to data, and node document set to the context object. + * 1. If the require well-formed flag is true and the node's publicId + * attribute contains characters that are not matched by the XML PubidChar + * production, then throw an exception; the serialization of this node + * would not be a well-formed document type declaration. */ - if (!algorithm_1.xml_isName(target)) - throw new DOMException_1.InvalidCharacterError(); - if (data.indexOf("?>") !== -1) - throw new DOMException_1.InvalidCharacterError(); - return algorithm_1.create_processingInstruction(this, target, data); - }; - /** @inheritdoc */ - DocumentImpl.prototype.importNode = function (node, deep) { - if (deep === void 0) { deep = false; } + if (requireWellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { + throw new Error("DocType public identifier does not match PubidChar construct (well-formed required)."); + } /** - * 1. If node is a document or shadow root, then throw a "NotSupportedError" DOMException. + * 2. If the require well-formed flag is true and the node's systemId + * attribute contains characters that are not matched by the XML Char + * production or that contains both a """ (U+0022 QUOTATION MARK) and a + * "'" (U+0027 APOSTROPHE), then throw an exception; the serialization + * of this node would not be a well-formed document type declaration. */ - if (util_1.Guard.isDocumentNode(node) || util_1.Guard.isShadowRoot(node)) - throw new DOMException_1.NotSupportedError(); + if (requireWellFormed && + (!algorithm_1.xml_isLegalChar(node.systemId) || + (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { + throw new Error("DocType system identifier contains invalid characters (well-formed required)."); + } /** - * 2. Return a clone of node, with context object and the clone children flag set if deep is true. + * 3. Let markup be an empty string. + * 4. Append the string "" (U+003E GREATER-THAN SIGN) to markup. + * 11. Return the value of markup. */ - return algorithm_1.node_clone(node, this, deep); + this.docType(node.name, node.publicId, node.systemId); }; - /** @inheritdoc */ - DocumentImpl.prototype.adoptNode = function (node) { + /** + * Produces an XML serialization of a processing instruction node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeProcessingInstruction = function (node, requireWellFormed, noDoubleEncoding) { /** - * 1. If node is a document, then throw a "NotSupportedError" DOMException. + * 1. If the require well-formed flag is set (its value is true), and node's + * target contains a ":" (U+003A COLON) character or is an ASCII + * case-insensitive match for the string "xml", then throw an exception; + * the serialization of this node's target would not be well-formed. */ - if (util_1.Guard.isDocumentNode(node)) - throw new DOMException_1.NotSupportedError(); + if (requireWellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { + throw new Error("Processing instruction target contains invalid characters (well-formed required)."); + } /** - * 2. If node is a shadow root, then throw a "HierarchyRequestError" DOMException. + * 2. If the require well-formed flag is set (its value is true), and node's + * data contains characters that are not matched by the XML Char production + * or contains the string "?>" (U+003F QUESTION MARK, + * U+003E GREATER-THAN SIGN), then throw an exception; the serialization of + * this node's data would not be well-formed. */ - if (util_1.Guard.isShadowRoot(node)) - throw new DOMException_1.HierarchyRequestError(); + if (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || + node.data.indexOf("?>") !== -1)) { + throw new Error("Processing instruction data contains invalid characters (well-formed required)."); + } /** - * 3. Adopt node into the context object. - * 4. Return node. + * 3. Let markup be the concatenation of the following, in the order listed: + * 3.1. "" (U+003F QUESTION MARK, U+003E GREATER-THAN SIGN). + * 4. Return the value of markup. */ - algorithm_1.document_adopt(node, this); - return node; + this.instruction(node.target, node.data); }; - /** @inheritdoc */ - DocumentImpl.prototype.createAttribute = function (localName) { - /** - * 1. If localName does not match the Name production in XML, then throw - * an "InvalidCharacterError" DOMException. - * 2. If the context object is an HTML document, then set localName to - * localName in ASCII lowercase. - * 3. Return a new attribute whose local name is localName and node document - * is context object. - */ - if (!algorithm_1.xml_isName(localName)) - throw new DOMException_1.InvalidCharacterError(); - if (this._type === "html") { - localName = localName.toLowerCase(); + /** + * Produces an XML serialization of a CDATA node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeCData = function (node, requireWellFormed, noDoubleEncoding) { + if (requireWellFormed && (node.data.indexOf("]]>") !== -1)) { + throw new Error("CDATA contains invalid characters (well-formed required)."); } - var attr = algorithm_1.create_attr(this, localName); - return attr; + this.cdata(node.data); }; - /** @inheritdoc */ - DocumentImpl.prototype.createAttributeNS = function (namespace, qualifiedName) { + /** + * Produces an XML serialization of the attributes of an element node. + * + * @param node - node to serialize + * @param map - namespace prefix map + * @param prefixIndex - generated namespace prefix index + * @param localPrefixesMap - local prefixes map + * @param ignoreNamespaceDefinitionAttribute - whether to ignore namespace + * attributes + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeAttributesNS = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed, noDoubleEncoding) { + var e_8, _a; /** - * 1. Let namespace, prefix, and localName be the result of passing - * namespace and qualifiedName to validate and extract. - * 2. Return a new attribute whose namespace is namespace, namespace prefix - * is prefix, local name is localName, and node document is context object. + * 1. Let result be the empty string. + * 2. Let localname set be a new empty namespace localname set. This + * localname set will contain tuples of unique attribute namespaceURI and + * localName pairs, and is populated as each attr is processed. This set is + * used to [optionally] enforce the well-formed constraint that an element + * cannot have two attributes with the same namespaceURI and localName. + * This can occur when two otherwise identical attributes on the same + * element differ only by their prefix values. */ - var _a = __read(algorithm_1.namespace_validateAndExtract(namespace, qualifiedName), 3), ns = _a[0], prefix = _a[1], localName = _a[2]; - var attr = algorithm_1.create_attr(this, localName); - attr._namespace = ns; - attr._namespacePrefix = prefix; - return attr; - }; - /** @inheritdoc */ - DocumentImpl.prototype.createEvent = function (eventInterface) { - return algorithm_1.event_createLegacyEvent(eventInterface); - }; - /** @inheritdoc */ - DocumentImpl.prototype.createRange = function () { + var result = []; + var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; + try { + /** + * 3. Loop: For each attribute attr in element's attributes, in the order + * they are specified in the element's attribute list: + */ + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + // Optimize common case + if (!requireWellFormed && !ignoreNamespaceDefinitionAttribute && attr.namespaceURI === null) { + result.push([null, null, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + continue; + } + /** + * 3.1. If the require well-formed flag is set (its value is true), and the + * localname set contains a tuple whose values match those of a new tuple + * consisting of attr's namespaceURI attribute and localName attribute, + * then throw an exception; the serialization of this attr would fail to + * produce a well-formed element serialization. + */ + if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { + throw new Error("Element contains duplicate attributes (well-formed required)."); + } + /** + * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and + * localName attribute, and add it to the localname set. + * 3.3. Let attribute namespace be the value of attr's namespaceURI value. + * 3.4. Let candidate prefix be null. + */ + if (requireWellFormed && localNameSet) + localNameSet.set(attr.namespaceURI, attr.localName); + var attributeNamespace = attr.namespaceURI; + var candidatePrefix = null; + /** 3.5. If attribute namespace is not null, then run these sub-steps: */ + if (attributeNamespace !== null) { + /** + * 3.5.1. Let candidate prefix be the result of retrieving a preferred + * prefix string from map given namespace attribute namespace with + * preferred prefix being attr's prefix value. + */ + candidatePrefix = map.get(attr.prefix, attributeNamespace); + /** + * 3.5.2. If the value of attribute namespace is the XMLNS namespace, + * then run these steps: + */ + if (attributeNamespace === infra_1.namespace.XMLNS) { + /** + * 3.5.2.1. If any of the following are true, then stop running these + * steps and goto Loop to visit the next attribute: + * - the attr's value is the XML namespace; + * _Note:_ The XML namespace cannot be redeclared and survive + * round-tripping (unless it defines the prefix "xml"). To avoid this + * problem, this algorithm always prefixes elements in the XML + * namespace with "xml" and drops any related definitions as seen + * in the above condition. + * - the attr's prefix is null and the ignore namespace definition + * attribute flag is true (the Element's default namespace attribute + * should be skipped); + * - the attr's prefix is not null and either + * * the attr's localName is not a key contained in the local + * prefixes map, or + * * the attr's localName is present in the local prefixes map but + * the value of the key does not match attr's value + * and furthermore that the attr's localName (as the prefix to find) + * is found in the namespace prefix map given the namespace consisting + * of the attr's value (the current namespace prefix definition was + * exactly defined previously--on an ancestor element not the current + * element whose attributes are being processed). + */ + if (attr.value === infra_1.namespace.XML || + (attr.prefix === null && ignoreNamespaceDefinitionAttribute) || + (attr.prefix !== null && (!(attr.localName in localPrefixesMap) || + localPrefixesMap[attr.localName] !== attr.value) && + map.has(attr.localName, attr.value))) + continue; + /** + * 3.5.2.2. If the require well-formed flag is set (its value is true), + * and the value of attr's value attribute matches the XMLNS + * namespace, then throw an exception; the serialization of this + * attribute would produce invalid XML because the XMLNS namespace + * is reserved and cannot be applied as an element's namespace via + * XML parsing. + * + * _Note:_ DOM APIs do allow creation of elements in the XMLNS + * namespace but with strict qualifications. + */ + if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { + throw new Error("XMLNS namespace is reserved (well-formed required)."); + } + /** + * 3.5.2.3. If the require well-formed flag is set (its value is true), + * and the value of attr's value attribute is the empty string, then + * throw an exception; namespace prefix declarations cannot be used + * to undeclare a namespace (use a default namespace declaration + * instead). + */ + if (requireWellFormed && attr.value === '') { + throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required)."); + } + /** + * 3.5.2.4. the attr's prefix matches the string "xmlns", then let + * candidate prefix be the string "xmlns". + */ + if (attr.prefix === 'xmlns') + candidatePrefix = 'xmlns'; + /** + * 3.5.3. Otherwise, the attribute namespace is not the XMLNS namespace. + * Run these steps: + * + * _Note:_ The (candidatePrefix === null) check is not in the spec. + * We deviate from the spec here. Otherwise a prefix is generated for + * all attributes with namespaces. + */ + } + else if (candidatePrefix === null) { + if (attr.prefix !== null && + (!map.hasPrefix(attr.prefix) || + map.has(attr.prefix, attributeNamespace))) { + /** + * Check if we can use the attribute's own prefix. + * We deviate from the spec here. + * TODO: This is not an efficient way of searching for prefixes. + * Follow developments to the spec. + */ + candidatePrefix = attr.prefix; + } + else { + /** + * 3.5.3.1. Let candidate prefix be the result of generating a prefix + * providing map, attribute namespace, and prefix index as input. + */ + candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); + } + /** + * 3.5.3.2. Append the following to result, in the order listed: + * 3.5.3.2.1. " " (U+0020 SPACE); + * 3.5.3.2.2. The string "xmlns:"; + * 3.5.3.2.3. The value of candidate prefix; + * 3.5.3.2.4. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 3.5.3.2.5. The result of serializing an attribute value given + * attribute namespace and the require well-formed flag as input; + * 3.5.3.2.6. """ (U+0022 QUOTATION MARK). + */ + result.push([null, "xmlns", candidatePrefix, + this._serializeAttributeValue(attributeNamespace, requireWellFormed, noDoubleEncoding)]); + } + } + /** + * 3.6. Append a " " (U+0020 SPACE) to result. + * 3.7. If candidate prefix is not null, then append to result the + * concatenation of candidate prefix with ":" (U+003A COLON). + */ + var attrName = ''; + if (candidatePrefix !== null) { + attrName = candidatePrefix; + } + /** + * 3.8. If the require well-formed flag is set (its value is true), and + * this attr's localName attribute contains the character + * ":" (U+003A COLON) or does not match the XML Name production or + * equals "xmlns" and attribute namespace is null, then throw an + * exception; the serialization of this attr would not be a + * well-formed attribute. + */ + if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(attr.localName) || + (attr.localName === "xmlns" && attributeNamespace === null))) { + throw new Error("Attribute local name contains invalid characters (well-formed required)."); + } + /** + * 3.9. Append the following strings to result, in the order listed: + * 3.9.1. The value of attr's localName; + * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 3.9.3. The result of serializing an attribute value given attr's value + * attribute and the require well-formed flag as input; + * 3.9.4. """ (U+0022 QUOTATION MARK). + */ + result.push([attributeNamespace, candidatePrefix, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + } + } + catch (e_8_1) { e_8 = { error: e_8_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_8) throw e_8.error; } + } /** - * The createRange() method, when invoked, must return a new live range - * with (context object, 0) as its start and end. + * 4. Return the value of result. */ - var range = algorithm_1.create_range(); - range._start = [this, 0]; - range._end = [this, 0]; - return range; + return result; }; - /** @inheritdoc */ - DocumentImpl.prototype.createNodeIterator = function (root, whatToShow, filter) { - if (whatToShow === void 0) { whatToShow = interfaces_1.WhatToShow.All; } - if (filter === void 0) { filter = null; } + /** + * Produces an XML serialization of the attributes of an element node. + * + * @param node - node to serialize + * @param requireWellFormed - whether to check conformance + */ + BaseWriter.prototype._serializeAttributes = function (node, requireWellFormed, noDoubleEncoding) { + var e_9, _a; /** - * 1. Let iterator be a new NodeIterator object. - * 2. Set iterator’s root and iterator’s reference to root. - * 3. Set iterator’s pointer before reference to true. - * 4. Set iterator’s whatToShow to whatToShow. - * 5. Set iterator’s filter to filter. - * 6. Return iterator. + * 1. Let result be the empty string. + * 2. Let localname set be a new empty namespace localname set. This + * localname set will contain tuples of unique attribute namespaceURI and + * localName pairs, and is populated as each attr is processed. This set is + * used to [optionally] enforce the well-formed constraint that an element + * cannot have two attributes with the same namespaceURI and localName. + * This can occur when two otherwise identical attributes on the same + * element differ only by their prefix values. */ - var iterator = algorithm_1.create_nodeIterator(root, root, true); - iterator._whatToShow = whatToShow; - iterator._iteratorCollection = algorithm_1.create_nodeList(root); - if (util_2.isFunction(filter)) { - iterator._filter = algorithm_1.create_nodeFilter(); - iterator._filter.acceptNode = filter; + var result = []; + var localNameSet = requireWellFormed ? {} : undefined; + try { + /** + * 3. Loop: For each attribute attr in element's attributes, in the order + * they are specified in the element's attribute list: + */ + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + // Optimize common case + if (!requireWellFormed) { + result.push([null, null, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + continue; + } + /** + * 3.1. If the require well-formed flag is set (its value is true), and the + * localname set contains a tuple whose values match those of a new tuple + * consisting of attr's namespaceURI attribute and localName attribute, + * then throw an exception; the serialization of this attr would fail to + * produce a well-formed element serialization. + */ + if (requireWellFormed && localNameSet && (attr.localName in localNameSet)) { + throw new Error("Element contains duplicate attributes (well-formed required)."); + } + /** + * 3.2. Create a new tuple consisting of attr's namespaceURI attribute and + * localName attribute, and add it to the localname set. + * 3.3. Let attribute namespace be the value of attr's namespaceURI value. + * 3.4. Let candidate prefix be null. + */ + /* istanbul ignore else */ + if (requireWellFormed && localNameSet) + localNameSet[attr.localName] = true; + /** 3.5. If attribute namespace is not null, then run these sub-steps: */ + /** + * 3.6. Append a " " (U+0020 SPACE) to result. + * 3.7. If candidate prefix is not null, then append to result the + * concatenation of candidate prefix with ":" (U+003A COLON). + */ + /** + * 3.8. If the require well-formed flag is set (its value is true), and + * this attr's localName attribute contains the character + * ":" (U+003A COLON) or does not match the XML Name production or + * equals "xmlns" and attribute namespace is null, then throw an + * exception; the serialization of this attr would not be a + * well-formed attribute. + */ + if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(attr.localName))) { + throw new Error("Attribute local name contains invalid characters (well-formed required)."); + } + /** + * 3.9. Append the following strings to result, in the order listed: + * 3.9.1. The value of attr's localName; + * 3.9.2. "="" (U+003D EQUALS SIGN, U+0022 QUOTATION MARK); + * 3.9.3. The result of serializing an attribute value given attr's value + * attribute and the require well-formed flag as input; + * 3.9.4. """ (U+0022 QUOTATION MARK). + */ + result.push([null, null, attr.localName, + this._serializeAttributeValue(attr.value, requireWellFormed, noDoubleEncoding)]); + } } - else { - iterator._filter = filter; + catch (e_9_1) { e_9 = { error: e_9_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_9) throw e_9.error; } } - return iterator; - }; - /** @inheritdoc */ - DocumentImpl.prototype.createTreeWalker = function (root, whatToShow, filter) { - if (whatToShow === void 0) { whatToShow = interfaces_1.WhatToShow.All; } - if (filter === void 0) { filter = null; } /** - * 1. Let walker be a new TreeWalker object. - * 2. Set walker’s root and walker’s current to root. - * 3. Set walker’s whatToShow to whatToShow. - * 4. Set walker’s filter to filter. - * 5. Return walker. + * 4. Return the value of result. */ - var walker = algorithm_1.create_treeWalker(root, root); - walker._whatToShow = whatToShow; - if (util_2.isFunction(filter)) { - walker._filter = algorithm_1.create_nodeFilter(); - walker._filter.acceptNode = filter; - } - else { - walker._filter = filter; - } - return walker; + return result; }; /** - * Gets the parent event target for the given event. - * - * @param event - an event - */ - DocumentImpl.prototype._getTheParent = function (event) { + * Records namespace information for the given element and returns the + * default namespace attribute value. + * + * @param node - element node to process + * @param map - namespace prefix map + * @param localPrefixesMap - local prefixes map + */ + BaseWriter.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { + var e_10, _a; /** - * TODO: Implement realms - * A document’s get the parent algorithm, given an event, returns null if - * event’s type attribute value is "load" or document does not have a - * browsing context, and the document’s relevant global object otherwise. + * 1. Let default namespace attr value be null. */ - if (event._type === "load") { - return null; - } - else { - return DOMImpl_1.dom.window; - } - }; - // MIXIN: NonElementParentNode - /* istanbul ignore next */ - DocumentImpl.prototype.getElementById = function (elementId) { throw new Error("Mixin: NonElementParentNode not implemented."); }; - Object.defineProperty(DocumentImpl.prototype, "children", { - // MIXIN: DocumentOrShadowRoot - // No elements - // MIXIN: ParentNode - /* istanbul ignore next */ - get: function () { throw new Error("Mixin: ParentNode not implemented."); }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "firstElementChild", { - /* istanbul ignore next */ - get: function () { throw new Error("Mixin: ParentNode not implemented."); }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "lastElementChild", { - /* istanbul ignore next */ - get: function () { throw new Error("Mixin: ParentNode not implemented."); }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "childElementCount", { - /* istanbul ignore next */ - get: function () { throw new Error("Mixin: ParentNode not implemented."); }, - enumerable: true, - configurable: true - }); - /* istanbul ignore next */ - DocumentImpl.prototype.prepend = function () { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; - } - throw new Error("Mixin: ParentNode not implemented."); - }; - /* istanbul ignore next */ - DocumentImpl.prototype.append = function () { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; - } - throw new Error("Mixin: ParentNode not implemented."); - }; - /* istanbul ignore next */ - DocumentImpl.prototype.querySelector = function (selectors) { throw new Error("Mixin: ParentNode not implemented."); }; - /* istanbul ignore next */ - DocumentImpl.prototype.querySelectorAll = function (selectors) { throw new Error("Mixin: ParentNode not implemented."); }; - return DocumentImpl; -}(NodeImpl_1.NodeImpl)); -exports.DocumentImpl = DocumentImpl; -/** - * Initialize prototype properties - */ -WebIDLAlgorithm_1.idl_defineConst(DocumentImpl.prototype, "_nodeType", interfaces_1.NodeType.Document); -//# sourceMappingURL=DocumentImpl.js.map - -/***/ }), -/* 489 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const patch = (a, loose) => new SemVer(a, loose).patch -module.exports = patch - - -/***/ }), -/* 490 */, -/* 491 */, -/* 492 */, -/* 493 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { + var defaultNamespaceAttrValue = null; try { - if (r && !r.done && (m = i["return"])) m.call(i); + /** + * 2. Main: For each attribute attr in element's attributes, in the order + * they are specified in the element's attribute list: + */ + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + /** + * _Note:_ The following conditional steps find namespace prefixes. Only + * attributes in the XMLNS namespace are considered (e.g., attributes made + * to look like namespace declarations via + * setAttribute("xmlns:pretend-prefix", "pretend-namespace") are not + * included). + */ + /** 2.1. Let attribute namespace be the value of attr's namespaceURI value. */ + var attributeNamespace = attr.namespaceURI; + /** 2.2. Let attribute prefix be the value of attr's prefix. */ + var attributePrefix = attr.prefix; + /** 2.3. If the attribute namespace is the XMLNS namespace, then: */ + if (attributeNamespace === infra_1.namespace.XMLNS) { + /** + * 2.3.1. If attribute prefix is null, then attr is a default namespace + * declaration. Set the default namespace attr value to attr's value and + * stop running these steps, returning to Main to visit the next + * attribute. + */ + if (attributePrefix === null) { + defaultNamespaceAttrValue = attr.value; + continue; + /** + * 2.3.2. Otherwise, the attribute prefix is not null and attr is a + * namespace prefix definition. Run the following steps: + */ + } + else { + /** 2.3.2.1. Let prefix definition be the value of attr's localName. */ + var prefixDefinition = attr.localName; + /** 2.3.2.2. Let namespace definition be the value of attr's value. */ + var namespaceDefinition = attr.value; + /** + * 2.3.2.3. If namespace definition is the XML namespace, then stop + * running these steps, and return to Main to visit the next + * attribute. + * + * _Note:_ XML namespace definitions in prefixes are completely + * ignored (in order to avoid unnecessary work when there might be + * prefix conflicts). XML namespaced elements are always handled + * uniformly by prefixing (and overriding if necessary) the element's + * localname with the reserved "xml" prefix. + */ + if (namespaceDefinition === infra_1.namespace.XML) { + continue; + } + /** + * 2.3.2.4. If namespace definition is the empty string (the + * declarative form of having no namespace), then let namespace + * definition be null instead. + */ + if (namespaceDefinition === '') { + namespaceDefinition = null; + } + /** + * 2.3.2.5. If prefix definition is found in map given the namespace + * namespace definition, then stop running these steps, and return to + * Main to visit the next attribute. + * + * _Note:_ This step avoids adding duplicate prefix definitions for + * the same namespace in the map. This has the side-effect of avoiding + * later serialization of duplicate namespace prefix declarations in + * any descendant nodes. + */ + if (map.has(prefixDefinition, namespaceDefinition)) { + continue; + } + /** + * 2.3.2.6. Add the prefix prefix definition to map given namespace + * namespace definition. + */ + map.set(prefixDefinition, namespaceDefinition); + /** + * 2.3.2.7. Add the value of prefix definition as a new key to the + * local prefixes map, with the namespace definition as the key's + * value replacing the value of null with the empty string if + * applicable. + */ + localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; + } + } + } } - finally { if (e) throw e.error; } - } - return ar; -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; + catch (e_10_1) { e_10 = { error: e_10_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_10) throw e_10.error; } } + /** + * 3. Return the value of default namespace attr value. + * + * _Note:_ The empty string is a legitimate return value and is not + * converted to null. + */ + return defaultNamespaceAttrValue; }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var util_1 = __webpack_require__(918); -var util_2 = __webpack_require__(592); -var ElementImpl_1 = __webpack_require__(695); -var CustomElementAlgorithm_1 = __webpack_require__(344); -var TreeAlgorithm_1 = __webpack_require__(873); -var NamespaceAlgorithm_1 = __webpack_require__(664); -var DOMAlgorithm_1 = __webpack_require__(304); -var ElementAlgorithm_1 = __webpack_require__(33); -var MutationAlgorithm_1 = __webpack_require__(479); -/** - * Returns an element interface for the given name and namespace. - * - * @param name - element name - * @param namespace - namespace - */ -function document_elementInterface(name, namespace) { - return ElementImpl_1.ElementImpl; -} -exports.document_elementInterface = document_elementInterface; -/** - * Creates a new element node. - * See: https://dom.spec.whatwg.org/#internal-createelementns-steps - * - * @param document - owner document - * @param namespace - element namespace - * @param qualifiedName - qualified name - * @param options - element options - */ -function document_internalCreateElementNS(document, namespace, qualifiedName, options) { - /** - * 1. Let namespace, prefix, and localName be the result of passing - * namespace and qualifiedName to validate and extract. - * 2. Let is be null. - * 3. If options is a dictionary and options’s is is present, then set - * is to it. - * 4. Return the result of creating an element given document, localName, - * namespace, prefix, is, and with the synchronous custom elements flag set. - */ - var _a = __read(NamespaceAlgorithm_1.namespace_validateAndExtract(namespace, qualifiedName), 3), ns = _a[0], prefix = _a[1], localName = _a[2]; - var is = null; - if (options !== undefined) { - if (util_2.isString(options)) { - is = options; - } - else { - is = options.is; - } - } - return ElementAlgorithm_1.element_createAnElement(document, localName, ns, prefix, is, true); -} -exports.document_internalCreateElementNS = document_internalCreateElementNS; -/** - * Removes `node` and its subtree from its document and changes - * its owner document to `document` so that it can be inserted - * into `document`. - * - * @param node - the node to move - * @param document - document to receive the node and its subtree - */ -function document_adopt(node, document) { - var e_1, _a; - // Optimize for common case of inserting a fresh node - if (node._nodeDocument === document && node._parent === null) { - return; - } /** - * 1. Let oldDocument be node’s node document. - * 2. If node’s parent is not null, remove node from its parent. - */ - var oldDocument = node._nodeDocument; - if (node._parent) - MutationAlgorithm_1.mutation_remove(node, node._parent); + * Generates a new prefix for the given namespace. + * + * @param newNamespace - a namespace to generate prefix for + * @param prefixMap - namespace prefix map + * @param prefixIndex - generated namespace prefix index + */ + BaseWriter.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { + /** + * 1. Let generated prefix be the concatenation of the string "ns" and the + * current numerical value of prefix index. + * 2. Let the value of prefix index be incremented by one. + * 3. Add to map the generated prefix given the new namespace namespace. + * 4. Return the value of generated prefix. + */ + var generatedPrefix = "ns" + prefixIndex.value.toString(); + prefixIndex.value++; + prefixMap.set(generatedPrefix, newNamespace); + return generatedPrefix; + }; /** - * 3. If document is not oldDocument, then: + * Produces an XML serialization of an attribute value. + * + * @param value - attribute value + * @param requireWellFormed - whether to check conformance */ - if (document !== oldDocument) { + BaseWriter.prototype._serializeAttributeValue = function (value, requireWellFormed, noDoubleEncoding) { /** - * 3.1. For each inclusiveDescendant in node’s shadow-including inclusive - * descendants: + * From: https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value + * + * 1. If the require well-formed flag is set (its value is true), and + * attribute value contains characters that are not matched by the XML Char + * production, then throw an exception; the serialization of this attribute + * value would fail to produce a well-formed element serialization. */ - var inclusiveDescendant = TreeAlgorithm_1.tree_getFirstDescendantNode(node, true, true); - while (inclusiveDescendant !== null) { - /** - * 3.1.1. Set inclusiveDescendant’s node document to document. - * 3.1.2. If inclusiveDescendant is an element, then set the node - * document of each attribute in inclusiveDescendant’s attribute list - * to document. - */ - inclusiveDescendant._nodeDocument = document; - if (util_1.Guard.isElementNode(inclusiveDescendant)) { - try { - for (var _b = (e_1 = void 0, __values(inclusiveDescendant._attributeList._asArray())), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - attr._nodeDocument = document; - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_1) throw e_1.error; } - } - } - /** - * 3.2. For each inclusiveDescendant in node's shadow-including - * inclusive descendants that is custom, enqueue a custom - * element callback reaction with inclusiveDescendant, - * callback name "adoptedCallback", and an argument list - * containing oldDocument and document. - */ - if (DOMImpl_1.dom.features.customElements) { - if (util_1.Guard.isElementNode(inclusiveDescendant) && - inclusiveDescendant._customElementState === "custom") { - CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(inclusiveDescendant, "adoptedCallback", [oldDocument, document]); - } - } - /** - * 3.3. For each inclusiveDescendant in node’s shadow-including - * inclusive descendants, in shadow-including tree order, run the - * adopting steps with inclusiveDescendant and oldDocument. - */ - if (DOMImpl_1.dom.features.steps) { - DOMAlgorithm_1.dom_runAdoptingSteps(inclusiveDescendant, oldDocument); + if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { + throw new Error("Invalid characters in attribute value."); + } + /** + * 2. If attribute value is null, then return the empty string. + */ + if (value === null) + return ""; + /** + * 3. Otherwise, attribute value is a string. Return the value of attribute + * value, first replacing any occurrences of the following: + * - "&" with "&" + * - """ with """ + * - "<" with "<" + * - ">" with ">" + * NOTE + * This matches behavior present in browsers, and goes above and beyond the + * grammar requirement in the XML specification's AttValue production by + * also replacing ">" characters. + */ + if (noDoubleEncoding) { + return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + } + else { + var result = ""; + for (var i = 0; i < value.length; i++) { + var c = value[i]; + if (c === "\"") + result += """; + else if (c === "&") + result += "&"; + else if (c === "<") + result += "<"; + else if (c === ">") + result += ">"; + else + result += c; } - inclusiveDescendant = TreeAlgorithm_1.tree_getNextDescendantNode(node, inclusiveDescendant, true, true); + return result; } - } -} -exports.document_adopt = document_adopt; -//# sourceMappingURL=DocumentAlgorithm.js.map - -/***/ }), -/* 494 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -var rng = __webpack_require__(58); -var bytesToUuid = __webpack_require__(722); - -function v4(options, buf, offset) { - var i = buf && offset || 0; - - if (typeof(options) == 'string') { - buf = options === 'binary' ? new Array(16) : null; - options = null; - } - options = options || {}; - - var rnds = options.random || (options.rng || rng)(); - - // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` - rnds[6] = (rnds[6] & 0x0f) | 0x40; - rnds[8] = (rnds[8] & 0x3f) | 0x80; - - // Copy bytes to buffer, if provided - if (buf) { - for (var ii = 0; ii < 16; ++ii) { - buf[i + ii] = rnds[ii]; - } - } - - return buf || bytesToUuid(rnds); -} - -module.exports = v4; - + }; + BaseWriter._VoidElementNames = new Set(['area', 'base', 'basefont', + 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', + 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); + return BaseWriter; +}()); +exports.BaseWriter = BaseWriter; +//# sourceMappingURL=BaseWriter.js.map /***/ }), -/* 495 */ -/***/ (function(__unusedmodule, exports) { +/* 463 */, +/* 464 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +var interfaces_1 = __webpack_require__(970); +var DOMException_1 = __webpack_require__(35); /** - * Defines a WebIDL `Const` property on the given object. + * Applies the filter to the given node and returns the result. * - * @param o - object on which to add the property - * @param name - property name - * @param value - property value + * @param traverser - the `NodeIterator` or `TreeWalker` instance + * @param node - the node to filter */ -function idl_defineConst(o, name, value) { - Object.defineProperty(o, name, { writable: false, enumerable: true, configurable: false, value: value }); +function traversal_filter(traverser, node) { + /** + * 1. If traverser’s active flag is set, then throw an "InvalidStateError" + * DOMException. + */ + if (traverser._activeFlag) { + throw new DOMException_1.InvalidStateError(); + } + /** + * 2. Let n be node’s nodeType attribute value − 1. + */ + var n = node._nodeType - 1; + /** + * 3. If the nth bit (where 0 is the least significant bit) of traverser’s + * whatToShow is not set, then return FILTER_SKIP. + */ + var mask = 1 << n; + if ((traverser.whatToShow & mask) === 0) { + return interfaces_1.FilterResult.Skip; + } + /** + * 4. If traverser’s filter is null, then return FILTER_ACCEPT. + */ + if (!traverser.filter) { + return interfaces_1.FilterResult.Accept; + } + /** + * 5. Set traverser’s active flag. + */ + traverser._activeFlag = true; + /** + * 6. Let result be the return value of call a user object’s operation with + * traverser’s filter, "acceptNode", and « node ». If this throws an + * exception, then unset traverser’s active flag and rethrow the exception. + */ + var result = interfaces_1.FilterResult.Reject; + try { + result = traverser.filter.acceptNode(node); + } + catch (err) { + traverser._activeFlag = false; + throw err; + } + /** + * 7. Unset traverser’s active flag. + * 8. Return result. + */ + traverser._activeFlag = false; + return result; } -exports.idl_defineConst = idl_defineConst; -//# sourceMappingURL=WebIDLAlgorithm.js.map +exports.traversal_filter = traversal_filter; +//# sourceMappingURL=TraversalAlgorithm.js.map /***/ }), -/* 496 */ +/* 465 */, +/* 466 */, +/* 467 */, +/* 468 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; @@ -21773,734 +19771,465 @@ var __read = (this && this.__read) || function (o, n) { } return ar; }; -var __spread = (this && this.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); -var util_1 = __webpack_require__(592); -/** - * Adds the given item to the end of the set. - * - * @param set - a set - * @param item - an item - */ -function append(set, item) { - set.add(item); -} -exports.append = append; -/** - * Extends a set by appending all items from another set. - * - * @param setA - a list to extend - * @param setB - a list containing items to append to `setA` - */ -function extend(setA, setB) { - setB.forEach(setA.add, setA); -} -exports.extend = extend; -/** - * Inserts the given item to the start of the set. - * - * @param set - a set - * @param item - an item - */ -function prepend(set, item) { - var cloned = new Set(set); - set.clear(); - set.add(item); - cloned.forEach(set.add, set); -} -exports.prepend = prepend; -/** - * Replaces the given item or all items matching condition with a new item. - * - * @param set - a set - * @param conditionOrItem - an item to replace or a condition matching items - * to replace - * @param item - an item - */ -function replace(set, conditionOrItem, newItem) { - var e_1, _a; - var newSet = new Set(); - try { - for (var set_1 = __values(set), set_1_1 = set_1.next(); !set_1_1.done; set_1_1 = set_1.next()) { - var oldItem = set_1_1.value; - if (util_1.isFunction(conditionOrItem)) { - if (!!conditionOrItem.call(null, oldItem)) { - newSet.add(newItem); - } - else { - newSet.add(oldItem); - } - } - else if (oldItem === conditionOrItem) { - newSet.add(newItem); - } - else { - newSet.add(oldItem); - } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (set_1_1 && !set_1_1.done && (_a = set_1.return)) _a.call(set_1); - } - finally { if (e_1) throw e_1.error; } - } - set.clear(); - newSet.forEach(set.add, set); -} -exports.replace = replace; -/** - * Inserts the given item before the given index. - * - * @param set - a set - * @param item - an item - */ -function insert(set, item, index) { - var e_2, _a; - var newSet = new Set(); - var i = 0; - try { - for (var set_2 = __values(set), set_2_1 = set_2.next(); !set_2_1.done; set_2_1 = set_2.next()) { - var oldItem = set_2_1.value; - if (i === index) - newSet.add(item); - newSet.add(oldItem); - i++; - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (set_2_1 && !set_2_1.done && (_a = set_2.return)) _a.call(set_2); - } - finally { if (e_2) throw e_2.error; } - } - set.clear(); - newSet.forEach(set.add, set); -} -exports.insert = insert; +var XMLStringLexer_1 = __webpack_require__(911); +var interfaces_1 = __webpack_require__(172); +var infra_1 = __webpack_require__(23); +var algorithm_1 = __webpack_require__(163); +var LocalNameSet_1 = __webpack_require__(575); /** - * Removes the given item or all items matching condition. + * Represents a parser for XML content. * - * @param set - a set - * @param conditionOrItem - an item to remove or a condition matching items - * to remove + * See: https://html.spec.whatwg.org/#xml-parser */ -function remove(set, conditionOrItem) { - var e_3, _a, e_4, _b; - if (!util_1.isFunction(conditionOrItem)) { - set.delete(conditionOrItem); +var XMLParserImpl = /** @class */ (function () { + function XMLParserImpl() { } - else { - var toRemove = []; - try { - for (var set_3 = __values(set), set_3_1 = set_3.next(); !set_3_1.done; set_3_1 = set_3.next()) { - var item = set_3_1.value; - if (!!conditionOrItem.call(null, item)) { - toRemove.push(item); - } - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (set_3_1 && !set_3_1.done && (_a = set_3.return)) _a.call(set_3); - } - finally { if (e_3) throw e_3.error; } - } - try { - for (var toRemove_1 = __values(toRemove), toRemove_1_1 = toRemove_1.next(); !toRemove_1_1.done; toRemove_1_1 = toRemove_1.next()) { - var oldItem = toRemove_1_1.value; - set.delete(oldItem); - } - } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (toRemove_1_1 && !toRemove_1_1.done && (_b = toRemove_1.return)) _b.call(toRemove_1); + /** + * Parses XML content. + * + * @param source - a string containing XML content + */ + XMLParserImpl.prototype.parse = function (source) { + var e_1, _a, e_2, _b; + var lexer = new XMLStringLexer_1.XMLStringLexer(source, { skipWhitespaceOnlyText: true }); + var doc = algorithm_1.create_document(); + var context = doc; + var token = lexer.nextToken(); + while (token.type !== interfaces_1.TokenType.EOF) { + switch (token.type) { + case interfaces_1.TokenType.Declaration: + var declaration = token; + if (declaration.version !== "1.0") { + throw new Error("Invalid xml version: " + declaration.version); + } + break; + case interfaces_1.TokenType.DocType: + var doctype = token; + if (!algorithm_1.xml_isPubidChar(doctype.pubId)) { + throw new Error("DocType public identifier does not match PubidChar construct."); + } + if (!algorithm_1.xml_isLegalChar(doctype.sysId) || + (doctype.sysId.indexOf('"') !== -1 && doctype.sysId.indexOf("'") !== -1)) { + throw new Error("DocType system identifier contains invalid characters."); + } + context.appendChild(doc.implementation.createDocumentType(doctype.name, doctype.pubId, doctype.sysId)); + break; + case interfaces_1.TokenType.CDATA: + var cdata = token; + if (!algorithm_1.xml_isLegalChar(cdata.data) || + cdata.data.indexOf("]]>") !== -1) { + throw new Error("CDATA contains invalid characters."); + } + context.appendChild(doc.createCDATASection(cdata.data)); + break; + case interfaces_1.TokenType.Comment: + var comment = token; + if (!algorithm_1.xml_isLegalChar(comment.data) || + comment.data.indexOf("--") !== -1 || comment.data.endsWith("-")) { + throw new Error("Comment data contains invalid characters."); + } + context.appendChild(doc.createComment(comment.data)); + break; + case interfaces_1.TokenType.PI: + var pi = token; + if (pi.target.indexOf(":") !== -1 || (/^xml$/i).test(pi.target)) { + throw new Error("Processing instruction target contains invalid characters."); + } + if (!algorithm_1.xml_isLegalChar(pi.data) || pi.data.indexOf("?>") !== -1) { + throw new Error("Processing instruction data contains invalid characters."); + } + context.appendChild(doc.createProcessingInstruction(pi.target, pi.data)); + break; + case interfaces_1.TokenType.Text: + var text = token; + if (!algorithm_1.xml_isLegalChar(text.data)) { + throw new Error("Text data contains invalid characters."); + } + context.appendChild(doc.createTextNode(text.data)); + break; + case interfaces_1.TokenType.Element: + var element = token; + // inherit namespace from parent + var _c = __read(algorithm_1.namespace_extractQName(element.name), 2), prefix = _c[0], localName = _c[1]; + if (localName.indexOf(":") !== -1 || !algorithm_1.xml_isName(localName)) { + throw new Error("Node local name contains invalid characters."); + } + if (prefix === "xmlns") { + throw new Error("An element cannot have the 'xmlns' prefix."); + } + var namespace = context.lookupNamespaceURI(prefix); + // override namespace if there is a namespace declaration + // attribute + // also lookup namespace declaration attributes + var nsDeclarations = {}; + try { + for (var _d = (e_1 = void 0, __values(element.attributes)), _e = _d.next(); !_e.done; _e = _d.next()) { + var _f = __read(_e.value, 2), attName = _f[0], attValue = _f[1]; + if (attName === "xmlns") { + namespace = attValue; + } + else { + var _g = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _g[0], attLocalName = _g[1]; + if (attPrefix === "xmlns") { + if (attLocalName === prefix) { + namespace = attValue; + } + nsDeclarations[attLocalName] = attValue; + } + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_e && !_e.done && (_a = _d.return)) _a.call(_d); + } + finally { if (e_1) throw e_1.error; } + } + // create the DOM element node + var elementNode = (namespace !== null ? + doc.createElementNS(namespace, element.name) : + doc.createElement(element.name)); + context.appendChild(elementNode); + // assign attributes + var localNameSet = new LocalNameSet_1.LocalNameSet(); + try { + for (var _h = (e_2 = void 0, __values(element.attributes)), _j = _h.next(); !_j.done; _j = _h.next()) { + var _k = __read(_j.value, 2), attName = _k[0], attValue = _k[1]; + var _l = __read(algorithm_1.namespace_extractQName(attName), 2), attPrefix = _l[0], attLocalName = _l[1]; + var attNamespace = null; + if (attPrefix === "xmlns" || (attPrefix === null && attLocalName === "xmlns")) { + // namespace declaration attribute + attNamespace = infra_1.namespace.XMLNS; + } + else { + attNamespace = elementNode.lookupNamespaceURI(attPrefix); + if (attNamespace !== null && elementNode.isDefaultNamespace(attNamespace)) { + attNamespace = null; + } + else if (attNamespace === null && attPrefix !== null) { + attNamespace = nsDeclarations[attPrefix] || null; + } + } + if (localNameSet.has(attNamespace, attLocalName)) { + throw new Error("Element contains duplicate attributes."); + } + localNameSet.set(attNamespace, attLocalName); + if (attNamespace === infra_1.namespace.XMLNS) { + if (attValue === infra_1.namespace.XMLNS) { + throw new Error("XMLNS namespace is reserved."); + } + } + if (attLocalName.indexOf(":") !== -1 || !algorithm_1.xml_isName(attLocalName)) { + throw new Error("Attribute local name contains invalid characters."); + } + if (attPrefix === "xmlns" && attValue === "") { + throw new Error("Empty XML namespace is not allowed."); + } + if (attNamespace !== null) + elementNode.setAttributeNS(attNamespace, attName, attValue); + else + elementNode.setAttribute(attName, attValue); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_j && !_j.done && (_b = _h.return)) _b.call(_h); + } + finally { if (e_2) throw e_2.error; } + } + if (!element.selfClosing) { + context = elementNode; + } + break; + case interfaces_1.TokenType.ClosingTag: + var closingTag = token; + if (closingTag.name !== context.nodeName) { + throw new Error('Closing tag name does not match opening tag name.'); + } + /* istanbul ignore else */ + if (context._parent) { + context = context._parent; + } + break; } - finally { if (e_4) throw e_4.error; } + token = lexer.nextToken(); } - } -} -exports.remove = remove; + return doc; + }; + return XMLParserImpl; +}()); +exports.XMLParserImpl = XMLParserImpl; +//# sourceMappingURL=XMLParserImpl.js.map + +/***/ }), +/* 469 */, +/* 470 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + 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; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const command_1 = __webpack_require__(431); +const file_command_1 = __webpack_require__(102); +const utils_1 = __webpack_require__(82); +const os = __importStar(__webpack_require__(87)); +const path = __importStar(__webpack_require__(622)); /** - * Removes all items from the set. + * The code to exit an action */ -function empty(set) { - set.clear(); -} -exports.empty = empty; +var ExitCode; +(function (ExitCode) { + /** + * A code indicating that the action was successful + */ + ExitCode[ExitCode["Success"] = 0] = "Success"; + /** + * A code indicating that the action was a failure + */ + ExitCode[ExitCode["Failure"] = 1] = "Failure"; +})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); +//----------------------------------------------------------------------- +// Variables +//----------------------------------------------------------------------- /** - * Determines if the set contains the given item or any items matching - * condition. - * - * @param set - a set - * @param conditionOrItem - an item to a condition to match + * Sets env variable for this action and future actions in the job + * @param name the name of the variable to set + * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify */ -function contains(set, conditionOrItem) { - var e_5, _a; - if (!util_1.isFunction(conditionOrItem)) { - return set.has(conditionOrItem); +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function exportVariable(name, val) { + const convertedVal = utils_1.toCommandValue(val); + process.env[name] = convertedVal; + const filePath = process.env['GITHUB_ENV'] || ''; + if (filePath) { + const delimiter = '_GitHubActionsFileCommandDelimeter_'; + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); } else { - try { - for (var set_4 = __values(set), set_4_1 = set_4.next(); !set_4_1.done; set_4_1 = set_4.next()) { - var oldItem = set_4_1.value; - if (!!conditionOrItem.call(null, oldItem)) { - return true; - } - } - } - catch (e_5_1) { e_5 = { error: e_5_1 }; } - finally { - try { - if (set_4_1 && !set_4_1.done && (_a = set_4.return)) _a.call(set_4); - } - finally { if (e_5) throw e_5.error; } - } + command_1.issueCommand('set-env', { name }, convertedVal); } - return false; } -exports.contains = contains; +exports.exportVariable = exportVariable; /** - * Returns the count of items in the set matching the given condition. - * - * @param set - a set - * @param condition - an optional condition to match + * Registers a secret which will get masked from logs + * @param secret value of the secret */ -function size(set, condition) { - var e_6, _a; - if (condition === undefined) { - return set.size; +function setSecret(secret) { + command_1.issueCommand('add-mask', {}, secret); +} +exports.setSecret = setSecret; +/** + * Prepends inputPath to the PATH (for this action and future actions) + * @param inputPath + */ +function addPath(inputPath) { + const filePath = process.env['GITHUB_PATH'] || ''; + if (filePath) { + file_command_1.issueCommand('PATH', inputPath); } else { - var count = 0; - try { - for (var set_5 = __values(set), set_5_1 = set_5.next(); !set_5_1.done; set_5_1 = set_5.next()) { - var item = set_5_1.value; - if (!!condition.call(null, item)) { - count++; - } - } - } - catch (e_6_1) { e_6 = { error: e_6_1 }; } - finally { - try { - if (set_5_1 && !set_5_1.done && (_a = set_5.return)) _a.call(set_5); - } - finally { if (e_6) throw e_6.error; } - } - return count; + command_1.issueCommand('add-path', {}, inputPath); } + process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; } -exports.size = size; +exports.addPath = addPath; /** - * Determines if the set is empty. + * Gets the value of an input. The value is also trimmed. * - * @param set - a set + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string */ -function isEmpty(set) { - return set.size === 0; +function getInput(name, options) { + const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; + if (options && options.required && !val) { + throw new Error(`Input required and not supplied: ${name}`); + } + return val.trim(); } -exports.isEmpty = isEmpty; +exports.getInput = getInput; /** - * Returns an iterator for the items of the set. + * Sets the value of an output. * - * @param set - a set - * @param condition - an optional condition to match + * @param name name of the output to set + * @param value value to store. Non-string values will be converted to a string via JSON.stringify */ -function forEach(set, condition) { - var set_6, set_6_1, item, e_7_1; - var e_7, _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (!(condition === undefined)) return [3 /*break*/, 2]; - return [5 /*yield**/, __values(set)]; - case 1: - _b.sent(); - return [3 /*break*/, 9]; - case 2: - _b.trys.push([2, 7, 8, 9]); - set_6 = __values(set), set_6_1 = set_6.next(); - _b.label = 3; - case 3: - if (!!set_6_1.done) return [3 /*break*/, 6]; - item = set_6_1.value; - if (!!!condition.call(null, item)) return [3 /*break*/, 5]; - return [4 /*yield*/, item]; - case 4: - _b.sent(); - _b.label = 5; - case 5: - set_6_1 = set_6.next(); - return [3 /*break*/, 3]; - case 6: return [3 /*break*/, 9]; - case 7: - e_7_1 = _b.sent(); - e_7 = { error: e_7_1 }; - return [3 /*break*/, 9]; - case 8: - try { - if (set_6_1 && !set_6_1.done && (_a = set_6.return)) _a.call(set_6); - } - finally { if (e_7) throw e_7.error; } - return [7 /*endfinally*/]; - case 9: return [2 /*return*/]; - } - }); +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function setOutput(name, value) { + command_1.issueCommand('set-output', { name }, value); } -exports.forEach = forEach; +exports.setOutput = setOutput; /** - * Creates and returns a shallow clone of set. + * Enables or disables the echoing of commands into stdout for the rest of the step. + * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. * - * @param set - a set */ -function clone(set) { - return new Set(set); +function setCommandEcho(enabled) { + command_1.issue('echo', enabled ? 'on' : 'off'); } -exports.clone = clone; +exports.setCommandEcho = setCommandEcho; +//----------------------------------------------------------------------- +// Results +//----------------------------------------------------------------------- /** - * Returns a new set containing items from the set sorted in ascending - * order. - * - * @param set - a set - * @param lessThanAlgo - a function that returns `true` if its first argument - * is less than its second argument, and `false` otherwise. + * Sets the action status to failed. + * When the action exits it will be with an exit code of 1 + * @param message add error issue message */ -function sortInAscendingOrder(set, lessThanAlgo) { - var list = new (Array.bind.apply(Array, __spread([void 0], set)))(); - list.sort(function (itemA, itemB) { - return lessThanAlgo.call(null, itemA, itemB) ? -1 : 1; - }); - return new Set(list); +function setFailed(message) { + process.exitCode = ExitCode.Failure; + error(message); } -exports.sortInAscendingOrder = sortInAscendingOrder; +exports.setFailed = setFailed; +//----------------------------------------------------------------------- +// Logging Commands +//----------------------------------------------------------------------- /** - * Returns a new set containing items from the set sorted in descending - * order. - * - * @param set - a set - * @param lessThanAlgo - a function that returns `true` if its first argument - * is less than its second argument, and `false` otherwise. + * Gets whether Actions Step Debug is on or not */ -function sortInDescendingOrder(set, lessThanAlgo) { - var list = new (Array.bind.apply(Array, __spread([void 0], set)))(); - list.sort(function (itemA, itemB) { - return lessThanAlgo.call(null, itemA, itemB) ? 1 : -1; - }); - return new Set(list); +function isDebug() { + return process.env['RUNNER_DEBUG'] === '1'; } -exports.sortInDescendingOrder = sortInDescendingOrder; +exports.isDebug = isDebug; /** - * Determines if a set is a subset of another set. - * - * @param subset - a set - * @param superset - a superset possibly containing all items from `subset`. + * Writes debug message to user log + * @param message debug message */ -function isSubsetOf(subset, superset) { - var e_8, _a; - try { - for (var subset_1 = __values(subset), subset_1_1 = subset_1.next(); !subset_1_1.done; subset_1_1 = subset_1.next()) { - var item = subset_1_1.value; - if (!superset.has(item)) - return false; - } - } - catch (e_8_1) { e_8 = { error: e_8_1 }; } - finally { - try { - if (subset_1_1 && !subset_1_1.done && (_a = subset_1.return)) _a.call(subset_1); - } - finally { if (e_8) throw e_8.error; } - } - return true; +function debug(message) { + command_1.issueCommand('debug', {}, message); } -exports.isSubsetOf = isSubsetOf; +exports.debug = debug; /** - * Determines if a set is a superset of another set. - * - * @param superset - a set - * @param subset - a subset possibly contained within `superset`. + * Adds an error issue + * @param message error issue message. Errors will be converted to string via toString() */ -function isSupersetOf(superset, subset) { - return isSubsetOf(subset, superset); +function error(message) { + command_1.issue('error', message instanceof Error ? message.toString() : message); } -exports.isSupersetOf = isSupersetOf; +exports.error = error; /** - * Returns a new set with items that are contained in both sets. - * - * @param setA - a set - * @param setB - a set + * Adds an warning issue + * @param message warning issue message. Errors will be converted to string via toString() */ -function intersection(setA, setB) { - var e_9, _a; - var newSet = new Set(); - try { - for (var setA_1 = __values(setA), setA_1_1 = setA_1.next(); !setA_1_1.done; setA_1_1 = setA_1.next()) { - var item = setA_1_1.value; - if (setB.has(item)) - newSet.add(item); - } - } - catch (e_9_1) { e_9 = { error: e_9_1 }; } - finally { - try { - if (setA_1_1 && !setA_1_1.done && (_a = setA_1.return)) _a.call(setA_1); - } - finally { if (e_9) throw e_9.error; } - } - return newSet; +function warning(message) { + command_1.issue('warning', message instanceof Error ? message.toString() : message); } -exports.intersection = intersection; +exports.warning = warning; /** - * Returns a new set with items from both sets. - * - * @param setA - a set - * @param setB - a set + * Writes info to log with console.log. + * @param message info message */ -function union(setA, setB) { - var newSet = new Set(setA); - setB.forEach(newSet.add, newSet); - return newSet; +function info(message) { + process.stdout.write(message + os.EOL); } -exports.union = union; +exports.info = info; /** - * Returns a set of integers from `n` to `m` inclusive. + * Begin an output group. * - * @param n - starting number - * @param m - ending number + * Output until the next `groupEnd` will be foldable in this group + * + * @param name The name of the output group */ -function range(n, m) { - var newSet = new Set(); - for (var i = n; i <= m; i++) { - newSet.add(i); - } - return newSet; +function startGroup(name) { + command_1.issue('group', name); } -exports.range = range; -//# sourceMappingURL=Set.js.map - -/***/ }), -/* 497 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var BaseCBWriter_1 = __webpack_require__(512); +exports.startGroup = startGroup; /** - * Serializes XML nodes. + * End an output group. */ -var YAMLCBWriter = /** @class */ (function (_super) { - __extends(YAMLCBWriter, _super); - /** - * Initializes a new instance of `BaseCBWriter`. - * - * @param builderOptions - XML builder options - */ - function YAMLCBWriter(builderOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._rootWritten = false; - _this._additionalLevel = 0; - if (builderOptions.indent.length < 2) { - throw new Error("YAML indententation string must be at least two characters long."); - } - if (builderOptions.offset < 0) { - throw new Error("YAML offset should be zero or a positive number."); - } - return _this; - } - /** @inheritdoc */ - YAMLCBWriter.prototype.frontMatter = function () { - return this._beginLine() + "---"; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.declaration = function (version, encoding, standalone) { - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.docType = function (name, publicId, systemId) { - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.comment = function (data) { - // "!": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.comment) + " " + - this._val(data); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.text = function (data) { - // "#": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.text) + " " + - this._val(data); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.instruction = function (target, data) { - // "?": "target hello" - return this._beginLine() + - this._key(this._builderOptions.convert.ins) + " " + - this._val(data ? target + " " + data : target); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.cdata = function (data) { - // "$": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.cdata) + " " + - this._val(data); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.attribute = function (name, value) { - // "@name": "val" - this._additionalLevel++; - var str = this._beginLine() + - this._key(this._builderOptions.convert.att + name) + " " + - this._val(value); - this._additionalLevel--; - return str; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.openTagBegin = function (name) { - // "node": - // "#": - // - - var str = this._beginLine() + this._key(name); - if (!this._rootWritten) { - this._rootWritten = true; - } - this.hasData = true; - this._additionalLevel++; - str += this._beginLine(true) + this._key(this._builderOptions.convert.text); - return str; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (selfClosing) { - return " " + this._val(""); - } - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.closeTag = function (name) { - this._additionalLevel--; - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - YAMLCBWriter.prototype.endElement = function (name) { }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - YAMLCBWriter.prototype._beginLine = function (suppressArray) { - if (suppressArray === void 0) { suppressArray = false; } - return (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level, suppressArray); - }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - * @param suppressArray - whether the suppress array marker - */ - YAMLCBWriter.prototype._indent = function (level, suppressArray) { - if (level + this._additionalLevel <= 0) { - return ""; - } - else { - var chars = this._writerOptions.indent.repeat(level + this._additionalLevel); - if (!suppressArray && this._rootWritten) { - return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); - } - return chars; - } - }; - /** - * Produces a YAML key string delimited with double quotes. - */ - YAMLCBWriter.prototype._key = function (key) { - return "\"" + key + "\":"; - }; - /** - * Produces a YAML value string delimited with double quotes. - */ - YAMLCBWriter.prototype._val = function (val) { - return JSON.stringify(val); - }; - return YAMLCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.YAMLCBWriter = YAMLCBWriter; -//# sourceMappingURL=YAMLCBWriter.js.map - -/***/ }), -/* 498 */, -/* 499 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const parse = __webpack_require__(830) -const {re, t} = __webpack_require__(976) - -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) +function endGroup() { + command_1.issue('endgroup'); } -module.exports = coerce - - -/***/ }), -/* 500 */, -/* 501 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); +exports.endGroup = endGroup; /** - * Appends the given item to the queue. + * Wrap an asynchronous function call in a group. * - * @param list - a list - * @param item - an item + * Returns the same type as the function itself. + * + * @param name The name of the group + * @param fn The function to wrap in the group */ -function enqueue(list, item) { - list.push(item); +function group(name, fn) { + return __awaiter(this, void 0, void 0, function* () { + startGroup(name); + let result; + try { + result = yield fn(); + } + finally { + endGroup(); + } + return result; + }); } -exports.enqueue = enqueue; +exports.group = group; +//----------------------------------------------------------------------- +// Wrapper action state +//----------------------------------------------------------------------- /** - * Removes and returns an item from the queue. + * Saves state for current action, the state can only be retrieved by this action's post job execution. * - * @param list - a list + * @param name name of the state to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify */ -function dequeue(list) { - return list.shift() || null; -} -exports.dequeue = dequeue; -//# sourceMappingURL=Queue.js.map - -/***/ }), -/* 502 */, -/* 503 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const parse = __webpack_require__(830) -const clean = (version, options) => { - const s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function saveState(name, value) { + command_1.issueCommand('save-state', { name }, value); } -module.exports = clean - - -/***/ }), -/* 504 */, -/* 505 */, -/* 506 */, -/* 507 */, -/* 508 */, -/* 509 */, -/* 510 */, -/* 511 */, -/* 512 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); +exports.saveState = saveState; /** - * Pre-serializes XML nodes. + * Gets the value of an state set by this action's main execution. + * + * @param name name of the state to get + * @returns string */ -var BaseCBWriter = /** @class */ (function () { - /** - * Initializes a new instance of `BaseCBWriter`. - * - * @param builderOptions - XML builder options - */ - function BaseCBWriter(builderOptions) { - /** - * Gets the current depth of the XML tree. - */ - this.level = 0; - this._builderOptions = builderOptions; - this._writerOptions = builderOptions; - } - return BaseCBWriter; -}()); -exports.BaseCBWriter = BaseCBWriter; -//# sourceMappingURL=BaseCBWriter.js.map +function getState(name) { + return process.env[`STATE_${name}`] || ''; +} +exports.getState = getState; +//# sourceMappingURL=core.js.map /***/ }), -/* 513 */, -/* 514 */, -/* 515 */, -/* 516 */, -/* 517 */, -/* 518 */, -/* 519 */, -/* 520 */, -/* 521 */, -/* 522 */ +/* 471 */, +/* 472 */, +/* 473 */, +/* 474 */, +/* 475 */, +/* 476 */, +/* 477 */, +/* 478 */, +/* 479 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; @@ -22516,3115 +20245,4106 @@ var __values = (this && this.__values) || function(o) { }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; Object.defineProperty(exports, "__esModule", { value: true }); -var util_1 = __webpack_require__(592); +var DOMImpl_1 = __webpack_require__(648); +var DOMException_1 = __webpack_require__(35); +var interfaces_1 = __webpack_require__(970); +var util_1 = __webpack_require__(918); +var util_2 = __webpack_require__(592); +var infra_1 = __webpack_require__(23); +var CustomElementAlgorithm_1 = __webpack_require__(344); +var TreeAlgorithm_1 = __webpack_require__(873); +var NodeIteratorAlgorithm_1 = __webpack_require__(272); +var ShadowTreeAlgorithm_1 = __webpack_require__(180); +var MutationObserverAlgorithm_1 = __webpack_require__(151); +var DOMAlgorithm_1 = __webpack_require__(304); +var DocumentAlgorithm_1 = __webpack_require__(493); /** - * Parses the given byte sequence representing a JSON string into an object. + * Ensures pre-insertion validity of a node into a parent before a + * child. * - * @param bytes - a byte sequence + * @param node - node to insert + * @param parent - parent node to receive node + * @param child - child node to insert node before */ -function parseJSONFromBytes(bytes) { +function mutation_ensurePreInsertionValidity(node, parent, child) { + var e_1, _a, e_2, _b, e_3, _c, e_4, _d; + var parentNodeType = parent._nodeType; + var nodeNodeType = node._nodeType; + var childNodeType = child ? child._nodeType : null; /** - * 1. Let jsonText be the result of running UTF-8 decode on bytes. [ENCODING] - * 2. Return ? Call(%JSONParse%, undefined, « jsonText »). + * 1. If parent is not a Document, DocumentFragment, or Element node, + * throw a "HierarchyRequestError" DOMException. */ - var jsonText = util_1.utf8Decode(bytes); - return JSON.parse.call(undefined, jsonText); -} -exports.parseJSONFromBytes = parseJSONFromBytes; -/** - * Serialize the given JavaScript value into a byte sequence. - * - * @param value - a JavaScript value - */ -function serializeJSONToBytes(value) { + if (parentNodeType !== interfaces_1.NodeType.Document && + parentNodeType !== interfaces_1.NodeType.DocumentFragment && + parentNodeType !== interfaces_1.NodeType.Element) + throw new DOMException_1.HierarchyRequestError("Only document, document fragment and element nodes can contain child nodes. Parent node is " + parent.nodeName + "."); /** - * 1. Let jsonString be ? Call(%JSONStringify%, undefined, « value »). - * 2. Return the result of running UTF-8 encode on jsonString. [ENCODING] + * 2. If node is a host-including inclusive ancestor of parent, throw a + * "HierarchyRequestError" DOMException. */ - var jsonString = JSON.stringify.call(undefined, value); - return util_1.utf8Encode(jsonString); + if (TreeAlgorithm_1.tree_isHostIncludingAncestorOf(parent, node, true)) + throw new DOMException_1.HierarchyRequestError("The node to be inserted cannot be an inclusive ancestor of parent node. Node is " + node.nodeName + ", parent node is " + parent.nodeName + "."); + /** + * 3. If child is not null and its parent is not parent, then throw a + * "NotFoundError" DOMException. + */ + if (child !== null && child._parent !== parent) + throw new DOMException_1.NotFoundError("The reference child node cannot be found under parent node. Child node is " + child.nodeName + ", parent node is " + parent.nodeName + "."); + /** + * 4. If node is not a DocumentFragment, DocumentType, Element, Text, + * ProcessingInstruction, or Comment node, throw a "HierarchyRequestError" + * DOMException. + */ + if (nodeNodeType !== interfaces_1.NodeType.DocumentFragment && + nodeNodeType !== interfaces_1.NodeType.DocumentType && + nodeNodeType !== interfaces_1.NodeType.Element && + nodeNodeType !== interfaces_1.NodeType.Text && + nodeNodeType !== interfaces_1.NodeType.ProcessingInstruction && + nodeNodeType !== interfaces_1.NodeType.CData && + nodeNodeType !== interfaces_1.NodeType.Comment) + throw new DOMException_1.HierarchyRequestError("Only document fragment, document type, element, text, processing instruction, cdata section or comment nodes can be inserted. Node is " + node.nodeName + "."); + /** + * 5. If either node is a Text node and parent is a document, or node is a + * doctype and parent is not a document, throw a "HierarchyRequestError" + * DOMException. + */ + if (nodeNodeType === interfaces_1.NodeType.Text && + parentNodeType === interfaces_1.NodeType.Document) + throw new DOMException_1.HierarchyRequestError("Cannot insert a text node as a child of a document node. Node is " + node.nodeName + "."); + if (nodeNodeType === interfaces_1.NodeType.DocumentType && + parentNodeType !== interfaces_1.NodeType.Document) + throw new DOMException_1.HierarchyRequestError("A document type node can only be inserted under a document node. Parent node is " + parent.nodeName + "."); + /** + * 6. If parent is a document, and any of the statements below, switched on + * node, are true, throw a "HierarchyRequestError" DOMException. + * - DocumentFragment node + * If node has more than one element child or has a Text node child. + * Otherwise, if node has one element child and either parent has an element + * child, child is a doctype, or child is not null and a doctype is + * following child. + * - element + * parent has an element child, child is a doctype, or child is not null and + * a doctype is following child. + * - doctype + * parent has a doctype child, child is non-null and an element is preceding + * child, or child is null and parent has an element child. + */ + if (parentNodeType === interfaces_1.NodeType.Document) { + if (nodeNodeType === interfaces_1.NodeType.DocumentFragment) { + var eleCount = 0; + try { + for (var _e = __values(node._children), _f = _e.next(); !_f.done; _f = _e.next()) { + var childNode = _f.value; + if (childNode._nodeType === interfaces_1.NodeType.Element) + eleCount++; + else if (childNode._nodeType === interfaces_1.NodeType.Text) + throw new DOMException_1.HierarchyRequestError("Cannot insert text a node as a child of a document node. Node is " + childNode.nodeName + "."); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_f && !_f.done && (_a = _e.return)) _a.call(_e); + } + finally { if (e_1) throw e_1.error; } + } + if (eleCount > 1) { + throw new DOMException_1.HierarchyRequestError("A document node can only have one document element node. Document fragment to be inserted has " + eleCount + " element nodes."); + } + else if (eleCount === 1) { + try { + for (var _g = __values(parent._children), _h = _g.next(); !_h.done; _h = _g.next()) { + var ele = _h.value; + if (ele._nodeType === interfaces_1.NodeType.Element) + throw new DOMException_1.HierarchyRequestError("The document node already has a document element node."); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_h && !_h.done && (_b = _g.return)) _b.call(_g); + } + finally { if (e_2) throw e_2.error; } + } + if (child) { + if (childNodeType === interfaces_1.NodeType.DocumentType) + throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node."); + var doctypeChild = child._nextSibling; + while (doctypeChild) { + if (doctypeChild._nodeType === interfaces_1.NodeType.DocumentType) + throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node."); + doctypeChild = doctypeChild._nextSibling; + } + } + } + } + else if (nodeNodeType === interfaces_1.NodeType.Element) { + try { + for (var _j = __values(parent._children), _k = _j.next(); !_k.done; _k = _j.next()) { + var ele = _k.value; + if (ele._nodeType === interfaces_1.NodeType.Element) + throw new DOMException_1.HierarchyRequestError("Document already has a document element node. Node is " + node.nodeName + "."); + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_k && !_k.done && (_c = _j.return)) _c.call(_j); + } + finally { if (e_3) throw e_3.error; } + } + if (child) { + if (childNodeType === interfaces_1.NodeType.DocumentType) + throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node. Node is " + node.nodeName + "."); + var doctypeChild = child._nextSibling; + while (doctypeChild) { + if (doctypeChild._nodeType === interfaces_1.NodeType.DocumentType) + throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node. Node is " + node.nodeName + "."); + doctypeChild = doctypeChild._nextSibling; + } + } + } + else if (nodeNodeType === interfaces_1.NodeType.DocumentType) { + try { + for (var _l = __values(parent._children), _m = _l.next(); !_m.done; _m = _l.next()) { + var ele = _m.value; + if (ele._nodeType === interfaces_1.NodeType.DocumentType) + throw new DOMException_1.HierarchyRequestError("Document already has a document type node. Node is " + node.nodeName + "."); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (_m && !_m.done && (_d = _l.return)) _d.call(_l); + } + finally { if (e_4) throw e_4.error; } + } + if (child) { + var elementChild = child._previousSibling; + while (elementChild) { + if (elementChild._nodeType === interfaces_1.NodeType.Element) + throw new DOMException_1.HierarchyRequestError("Cannot insert a document type node before an element node. Node is " + node.nodeName + "."); + elementChild = elementChild._previousSibling; + } + } + else { + var elementChild = parent._firstChild; + while (elementChild) { + if (elementChild._nodeType === interfaces_1.NodeType.Element) + throw new DOMException_1.HierarchyRequestError("Cannot insert a document type node before an element node. Node is " + node.nodeName + "."); + elementChild = elementChild._nextSibling; + } + } + } + } } -exports.serializeJSONToBytes = serializeJSONToBytes; +exports.mutation_ensurePreInsertionValidity = mutation_ensurePreInsertionValidity; /** - * Parses the given JSON string into a Realm-independent JavaScript value. + * Ensures pre-insertion validity of a node into a parent before a + * child, then adopts the node to the tree and inserts it. * - * @param jsonText - a JSON string + * @param node - node to insert + * @param parent - parent node to receive node + * @param child - child node to insert node before */ -function parseJSONIntoInfraValues(jsonText) { +function mutation_preInsert(node, parent, child) { /** - * 1. Let jsValue be ? Call(%JSONParse%, undefined, « jsonText »). - * 2. Return the result of converting a JSON-derived JavaScript value to an - * Infra value, given jsValue. + * 1. Ensure pre-insertion validity of node into parent before child. + * 2. Let reference child be child. + * 3. If reference child is node, set it to node’s next sibling. + * 4. Adopt node into parent’s node document. + * 5. Insert node into parent before reference child. + * 6. Return node. */ - var jsValue = JSON.parse.call(undefined, jsonText); - return convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValue); + mutation_ensurePreInsertionValidity(node, parent, child); + var referenceChild = child; + if (referenceChild === node) + referenceChild = node._nextSibling; + DocumentAlgorithm_1.document_adopt(node, parent._nodeDocument); + mutation_insert(node, parent, referenceChild); + return node; } -exports.parseJSONIntoInfraValues = parseJSONIntoInfraValues; +exports.mutation_preInsert = mutation_preInsert; /** - * Parses the value into a Realm-independent JavaScript value. + * Inserts a node into a parent node before the given child node. * - * @param jsValue - a JavaScript value + * @param node - node to insert + * @param parent - parent node to receive node + * @param child - child node to insert node before + * @param suppressObservers - whether to notify observers */ -function convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValue) { - var e_1, _a; +function mutation_insert(node, parent, child, suppressObservers) { + var e_5, _a; + // Optimized common case + if (child === null && node._nodeType !== interfaces_1.NodeType.DocumentFragment) { + mutation_insert_single(node, parent, suppressObservers); + return; + } /** - * 1. If Type(jsValue) is Null, String, or Number, then return jsValue. + * 1. Let count be the number of children of node if it is a + * DocumentFragment node, and one otherwise. */ - if (jsValue === null || util_1.isString(jsValue) || util_1.isNumber(jsValue)) - return jsValue; + var count = (node._nodeType === interfaces_1.NodeType.DocumentFragment ? + node._children.size : 1); /** - * 2. If IsArray(jsValue) is true, then: - * 2.1. Let result be an empty list. - * 2.2. Let length be ! ToLength(! Get(jsValue, "length")). - * 2.3. For each index of the range 0 to length − 1, inclusive: - * 2.3.1. Let indexName be ! ToString(index). - * 2.3.2. Let jsValueAtIndex be ! Get(jsValue, indexName). - * 2.3.3. Let infraValueAtIndex be the result of converting a JSON-derived - * JavaScript value to an Infra value, given jsValueAtIndex. - * 2.3.4. Append infraValueAtIndex to result. - * 2.8. Return result. + * 2. If child is non-null, then: */ - if (util_1.isArray(jsValue)) { - var result = new Array(); - try { - for (var jsValue_1 = __values(jsValue), jsValue_1_1 = jsValue_1.next(); !jsValue_1_1.done; jsValue_1_1 = jsValue_1.next()) { - var jsValueAtIndex = jsValue_1_1.value; - result.push(convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValueAtIndex)); + if (child !== null) { + /** + * 2.1. For each live range whose start node is parent and start + * offset is greater than child's index, increase its start + * offset by count. + * 2.2. For each live range whose end node is parent and end + * offset is greater than child's index, increase its end + * offset by count. + */ + if (DOMImpl_1.dom.rangeList.size !== 0) { + var index_1 = TreeAlgorithm_1.tree_index(child); + try { + for (var _b = __values(DOMImpl_1.dom.rangeList), _c = _b.next(); !_c.done; _c = _b.next()) { + var range = _c.value; + if (range._start[0] === parent && range._start[1] > index_1) { + range._start[1] += count; + } + if (range._end[0] === parent && range._end[1] > index_1) { + range._end[1] += count; + } + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_5) throw e_5.error; } + } + } + } + /** + * 3. Let nodes be node’s children, if node is a DocumentFragment node; + * otherwise « node ». + */ + var nodes = node._nodeType === interfaces_1.NodeType.DocumentFragment ? new (Array.bind.apply(Array, __spread([void 0], node._children)))() : [node]; + /** + * 4. If node is a DocumentFragment node, remove its children with the + * suppress observers flag set. + */ + if (node._nodeType === interfaces_1.NodeType.DocumentFragment) { + while (node._firstChild) { + mutation_remove(node._firstChild, node, true); + } + } + /** + * 5. If node is a DocumentFragment node, then queue a tree mutation record + * for node with « », nodes, null, and null. + */ + if (DOMImpl_1.dom.features.mutationObservers) { + if (node._nodeType === interfaces_1.NodeType.DocumentFragment) { + MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(node, [], nodes, null, null); + } + } + /** + * 6. Let previousSibling be child’s previous sibling or parent’s last + * child if child is null. + */ + var previousSibling = (child ? child._previousSibling : parent._lastChild); + var index = child === null ? -1 : TreeAlgorithm_1.tree_index(child); + /** + * 7. For each node in nodes, in tree order: + */ + for (var i = 0; i < nodes.length; i++) { + var node_1 = nodes[i]; + if (util_1.Guard.isElementNode(node_1)) { + // set document element node + if (util_1.Guard.isDocumentNode(parent)) { + parent._documentElement = node_1; + } + // mark that the document has namespaces + if (!node_1._nodeDocument._hasNamespaces && (node_1._namespace !== null || + node_1._namespacePrefix !== null)) { + node_1._nodeDocument._hasNamespaces = true; + } + } + /** + * 7.1. If child is null, then append node to parent’s children. + * 7.2. Otherwise, insert node into parent’s children before child’s + * index. + */ + node_1._parent = parent; + if (child === null) { + infra_1.set.append(parent._children, node_1); + } + else { + infra_1.set.insert(parent._children, node_1, index); + index++; + } + // assign siblings and children for quick lookups + if (parent._firstChild === null) { + node_1._previousSibling = null; + node_1._nextSibling = null; + parent._firstChild = node_1; + parent._lastChild = node_1; + } + else { + var prev = (child ? child._previousSibling : parent._lastChild); + var next = (child ? child : null); + node_1._previousSibling = prev; + node_1._nextSibling = next; + if (prev) + prev._nextSibling = node_1; + if (next) + next._previousSibling = node_1; + if (!prev) + parent._firstChild = node_1; + if (!next) + parent._lastChild = node_1; + } + /** + * 7.3. If parent is a shadow host and node is a slotable, then + * assign a slot for node. + */ + if (DOMImpl_1.dom.features.slots) { + if (parent._shadowRoot !== null && util_1.Guard.isSlotable(node_1)) { + ShadowTreeAlgorithm_1.shadowTree_assignASlot(node_1); } } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (jsValue_1_1 && !jsValue_1_1.done && (_a = jsValue_1.return)) _a.call(jsValue_1); + /** + * 7.4. If node is a Text node, run the child text content change + * steps for parent. + */ + if (DOMImpl_1.dom.features.steps) { + if (util_1.Guard.isTextNode(node_1)) { + DOMAlgorithm_1.dom_runChildTextContentChangeSteps(parent); } - finally { if (e_1) throw e_1.error; } } - return result; - } - else if (util_1.isObject(jsValue)) { /** - * 3. Let result be an empty ordered map. - * 4. For each key of ! jsValue.[[OwnPropertyKeys]](): - * 4.1. Let jsValueAtKey be ! Get(jsValue, key). - * 4.2. Let infraValueAtKey be the result of converting a JSON-derived - * JavaScript value to an Infra value, given jsValueAtKey. - * 4.3. Set result[key] to infraValueAtKey. - * 5. Return result. + * 7.5. If parent's root is a shadow root, and parent is a slot + * whose assigned nodes is the empty list, then run signal + * a slot change for parent. */ - var result = new Map(); - for (var key in jsValue) { - /* istanbul ignore else */ - if (jsValue.hasOwnProperty(key)) { - var jsValueAtKey = jsValue[key]; - result.set(key, convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValueAtKey)); + if (DOMImpl_1.dom.features.slots) { + if (util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(parent)) && + util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { + ShadowTreeAlgorithm_1.shadowTree_signalASlotChange(parent); } } - return result; + /** + * 7.6. Run assign slotables for a tree with node's root. + */ + if (DOMImpl_1.dom.features.slots) { + ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(node_1)); + } + /** + * 7.7. For each shadow-including inclusive descendant + * inclusiveDescendant of node, in shadow-including tree + * order: + */ + var inclusiveDescendant = TreeAlgorithm_1.tree_getFirstDescendantNode(node_1, true, true); + while (inclusiveDescendant !== null) { + /** + * 7.7.1. Run the insertion steps with inclusiveDescendant. + */ + if (DOMImpl_1.dom.features.steps) { + DOMAlgorithm_1.dom_runInsertionSteps(inclusiveDescendant); + } + if (DOMImpl_1.dom.features.customElements) { + /** + * 7.7.2. If inclusiveDescendant is connected, then: + */ + if (util_1.Guard.isElementNode(inclusiveDescendant) && + ShadowTreeAlgorithm_1.shadowTree_isConnected(inclusiveDescendant)) { + if (util_1.Guard.isCustomElementNode(inclusiveDescendant)) { + /** + * 7.7.2.1. If inclusiveDescendant is custom, then enqueue a custom + * element callback reaction with inclusiveDescendant, callback name + * "connectedCallback", and an empty argument list. + */ + CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(inclusiveDescendant, "connectedCallback", []); + } + else { + /** + * 7.7.2.2. Otherwise, try to upgrade inclusiveDescendant. + */ + CustomElementAlgorithm_1.customElement_tryToUpgrade(inclusiveDescendant); + } + } + } + inclusiveDescendant = TreeAlgorithm_1.tree_getNextDescendantNode(node_1, inclusiveDescendant, true, true); + } + } + /** + * 8. If suppress observers flag is unset, then queue a tree mutation record + * for parent with nodes, « », previousSibling, and child. + */ + if (DOMImpl_1.dom.features.mutationObservers) { + if (!suppressObservers) { + MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, nodes, [], previousSibling, child); + } } - /* istanbul ignore next */ - return jsValue; } -exports.convertAJSONDerivedJavaScriptValueToAnInfraValue = convertAJSONDerivedJavaScriptValueToAnInfraValue; -//# sourceMappingURL=JSON.js.map - -/***/ }), -/* 523 */, -/* 524 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); +exports.mutation_insert = mutation_insert; /** - * Represents a cache for storing order between equal objects. - * - * This cache is used when an algorithm compares two objects and finds them to - * be equal but still needs to establish an order between those two objects. - * When two such objects `a` and `b` are passed to the `check` method, a random - * number is generated with `Math.random()`. If the random number is less than - * `0.5` it is assumed that `a < b` otherwise `a > b`. The random number along - * with `a` and `b` is stored in the cache, so that subsequent checks result - * in the same consistent result. + * Inserts a node into a parent node. Optimized routine for the common case where + * node is not a document fragment node and it has no child nodes. * - * The cache has a size limit which is defined on initialization. + * @param node - node to insert + * @param parent - parent node to receive node + * @param suppressObservers - whether to notify observers */ -var CompareCache = /** @class */ (function () { +function mutation_insert_single(node, parent, suppressObservers) { /** - * Initializes a new instance of `CompareCache`. - * - * @param limit - maximum number of items to keep in the cache. When the limit - * is exceeded the first item is removed from the cache. + * 1. Let count be the number of children of node if it is a + * DocumentFragment node, and one otherwise. + * 2. If child is non-null, then: + * 2.1. For each live range whose start node is parent and start + * offset is greater than child's index, increase its start + * offset by count. + * 2.2. For each live range whose end node is parent and end + * offset is greater than child's index, increase its end + * offset by count. + * 3. Let nodes be node’s children, if node is a DocumentFragment node; + * otherwise « node ». + * 4. If node is a DocumentFragment node, remove its children with the + * suppress observers flag set. + * 5. If node is a DocumentFragment node, then queue a tree mutation record + * for node with « », nodes, null, and null. */ - function CompareCache(limit) { - if (limit === void 0) { limit = 1000; } - this._items = new Map(); - this._limit = limit; - } /** - * Compares and caches the given objects. Returns `true` if `objA < objB` and - * `false` otherwise. - * - * @param objA - an item to compare - * @param objB - an item to compare + * 6. Let previousSibling be child’s previous sibling or parent’s last + * child if child is null. */ - CompareCache.prototype.check = function (objA, objB) { - if (this._items.get(objA) === objB) - return true; - else if (this._items.get(objB) === objA) - return false; - var result = (Math.random() < 0.5); - if (result) { - this._items.set(objA, objB); - } - else { - this._items.set(objB, objA); + var previousSibling = parent._lastChild; + // set document element node + if (util_1.Guard.isElementNode(node)) { + // set document element node + if (util_1.Guard.isDocumentNode(parent)) { + parent._documentElement = node; } - if (this._items.size > this._limit) { - var it_1 = this._items.keys().next(); - /* istanbul ignore else */ - if (!it_1.done) { - this._items.delete(it_1.value); - } + // mark that the document has namespaces + if (!node._nodeDocument._hasNamespaces && (node._namespace !== null || + node._namespacePrefix !== null)) { + node._nodeDocument._hasNamespaces = true; } - return result; - }; - return CompareCache; -}()); -exports.CompareCache = CompareCache; -//# sourceMappingURL=CompareCache.js.map - -/***/ }), -/* 525 */, -/* 526 */, -/* 527 */, -/* 528 */, -/* 529 */, -/* 530 */, -/* 531 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -// Determine if version is greater than all the versions possible in the range. -const outside = __webpack_require__(881) -const gtr = (version, range, options) => outside(version, range, '>', options) -module.exports = gtr - - -/***/ }), -/* 532 */, -/* 533 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var Guard_1 = __webpack_require__(783); -/** - * Contains type casts for DOM objects. - */ -var Cast = /** @class */ (function () { - function Cast() { } /** - * Casts the given object to a `Node`. - * - * @param a - the object to cast + * 7. For each node in nodes, in tree order: + * 7.1. If child is null, then append node to parent’s children. + * 7.2. Otherwise, insert node into parent’s children before child’s + * index. */ - Cast.asNode = function (a) { - if (Guard_1.Guard.isNode(a)) { - return a; - } - else { - throw new Error("Invalid object. Node expected."); - } - }; - return Cast; -}()); -exports.Cast = Cast; -//# sourceMappingURL=Cast.js.map - -/***/ }), -/* 534 */, -/* 535 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var XMLBuilderImpl_1 = __webpack_require__(595); -exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; -var XMLBuilderCBImpl_1 = __webpack_require__(551); -exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; -var BuilderFunctions_1 = __webpack_require__(961); -exports.builder = BuilderFunctions_1.builder; -exports.create = BuilderFunctions_1.create; -exports.fragment = BuilderFunctions_1.fragment; -exports.convert = BuilderFunctions_1.convert; -var BuilderFunctionsCB_1 = __webpack_require__(295); -exports.createCB = BuilderFunctionsCB_1.createCB; -exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; -//# sourceMappingURL=index.js.map - -/***/ }), -/* 536 */ -/***/ (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) { - options = parseOptions(options) - - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp - } else { - comp = comp.value - } + node._parent = parent; + parent._children.add(node); + // assign siblings and children for quick lookups + if (parent._firstChild === null) { + node._previousSibling = null; + node._nextSibling = null; + parent._firstChild = node; + parent._lastChild = node; } - - 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 + else { + var prev = parent._lastChild; + node._previousSibling = prev; + node._nextSibling = null; + if (prev) + prev._nextSibling = node; + if (!prev) + parent._firstChild = node; + parent._lastChild = node; } - - 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}`) + /** + * 7.3. If parent is a shadow host and node is a slotable, then + * assign a slot for node. + */ + if (DOMImpl_1.dom.features.slots) { + if (parent._shadowRoot !== null && util_1.Guard.isSlotable(node)) { + ShadowTreeAlgorithm_1.shadowTree_assignASlot(node); + } } - - this.operator = m[1] !== undefined ? m[1] : '' - if (this.operator === '=') { - this.operator = '' + /** + * 7.4. If node is a Text node, run the child text content change + * steps for parent. + */ + if (DOMImpl_1.dom.features.steps) { + if (util_1.Guard.isTextNode(node)) { + DOMAlgorithm_1.dom_runChildTextContentChangeSteps(parent); + } } - - // 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) + /** + * 7.5. If parent's root is a shadow root, and parent is a slot + * whose assigned nodes is the empty list, then run signal + * a slot change for parent. + */ + if (DOMImpl_1.dom.features.slots) { + if (util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(parent)) && + util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { + ShadowTreeAlgorithm_1.shadowTree_signalASlotChange(parent); + } } - } - - toString () { - return this.value - } - - test (version) { - debug('Comparator.test', version, this.options.loose) - - if (this.semver === ANY || version === ANY) { - return true + /** + * 7.6. Run assign slotables for a tree with node's root. + */ + if (DOMImpl_1.dom.features.slots) { + ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(node)); } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } + /** + * 7.7. For each shadow-including inclusive descendant + * inclusiveDescendant of node, in shadow-including tree + * order: + * 7.7.1. Run the insertion steps with inclusiveDescendant. + */ + if (DOMImpl_1.dom.features.steps) { + DOMAlgorithm_1.dom_runInsertionSteps(node); } - - return cmp(version, this.operator, this.semver, this.options) - } - - intersects (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') + if (DOMImpl_1.dom.features.customElements) { + /** + * 7.7.2. If inclusiveDescendant is connected, then: + */ + if (util_1.Guard.isElementNode(node) && + ShadowTreeAlgorithm_1.shadowTree_isConnected(node)) { + if (util_1.Guard.isCustomElementNode(node)) { + /** + * 7.7.2.1. If inclusiveDescendant is custom, then enqueue a custom + * element callback reaction with inclusiveDescendant, callback name + * "connectedCallback", and an empty argument list. + */ + CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(node, "connectedCallback", []); + } + else { + /** + * 7.7.2.2. Otherwise, try to upgrade inclusiveDescendant. + */ + CustomElementAlgorithm_1.customElement_tryToUpgrade(node); + } + } } - - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } + /** + * 8. If suppress observers flag is unset, then queue a tree mutation record + * for parent with nodes, « », previousSibling, and child. + */ + if (DOMImpl_1.dom.features.mutationObservers) { + if (!suppressObservers) { + MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, [node], [], previousSibling, null); + } } - - 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 parseOptions = __webpack_require__(143) -const {re, t} = __webpack_require__(976) -const cmp = __webpack_require__(752) -const debug = __webpack_require__(548) -const SemVer = __webpack_require__(65) -const Range = __webpack_require__(124) - - -/***/ }), -/* 537 */, -/* 538 */, -/* 539 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const http = __webpack_require__(605); -const https = __webpack_require__(34); -const pm = __webpack_require__(950); -let tunnel; -var HttpCodes; -(function (HttpCodes) { - HttpCodes[HttpCodes["OK"] = 200] = "OK"; - HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; - HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; - HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; - HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; - HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; - HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; - HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; - HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; - HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; - HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); -var Headers; -(function (Headers) { - Headers["Accept"] = "accept"; - Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); -var MediaTypes; -(function (MediaTypes) { - MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); /** - * Returns the proxy URL, depending upon the supplied url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ -function getProxyUrl(serverUrl) { - let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); - return proxyUrl ? proxyUrl.href : ''; -} -exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [ - HttpCodes.MovedPermanently, - HttpCodes.ResourceMoved, - HttpCodes.SeeOther, - HttpCodes.TemporaryRedirect, - HttpCodes.PermanentRedirect -]; -const HttpResponseRetryCodes = [ - HttpCodes.BadGateway, - HttpCodes.ServiceUnavailable, - HttpCodes.GatewayTimeout -]; -const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; -const ExponentialBackoffCeiling = 10; -const ExponentialBackoffTimeSlice = 5; -class HttpClientError extends Error { - constructor(message, statusCode) { - super(message); - this.name = 'HttpClientError'; - this.statusCode = statusCode; - Object.setPrototypeOf(this, HttpClientError.prototype); - } -} -exports.HttpClientError = HttpClientError; -class HttpClientResponse { - constructor(message) { - this.message = message; - } - readBody() { - return new Promise(async (resolve, reject) => { - let output = Buffer.alloc(0); - this.message.on('data', (chunk) => { - output = Buffer.concat([output, chunk]); - }); - this.message.on('end', () => { - resolve(output.toString()); - }); - }); - } -} -exports.HttpClientResponse = HttpClientResponse; -function isHttps(requestUrl) { - let parsedUrl = new URL(requestUrl); - return parsedUrl.protocol === 'https:'; -} -exports.isHttps = isHttps; -class HttpClient { - constructor(userAgent, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = userAgent; - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { - if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; + * Appends a node to the children of a parent node. + * + * @param node - a node + * @param parent - the parent to receive node + */ +function mutation_append(node, parent) { + /** + * To append a node to a parent, pre-insert node into parent before null. + */ + return mutation_preInsert(node, parent, null); +} +exports.mutation_append = mutation_append; +/** + * Replaces a node with another node. + * + * @param child - child node to remove + * @param node - node to insert + * @param parent - parent node to receive node + */ +function mutation_replace(child, node, parent) { + var e_6, _a, e_7, _b, e_8, _c, e_9, _d; + /** + * 1. If parent is not a Document, DocumentFragment, or Element node, + * throw a "HierarchyRequestError" DOMException. + */ + if (parent._nodeType !== interfaces_1.NodeType.Document && + parent._nodeType !== interfaces_1.NodeType.DocumentFragment && + parent._nodeType !== interfaces_1.NodeType.Element) + throw new DOMException_1.HierarchyRequestError("Only document, document fragment and element nodes can contain child nodes. Parent node is " + parent.nodeName + "."); + /** + * 2. If node is a host-including inclusive ancestor of parent, throw a + * "HierarchyRequestError" DOMException. + */ + if (TreeAlgorithm_1.tree_isHostIncludingAncestorOf(parent, node, true)) + throw new DOMException_1.HierarchyRequestError("The node to be inserted cannot be an ancestor of parent node. Node is " + node.nodeName + ", parent node is " + parent.nodeName + "."); + /** + * 3. If child’s parent is not parent, then throw a "NotFoundError" + * DOMException. + */ + if (child._parent !== parent) + throw new DOMException_1.NotFoundError("The reference child node cannot be found under parent node. Child node is " + child.nodeName + ", parent node is " + parent.nodeName + "."); + /** + * 4. If node is not a DocumentFragment, DocumentType, Element, Text, + * ProcessingInstruction, or Comment node, throw a "HierarchyRequestError" + * DOMException. + */ + if (node._nodeType !== interfaces_1.NodeType.DocumentFragment && + node._nodeType !== interfaces_1.NodeType.DocumentType && + node._nodeType !== interfaces_1.NodeType.Element && + node._nodeType !== interfaces_1.NodeType.Text && + node._nodeType !== interfaces_1.NodeType.ProcessingInstruction && + node._nodeType !== interfaces_1.NodeType.CData && + node._nodeType !== interfaces_1.NodeType.Comment) + throw new DOMException_1.HierarchyRequestError("Only document fragment, document type, element, text, processing instruction, cdata section or comment nodes can be inserted. Node is " + node.nodeName + "."); + /** + * 5. If either node is a Text node and parent is a document, or node is a + * doctype and parent is not a document, throw a "HierarchyRequestError" + * DOMException. + */ + if (node._nodeType === interfaces_1.NodeType.Text && + parent._nodeType === interfaces_1.NodeType.Document) + throw new DOMException_1.HierarchyRequestError("Cannot insert a text node as a child of a document node. Node is " + node.nodeName + "."); + if (node._nodeType === interfaces_1.NodeType.DocumentType && + parent._nodeType !== interfaces_1.NodeType.Document) + throw new DOMException_1.HierarchyRequestError("A document type node can only be inserted under a document node. Parent node is " + parent.nodeName + "."); + /** + * 6. If parent is a document, and any of the statements below, switched on + * node, are true, throw a "HierarchyRequestError" DOMException. + * - DocumentFragment node + * If node has more than one element child or has a Text node child. + * Otherwise, if node has one element child and either parent has an element + * child that is not child or a doctype is following child. + * - element + * parent has an element child that is not child or a doctype is + * following child. + * - doctype + * parent has a doctype child that is not child, or an element is + * preceding child. + */ + if (parent._nodeType === interfaces_1.NodeType.Document) { + if (node._nodeType === interfaces_1.NodeType.DocumentFragment) { + var eleCount = 0; + try { + for (var _e = __values(node._children), _f = _e.next(); !_f.done; _f = _e.next()) { + var childNode = _f.value; + if (childNode._nodeType === interfaces_1.NodeType.Element) + eleCount++; + else if (childNode._nodeType === interfaces_1.NodeType.Text) + throw new DOMException_1.HierarchyRequestError("Cannot insert text a node as a child of a document node. Node is " + childNode.nodeName + "."); + } } - this._socketTimeout = requestOptions.socketTimeout; - if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; + catch (e_6_1) { e_6 = { error: e_6_1 }; } + finally { + try { + if (_f && !_f.done && (_a = _e.return)) _a.call(_e); + } + finally { if (e_6) throw e_6.error; } } - if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + if (eleCount > 1) { + throw new DOMException_1.HierarchyRequestError("A document node can only have one document element node. Document fragment to be inserted has " + eleCount + " element nodes."); } - if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + else if (eleCount === 1) { + try { + for (var _g = __values(parent._children), _h = _g.next(); !_h.done; _h = _g.next()) { + var ele = _h.value; + if (ele._nodeType === interfaces_1.NodeType.Element && ele !== child) + throw new DOMException_1.HierarchyRequestError("The document node already has a document element node."); + } + } + catch (e_7_1) { e_7 = { error: e_7_1 }; } + finally { + try { + if (_h && !_h.done && (_b = _g.return)) _b.call(_g); + } + finally { if (e_7) throw e_7.error; } + } + var doctypeChild = child._nextSibling; + while (doctypeChild) { + if (doctypeChild._nodeType === interfaces_1.NodeType.DocumentType) + throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node."); + doctypeChild = doctypeChild._nextSibling; + } } - if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; + } + else if (node._nodeType === interfaces_1.NodeType.Element) { + try { + for (var _j = __values(parent._children), _k = _j.next(); !_k.done; _k = _j.next()) { + var ele = _k.value; + if (ele._nodeType === interfaces_1.NodeType.Element && ele !== child) + throw new DOMException_1.HierarchyRequestError("Document already has a document element node. Node is " + node.nodeName + "."); + } } - if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; + catch (e_8_1) { e_8 = { error: e_8_1 }; } + finally { + try { + if (_k && !_k.done && (_c = _j.return)) _c.call(_j); + } + finally { if (e_8) throw e_8.error; } } - if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; + var doctypeChild = child._nextSibling; + while (doctypeChild) { + if (doctypeChild._nodeType === interfaces_1.NodeType.DocumentType) + throw new DOMException_1.HierarchyRequestError("Cannot insert an element node before a document type node. Node is " + node.nodeName + "."); + doctypeChild = doctypeChild._nextSibling; + } + } + else if (node._nodeType === interfaces_1.NodeType.DocumentType) { + try { + for (var _l = __values(parent._children), _m = _l.next(); !_m.done; _m = _l.next()) { + var ele = _m.value; + if (ele._nodeType === interfaces_1.NodeType.DocumentType && ele !== child) + throw new DOMException_1.HierarchyRequestError("Document already has a document type node. Node is " + node.nodeName + "."); + } + } + catch (e_9_1) { e_9 = { error: e_9_1 }; } + finally { + try { + if (_m && !_m.done && (_d = _l.return)) _d.call(_l); + } + finally { if (e_9) throw e_9.error; } + } + var elementChild = child._previousSibling; + while (elementChild) { + if (elementChild._nodeType === interfaces_1.NodeType.Element) + throw new DOMException_1.HierarchyRequestError("Cannot insert a document type node before an element node. Node is " + node.nodeName + "."); + elementChild = elementChild._previousSibling; } } } - options(requestUrl, additionalHeaders) { - return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); + /** + * 7. Let reference child be child’s next sibling. + * 8. If reference child is node, set it to node’s next sibling. + * 8. Let previousSibling be child’s previous sibling. + */ + var referenceChild = child._nextSibling; + if (referenceChild === node) + referenceChild = node._nextSibling; + var previousSibling = child._previousSibling; + /** + * 10. Adopt node into parent’s node document. + * 11. Let removedNodes be the empty list. + */ + DocumentAlgorithm_1.document_adopt(node, parent._nodeDocument); + var removedNodes = []; + /** + * 12. If child’s parent is not null, then: + */ + if (child._parent !== null) { + /** + * 12.1. Set removedNodes to [child]. + * 12.2. Remove child from its parent with the suppress observers flag + * set. + */ + removedNodes.push(child); + mutation_remove(child, child._parent, true); } - get(requestUrl, additionalHeaders) { - return this.request('GET', requestUrl, null, additionalHeaders || {}); + /** + * 13. Let nodes be node’s children if node is a DocumentFragment node; + * otherwise [node]. + */ + var nodes = []; + if (node._nodeType === interfaces_1.NodeType.DocumentFragment) { + nodes = Array.from(node._children); } - del(requestUrl, additionalHeaders) { - return this.request('DELETE', requestUrl, null, additionalHeaders || {}); + else { + nodes.push(node); } - post(requestUrl, data, additionalHeaders) { - return this.request('POST', requestUrl, data, additionalHeaders || {}); + /** + * 14. Insert node into parent before reference child with the suppress + * observers flag set. + */ + mutation_insert(node, parent, referenceChild, true); + /** + * 15. Queue a tree mutation record for parent with nodes, removedNodes, + * previousSibling, and reference child. + */ + if (DOMImpl_1.dom.features.mutationObservers) { + MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, nodes, removedNodes, previousSibling, referenceChild); } - patch(requestUrl, data, additionalHeaders) { - return this.request('PATCH', requestUrl, data, additionalHeaders || {}); + /** + * 16. Return child. + */ + return child; +} +exports.mutation_replace = mutation_replace; +/** + * Replaces all nodes of a parent with the given node. + * + * @param node - node to insert + * @param parent - parent node to receive node + */ +function mutation_replaceAll(node, parent) { + var e_10, _a; + /** + * 1. If node is not null, adopt node into parent’s node document. + */ + if (node !== null) { + DocumentAlgorithm_1.document_adopt(node, parent._nodeDocument); } - put(requestUrl, data, additionalHeaders) { - return this.request('PUT', requestUrl, data, additionalHeaders || {}); + /** + * 2. Let removedNodes be parent’s children. + */ + var removedNodes = Array.from(parent._children); + /** + * 3. Let addedNodes be the empty list. + * 4. If node is DocumentFragment node, then set addedNodes to node’s + * children. + * 5. Otherwise, if node is non-null, set addedNodes to [node]. + */ + var addedNodes = []; + if (node && node._nodeType === interfaces_1.NodeType.DocumentFragment) { + addedNodes = Array.from(node._children); } - head(requestUrl, additionalHeaders) { - return this.request('HEAD', requestUrl, null, additionalHeaders || {}); + else if (node !== null) { + addedNodes.push(node); } - sendStream(verb, requestUrl, stream, additionalHeaders) { - return this.request(verb, requestUrl, stream, additionalHeaders); + try { + /** + * 6. Remove all parent’s children, in tree order, with the suppress + * observers flag set. + */ + for (var removedNodes_1 = __values(removedNodes), removedNodes_1_1 = removedNodes_1.next(); !removedNodes_1_1.done; removedNodes_1_1 = removedNodes_1.next()) { + var childNode = removedNodes_1_1.value; + mutation_remove(childNode, parent, true); + } + } + catch (e_10_1) { e_10 = { error: e_10_1 }; } + finally { + try { + if (removedNodes_1_1 && !removedNodes_1_1.done && (_a = removedNodes_1.return)) _a.call(removedNodes_1); + } + finally { if (e_10) throw e_10.error; } } /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise + * 7. If node is not null, then insert node into parent before null with the + * suppress observers flag set. */ - async getJson(requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - let res = await this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async postJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async putJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); + if (node !== null) { + mutation_insert(node, parent, null, true); } - async patchJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); + /** + * 8. Queue a tree mutation record for parent with addedNodes, removedNodes, + * null, and null. + */ + if (DOMImpl_1.dom.features.mutationObservers) { + MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, addedNodes, removedNodes, null, null); } +} +exports.mutation_replaceAll = mutation_replaceAll; +/** + * Ensures pre-removal validity of a child node from a parent, then + * removes it. + * + * @param child - child node to remove + * @param parent - parent node + */ +function mutation_preRemove(child, parent) { /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch + * 1. If child’s parent is not parent, then throw a "NotFoundError" + * DOMException. + * 2. Remove child from parent. + * 3. Return child. */ - async request(verb, requestUrl, data, headers) { - if (this._disposed) { - throw new Error('Client has already been disposed.'); - } - let parsedUrl = new URL(requestUrl); - let info = this._prepareRequest(verb, parsedUrl, headers); - // Only perform retries on reads since writes may not be idempotent. - let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 - ? this._maxRetries + 1 - : 1; - let numTries = 0; - let response; - while (numTries < maxTries) { - response = await this.requestRaw(info, data); - // Check if it's an authentication challenge - if (response && - response.message && - response.message.statusCode === HttpCodes.Unauthorized) { - let authenticationHandler; - for (let i = 0; i < this.handlers.length; i++) { - if (this.handlers[i].canHandleAuthentication(response)) { - authenticationHandler = this.handlers[i]; - break; - } + if (child._parent !== parent) + throw new DOMException_1.NotFoundError("The child node cannot be found under parent node. Child node is " + child.nodeName + ", parent node is " + parent.nodeName + "."); + mutation_remove(child, parent); + return child; +} +exports.mutation_preRemove = mutation_preRemove; +/** + * Removes a child node from its parent. + * + * @param node - node to remove + * @param parent - parent node + * @param suppressObservers - whether to notify observers + */ +function mutation_remove(node, parent, suppressObservers) { + var e_11, _a, e_12, _b, e_13, _c, e_14, _d; + if (DOMImpl_1.dom.rangeList.size !== 0) { + /** + * 1. Let index be node’s index. + */ + var index = TreeAlgorithm_1.tree_index(node); + try { + /** + * 2. For each live range whose start node is an inclusive descendant of + * node, set its start to (parent, index). + * 3. For each live range whose end node is an inclusive descendant of + * node, set its end to (parent, index). + */ + for (var _e = __values(DOMImpl_1.dom.rangeList), _f = _e.next(); !_f.done; _f = _e.next()) { + var range = _f.value; + if (TreeAlgorithm_1.tree_isDescendantOf(node, range._start[0], true)) { + range._start = [parent, index]; } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info, data); + if (TreeAlgorithm_1.tree_isDescendantOf(node, range._end[0], true)) { + range._end = [parent, index]; } - else { - // We have received an unauthorized response but have no handlers to handle it. - // Let the response return to the caller. - return response; + if (range._start[0] === parent && range._start[1] > index) { + range._start[1]--; } - } - let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && - this._allowRedirects && - redirectsRemaining > 0) { - const redirectUrl = response.message.headers['location']; - if (!redirectUrl) { - // if there's no location to redirect to, we won't - break; + if (range._end[0] === parent && range._end[1] > index) { + range._end[1]--; } - let parsedRedirectUrl = new URL(redirectUrl); - if (parsedUrl.protocol == 'https:' && - parsedUrl.protocol != parsedRedirectUrl.protocol && - !this._allowRedirectDowngrade) { - throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); + } + } + catch (e_11_1) { e_11 = { error: e_11_1 }; } + finally { + try { + if (_f && !_f.done && (_a = _e.return)) _a.call(_e); + } + finally { if (e_11) throw e_11.error; } + } + try { + /** + * 4. For each live range whose start node is parent and start offset is + * greater than index, decrease its start offset by 1. + * 5. For each live range whose end node is parent and end offset is greater + * than index, decrease its end offset by 1. + */ + for (var _g = __values(DOMImpl_1.dom.rangeList), _h = _g.next(); !_h.done; _h = _g.next()) { + var range = _h.value; + if (range._start[0] === parent && range._start[1] > index) { + range._start[1] -= 1; } - // we need to finish reading the response before reassigning response - // which will leak the open socket. - await response.readBody(); - // strip authorization header if redirected to a different hostname - if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { - for (let header in headers) { - // header names are case insensitive - if (header.toLowerCase() === 'authorization') { - delete headers[header]; - } - } + if (range._end[0] === parent && range._end[1] > index) { + range._end[1] -= 1; } - // let's make the request with the new redirectUrl - info = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = await this.requestRaw(info, data); - redirectsRemaining--; } - if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { - // If not a retry code, return immediately instead of retrying - return response; + } + catch (e_12_1) { e_12 = { error: e_12_1 }; } + finally { + try { + if (_h && !_h.done && (_b = _g.return)) _b.call(_g); } - numTries += 1; - if (numTries < maxTries) { - await response.readBody(); - await this._performExponentialBackoff(numTries); + finally { if (e_12) throw e_12.error; } + } + } + /** + * 6. For each NodeIterator object iterator whose root’s node document is + * node’s node document, run the NodeIterator pre-removing steps given node + * and iterator. + */ + if (DOMImpl_1.dom.features.steps) { + try { + for (var _j = __values(NodeIteratorAlgorithm_1.nodeIterator_iteratorList()), _k = _j.next(); !_k.done; _k = _j.next()) { + var iterator = _k.value; + if (iterator._root._nodeDocument === node._nodeDocument) { + DOMAlgorithm_1.dom_runNodeIteratorPreRemovingSteps(iterator, node); + } } } - return response; + catch (e_13_1) { e_13 = { error: e_13_1 }; } + finally { + try { + if (_k && !_k.done && (_c = _j.return)) _c.call(_j); + } + finally { if (e_13) throw e_13.error; } + } + } + /** + * 7. Let oldPreviousSibling be node’s previous sibling. + * 8. Let oldNextSibling be node’s next sibling. + */ + var oldPreviousSibling = node._previousSibling; + var oldNextSibling = node._nextSibling; + // set document element node + if (util_1.Guard.isDocumentNode(parent) && util_1.Guard.isElementNode(node)) { + parent._documentElement = null; } /** - * Needs to be called if keepAlive is set to true in request options. + * 9. Remove node from its parent’s children. + */ + node._parent = null; + parent._children.delete(node); + // assign siblings and children for quick lookups + var prev = node._previousSibling; + var next = node._nextSibling; + node._previousSibling = null; + node._nextSibling = null; + if (prev) + prev._nextSibling = next; + if (next) + next._previousSibling = prev; + if (!prev) + parent._firstChild = next; + if (!next) + parent._lastChild = prev; + /** + * 10. If node is assigned, then run assign slotables for node’s assigned + * slot. */ - dispose() { - if (this._agent) { - this._agent.destroy(); + if (DOMImpl_1.dom.features.slots) { + if (util_1.Guard.isSlotable(node) && node._assignedSlot !== null && ShadowTreeAlgorithm_1.shadowTree_isAssigned(node)) { + ShadowTreeAlgorithm_1.shadowTree_assignSlotables(node._assignedSlot); } - this._disposed = true; } /** - * Raw request. - * @param info - * @param data + * 11. If parent’s root is a shadow root, and parent is a slot whose + * assigned nodes is the empty list, then run signal a slot change for + * parent. */ - requestRaw(info, data) { - return new Promise((resolve, reject) => { - let callbackForResult = function (err, res) { - if (err) { - reject(err); - } - resolve(res); - }; - this.requestRawWithCallback(info, data, callbackForResult); - }); + if (DOMImpl_1.dom.features.slots) { + if (util_1.Guard.isShadowRoot(TreeAlgorithm_1.tree_rootNode(parent)) && + util_1.Guard.isSlot(parent) && util_2.isEmpty(parent._assignedNodes)) { + ShadowTreeAlgorithm_1.shadowTree_signalASlotChange(parent); + } } /** - * Raw request with callback. - * @param info - * @param data - * @param onResult + * 12. If node has an inclusive descendant that is a slot, then: + * 12.1. Run assign slotables for a tree with parent's root. + * 12.2. Run assign slotables for a tree with node. */ - requestRawWithCallback(info, data, onResult) { - let socket; - if (typeof data === 'string') { - info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); - } - let callbackCalled = false; - let handleResult = (err, res) => { - if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); - } - }; - let req = info.httpModule.request(info.options, (msg) => { - let res = new HttpClientResponse(msg); - handleResult(null, res); - }); - req.on('socket', sock => { - socket = sock; - }); - // If we ever get disconnected, we want the socket to timeout eventually - req.setTimeout(this._socketTimeout || 3 * 60000, () => { - if (socket) { - socket.end(); - } - handleResult(new Error('Request timeout: ' + info.options.path), null); - }); - req.on('error', function (err) { - // err has statusCode property - // res should have headers - handleResult(err, null); - }); - if (data && typeof data === 'string') { - req.write(data, 'utf8'); - } - if (data && typeof data !== 'string') { - data.on('close', function () { - req.end(); - }); - data.pipe(req); - } - else { - req.end(); + if (DOMImpl_1.dom.features.slots) { + var descendant_1 = TreeAlgorithm_1.tree_getFirstDescendantNode(node, true, false, function (e) { return util_1.Guard.isSlot(e); }); + if (descendant_1 !== null) { + ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(parent)); + ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(node); } } /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + * 13. Run the removing steps with node and parent. */ - getAgent(serverUrl) { - let parsedUrl = new URL(serverUrl); - return this._getAgent(parsedUrl); + if (DOMImpl_1.dom.features.steps) { + DOMAlgorithm_1.dom_runRemovingSteps(node, parent); } - _prepareRequest(method, requestUrl, headers) { - const info = {}; - info.parsedUrl = requestUrl; - const usingSsl = info.parsedUrl.protocol === 'https:'; - info.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info.options = {}; - info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port - ? parseInt(info.parsedUrl.port) - : defaultPort; - info.options.path = - (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); - info.options.method = method; - info.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info.options.headers['user-agent'] = this.userAgent; - } - info.options.agent = this._getAgent(info.parsedUrl); - // gives handlers an opportunity to participate - if (this.handlers) { - this.handlers.forEach(handler => { - handler.prepareRequest(info.options); - }); + /** + * 14. If node is custom, then enqueue a custom element callback + * reaction with node, callback name "disconnectedCallback", + * and an empty argument list. + */ + if (DOMImpl_1.dom.features.customElements) { + if (util_1.Guard.isCustomElementNode(node)) { + CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(node, "disconnectedCallback", []); } - return info; } - _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); + /** + * 15. For each shadow-including descendant descendant of node, + * in shadow-including tree order, then: + */ + var descendant = TreeAlgorithm_1.tree_getFirstDescendantNode(node, false, true); + while (descendant !== null) { + /** + * 15.1. Run the removing steps with descendant. + */ + if (DOMImpl_1.dom.features.steps) { + DOMAlgorithm_1.dom_runRemovingSteps(descendant, node); } - return lowercaseKeys(headers || {}); - } - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; + /** + * 15.2. If descendant is custom, then enqueue a custom element + * callback reaction with descendant, callback name + * "disconnectedCallback", and an empty argument list. + */ + if (DOMImpl_1.dom.features.customElements) { + if (util_1.Guard.isCustomElementNode(descendant)) { + CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(descendant, "disconnectedCallback", []); + } } - return additionalHeaders[header] || clientHeader || _default; + descendant = TreeAlgorithm_1.tree_getNextDescendantNode(node, descendant, false, true); } - _getAgent(parsedUrl) { - let agent; - let proxyUrl = pm.getProxyUrl(parsedUrl); - let useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; - } - if (this._keepAlive && !useProxy) { - agent = this._agent; - } - // if agent is already assigned use that agent. - if (!!agent) { - return agent; - } - const usingSsl = parsedUrl.protocol === 'https:'; - let maxSockets = 100; - if (!!this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; - } - if (useProxy) { - // If using proxy, need tunnel - if (!tunnel) { - tunnel = __webpack_require__(856); - } - const agentOptions = { - maxSockets: maxSockets, - keepAlive: this._keepAlive, - proxy: { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`, - host: proxyUrl.hostname, - port: proxyUrl.port + /** + * 16. For each inclusive ancestor inclusiveAncestor of parent, and + * then for each registered of inclusiveAncestor's registered + * observer list, if registered's options's subtree is true, + * then append a new transient registered observer whose + * observer is registered's observer, options is registered's + * options, and source is registered to node's registered + * observer list. + */ + if (DOMImpl_1.dom.features.mutationObservers) { + var inclusiveAncestor = TreeAlgorithm_1.tree_getFirstAncestorNode(parent, true); + while (inclusiveAncestor !== null) { + try { + for (var _l = (e_14 = void 0, __values(inclusiveAncestor._registeredObserverList)), _m = _l.next(); !_m.done; _m = _l.next()) { + var registered = _m.value; + if (registered.options.subtree) { + node._registeredObserverList.push({ + observer: registered.observer, + options: registered.options, + source: registered + }); + } } - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === 'https:'; - if (usingSsl) { - tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; } - else { - tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; + catch (e_14_1) { e_14 = { error: e_14_1 }; } + finally { + try { + if (_m && !_m.done && (_d = _l.return)) _d.call(_l); + } + finally { if (e_14) throw e_14.error; } } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; - } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { - const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; + inclusiveAncestor = TreeAlgorithm_1.tree_getNextAncestorNode(parent, inclusiveAncestor, true); } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; + } + /** + * 17. If suppress observers flag is unset, then queue a tree mutation + * record for parent with « », « node », oldPreviousSibling, and + * oldNextSibling. + */ + if (DOMImpl_1.dom.features.mutationObservers) { + if (!suppressObservers) { + MutationObserverAlgorithm_1.observer_queueTreeMutationRecord(parent, [], [node], oldPreviousSibling, oldNextSibling); } - if (usingSsl && this._ignoreSslError) { - // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process - // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options - // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { - rejectUnauthorized: false - }); + } + /** + * 18. If node is a Text node, then run the child text content change steps + * for parent. + */ + if (DOMImpl_1.dom.features.steps) { + if (util_1.Guard.isTextNode(node)) { + DOMAlgorithm_1.dom_runChildTextContentChangeSteps(parent); } - return agent; } - _performExponentialBackoff(retryNumber) { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise(resolve => setTimeout(() => resolve(), ms)); +} +exports.mutation_remove = mutation_remove; +//# sourceMappingURL=MutationAlgorithm.js.map + +/***/ }), +/* 480 */, +/* 481 */, +/* 482 */, +/* 483 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var DOMException_1 = __webpack_require__(35); +/** + * Matches elements with the given selectors. + * + * @param selectors - selectors + * @param node - the node to match against + */ +function selectors_scopeMatchASelectorsString(selectors, node) { + /** + * TODO: Selectors + * 1. Let s be the result of parse a selector selectors. [SELECTORS4] + * 2. If s is failure, then throw a "SyntaxError" DOMException. + * 3. Return the result of match a selector against a tree with s and node’s + * root using scoping root node. [SELECTORS4]. + */ + throw new DOMException_1.NotSupportedError(); +} +exports.selectors_scopeMatchASelectorsString = selectors_scopeMatchASelectorsString; +//# sourceMappingURL=SelectorsAlgorithm.js.map + +/***/ }), +/* 484 */, +/* 485 */, +/* 486 */, +/* 487 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var interfaces_1 = __webpack_require__(970); +/** + * Represents an object which can be used to iterate through the nodes + * of a subtree. + */ +var TraverserImpl = /** @class */ (function () { + /** + * Initializes a new instance of `Traverser`. + * + * @param root - root node + */ + function TraverserImpl(root) { + this._activeFlag = false; + this._root = root; + this._whatToShow = interfaces_1.WhatToShow.All; + this._filter = null; } - static dateTimeDeserializer(key, value) { - if (typeof value === 'string') { - let a = new Date(value); - if (!isNaN(a.valueOf())) { - return a; - } + Object.defineProperty(TraverserImpl.prototype, "root", { + /** @inheritdoc */ + get: function () { return this._root; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TraverserImpl.prototype, "whatToShow", { + /** @inheritdoc */ + get: function () { return this._whatToShow; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TraverserImpl.prototype, "filter", { + /** @inheritdoc */ + get: function () { return this._filter; }, + enumerable: true, + configurable: true + }); + return TraverserImpl; +}()); +exports.TraverserImpl = TraverserImpl; +//# sourceMappingURL=TraverserImpl.js.map + +/***/ }), +/* 488 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; } - return value; + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } - async _processResponse(res, options) { - return new Promise(async (resolve, reject) => { - const statusCode = res.message.statusCode; - const response = { - statusCode: statusCode, - result: null, - headers: {} - }; - // not found leads to null obj returned - if (statusCode == HttpCodes.NotFound) { - resolve(response); - } - let obj; - let contents; - // get the result from the body + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var DOMImpl_1 = __webpack_require__(648); +var interfaces_1 = __webpack_require__(970); +var DOMException_1 = __webpack_require__(35); +var NodeImpl_1 = __webpack_require__(935); +var util_1 = __webpack_require__(918); +var util_2 = __webpack_require__(592); +var infra_1 = __webpack_require__(23); +var URLAlgorithm_1 = __webpack_require__(813); +var algorithm_1 = __webpack_require__(163); +var WebIDLAlgorithm_1 = __webpack_require__(495); +/** + * Represents a document node. + */ +var DocumentImpl = /** @class */ (function (_super) { + __extends(DocumentImpl, _super); + /** + * Initializes a new instance of `Document`. + */ + function DocumentImpl() { + var _this = _super.call(this) || this; + _this._children = new Set(); + _this._encoding = { + name: "UTF-8", + labels: ["unicode-1-1-utf-8", "utf-8", "utf8"] + }; + _this._contentType = 'application/xml'; + _this._URL = { + scheme: "about", + username: "", + password: "", + host: null, + port: null, + path: ["blank"], + query: null, + fragment: null, + _cannotBeABaseURLFlag: true, + _blobURLEntry: null + }; + _this._origin = null; + _this._type = "xml"; + _this._mode = "no-quirks"; + _this._documentElement = null; + _this._hasNamespaces = false; + _this._nodeDocumentOverwrite = null; + return _this; + } + Object.defineProperty(DocumentImpl.prototype, "_nodeDocument", { + get: function () { return this._nodeDocumentOverwrite || this; }, + set: function (val) { this._nodeDocumentOverwrite = val; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "implementation", { + /** @inheritdoc */ + get: function () { + /** + * The implementation attribute’s getter must return the DOMImplementation + * object that is associated with the document. + */ + return this._implementation || (this._implementation = algorithm_1.create_domImplementation(this)); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "URL", { + /** @inheritdoc */ + get: function () { + /** + * The URL attribute’s getter and documentURI attribute’s getter must return + * the URL, serialized. + * See: https://url.spec.whatwg.org/#concept-url-serializer + */ + return URLAlgorithm_1.urlSerializer(this._URL); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "documentURI", { + /** @inheritdoc */ + get: function () { return this.URL; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "origin", { + /** @inheritdoc */ + get: function () { + return "null"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "compatMode", { + /** @inheritdoc */ + get: function () { + /** + * The compatMode attribute’s getter must return "BackCompat" if context + * object’s mode is "quirks", and "CSS1Compat" otherwise. + */ + return this._mode === "quirks" ? "BackCompat" : "CSS1Compat"; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "characterSet", { + /** @inheritdoc */ + get: function () { + /** + * The characterSet attribute’s getter, charset attribute’s getter, and + * inputEncoding attribute’s getter, must return context object’s + * encoding’s name. + */ + return this._encoding.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "charset", { + /** @inheritdoc */ + get: function () { return this._encoding.name; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "inputEncoding", { + /** @inheritdoc */ + get: function () { return this._encoding.name; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "contentType", { + /** @inheritdoc */ + get: function () { + /** + * The contentType attribute’s getter must return the content type. + */ + return this._contentType; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "doctype", { + /** @inheritdoc */ + get: function () { + var e_1, _a; try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; + /** + * The doctype attribute’s getter must return the child of the document + * that is a doctype, and null otherwise. + */ + for (var _b = __values(this._children), _c = _b.next(); !_c.done; _c = _b.next()) { + var child = _c.value; + if (util_1.Guard.isDocumentTypeNode(child)) + return child; } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null } - // note that 3xx redirects are handled by the http layer. - if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = 'Failed request: (' + statusCode + ')'; + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } - let err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); - } - else { - resolve(response); + finally { if (e_1) throw e_1.error; } } - }); - } -} -exports.HttpClient = HttpClient; - - -/***/ }), -/* 540 */, -/* 541 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } + return null; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "documentElement", { + /** @inheritdoc */ + get: function () { + /** + * The documentElement attribute’s getter must return the document element. + */ + return this._documentElement; + }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + DocumentImpl.prototype.getElementsByTagName = function (qualifiedName) { + /** + * The getElementsByTagName(qualifiedName) method, when invoked, must return + * the list of elements with qualified name qualifiedName for the context object. + */ + return algorithm_1.node_listOfElementsWithQualifiedName(qualifiedName, this); }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var util_1 = __webpack_require__(918); -var infra_1 = __webpack_require__(23); -var CreateAlgorithm_1 = __webpack_require__(86); -var OrderedSetAlgorithm_1 = __webpack_require__(146); -var DOMAlgorithm_1 = __webpack_require__(304); -var MutationAlgorithm_1 = __webpack_require__(479); -var ElementAlgorithm_1 = __webpack_require__(33); -/** - * Replaces the contents of the given node with a single text node. - * - * @param string - node contents - * @param parent - a node - */ -function node_stringReplaceAll(str, parent) { - /** - * 1. Let node be null. - * 2. If string is not the empty string, then set node to a new Text node - * whose data is string and node document is parent’s node document. - * 3. Replace all with node within parent. - */ - var node = null; - if (str !== '') { - node = CreateAlgorithm_1.create_text(parent._nodeDocument, str); - } - MutationAlgorithm_1.mutation_replaceAll(node, parent); -} -exports.node_stringReplaceAll = node_stringReplaceAll; -/** - * Clones a node. - * - * @param node - a node to clone - * @param document - the document to own the cloned node - * @param cloneChildrenFlag - whether to clone node's children - */ -function node_clone(node, document, cloneChildrenFlag) { - var e_1, _a, e_2, _b; - if (document === void 0) { document = null; } - if (cloneChildrenFlag === void 0) { cloneChildrenFlag = false; } - /** - * 1. If document is not given, let document be node’s node document. - */ - if (document === null) - document = node._nodeDocument; - var copy; - if (util_1.Guard.isElementNode(node)) { + /** @inheritdoc */ + DocumentImpl.prototype.getElementsByTagNameNS = function (namespace, localName) { /** - * 2. If node is an element, then: - * 2.1. Let copy be the result of creating an element, given document, - * node’s local name, node’s namespace, node’s namespace prefix, - * and node’s is value, with the synchronous custom elements flag unset. - * 2.2. For each attribute in node’s attribute list: - * 2.2.1. Let copyAttribute be a clone of attribute. - * 2.2.2. Append copyAttribute to copy. + * The getElementsByTagNameNS(namespace, localName) method, when invoked, + * must return the list of elements with namespace namespace and local name + * localName for the context object. */ - copy = ElementAlgorithm_1.element_createAnElement(document, node._localName, node._namespace, node._namespacePrefix, node._is, false); - try { - for (var _c = __values(node._attributeList), _d = _c.next(); !_d.done; _d = _c.next()) { - var attribute = _d.value; - var copyAttribute = node_clone(attribute, document); - ElementAlgorithm_1.element_append(copyAttribute, copy); + return algorithm_1.node_listOfElementsWithNamespace(namespace, localName, this); + }; + /** @inheritdoc */ + DocumentImpl.prototype.getElementsByClassName = function (classNames) { + /** + * The getElementsByClassName(classNames) method, when invoked, must return + * the list of elements with class names classNames for the context object. + */ + return algorithm_1.node_listOfElementsWithClassNames(classNames, this); + }; + /** @inheritdoc */ + DocumentImpl.prototype.createElement = function (localName, options) { + /** + * 1. If localName does not match the Name production, then throw an + * "InvalidCharacterError" DOMException. + * 2. If the context object is an HTML document, then set localName to + * localName in ASCII lowercase. + * 3. Let is be null. + * 4. If options is a dictionary and options’s is is present, then set is + * to it. + * 5. Let namespace be the HTML namespace, if the context object is an + * HTML document or context object’s content type is + * "application/xhtml+xml", and null otherwise. + * 6. Return the result of creating an element given the context object, + * localName, namespace, null, is, and with the synchronous custom elements + * flag set. + */ + if (!algorithm_1.xml_isName(localName)) + throw new DOMException_1.InvalidCharacterError(); + if (this._type === "html") + localName = localName.toLowerCase(); + var is = null; + if (options !== undefined) { + if (util_2.isString(options)) { + is = options; } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + else { + is = options.is; } - finally { if (e_1) throw e_1.error; } } - } - else { + var namespace = (this._type === "html" || this._contentType === "application/xhtml+xml") ? + infra_1.namespace.HTML : null; + return algorithm_1.element_createAnElement(this, localName, namespace, null, is, true); + }; + /** @inheritdoc */ + DocumentImpl.prototype.createElementNS = function (namespace, qualifiedName, options) { /** - * 3. Otherwise, let copy be a node that implements the same interfaces as - * node, and fulfills these additional requirements, switching on node: - * - Document - * Set copy’s encoding, content type, URL, origin, type, and mode, to those - * of node. - * - DocumentType - * Set copy’s name, public ID, and system ID, to those of node. - * - Attr - * Set copy’s namespace, namespace prefix, local name, and value, to - * those of node. - * - Text - * - Comment - * Set copy’s data, to that of node. - * - ProcessingInstruction - * Set copy’s target and data to those of node. - * - Any other node + * The createElementNS(namespace, qualifiedName, options) method, when + * invoked, must return the result of running the internal createElementNS + * steps, given context object, namespace, qualifiedName, and options. */ - if (util_1.Guard.isDocumentNode(node)) { - var doc = CreateAlgorithm_1.create_document(); - doc._encoding = node._encoding; - doc._contentType = node._contentType; - doc._URL = node._URL; - doc._origin = node._origin; - doc._type = node._type; - doc._mode = node._mode; - copy = doc; - } - else if (util_1.Guard.isDocumentTypeNode(node)) { - var doctype = CreateAlgorithm_1.create_documentType(document, node._name, node._publicId, node._systemId); - copy = doctype; - } - else if (util_1.Guard.isAttrNode(node)) { - var attr = CreateAlgorithm_1.create_attr(document, node.localName); - attr._namespace = node._namespace; - attr._namespacePrefix = node._namespacePrefix; - attr._value = node._value; - copy = attr; - } - else if (util_1.Guard.isExclusiveTextNode(node)) { - copy = CreateAlgorithm_1.create_text(document, node._data); - } - else if (util_1.Guard.isCDATASectionNode(node)) { - copy = CreateAlgorithm_1.create_cdataSection(document, node._data); - } - else if (util_1.Guard.isCommentNode(node)) { - copy = CreateAlgorithm_1.create_comment(document, node._data); - } - else if (util_1.Guard.isProcessingInstructionNode(node)) { - copy = CreateAlgorithm_1.create_processingInstruction(document, node._target, node._data); + return algorithm_1.document_internalCreateElementNS(this, namespace, qualifiedName, options); + }; + /** @inheritdoc */ + DocumentImpl.prototype.createDocumentFragment = function () { + /** + * The createDocumentFragment() method, when invoked, must return a new + * DocumentFragment node with its node document set to the context object. + */ + return algorithm_1.create_documentFragment(this); + }; + /** @inheritdoc */ + DocumentImpl.prototype.createTextNode = function (data) { + /** + * The createTextNode(data) method, when invoked, must return a new Text + * node with its data set to data and node document set to the context object. + */ + return algorithm_1.create_text(this, data); + }; + /** @inheritdoc */ + DocumentImpl.prototype.createCDATASection = function (data) { + /** + * 1. If context object is an HTML document, then throw a + * "NotSupportedError" DOMException. + * 2. If data contains the string "]]>", then throw an + * "InvalidCharacterError" DOMException. + * 3. Return a new CDATASection node with its data set to data and node + * document set to the context object. + */ + if (this._type === "html") + throw new DOMException_1.NotSupportedError(); + if (data.indexOf(']]>') !== -1) + throw new DOMException_1.InvalidCharacterError(); + return algorithm_1.create_cdataSection(this, data); + }; + /** @inheritdoc */ + DocumentImpl.prototype.createComment = function (data) { + /** + * The createComment(data) method, when invoked, must return a new Comment + * node with its data set to data and node document set to the context object. + */ + return algorithm_1.create_comment(this, data); + }; + /** @inheritdoc */ + DocumentImpl.prototype.createProcessingInstruction = function (target, data) { + /** + * 1. If target does not match the Name production, then throw an + * "InvalidCharacterError" DOMException. + * 2. If data contains the string "?>", then throw an + * "InvalidCharacterError" DOMException. + * 3. Return a new ProcessingInstruction node, with target set to target, + * data set to data, and node document set to the context object. + */ + if (!algorithm_1.xml_isName(target)) + throw new DOMException_1.InvalidCharacterError(); + if (data.indexOf("?>") !== -1) + throw new DOMException_1.InvalidCharacterError(); + return algorithm_1.create_processingInstruction(this, target, data); + }; + /** @inheritdoc */ + DocumentImpl.prototype.importNode = function (node, deep) { + if (deep === void 0) { deep = false; } + /** + * 1. If node is a document or shadow root, then throw a "NotSupportedError" DOMException. + */ + if (util_1.Guard.isDocumentNode(node) || util_1.Guard.isShadowRoot(node)) + throw new DOMException_1.NotSupportedError(); + /** + * 2. Return a clone of node, with context object and the clone children flag set if deep is true. + */ + return algorithm_1.node_clone(node, this, deep); + }; + /** @inheritdoc */ + DocumentImpl.prototype.adoptNode = function (node) { + /** + * 1. If node is a document, then throw a "NotSupportedError" DOMException. + */ + if (util_1.Guard.isDocumentNode(node)) + throw new DOMException_1.NotSupportedError(); + /** + * 2. If node is a shadow root, then throw a "HierarchyRequestError" DOMException. + */ + if (util_1.Guard.isShadowRoot(node)) + throw new DOMException_1.HierarchyRequestError(); + /** + * 3. Adopt node into the context object. + * 4. Return node. + */ + algorithm_1.document_adopt(node, this); + return node; + }; + /** @inheritdoc */ + DocumentImpl.prototype.createAttribute = function (localName) { + /** + * 1. If localName does not match the Name production in XML, then throw + * an "InvalidCharacterError" DOMException. + * 2. If the context object is an HTML document, then set localName to + * localName in ASCII lowercase. + * 3. Return a new attribute whose local name is localName and node document + * is context object. + */ + if (!algorithm_1.xml_isName(localName)) + throw new DOMException_1.InvalidCharacterError(); + if (this._type === "html") { + localName = localName.toLowerCase(); } - else if (util_1.Guard.isDocumentFragmentNode(node)) { - copy = CreateAlgorithm_1.create_documentFragment(document); + var attr = algorithm_1.create_attr(this, localName); + return attr; + }; + /** @inheritdoc */ + DocumentImpl.prototype.createAttributeNS = function (namespace, qualifiedName) { + /** + * 1. Let namespace, prefix, and localName be the result of passing + * namespace and qualifiedName to validate and extract. + * 2. Return a new attribute whose namespace is namespace, namespace prefix + * is prefix, local name is localName, and node document is context object. + */ + var _a = __read(algorithm_1.namespace_validateAndExtract(namespace, qualifiedName), 3), ns = _a[0], prefix = _a[1], localName = _a[2]; + var attr = algorithm_1.create_attr(this, localName); + attr._namespace = ns; + attr._namespacePrefix = prefix; + return attr; + }; + /** @inheritdoc */ + DocumentImpl.prototype.createEvent = function (eventInterface) { + return algorithm_1.event_createLegacyEvent(eventInterface); + }; + /** @inheritdoc */ + DocumentImpl.prototype.createRange = function () { + /** + * The createRange() method, when invoked, must return a new live range + * with (context object, 0) as its start and end. + */ + var range = algorithm_1.create_range(); + range._start = [this, 0]; + range._end = [this, 0]; + return range; + }; + /** @inheritdoc */ + DocumentImpl.prototype.createNodeIterator = function (root, whatToShow, filter) { + if (whatToShow === void 0) { whatToShow = interfaces_1.WhatToShow.All; } + if (filter === void 0) { filter = null; } + /** + * 1. Let iterator be a new NodeIterator object. + * 2. Set iterator’s root and iterator’s reference to root. + * 3. Set iterator’s pointer before reference to true. + * 4. Set iterator’s whatToShow to whatToShow. + * 5. Set iterator’s filter to filter. + * 6. Return iterator. + */ + var iterator = algorithm_1.create_nodeIterator(root, root, true); + iterator._whatToShow = whatToShow; + iterator._iteratorCollection = algorithm_1.create_nodeList(root); + if (util_2.isFunction(filter)) { + iterator._filter = algorithm_1.create_nodeFilter(); + iterator._filter.acceptNode = filter; } else { - copy = Object.create(node); + iterator._filter = filter; } - } - /** - * 4. Set copy’s node document and document to copy, if copy is a document, - * and set copy’s node document to document otherwise. - */ - if (util_1.Guard.isDocumentNode(copy)) { - copy._nodeDocument = copy; - document = copy; - } - else { - copy._nodeDocument = document; - } - /** - * 5. Run any cloning steps defined for node in other applicable - * specifications and pass copy, node, document and the clone children flag - * if set, as parameters. - */ - if (DOMImpl_1.dom.features.steps) { - DOMAlgorithm_1.dom_runCloningSteps(copy, node, document, cloneChildrenFlag); - } - /** - * 6. If the clone children flag is set, clone all the children of node and - * append them to copy, with document as specified and the clone children - * flag being set. - */ - if (cloneChildrenFlag) { - try { - for (var _e = __values(node._children), _f = _e.next(); !_f.done; _f = _e.next()) { - var child = _f.value; - var childCopy = node_clone(child, document, true); - MutationAlgorithm_1.mutation_append(childCopy, copy); - } + return iterator; + }; + /** @inheritdoc */ + DocumentImpl.prototype.createTreeWalker = function (root, whatToShow, filter) { + if (whatToShow === void 0) { whatToShow = interfaces_1.WhatToShow.All; } + if (filter === void 0) { filter = null; } + /** + * 1. Let walker be a new TreeWalker object. + * 2. Set walker’s root and walker’s current to root. + * 3. Set walker’s whatToShow to whatToShow. + * 4. Set walker’s filter to filter. + * 5. Return walker. + */ + var walker = algorithm_1.create_treeWalker(root, root); + walker._whatToShow = whatToShow; + if (util_2.isFunction(filter)) { + walker._filter = algorithm_1.create_nodeFilter(); + walker._filter.acceptNode = filter; } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_f && !_f.done && (_b = _e.return)) _b.call(_e); - } - finally { if (e_2) throw e_2.error; } + else { + walker._filter = filter; } - } - /** - * 7. Return copy. - */ - return copy; -} -exports.node_clone = node_clone; -/** - * Determines if two nodes can be considered equal. - * - * @param a - node to compare - * @param b - node to compare - */ -function node_equals(a, b) { - var e_3, _a, e_4, _b; - /** - * 1. A and B’s nodeType attribute value is identical. - */ - if (a._nodeType !== b._nodeType) - return false; - /** - * 2. The following are also equal, depending on A: - * - DocumentType - * Its name, public ID, and system ID. - * - Element - * Its namespace, namespace prefix, local name, and its attribute list’s size. - * - Attr - * Its namespace, local name, and value. - * - ProcessingInstruction - * Its target and data. - * - Text - * - Comment - * Its data. - */ - if (util_1.Guard.isDocumentTypeNode(a) && util_1.Guard.isDocumentTypeNode(b)) { - if (a._name !== b._name || a._publicId !== b._publicId || - a._systemId !== b._systemId) - return false; - } - else if (util_1.Guard.isElementNode(a) && util_1.Guard.isElementNode(b)) { - if (a._namespace !== b._namespace || a._namespacePrefix !== b._namespacePrefix || - a._localName !== b._localName || - a._attributeList.length !== b._attributeList.length) - return false; - } - else if (util_1.Guard.isAttrNode(a) && util_1.Guard.isAttrNode(b)) { - if (a._namespace !== b._namespace || a._localName !== b._localName || - a._value !== b._value) - return false; - } - else if (util_1.Guard.isProcessingInstructionNode(a) && util_1.Guard.isProcessingInstructionNode(b)) { - if (a._target !== b._target || a._data !== b._data) - return false; - } - else if (util_1.Guard.isCharacterDataNode(a) && util_1.Guard.isCharacterDataNode(b)) { - if (a._data !== b._data) - return false; - } + return walker; + }; /** - * 3. If A is an element, each attribute in its attribute list has an attribute - * that equals an attribute in B’s attribute list. + * Gets the parent event target for the given event. + * + * @param event - an event */ - if (util_1.Guard.isElementNode(a) && util_1.Guard.isElementNode(b)) { - var attrMap = {}; - try { - for (var _c = __values(a._attributeList), _d = _c.next(); !_d.done; _d = _c.next()) { - var attrA = _d.value; - attrMap[attrA._localName] = attrA; - } + DocumentImpl.prototype._getTheParent = function (event) { + /** + * TODO: Implement realms + * A document’s get the parent algorithm, given an event, returns null if + * event’s type attribute value is "load" or document does not have a + * browsing context, and the document’s relevant global object otherwise. + */ + if (event._type === "load") { + return null; } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_d && !_d.done && (_a = _c.return)) _a.call(_c); - } - finally { if (e_3) throw e_3.error; } + else { + return DOMImpl_1.dom.window; } - try { - for (var _e = __values(b._attributeList), _f = _e.next(); !_f.done; _f = _e.next()) { - var attrB = _f.value; - var attrA = attrMap[attrB._localName]; - if (!attrA) - return false; - if (!node_equals(attrA, attrB)) - return false; - } + }; + // MIXIN: NonElementParentNode + /* istanbul ignore next */ + DocumentImpl.prototype.getElementById = function (elementId) { throw new Error("Mixin: NonElementParentNode not implemented."); }; + Object.defineProperty(DocumentImpl.prototype, "children", { + // MIXIN: DocumentOrShadowRoot + // No elements + // MIXIN: ParentNode + /* istanbul ignore next */ + get: function () { throw new Error("Mixin: ParentNode not implemented."); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "firstElementChild", { + /* istanbul ignore next */ + get: function () { throw new Error("Mixin: ParentNode not implemented."); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "lastElementChild", { + /* istanbul ignore next */ + get: function () { throw new Error("Mixin: ParentNode not implemented."); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "childElementCount", { + /* istanbul ignore next */ + get: function () { throw new Error("Mixin: ParentNode not implemented."); }, + enumerable: true, + configurable: true + }); + /* istanbul ignore next */ + DocumentImpl.prototype.prepend = function () { + var nodes = []; + for (var _i = 0; _i < arguments.length; _i++) { + nodes[_i] = arguments[_i]; } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (_f && !_f.done && (_b = _e.return)) _b.call(_e); - } - finally { if (e_4) throw e_4.error; } + throw new Error("Mixin: ParentNode not implemented."); + }; + /* istanbul ignore next */ + DocumentImpl.prototype.append = function () { + var nodes = []; + for (var _i = 0; _i < arguments.length; _i++) { + nodes[_i] = arguments[_i]; } - } - /** - * 4. A and B have the same number of children. - * 5. Each child of A equals the child of B at the identical index. - */ - if (a._children.size !== b._children.size) - return false; - var itA = a._children[Symbol.iterator](); - var itB = b._children[Symbol.iterator](); - var resultA = itA.next(); - var resultB = itB.next(); - while (!resultA.done && !resultB.done) { - var child1 = resultA.value; - var child2 = resultB.value; - if (!node_equals(child1, child2)) - return false; - resultA = itA.next(); - resultB = itB.next(); - } - return true; -} -exports.node_equals = node_equals; + throw new Error("Mixin: ParentNode not implemented."); + }; + /* istanbul ignore next */ + DocumentImpl.prototype.querySelector = function (selectors) { throw new Error("Mixin: ParentNode not implemented."); }; + /* istanbul ignore next */ + DocumentImpl.prototype.querySelectorAll = function (selectors) { throw new Error("Mixin: ParentNode not implemented."); }; + return DocumentImpl; +}(NodeImpl_1.NodeImpl)); +exports.DocumentImpl = DocumentImpl; /** - * Returns a collection of elements with the given qualified name which are - * descendants of the given root node. - * See: https://dom.spec.whatwg.org/#concept-getelementsbytagname - * - * @param qualifiedName - qualified name - * @param root - root node + * Initialize prototype properties */ -function node_listOfElementsWithQualifiedName(qualifiedName, root) { - /** - * 1. If qualifiedName is "*" (U+002A), return a HTMLCollection rooted at - * root, whose filter matches only descendant elements. - * 2. Otherwise, if root’s node document is an HTML document, return a - * HTMLCollection rooted at root, whose filter matches the following - * descendant elements: - * 2.1. Whose namespace is the HTML namespace and whose qualified name is - * qualifiedName, in ASCII lowercase. - * 2.2. Whose namespace is not the HTML namespace and whose qualified name - * is qualifiedName. - * 3. Otherwise, return a HTMLCollection rooted at root, whose filter - * matches descendant elements whose qualified name is qualifiedName. - */ - if (qualifiedName === "*") { - return CreateAlgorithm_1.create_htmlCollection(root); - } - else if (root._nodeDocument._type === "html") { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - if (ele._namespace === infra_1.namespace.HTML && - ele._qualifiedName === qualifiedName.toLowerCase()) { - return true; - } - else if (ele._namespace !== infra_1.namespace.HTML && - ele._qualifiedName === qualifiedName) { - return true; - } - else { - return false; - } - }); +WebIDLAlgorithm_1.idl_defineConst(DocumentImpl.prototype, "_nodeType", interfaces_1.NodeType.Document); +//# sourceMappingURL=DocumentImpl.js.map + +/***/ }), +/* 489 */, +/* 490 */, +/* 491 */, +/* 492 */, +/* 493 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } - else { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - return (ele._qualifiedName === qualifiedName); - }); + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } } -} -exports.node_listOfElementsWithQualifiedName = node_listOfElementsWithQualifiedName; + return ar; +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var DOMImpl_1 = __webpack_require__(648); +var util_1 = __webpack_require__(918); +var util_2 = __webpack_require__(592); +var ElementImpl_1 = __webpack_require__(695); +var CustomElementAlgorithm_1 = __webpack_require__(344); +var TreeAlgorithm_1 = __webpack_require__(873); +var NamespaceAlgorithm_1 = __webpack_require__(664); +var DOMAlgorithm_1 = __webpack_require__(304); +var ElementAlgorithm_1 = __webpack_require__(33); +var MutationAlgorithm_1 = __webpack_require__(479); /** - * Returns a collection of elements with the given namespace which are - * descendants of the given root node. - * See: https://dom.spec.whatwg.org/#concept-getelementsbytagnamens + * Returns an element interface for the given name and namespace. * - * @param namespace - element namespace - * @param localName - local name - * @param root - root node + * @param name - element name + * @param namespace - namespace */ -function node_listOfElementsWithNamespace(namespace, localName, root) { - /** - * 1. If namespace is the empty string, set it to null. - * 2. If both namespace and localName are "*" (U+002A), return a - * HTMLCollection rooted at root, whose filter matches descendant elements. - * 3. Otherwise, if namespace is "*" (U+002A), return a HTMLCollection - * rooted at root, whose filter matches descendant elements whose local - * name is localName. - * 4. Otherwise, if localName is "*" (U+002A), return a HTMLCollection - * rooted at root, whose filter matches descendant elements whose - * namespace is namespace. - * 5. Otherwise, return a HTMLCollection rooted at root, whose filter - * matches descendant elements whose namespace is namespace and local - * name is localName. - */ - if (namespace === '') - namespace = null; - if (namespace === "*" && localName === "*") { - return CreateAlgorithm_1.create_htmlCollection(root); - } - else if (namespace === "*") { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - return (ele._localName === localName); - }); - } - else if (localName === "*") { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - return (ele._namespace === namespace); - }); - } - else { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - return (ele._localName === localName && ele._namespace === namespace); - }); - } +function document_elementInterface(name, namespace) { + return ElementImpl_1.ElementImpl; } -exports.node_listOfElementsWithNamespace = node_listOfElementsWithNamespace; +exports.document_elementInterface = document_elementInterface; /** - * Returns a collection of elements with the given class names which are - * descendants of the given root node. - * See: https://dom.spec.whatwg.org/#concept-getelementsbyclassname + * Creates a new element node. + * See: https://dom.spec.whatwg.org/#internal-createelementns-steps * + * @param document - owner document * @param namespace - element namespace - * @param localName - local name - * @param root - root node + * @param qualifiedName - qualified name + * @param options - element options */ -function node_listOfElementsWithClassNames(classNames, root) { +function document_internalCreateElementNS(document, namespace, qualifiedName, options) { /** - * 1. Let classes be the result of running the ordered set parser - * on classNames. - * 2. If classes is the empty set, return an empty HTMLCollection. - * 3. Return a HTMLCollection rooted at root, whose filter matches - * descendant elements that have all their classes in classes. - * The comparisons for the classes must be done in an ASCII case-insensitive - * manner if root’s node document’s mode is "quirks", and in a - * case-sensitive manner otherwise. + * 1. Let namespace, prefix, and localName be the result of passing + * namespace and qualifiedName to validate and extract. + * 2. Let is be null. + * 3. If options is a dictionary and options’s is is present, then set + * is to it. + * 4. Return the result of creating an element given document, localName, + * namespace, prefix, is, and with the synchronous custom elements flag set. */ - var classes = OrderedSetAlgorithm_1.orderedSet_parse(classNames); - if (classes.size === 0) { - return CreateAlgorithm_1.create_htmlCollection(root, function () { return false; }); + var _a = __read(NamespaceAlgorithm_1.namespace_validateAndExtract(namespace, qualifiedName), 3), ns = _a[0], prefix = _a[1], localName = _a[2]; + var is = null; + if (options !== undefined) { + if (util_2.isString(options)) { + is = options; + } + else { + is = options.is; + } } - var caseSensitive = (root._nodeDocument._mode !== "quirks"); - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - var eleClasses = ele.classList; - return OrderedSetAlgorithm_1.orderedSet_contains(eleClasses._tokenSet, classes, caseSensitive); - }); + return ElementAlgorithm_1.element_createAnElement(document, localName, ns, prefix, is, true); } -exports.node_listOfElementsWithClassNames = node_listOfElementsWithClassNames; +exports.document_internalCreateElementNS = document_internalCreateElementNS; /** - * Searches for a namespace prefix associated with the given namespace - * starting from the given element through its ancestors. + * Removes `node` and its subtree from its document and changes + * its owner document to `document` so that it can be inserted + * into `document`. * - * @param element - an element node to start searching at - * @param namespace - namespace to search for + * @param node - the node to move + * @param document - document to receive the node and its subtree */ -function node_locateANamespacePrefix(element, namespace) { - /** - * 1. If element’s namespace is namespace and its namespace prefix is not - * null, then return its namespace prefix. - */ - if (element._namespace === namespace && element._namespacePrefix !== null) { - return element._namespacePrefix; - } - /** - * 2. If element has an attribute whose namespace prefix is "xmlns" and - * value is namespace, then return element’s first such attribute’s - * local name. - */ - for (var i = 0; i < element._attributeList.length; i++) { - var attr = element._attributeList[i]; - if (attr._namespacePrefix === "xmlns" && attr._value === namespace) { - return attr._localName; - } +function document_adopt(node, document) { + var e_1, _a; + // Optimize for common case of inserting a fresh node + if (node._nodeDocument === document && node._parent === null) { + return; } /** - * 3. If element’s parent element is not null, then return the result of - * running locate a namespace prefix on that element using namespace. + * 1. Let oldDocument be node’s node document. + * 2. If node’s parent is not null, remove node from its parent. */ - if (element._parent && util_1.Guard.isElementNode(element._parent)) { - return node_locateANamespacePrefix(element._parent, namespace); - } + var oldDocument = node._nodeDocument; + if (node._parent) + MutationAlgorithm_1.mutation_remove(node, node._parent); /** - * 4. Return null. + * 3. If document is not oldDocument, then: */ - return null; -} -exports.node_locateANamespacePrefix = node_locateANamespacePrefix; -/** - * Searches for a namespace associated with the given namespace prefix - * starting from the given node through its ancestors. - * - * @param node - a node to start searching at - * @param prefix - namespace prefix to search for - */ -function node_locateANamespace(node, prefix) { - if (util_1.Guard.isElementNode(node)) { - /** - * 1. If its namespace is not null and its namespace prefix is prefix, - * then return namespace. - */ - if (node._namespace !== null && node._namespacePrefix === prefix) { - return node._namespace; - } - /** - * 2. If it has an attribute whose namespace is the XMLNS namespace, - * namespace prefix is "xmlns", and local name is prefix, or if prefix - * is null and it has an attribute whose namespace is the XMLNS namespace, - * namespace prefix is null, and local name is "xmlns", then return its - * value if it is not the empty string, and null otherwise. - */ - for (var i = 0; i < node._attributeList.length; i++) { - var attr = node._attributeList[i]; - if (attr._namespace === infra_1.namespace.XMLNS && - attr._namespacePrefix === "xmlns" && - attr._localName === prefix) { - return attr._value || null; - } - if (prefix === null && attr._namespace === infra_1.namespace.XMLNS && - attr._namespacePrefix === null && attr._localName === "xmlns") { - return attr._value || null; - } - } - /** - * 3. If its parent element is null, then return null. - */ - if (node.parentElement === null) - return null; - /** - * 4. Return the result of running locate a namespace on its parent - * element using prefix. - */ - return node_locateANamespace(node.parentElement, prefix); - } - else if (util_1.Guard.isDocumentNode(node)) { - /** - * 1. If its document element is null, then return null. - * 2. Return the result of running locate a namespace on its document - * element using prefix. - */ - if (node.documentElement === null) - return null; - return node_locateANamespace(node.documentElement, prefix); - } - else if (util_1.Guard.isDocumentTypeNode(node) || util_1.Guard.isDocumentFragmentNode(node)) { - return null; - } - else if (util_1.Guard.isAttrNode(node)) { - /** - * 1. If its element is null, then return null. - * 2. Return the result of running locate a namespace on its element - * using prefix. - */ - if (node._element === null) - return null; - return node_locateANamespace(node._element, prefix); - } - else { + if (document !== oldDocument) { /** - * 1. If its parent element is null, then return null. - * 2. Return the result of running locate a namespace on its parent - * element using prefix. + * 3.1. For each inclusiveDescendant in node’s shadow-including inclusive + * descendants: */ - if (!node._parent || !util_1.Guard.isElementNode(node._parent)) - return null; - return node_locateANamespace(node._parent, prefix); + var inclusiveDescendant = TreeAlgorithm_1.tree_getFirstDescendantNode(node, true, true); + while (inclusiveDescendant !== null) { + /** + * 3.1.1. Set inclusiveDescendant’s node document to document. + * 3.1.2. If inclusiveDescendant is an element, then set the node + * document of each attribute in inclusiveDescendant’s attribute list + * to document. + */ + inclusiveDescendant._nodeDocument = document; + if (util_1.Guard.isElementNode(inclusiveDescendant)) { + try { + for (var _b = (e_1 = void 0, __values(inclusiveDescendant._attributeList._asArray())), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + attr._nodeDocument = document; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + } + /** + * 3.2. For each inclusiveDescendant in node's shadow-including + * inclusive descendants that is custom, enqueue a custom + * element callback reaction with inclusiveDescendant, + * callback name "adoptedCallback", and an argument list + * containing oldDocument and document. + */ + if (DOMImpl_1.dom.features.customElements) { + if (util_1.Guard.isElementNode(inclusiveDescendant) && + inclusiveDescendant._customElementState === "custom") { + CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(inclusiveDescendant, "adoptedCallback", [oldDocument, document]); + } + } + /** + * 3.3. For each inclusiveDescendant in node’s shadow-including + * inclusive descendants, in shadow-including tree order, run the + * adopting steps with inclusiveDescendant and oldDocument. + */ + if (DOMImpl_1.dom.features.steps) { + DOMAlgorithm_1.dom_runAdoptingSteps(inclusiveDescendant, oldDocument); + } + inclusiveDescendant = TreeAlgorithm_1.tree_getNextDescendantNode(node, inclusiveDescendant, true, true); + } } } -exports.node_locateANamespace = node_locateANamespace; -//# sourceMappingURL=NodeAlgorithm.js.map +exports.document_adopt = document_adopt; +//# sourceMappingURL=DocumentAlgorithm.js.map /***/ }), -/* 542 */, -/* 543 */, -/* 544 */, -/* 545 */, -/* 546 */, -/* 547 */, -/* 548 */ -/***/ (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 - +/* 494 */ +/***/ (function(module, __unusedexports, __webpack_require__) { -/***/ }), -/* 549 */, -/* 550 */ -/***/ (function(module, exports) { +var rng = __webpack_require__(58); +var bytesToUuid = __webpack_require__(722); -exports = module.exports = SemVer +function v4(options, buf, offset) { + var i = buf && offset || 0; -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) + if (typeof(options) == 'string') { + buf = options === 'binary' ? new Array(16) : null; + options = null; } -} else { - debug = function () {} -} - -// 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' + options = options || {}; -var MAX_LENGTH = 256 -var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 + var rnds = options.random || (options.rng || rng)(); -// Max safe segment length for coercion. -var MAX_SAFE_COMPONENT_LENGTH = 16 + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; -// The actual regexps go on exports.re -var re = exports.re = [] -var src = exports.src = [] -var t = exports.tokens = {} -var R = 0 + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ++ii) { + buf[i + ii] = rnds[ii]; + } + } -function tok (n) { - t[n] = R++ + return buf || bytesToUuid(rnds); } -// 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. - -tok('NUMERICIDENTIFIER') -src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' -tok('NUMERICIDENTIFIERLOOSE') -src[t.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. - -tok('NONNUMERICIDENTIFIER') -src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' - -// ## Main Version -// Three dot-separated numeric identifiers. - -tok('MAINVERSION') -src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')' - -tok('MAINVERSIONLOOSE') -src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' - -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. - -tok('PRERELEASEIDENTIFIER') -src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' - -tok('PRERELEASEIDENTIFIERLOOSE') -src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' - -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. - -tok('PRERELEASE') -src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' - -tok('PRERELEASELOOSE') -src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' - -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. - -tok('BUILDIDENTIFIER') -src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' - -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. - -tok('BUILD') -src[t.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. - -tok('FULL') -tok('FULLPLAIN') -src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + - src[t.PRERELEASE] + '?' + - src[t.BUILD] + '?' - -src[t.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. -tok('LOOSEPLAIN') -src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + - src[t.PRERELEASELOOSE] + '?' + - src[t.BUILD] + '?' - -tok('LOOSE') -src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' - -tok('GTLT') -src[t.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. -tok('XRANGEIDENTIFIERLOOSE') -src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' -tok('XRANGEIDENTIFIER') -src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' - -tok('XRANGEPLAIN') -src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:' + src[t.PRERELEASE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' - -tok('XRANGEPLAINLOOSE') -src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:' + src[t.PRERELEASELOOSE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' - -tok('XRANGE') -src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' -tok('XRANGELOOSE') -src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' - -// 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') - -// Tilde ranges. -// Meaning is "reasonably at or greater than" -tok('LONETILDE') -src[t.LONETILDE] = '(?:~>?)' - -tok('TILDETRIM') -src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' -re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') -var tildeTrimReplace = '$1~' - -tok('TILDE') -src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' -tok('TILDELOOSE') -src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' - -// Caret ranges. -// Meaning is "at least and backwards compatible with" -tok('LONECARET') -src[t.LONECARET] = '(?:\\^)' - -tok('CARETTRIM') -src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' -re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') -var caretTrimReplace = '$1^' - -tok('CARET') -src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' -tok('CARETLOOSE') -src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' +module.exports = v4; -// 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] + ')$|^$' -// 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] + ')' +/***/ }), +/* 495 */ +/***/ (function(__unusedmodule, exports) { -// this one has to use the /g flag -re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') -var comparatorTrimReplace = '$1$2$3' +"use strict"; -// 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*$' +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines a WebIDL `Const` property on the given object. + * + * @param o - object on which to add the property + * @param name - property name + * @param value - property value + */ +function idl_defineConst(o, name, value) { + Object.defineProperty(o, name, { writable: false, enumerable: true, configurable: false, value: value }); +} +exports.idl_defineConst = idl_defineConst; +//# sourceMappingURL=WebIDLAlgorithm.js.map -tok('HYPHENRANGELOOSE') -src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s*$' +/***/ }), +/* 496 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { -// Star ranges basically just allow anything at all. -tok('STAR') -src[t.STAR] = '(<|>)?=?\\s*\\*' +"use strict"; -// 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]) - } +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var util_1 = __webpack_require__(592); +/** + * Adds the given item to the end of the set. + * + * @param set - a set + * @param item - an item + */ +function append(set, item) { + set.add(item); } - -exports.parse = parse -function parse (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false +exports.append = append; +/** + * Extends a set by appending all items from another set. + * + * @param setA - a list to extend + * @param setB - a list containing items to append to `setA` + */ +function extend(setA, setB) { + setB.forEach(setA.add, setA); +} +exports.extend = extend; +/** + * Inserts the given item to the start of the set. + * + * @param set - a set + * @param item - an item + */ +function prepend(set, item) { + var cloned = new Set(set); + set.clear(); + set.add(item); + cloned.forEach(set.add, set); +} +exports.prepend = prepend; +/** + * Replaces the given item or all items matching condition with a new item. + * + * @param set - a set + * @param conditionOrItem - an item to replace or a condition matching items + * to replace + * @param item - an item + */ +function replace(set, conditionOrItem, newItem) { + var e_1, _a; + var newSet = new Set(); + try { + for (var set_1 = __values(set), set_1_1 = set_1.next(); !set_1_1.done; set_1_1 = set_1.next()) { + var oldItem = set_1_1.value; + if (util_1.isFunction(conditionOrItem)) { + if (!!conditionOrItem.call(null, oldItem)) { + newSet.add(newItem); + } + else { + newSet.add(oldItem); + } + } + else if (oldItem === conditionOrItem) { + newSet.add(newItem); + } + else { + newSet.add(oldItem); + } + } } - } - - if (version instanceof SemVer) { - return version - } - - if (typeof version !== 'string') { - return null - } - - if (version.length > MAX_LENGTH) { - return null - } - - var 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 - } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (set_1_1 && !set_1_1.done && (_a = set_1.return)) _a.call(set_1); + } + finally { if (e_1) throw e_1.error; } + } + set.clear(); + newSet.forEach(set.add, set); +} +exports.replace = replace; +/** + * Inserts the given item before the given index. + * + * @param set - a set + * @param item - an item + */ +function insert(set, item, index) { + var e_2, _a; + var newSet = new Set(); + var i = 0; + try { + for (var set_2 = __values(set), set_2_1 = set_2.next(); !set_2_1.done; set_2_1 = set_2.next()) { + var oldItem = set_2_1.value; + if (i === index) + newSet.add(item); + newSet.add(oldItem); + i++; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (set_2_1 && !set_2_1.done && (_a = set_2.return)) _a.call(set_2); + } + finally { if (e_2) throw e_2.error; } + } + set.clear(); + newSet.forEach(set.add, set); } - -exports.valid = valid -function valid (version, options) { - var v = parse(version, options) - return v ? v.version : null +exports.insert = insert; +/** + * Removes the given item or all items matching condition. + * + * @param set - a set + * @param conditionOrItem - an item to remove or a condition matching items + * to remove + */ +function remove(set, conditionOrItem) { + var e_3, _a, e_4, _b; + if (!util_1.isFunction(conditionOrItem)) { + set.delete(conditionOrItem); + } + else { + var toRemove = []; + try { + for (var set_3 = __values(set), set_3_1 = set_3.next(); !set_3_1.done; set_3_1 = set_3.next()) { + var item = set_3_1.value; + if (!!conditionOrItem.call(null, item)) { + toRemove.push(item); + } + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (set_3_1 && !set_3_1.done && (_a = set_3.return)) _a.call(set_3); + } + finally { if (e_3) throw e_3.error; } + } + try { + for (var toRemove_1 = __values(toRemove), toRemove_1_1 = toRemove_1.next(); !toRemove_1_1.done; toRemove_1_1 = toRemove_1.next()) { + var oldItem = toRemove_1_1.value; + set.delete(oldItem); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (toRemove_1_1 && !toRemove_1_1.done && (_b = toRemove_1.return)) _b.call(toRemove_1); + } + finally { if (e_4) throw e_4.error; } + } + } } - -exports.clean = clean -function clean (version, options) { - var s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null +exports.remove = remove; +/** + * Removes all items from the set. + */ +function empty(set) { + set.clear(); } - -exports.SemVer = SemVer - -function SemVer (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false +exports.empty = empty; +/** + * Determines if the set contains the given item or any items matching + * condition. + * + * @param set - a set + * @param conditionOrItem - an item to a condition to match + */ +function contains(set, conditionOrItem) { + var e_5, _a; + if (!util_1.isFunction(conditionOrItem)) { + return set.has(conditionOrItem); } - } - if (version instanceof SemVer) { - if (version.loose === options.loose) { - return version - } else { - version = version.version + else { + try { + for (var set_4 = __values(set), set_4_1 = set_4.next(); !set_4_1.done; set_4_1 = set_4.next()) { + var oldItem = set_4_1.value; + if (!!conditionOrItem.call(null, oldItem)) { + return true; + } + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (set_4_1 && !set_4_1.done && (_a = set_4.return)) _a.call(set_4); + } + finally { if (e_5) throw e_5.error; } + } } - } 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') - } - - if (!(this instanceof SemVer)) { - return new SemVer(version, options) - } - - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose - - var 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(function (id) { - if (/^[0-9]+$/.test(id)) { - var num = +id - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num + return false; +} +exports.contains = contains; +/** + * Returns the count of items in the set matching the given condition. + * + * @param set - a set + * @param condition - an optional condition to match + */ +function size(set, condition) { + var e_6, _a; + if (condition === undefined) { + return set.size; + } + else { + var count = 0; + try { + for (var set_5 = __values(set), set_5_1 = set_5.next(); !set_5_1.done; set_5_1 = set_5.next()) { + var item = set_5_1.value; + if (!!condition.call(null, item)) { + count++; + } + } } - } - return id - }) - } - - this.build = m[5] ? m[5].split('.') : [] - this.format() + catch (e_6_1) { e_6 = { error: e_6_1 }; } + finally { + try { + if (set_5_1 && !set_5_1.done && (_a = set_5.return)) _a.call(set_5); + } + finally { if (e_6) throw e_6.error; } + } + return count; + } } - -SemVer.prototype.format = function () { - this.version = this.major + '.' + this.minor + '.' + this.patch - if (this.prerelease.length) { - this.version += '-' + this.prerelease.join('.') - } - return this.version +exports.size = size; +/** + * Determines if the set is empty. + * + * @param set - a set + */ +function isEmpty(set) { + return set.size === 0; } - -SemVer.prototype.toString = function () { - return this.version +exports.isEmpty = isEmpty; +/** + * Returns an iterator for the items of the set. + * + * @param set - a set + * @param condition - an optional condition to match + */ +function forEach(set, condition) { + var set_6, set_6_1, item, e_7_1; + var e_7, _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!(condition === undefined)) return [3 /*break*/, 2]; + return [5 /*yield**/, __values(set)]; + case 1: + _b.sent(); + return [3 /*break*/, 9]; + case 2: + _b.trys.push([2, 7, 8, 9]); + set_6 = __values(set), set_6_1 = set_6.next(); + _b.label = 3; + case 3: + if (!!set_6_1.done) return [3 /*break*/, 6]; + item = set_6_1.value; + if (!!!condition.call(null, item)) return [3 /*break*/, 5]; + return [4 /*yield*/, item]; + case 4: + _b.sent(); + _b.label = 5; + case 5: + set_6_1 = set_6.next(); + return [3 /*break*/, 3]; + case 6: return [3 /*break*/, 9]; + case 7: + e_7_1 = _b.sent(); + e_7 = { error: e_7_1 }; + return [3 /*break*/, 9]; + case 8: + try { + if (set_6_1 && !set_6_1.done && (_a = set_6.return)) _a.call(set_6); + } + finally { if (e_7) throw e_7.error; } + return [7 /*endfinally*/]; + case 9: return [2 /*return*/]; + } + }); } - -SemVer.prototype.compare = function (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - return this.compareMain(other) || this.comparePre(other) +exports.forEach = forEach; +/** + * Creates and returns a shallow clone of set. + * + * @param set - a set + */ +function clone(set) { + return new Set(set); } - -SemVer.prototype.compareMain = function (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) +exports.clone = clone; +/** + * Returns a new set containing items from the set sorted in ascending + * order. + * + * @param set - a set + * @param lessThanAlgo - a function that returns `true` if its first argument + * is less than its second argument, and `false` otherwise. + */ +function sortInAscendingOrder(set, lessThanAlgo) { + var list = new (Array.bind.apply(Array, __spread([void 0], set)))(); + list.sort(function (itemA, itemB) { + return lessThanAlgo.call(null, itemA, itemB) ? -1 : 1; + }); + return new Set(list); } - -SemVer.prototype.comparePre = function (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 - } - - 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) +exports.sortInAscendingOrder = sortInAscendingOrder; +/** + * Returns a new set containing items from the set sorted in descending + * order. + * + * @param set - a set + * @param lessThanAlgo - a function that returns `true` if its first argument + * is less than its second argument, and `false` otherwise. + */ +function sortInDescendingOrder(set, lessThanAlgo) { + var list = new (Array.bind.apply(Array, __spread([void 0], set)))(); + list.sort(function (itemA, itemB) { + return lessThanAlgo.call(null, itemA, itemB) ? 1 : -1; + }); + return new Set(list); } - -SemVer.prototype.compareBuild = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - 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) +exports.sortInDescendingOrder = sortInDescendingOrder; +/** + * Determines if a set is a subset of another set. + * + * @param subset - a set + * @param superset - a superset possibly containing all items from `subset`. + */ +function isSubsetOf(subset, superset) { + var e_8, _a; + try { + for (var subset_1 = __values(subset), subset_1_1 = subset_1.next(); !subset_1_1.done; subset_1_1 = subset_1.next()) { + var item = subset_1_1.value; + if (!superset.has(item)) + return false; + } } - } 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. -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 - } + catch (e_8_1) { e_8 = { error: e_8_1 }; } + finally { + try { + if (subset_1_1 && !subset_1_1.done && (_a = subset_1.return)) _a.call(subset_1); } - if (i === -1) { - // didn't increment anything - this.prerelease.push(0) + finally { if (e_8) throw e_8.error; } + } + return true; +} +exports.isSubsetOf = isSubsetOf; +/** + * Determines if a set is a superset of another set. + * + * @param superset - a set + * @param subset - a subset possibly contained within `superset`. + */ +function isSupersetOf(superset, subset) { + return isSubsetOf(subset, superset); +} +exports.isSupersetOf = isSupersetOf; +/** + * Returns a new set with items that are contained in both sets. + * + * @param setA - a set + * @param setB - a set + */ +function intersection(setA, setB) { + var e_9, _a; + var newSet = new Set(); + try { + for (var setA_1 = __values(setA), setA_1_1 = setA_1.next(); !setA_1_1.done; setA_1_1 = setA_1.next()) { + var item = setA_1_1.value; + if (setB.has(item)) + newSet.add(item); } - } - 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] + } + catch (e_9_1) { e_9 = { error: e_9_1 }; } + finally { + try { + if (setA_1_1 && !setA_1_1.done && (_a = setA_1.return)) _a.call(setA_1); } - } - break - - default: - throw new Error('invalid increment argument: ' + release) - } - this.format() - this.raw = this.version - return this + finally { if (e_9) throw e_9.error; } + } + return newSet; } - -exports.inc = inc -function inc (version, release, loose, identifier) { - if (typeof (loose) === 'string') { - identifier = loose - loose = undefined - } - - try { - return new SemVer(version, loose).inc(release, identifier).version - } catch (er) { - return null - } +exports.intersection = intersection; +/** + * Returns a new set with items from both sets. + * + * @param setA - a set + * @param setB - a set + */ +function union(setA, setB) { + var newSet = new Set(setA); + setB.forEach(newSet.add, newSet); + return newSet; } - -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 - } - } +exports.union = union; +/** + * Returns a set of integers from `n` to `m` inclusive. + * + * @param n - starting number + * @param m - ending number + */ +function range(n, m) { + var newSet = new Set(); + for (var i = n; i <= m; i++) { + newSet.add(i); } - return defaultResult // may be undefined - } + return newSet; } +exports.range = range; +//# sourceMappingURL=Set.js.map -exports.compareIdentifiers = compareIdentifiers - -var numeric = /^[0-9]+$/ -function compareIdentifiers (a, b) { - var anum = numeric.test(a) - var bnum = numeric.test(b) +/***/ }), +/* 497 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { - if (anum && bnum) { - a = +a - b = +b - } +"use strict"; - return a === b ? 0 - : (anum && !bnum) ? -1 - : (bnum && !anum) ? 1 - : a < b ? -1 - : 1 -} +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var BaseCBWriter_1 = __webpack_require__(512); +/** + * Serializes XML nodes. + */ +var YAMLCBWriter = /** @class */ (function (_super) { + __extends(YAMLCBWriter, _super); + /** + * Initializes a new instance of `BaseCBWriter`. + * + * @param builderOptions - XML builder options + */ + function YAMLCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._rootWritten = false; + _this._additionalLevel = 0; + if (builderOptions.indent.length < 2) { + throw new Error("YAML indententation string must be at least two characters long."); + } + if (builderOptions.offset < 0) { + throw new Error("YAML offset should be zero or a positive number."); + } + return _this; + } + /** @inheritdoc */ + YAMLCBWriter.prototype.frontMatter = function () { + return this._beginLine() + "---"; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.declaration = function (version, encoding, standalone) { + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.docType = function (name, publicId, systemId) { + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.comment = function (data) { + // "!": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.comment) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.text = function (data) { + // "#": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.text) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.instruction = function (target, data) { + // "?": "target hello" + return this._beginLine() + + this._key(this._builderOptions.convert.ins) + " " + + this._val(data ? target + " " + data : target); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.cdata = function (data) { + // "$": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.cdata) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.attribute = function (name, value) { + // "@name": "val" + this._additionalLevel++; + var str = this._beginLine() + + this._key(this._builderOptions.convert.att + name) + " " + + this._val(value); + this._additionalLevel--; + return str; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.openTagBegin = function (name) { + // "node": + // "#": + // - + var str = this._beginLine() + this._key(name); + if (!this._rootWritten) { + this._rootWritten = true; + } + this.hasData = true; + this._additionalLevel++; + str += this._beginLine(true) + this._key(this._builderOptions.convert.text); + return str; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (selfClosing) { + return " " + this._val(""); + } + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.closeTag = function (name) { + this._additionalLevel--; + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + YAMLCBWriter.prototype.endElement = function (name) { }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + YAMLCBWriter.prototype._beginLine = function (suppressArray) { + if (suppressArray === void 0) { suppressArray = false; } + return (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level, suppressArray); + }; + /** + * Produces an indentation string. + * + * @param level - depth of the tree + * @param suppressArray - whether the suppress array marker + */ + YAMLCBWriter.prototype._indent = function (level, suppressArray) { + if (level + this._additionalLevel <= 0) { + return ""; + } + else { + var chars = this._writerOptions.indent.repeat(level + this._additionalLevel); + if (!suppressArray && this._rootWritten) { + return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); + } + return chars; + } + }; + /** + * Produces a YAML key string delimited with double quotes. + */ + YAMLCBWriter.prototype._key = function (key) { + return "\"" + key + "\":"; + }; + /** + * Produces a YAML value string delimited with double quotes. + */ + YAMLCBWriter.prototype._val = function (val) { + return JSON.stringify(val); + }; + return YAMLCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.YAMLCBWriter = YAMLCBWriter; +//# sourceMappingURL=YAMLCBWriter.js.map -exports.rcompareIdentifiers = rcompareIdentifiers -function rcompareIdentifiers (a, b) { - return compareIdentifiers(b, a) -} +/***/ }), +/* 498 */, +/* 499 */, +/* 500 */, +/* 501 */ +/***/ (function(__unusedmodule, exports) { -exports.major = major -function major (a, loose) { - return new SemVer(a, loose).major -} +"use strict"; -exports.minor = minor -function minor (a, loose) { - return new SemVer(a, loose).minor +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Appends the given item to the queue. + * + * @param list - a list + * @param item - an item + */ +function enqueue(list, item) { + list.push(item); } - -exports.patch = patch -function patch (a, loose) { - return new SemVer(a, loose).patch +exports.enqueue = enqueue; +/** + * Removes and returns an item from the queue. + * + * @param list - a list + */ +function dequeue(list) { + return list.shift() || null; } +exports.dequeue = dequeue; +//# sourceMappingURL=Queue.js.map -exports.compare = compare -function compare (a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)) -} +/***/ }), +/* 502 */, +/* 503 */, +/* 504 */, +/* 505 */, +/* 506 */, +/* 507 */, +/* 508 */, +/* 509 */, +/* 510 */, +/* 511 */, +/* 512 */ +/***/ (function(__unusedmodule, exports) { -exports.compareLoose = compareLoose -function compareLoose (a, b) { - return compare(a, b, true) -} +"use strict"; -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) -} +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Pre-serializes XML nodes. + */ +var BaseCBWriter = /** @class */ (function () { + /** + * Initializes a new instance of `BaseCBWriter`. + * + * @param builderOptions - XML builder options + */ + function BaseCBWriter(builderOptions) { + /** + * Gets the current depth of the XML tree. + */ + this.level = 0; + this._builderOptions = builderOptions; + this._writerOptions = builderOptions; + } + return BaseCBWriter; +}()); +exports.BaseCBWriter = BaseCBWriter; +//# sourceMappingURL=BaseCBWriter.js.map -exports.rcompare = rcompare -function rcompare (a, b, loose) { - return compare(b, a, loose) -} +/***/ }), +/* 513 */, +/* 514 */, +/* 515 */, +/* 516 */, +/* 517 */, +/* 518 */, +/* 519 */, +/* 520 */, +/* 521 */, +/* 522 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { -exports.sort = sort -function sort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(a, b, loose) - }) -} +"use strict"; -exports.rsort = rsort -function rsort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(b, a, loose) - }) +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var util_1 = __webpack_require__(592); +/** + * Parses the given byte sequence representing a JSON string into an object. + * + * @param bytes - a byte sequence + */ +function parseJSONFromBytes(bytes) { + /** + * 1. Let jsonText be the result of running UTF-8 decode on bytes. [ENCODING] + * 2. Return ? Call(%JSONParse%, undefined, « jsonText »). + */ + var jsonText = util_1.utf8Decode(bytes); + return JSON.parse.call(undefined, jsonText); } - -exports.gt = gt -function gt (a, b, loose) { - return compare(a, b, loose) > 0 +exports.parseJSONFromBytes = parseJSONFromBytes; +/** + * Serialize the given JavaScript value into a byte sequence. + * + * @param value - a JavaScript value + */ +function serializeJSONToBytes(value) { + /** + * 1. Let jsonString be ? Call(%JSONStringify%, undefined, « value »). + * 2. Return the result of running UTF-8 encode on jsonString. [ENCODING] + */ + var jsonString = JSON.stringify.call(undefined, value); + return util_1.utf8Encode(jsonString); } - -exports.lt = lt -function lt (a, b, loose) { - return compare(a, b, loose) < 0 +exports.serializeJSONToBytes = serializeJSONToBytes; +/** + * Parses the given JSON string into a Realm-independent JavaScript value. + * + * @param jsonText - a JSON string + */ +function parseJSONIntoInfraValues(jsonText) { + /** + * 1. Let jsValue be ? Call(%JSONParse%, undefined, « jsonText »). + * 2. Return the result of converting a JSON-derived JavaScript value to an + * Infra value, given jsValue. + */ + var jsValue = JSON.parse.call(undefined, jsonText); + return convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValue); } - -exports.eq = eq -function eq (a, b, loose) { - return compare(a, b, loose) === 0 +exports.parseJSONIntoInfraValues = parseJSONIntoInfraValues; +/** + * Parses the value into a Realm-independent JavaScript value. + * + * @param jsValue - a JavaScript value + */ +function convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValue) { + var e_1, _a; + /** + * 1. If Type(jsValue) is Null, String, or Number, then return jsValue. + */ + if (jsValue === null || util_1.isString(jsValue) || util_1.isNumber(jsValue)) + return jsValue; + /** + * 2. If IsArray(jsValue) is true, then: + * 2.1. Let result be an empty list. + * 2.2. Let length be ! ToLength(! Get(jsValue, "length")). + * 2.3. For each index of the range 0 to length − 1, inclusive: + * 2.3.1. Let indexName be ! ToString(index). + * 2.3.2. Let jsValueAtIndex be ! Get(jsValue, indexName). + * 2.3.3. Let infraValueAtIndex be the result of converting a JSON-derived + * JavaScript value to an Infra value, given jsValueAtIndex. + * 2.3.4. Append infraValueAtIndex to result. + * 2.8. Return result. + */ + if (util_1.isArray(jsValue)) { + var result = new Array(); + try { + for (var jsValue_1 = __values(jsValue), jsValue_1_1 = jsValue_1.next(); !jsValue_1_1.done; jsValue_1_1 = jsValue_1.next()) { + var jsValueAtIndex = jsValue_1_1.value; + result.push(convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValueAtIndex)); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (jsValue_1_1 && !jsValue_1_1.done && (_a = jsValue_1.return)) _a.call(jsValue_1); + } + finally { if (e_1) throw e_1.error; } + } + return result; + } + else if (util_1.isObject(jsValue)) { + /** + * 3. Let result be an empty ordered map. + * 4. For each key of ! jsValue.[[OwnPropertyKeys]](): + * 4.1. Let jsValueAtKey be ! Get(jsValue, key). + * 4.2. Let infraValueAtKey be the result of converting a JSON-derived + * JavaScript value to an Infra value, given jsValueAtKey. + * 4.3. Set result[key] to infraValueAtKey. + * 5. Return result. + */ + var result = new Map(); + for (var key in jsValue) { + /* istanbul ignore else */ + if (jsValue.hasOwnProperty(key)) { + var jsValueAtKey = jsValue[key]; + result.set(key, convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValueAtKey)); + } + } + return result; + } + /* istanbul ignore next */ + return jsValue; } +exports.convertAJSONDerivedJavaScriptValueToAnInfraValue = convertAJSONDerivedJavaScriptValueToAnInfraValue; +//# sourceMappingURL=JSON.js.map -exports.neq = neq -function neq (a, b, loose) { - return compare(a, b, loose) !== 0 -} +/***/ }), +/* 523 */, +/* 524 */ +/***/ (function(__unusedmodule, exports) { -exports.gte = gte -function gte (a, b, loose) { - return compare(a, b, loose) >= 0 -} +"use strict"; -exports.lte = lte -function lte (a, b, loose) { - return compare(a, b, loose) <= 0 -} +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Represents a cache for storing order between equal objects. + * + * This cache is used when an algorithm compares two objects and finds them to + * be equal but still needs to establish an order between those two objects. + * When two such objects `a` and `b` are passed to the `check` method, a random + * number is generated with `Math.random()`. If the random number is less than + * `0.5` it is assumed that `a < b` otherwise `a > b`. The random number along + * with `a` and `b` is stored in the cache, so that subsequent checks result + * in the same consistent result. + * + * The cache has a size limit which is defined on initialization. + */ +var CompareCache = /** @class */ (function () { + /** + * Initializes a new instance of `CompareCache`. + * + * @param limit - maximum number of items to keep in the cache. When the limit + * is exceeded the first item is removed from the cache. + */ + function CompareCache(limit) { + if (limit === void 0) { limit = 1000; } + this._items = new Map(); + this._limit = limit; + } + /** + * Compares and caches the given objects. Returns `true` if `objA < objB` and + * `false` otherwise. + * + * @param objA - an item to compare + * @param objB - an item to compare + */ + CompareCache.prototype.check = function (objA, objB) { + if (this._items.get(objA) === objB) + return true; + else if (this._items.get(objB) === objA) + return false; + var result = (Math.random() < 0.5); + if (result) { + this._items.set(objA, objB); + } + else { + this._items.set(objB, objA); + } + if (this._items.size > this._limit) { + var it_1 = this._items.keys().next(); + /* istanbul ignore else */ + if (!it_1.done) { + this._items.delete(it_1.value); + } + } + return result; + }; + return CompareCache; +}()); +exports.CompareCache = CompareCache; +//# sourceMappingURL=CompareCache.js.map -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 +/***/ }), +/* 525 */, +/* 526 */, +/* 527 */, +/* 528 */, +/* 529 */, +/* 530 */, +/* 531 */, +/* 532 */, +/* 533 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { - case '!==': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a !== b +"use strict"; - case '': - case '=': - case '==': - return eq(a, b, loose) +Object.defineProperty(exports, "__esModule", { value: true }); +var Guard_1 = __webpack_require__(783); +/** + * Contains type casts for DOM objects. + */ +var Cast = /** @class */ (function () { + function Cast() { + } + /** + * Casts the given object to a `Node`. + * + * @param a - the object to cast + */ + Cast.asNode = function (a) { + if (Guard_1.Guard.isNode(a)) { + return a; + } + else { + throw new Error("Invalid object. Node expected."); + } + }; + return Cast; +}()); +exports.Cast = Cast; +//# sourceMappingURL=Cast.js.map - case '!=': - return neq(a, b, loose) +/***/ }), +/* 534 */, +/* 535 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { - case '>': - return gt(a, b, loose) +"use strict"; - case '>=': - return gte(a, b, loose) +Object.defineProperty(exports, "__esModule", { value: true }); +var XMLBuilderImpl_1 = __webpack_require__(595); +exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; +var XMLBuilderCBImpl_1 = __webpack_require__(551); +exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; +var BuilderFunctions_1 = __webpack_require__(961); +exports.builder = BuilderFunctions_1.builder; +exports.create = BuilderFunctions_1.create; +exports.fragment = BuilderFunctions_1.fragment; +exports.convert = BuilderFunctions_1.convert; +var BuilderFunctionsCB_1 = __webpack_require__(295); +exports.createCB = BuilderFunctionsCB_1.createCB; +exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; +//# sourceMappingURL=index.js.map - case '<': - return lt(a, b, loose) +/***/ }), +/* 536 */, +/* 537 */, +/* 538 */, +/* 539 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { - case '<=': - return lte(a, b, loose) +"use strict"; - default: - throw new TypeError('Invalid operator: ' + op) - } +Object.defineProperty(exports, "__esModule", { value: true }); +const http = __webpack_require__(605); +const https = __webpack_require__(34); +const pm = __webpack_require__(950); +let tunnel; +var HttpCodes; +(function (HttpCodes) { + HttpCodes[HttpCodes["OK"] = 200] = "OK"; + HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; + HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; + HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; + HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; + HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; + HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; + HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; + HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; + HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; + HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; + HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; + HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; + HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; + HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; + HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; + HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; + HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; + HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; + HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; + HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; + HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; + HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; + HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; + HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; + HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; + HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; +})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); +var Headers; +(function (Headers) { + Headers["Accept"] = "accept"; + Headers["ContentType"] = "content-type"; +})(Headers = exports.Headers || (exports.Headers = {})); +var MediaTypes; +(function (MediaTypes) { + MediaTypes["ApplicationJson"] = "application/json"; +})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); +/** + * Returns the proxy URL, depending upon the supplied url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ +function getProxyUrl(serverUrl) { + let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); + return proxyUrl ? proxyUrl.href : ''; } - -exports.Comparator = Comparator -function Comparator (comp, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false +exports.getProxyUrl = getProxyUrl; +const HttpRedirectCodes = [ + HttpCodes.MovedPermanently, + HttpCodes.ResourceMoved, + HttpCodes.SeeOther, + HttpCodes.TemporaryRedirect, + HttpCodes.PermanentRedirect +]; +const HttpResponseRetryCodes = [ + HttpCodes.BadGateway, + HttpCodes.ServiceUnavailable, + HttpCodes.GatewayTimeout +]; +const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; +const ExponentialBackoffCeiling = 10; +const ExponentialBackoffTimeSlice = 5; +class HttpClientError extends Error { + constructor(message, statusCode) { + super(message); + this.name = 'HttpClientError'; + this.statusCode = statusCode; + Object.setPrototypeOf(this, HttpClientError.prototype); } - } - - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp - } else { - comp = comp.value +} +exports.HttpClientError = HttpClientError; +class HttpClientResponse { + constructor(message) { + this.message = message; + } + readBody() { + return new Promise(async (resolve, reject) => { + let output = Buffer.alloc(0); + this.message.on('data', (chunk) => { + output = Buffer.concat([output, chunk]); + }); + this.message.on('end', () => { + resolve(output.toString()); + }); + }); + } +} +exports.HttpClientResponse = HttpClientResponse; +function isHttps(requestUrl) { + let parsedUrl = new URL(requestUrl); + return parsedUrl.protocol === 'https:'; +} +exports.isHttps = isHttps; +class HttpClient { + constructor(userAgent, handlers, requestOptions) { + this._ignoreSslError = false; + this._allowRedirects = true; + this._allowRedirectDowngrade = false; + this._maxRedirects = 50; + this._allowRetries = false; + this._maxRetries = 1; + this._keepAlive = false; + this._disposed = false; + this.userAgent = userAgent; + this.handlers = handlers || []; + this.requestOptions = requestOptions; + if (requestOptions) { + if (requestOptions.ignoreSslError != null) { + this._ignoreSslError = requestOptions.ignoreSslError; + } + this._socketTimeout = requestOptions.socketTimeout; + if (requestOptions.allowRedirects != null) { + this._allowRedirects = requestOptions.allowRedirects; + } + if (requestOptions.allowRedirectDowngrade != null) { + this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + } + if (requestOptions.maxRedirects != null) { + this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + } + if (requestOptions.keepAlive != null) { + this._keepAlive = requestOptions.keepAlive; + } + if (requestOptions.allowRetries != null) { + this._allowRetries = requestOptions.allowRetries; + } + if (requestOptions.maxRetries != null) { + this._maxRetries = requestOptions.maxRetries; + } + } + } + options(requestUrl, additionalHeaders) { + return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); + } + get(requestUrl, additionalHeaders) { + return this.request('GET', requestUrl, null, additionalHeaders || {}); + } + del(requestUrl, additionalHeaders) { + return this.request('DELETE', requestUrl, null, additionalHeaders || {}); + } + post(requestUrl, data, additionalHeaders) { + return this.request('POST', requestUrl, data, additionalHeaders || {}); + } + patch(requestUrl, data, additionalHeaders) { + return this.request('PATCH', requestUrl, data, additionalHeaders || {}); + } + put(requestUrl, data, additionalHeaders) { + return this.request('PUT', requestUrl, data, additionalHeaders || {}); + } + head(requestUrl, additionalHeaders) { + return this.request('HEAD', requestUrl, null, additionalHeaders || {}); + } + sendStream(verb, requestUrl, stream, additionalHeaders) { + return this.request(verb, requestUrl, stream, additionalHeaders); + } + /** + * Gets a typed object from an endpoint + * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise + */ + async getJson(requestUrl, additionalHeaders = {}) { + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + let res = await this.get(requestUrl, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async postJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.post(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async putJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.put(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async patchJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.patch(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + /** + * Makes a raw http request. + * All other methods such as get, post, patch, and request ultimately call this. + * Prefer get, del, post and patch + */ + async request(verb, requestUrl, data, headers) { + if (this._disposed) { + throw new Error('Client has already been disposed.'); + } + let parsedUrl = new URL(requestUrl); + let info = this._prepareRequest(verb, parsedUrl, headers); + // Only perform retries on reads since writes may not be idempotent. + let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 + ? this._maxRetries + 1 + : 1; + let numTries = 0; + let response; + while (numTries < maxTries) { + response = await this.requestRaw(info, data); + // Check if it's an authentication challenge + if (response && + response.message && + response.message.statusCode === HttpCodes.Unauthorized) { + let authenticationHandler; + for (let i = 0; i < this.handlers.length; i++) { + if (this.handlers[i].canHandleAuthentication(response)) { + authenticationHandler = this.handlers[i]; + break; + } + } + if (authenticationHandler) { + return authenticationHandler.handleAuthentication(this, info, data); + } + else { + // We have received an unauthorized response but have no handlers to handle it. + // Let the response return to the caller. + return response; + } + } + let redirectsRemaining = this._maxRedirects; + while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && + this._allowRedirects && + redirectsRemaining > 0) { + const redirectUrl = response.message.headers['location']; + if (!redirectUrl) { + // if there's no location to redirect to, we won't + break; + } + let parsedRedirectUrl = new URL(redirectUrl); + if (parsedUrl.protocol == 'https:' && + parsedUrl.protocol != parsedRedirectUrl.protocol && + !this._allowRedirectDowngrade) { + throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); + } + // we need to finish reading the response before reassigning response + // which will leak the open socket. + await response.readBody(); + // strip authorization header if redirected to a different hostname + if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { + for (let header in headers) { + // header names are case insensitive + if (header.toLowerCase() === 'authorization') { + delete headers[header]; + } + } + } + // let's make the request with the new redirectUrl + info = this._prepareRequest(verb, parsedRedirectUrl, headers); + response = await this.requestRaw(info, data); + redirectsRemaining--; + } + if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { + // If not a retry code, return immediately instead of retrying + return response; + } + numTries += 1; + if (numTries < maxTries) { + await response.readBody(); + await this._performExponentialBackoff(numTries); + } + } + return response; + } + /** + * Needs to be called if keepAlive is set to true in request options. + */ + dispose() { + if (this._agent) { + this._agent.destroy(); + } + this._disposed = true; + } + /** + * Raw request. + * @param info + * @param data + */ + requestRaw(info, data) { + return new Promise((resolve, reject) => { + let callbackForResult = function (err, res) { + if (err) { + reject(err); + } + resolve(res); + }; + this.requestRawWithCallback(info, data, callbackForResult); + }); + } + /** + * Raw request with callback. + * @param info + * @param data + * @param onResult + */ + requestRawWithCallback(info, data, onResult) { + let socket; + if (typeof data === 'string') { + info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); + } + let callbackCalled = false; + let handleResult = (err, res) => { + if (!callbackCalled) { + callbackCalled = true; + onResult(err, res); + } + }; + let req = info.httpModule.request(info.options, (msg) => { + let res = new HttpClientResponse(msg); + handleResult(null, res); + }); + req.on('socket', sock => { + socket = sock; + }); + // If we ever get disconnected, we want the socket to timeout eventually + req.setTimeout(this._socketTimeout || 3 * 60000, () => { + if (socket) { + socket.end(); + } + handleResult(new Error('Request timeout: ' + info.options.path), null); + }); + req.on('error', function (err) { + // err has statusCode property + // res should have headers + handleResult(err, null); + }); + if (data && typeof data === 'string') { + req.write(data, 'utf8'); + } + if (data && typeof data !== 'string') { + data.on('close', function () { + req.end(); + }); + data.pipe(req); + } + else { + req.end(); + } } - } - - 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 - } - - debug('comp', this) -} - -var ANY = {} -Comparator.prototype.parse = function (comp) { - var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var 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) - } -} - -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 - } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false + /** + * Gets an http agent. This function is useful when you need an http agent that handles + * routing through a proxy server - depending upon the url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ + getAgent(serverUrl) { + let parsedUrl = new URL(serverUrl); + return this._getAgent(parsedUrl); } - } - - return cmp(version, this.operator, this.semver, this.options) -} - -Comparator.prototype.intersects = function (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } - - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false + _prepareRequest(method, requestUrl, headers) { + const info = {}; + info.parsedUrl = requestUrl; + const usingSsl = info.parsedUrl.protocol === 'https:'; + info.httpModule = usingSsl ? https : http; + const defaultPort = usingSsl ? 443 : 80; + info.options = {}; + info.options.host = info.parsedUrl.hostname; + info.options.port = info.parsedUrl.port + ? parseInt(info.parsedUrl.port) + : defaultPort; + info.options.path = + (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); + info.options.method = method; + info.options.headers = this._mergeHeaders(headers); + if (this.userAgent != null) { + info.options.headers['user-agent'] = this.userAgent; + } + info.options.agent = this._getAgent(info.parsedUrl); + // gives handlers an opportunity to participate + if (this.handlers) { + this.handlers.forEach(handler => { + handler.prepareRequest(info.options); + }); + } + return info; } - } - - var rangeTmp - - if (this.operator === '') { - if (this.value === '') { - return true + _mergeHeaders(headers) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + if (this.requestOptions && this.requestOptions.headers) { + return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); + } + return lowercaseKeys(headers || {}); } - rangeTmp = new Range(comp.value, options) - return satisfies(this.value, rangeTmp, options) - } else if (comp.operator === '') { - if (comp.value === '') { - return true + _getExistingOrDefaultHeader(additionalHeaders, header, _default) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + let clientHeader; + if (this.requestOptions && this.requestOptions.headers) { + clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; + } + return additionalHeaders[header] || clientHeader || _default; } - rangeTmp = new Range(this.value, options) - return satisfies(comp.semver, rangeTmp, options) - } - - 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 -} - -exports.Range = Range -function Range (range, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false + _getAgent(parsedUrl) { + let agent; + let proxyUrl = pm.getProxyUrl(parsedUrl); + let useProxy = proxyUrl && proxyUrl.hostname; + if (this._keepAlive && useProxy) { + agent = this._proxyAgent; + } + if (this._keepAlive && !useProxy) { + agent = this._agent; + } + // if agent is already assigned use that agent. + if (!!agent) { + return agent; + } + const usingSsl = parsedUrl.protocol === 'https:'; + let maxSockets = 100; + if (!!this.requestOptions) { + maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; + } + if (useProxy) { + // If using proxy, need tunnel + if (!tunnel) { + tunnel = __webpack_require__(856); + } + const agentOptions = { + maxSockets: maxSockets, + keepAlive: this._keepAlive, + proxy: { + proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`, + host: proxyUrl.hostname, + port: proxyUrl.port + } + }; + let tunnelAgent; + const overHttps = proxyUrl.protocol === 'https:'; + if (usingSsl) { + tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; + } + else { + tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; + } + agent = tunnelAgent(agentOptions); + this._proxyAgent = agent; + } + // if reusing agent across request and tunneling agent isn't assigned create a new agent + if (this._keepAlive && !agent) { + const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; + agent = usingSsl ? new https.Agent(options) : new http.Agent(options); + this._agent = agent; + } + // if not using private agent and tunnel agent isn't setup then use global agent + if (!agent) { + agent = usingSsl ? https.globalAgent : http.globalAgent; + } + if (usingSsl && this._ignoreSslError) { + // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process + // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options + // we have to cast it to any and change it directly + agent.options = Object.assign(agent.options || {}, { + rejectUnauthorized: false + }); + } + return agent; } - } - - if (range instanceof Range) { - if (range.loose === !!options.loose && - range.includePrerelease === !!options.includePrerelease) { - return range - } else { - return new Range(range.raw, options) + _performExponentialBackoff(retryNumber) { + retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); + const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); + return new Promise(resolve => setTimeout(() => resolve(), ms)); } - } - - if (range instanceof Comparator) { - return new Range(range.value, options) - } - - if (!(this instanceof Range)) { - return new Range(range, options) - } - - 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(function (range) { - return this.parseRange(range.trim()) - }, this).filter(function (c) { - // throw out any that are not relevant for whatever reason - return c.length - }) - - if (!this.set.length) { - throw new TypeError('Invalid SemVer Range: ' + range) - } - - this.format() -} - -Range.prototype.format = function () { - this.range = this.set.map(function (comps) { - return comps.join(' ').trim() - }).join('||').trim() - return this.range -} - -Range.prototype.toString = function () { - return this.range -} - -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]) - - // `~ 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. - - 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) - - return set -} - -Range.prototype.intersects = function (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') - } - - 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) - }) - - testComparator = remainingComparators.pop() - } - - 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' + static dateTimeDeserializer(key, value) { + if (typeof value === 'string') { + let a = new Date(value); + if (!isNaN(a.valueOf())) { + return a; + } + } + return value; + } + async _processResponse(res, options) { + return new Promise(async (resolve, reject) => { + const statusCode = res.message.statusCode; + const response = { + statusCode: statusCode, + result: null, + headers: {} + }; + // not found leads to null obj returned + if (statusCode == HttpCodes.NotFound) { + resolve(response); + } + let obj; + let contents; + // get the result from the body + try { + contents = await res.readBody(); + if (contents && contents.length > 0) { + if (options && options.deserializeDates) { + obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); + } + else { + obj = JSON.parse(contents); + } + response.result = obj; + } + response.headers = res.message.headers; + } + catch (err) { + // Invalid resource (contents not json); leaving result obj null + } + // note that 3xx redirects are handled by the http layer. + if (statusCode > 299) { + let msg; + // if exception/error in body, attempt to get better error + if (obj && obj.message) { + msg = obj.message; + } + else if (contents && contents.length > 0) { + // it may be the case that the exception is in the body message as string + msg = contents; + } + else { + msg = 'Failed request: (' + statusCode + ')'; + } + let err = new HttpClientError(msg, statusCode); + err.result = response.result; + reject(err); + } + else { + resolve(response); + } + }); } - - 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(' ') } +exports.HttpClient = HttpClient; -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' - } - } +/***/ }), +/* 540 */, +/* 541 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { - debug('caret return', ret) - return ret - }) -} +"use strict"; -function replaceXRanges (comp, options) { - debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map(function (comp) { - return replaceXRange(comp, options) - }).join(' ') +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var DOMImpl_1 = __webpack_require__(648); +var util_1 = __webpack_require__(918); +var infra_1 = __webpack_require__(23); +var CreateAlgorithm_1 = __webpack_require__(86); +var OrderedSetAlgorithm_1 = __webpack_require__(146); +var DOMAlgorithm_1 = __webpack_require__(304); +var MutationAlgorithm_1 = __webpack_require__(479); +var ElementAlgorithm_1 = __webpack_require__(33); +/** + * Replaces the contents of the given node with a single text node. + * + * @param string - node contents + * @param parent - a node + */ +function node_stringReplaceAll(str, parent) { + /** + * 1. Let node be null. + * 2. If string is not the empty string, then set node to a new Text node + * whose data is string and node document is parent’s node document. + * 3. Replace all with node within parent. + */ + var node = null; + if (str !== '') { + node = CreateAlgorithm_1.create_text(parent._nodeDocument, str); + } + MutationAlgorithm_1.mutation_replaceAll(node, parent); } - -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 = '' +exports.node_stringReplaceAll = node_stringReplaceAll; +/** + * Clones a node. + * + * @param node - a node to clone + * @param document - the document to own the cloned node + * @param cloneChildrenFlag - whether to clone node's children + */ +function node_clone(node, document, cloneChildrenFlag) { + var e_1, _a, e_2, _b; + if (document === void 0) { document = null; } + if (cloneChildrenFlag === void 0) { cloneChildrenFlag = false; } + /** + * 1. If document is not given, let document be node’s node document. + */ + if (document === null) + document = node._nodeDocument; + var copy; + if (util_1.Guard.isElementNode(node)) { + /** + * 2. If node is an element, then: + * 2.1. Let copy be the result of creating an element, given document, + * node’s local name, node’s namespace, node’s namespace prefix, + * and node’s is value, with the synchronous custom elements flag unset. + * 2.2. For each attribute in node’s attribute list: + * 2.2.1. Let copyAttribute be a clone of attribute. + * 2.2.2. Append copyAttribute to copy. + */ + copy = ElementAlgorithm_1.element_createAnElement(document, node._localName, node._namespace, node._namespacePrefix, node._is, false); + try { + for (var _c = __values(node._attributeList), _d = _c.next(); !_d.done; _d = _c.next()) { + var attribute = _d.value; + var copyAttribute = node_clone(attribute, document); + ElementAlgorithm_1.element_append(copyAttribute, copy); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_1) throw e_1.error; } + } } - - // 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 { + /** + * 3. Otherwise, let copy be a node that implements the same interfaces as + * node, and fulfills these additional requirements, switching on node: + * - Document + * Set copy’s encoding, content type, URL, origin, type, and mode, to those + * of node. + * - DocumentType + * Set copy’s name, public ID, and system ID, to those of node. + * - Attr + * Set copy’s namespace, namespace prefix, local name, and value, to + * those of node. + * - Text + * - Comment + * Set copy’s data, to that of node. + * - ProcessingInstruction + * Set copy’s target and data to those of node. + * - Any other node + */ + if (util_1.Guard.isDocumentNode(node)) { + var doc = CreateAlgorithm_1.create_document(); + doc._encoding = node._encoding; + doc._contentType = node._contentType; + doc._URL = node._URL; + doc._origin = node._origin; + doc._type = node._type; + doc._mode = node._mode; + copy = doc; } - } 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 + else if (util_1.Guard.isDocumentTypeNode(node)) { + var doctype = CreateAlgorithm_1.create_documentType(document, node._name, node._publicId, node._systemId); + copy = doctype; + } + else if (util_1.Guard.isAttrNode(node)) { + var attr = CreateAlgorithm_1.create_attr(document, node.localName); + attr._namespace = node._namespace; + attr._namespacePrefix = node._namespacePrefix; + attr._value = node._value; + copy = attr; + } + else if (util_1.Guard.isExclusiveTextNode(node)) { + copy = CreateAlgorithm_1.create_text(document, node._data); + } + else if (util_1.Guard.isCDATASectionNode(node)) { + copy = CreateAlgorithm_1.create_cdataSection(document, node._data); + } + else if (util_1.Guard.isCommentNode(node)) { + copy = CreateAlgorithm_1.create_comment(document, node._data); + } + else if (util_1.Guard.isProcessingInstructionNode(node)) { + copy = CreateAlgorithm_1.create_processingInstruction(document, node._target, node._data); + } + else if (util_1.Guard.isDocumentFragmentNode(node)) { + copy = CreateAlgorithm_1.create_documentFragment(document); + } + else { + copy = Object.create(node); } - } - - 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 } - - 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], '') + /** + * 4. Set copy’s node document and document to copy, if copy is a document, + * and set copy’s node document to document otherwise. + */ + if (util_1.Guard.isDocumentNode(copy)) { + copy._nodeDocument = copy; + document = copy; + } + else { + copy._nodeDocument = document; + } + /** + * 5. Run any cloning steps defined for node in other applicable + * specifications and pass copy, node, document and the clone children flag + * if set, as parameters. + */ + if (DOMImpl_1.dom.features.steps) { + DOMAlgorithm_1.dom_runCloningSteps(copy, node, document, cloneChildrenFlag); + } + /** + * 6. If the clone children flag is set, clone all the children of node and + * append them to copy, with document as specified and the clone children + * flag being set. + */ + if (cloneChildrenFlag) { + try { + for (var _e = __values(node._children), _f = _e.next(); !_f.done; _f = _e.next()) { + var child = _f.value; + var childCopy = node_clone(child, document, true); + MutationAlgorithm_1.mutation_append(childCopy, copy); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_f && !_f.done && (_b = _e.return)) _b.call(_e); + } + finally { if (e_2) throw e_2.error; } + } + } + /** + * 7. Return copy. + */ + return copy; } - -// 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() +exports.node_clone = node_clone; +/** + * Determines if two nodes can be considered equal. + * + * @param a - node to compare + * @param b - node to compare + */ +function node_equals(a, b) { + var e_3, _a, e_4, _b; + /** + * 1. A and B’s nodeType attribute value is identical. + */ + if (a._nodeType !== b._nodeType) + return false; + /** + * 2. The following are also equal, depending on A: + * - DocumentType + * Its name, public ID, and system ID. + * - Element + * Its namespace, namespace prefix, local name, and its attribute list’s size. + * - Attr + * Its namespace, local name, and value. + * - ProcessingInstruction + * Its target and data. + * - Text + * - Comment + * Its data. + */ + if (util_1.Guard.isDocumentTypeNode(a) && util_1.Guard.isDocumentTypeNode(b)) { + if (a._name !== b._name || a._publicId !== b._publicId || + a._systemId !== b._systemId) + return false; + } + else if (util_1.Guard.isElementNode(a) && util_1.Guard.isElementNode(b)) { + if (a._namespace !== b._namespace || a._namespacePrefix !== b._namespacePrefix || + a._localName !== b._localName || + a._attributeList.length !== b._attributeList.length) + return false; + } + else if (util_1.Guard.isAttrNode(a) && util_1.Guard.isAttrNode(b)) { + if (a._namespace !== b._namespace || a._localName !== b._localName || + a._value !== b._value) + return false; + } + else if (util_1.Guard.isProcessingInstructionNode(a) && util_1.Guard.isProcessingInstructionNode(b)) { + if (a._target !== b._target || a._data !== b._data) + return false; + } + else if (util_1.Guard.isCharacterDataNode(a) && util_1.Guard.isCharacterDataNode(b)) { + if (a._data !== b._data) + return false; + } + /** + * 3. If A is an element, each attribute in its attribute list has an attribute + * that equals an attribute in B’s attribute list. + */ + if (util_1.Guard.isElementNode(a) && util_1.Guard.isElementNode(b)) { + var attrMap = {}; + try { + for (var _c = __values(a._attributeList), _d = _c.next(); !_d.done; _d = _c.next()) { + var attrA = _d.value; + attrMap[attrA._localName] = attrA; + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_3) throw e_3.error; } + } + try { + for (var _e = __values(b._attributeList), _f = _e.next(); !_f.done; _f = _e.next()) { + var attrB = _f.value; + var attrA = attrMap[attrB._localName]; + if (!attrA) + return false; + if (!node_equals(attrA, attrB)) + return false; + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (_f && !_f.done && (_b = _e.return)) _b.call(_e); + } + finally { if (e_4) throw e_4.error; } + } + } + /** + * 4. A and B have the same number of children. + * 5. Each child of A equals the child of B at the identical index. + */ + if (a._children.size !== b._children.size) + return false; + var itA = a._children[Symbol.iterator](); + var itB = b._children[Symbol.iterator](); + var resultA = itA.next(); + var resultB = itB.next(); + while (!resultA.done && !resultB.done) { + var child1 = resultA.value; + var child2 = resultB.value; + if (!node_equals(child1, child2)) + return false; + resultA = itA.next(); + resultB = itB.next(); + } + return true; } - -// if ANY of the sets match ALL of its comparators, then pass -Range.prototype.test = function (version) { - if (!version) { - return false - } - - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false +exports.node_equals = node_equals; +/** + * Returns a collection of elements with the given qualified name which are + * descendants of the given root node. + * See: https://dom.spec.whatwg.org/#concept-getelementsbytagname + * + * @param qualifiedName - qualified name + * @param root - root node + */ +function node_listOfElementsWithQualifiedName(qualifiedName, root) { + /** + * 1. If qualifiedName is "*" (U+002A), return a HTMLCollection rooted at + * root, whose filter matches only descendant elements. + * 2. Otherwise, if root’s node document is an HTML document, return a + * HTMLCollection rooted at root, whose filter matches the following + * descendant elements: + * 2.1. Whose namespace is the HTML namespace and whose qualified name is + * qualifiedName, in ASCII lowercase. + * 2.2. Whose namespace is not the HTML namespace and whose qualified name + * is qualifiedName. + * 3. Otherwise, return a HTMLCollection rooted at root, whose filter + * matches descendant elements whose qualified name is qualifiedName. + */ + if (qualifiedName === "*") { + return CreateAlgorithm_1.create_htmlCollection(root); + } + else if (root._nodeDocument._type === "html") { + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + if (ele._namespace === infra_1.namespace.HTML && + ele._qualifiedName === qualifiedName.toLowerCase()) { + return true; + } + else if (ele._namespace !== infra_1.namespace.HTML && + ele._qualifiedName === qualifiedName) { + return true; + } + else { + return false; + } + }); } - } - - for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true + else { + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + return (ele._qualifiedName === qualifiedName); + }); } - } - return false } - -function testSet (set, version, options) { - for (var i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false +exports.node_listOfElementsWithQualifiedName = node_listOfElementsWithQualifiedName; +/** + * Returns a collection of elements with the given namespace which are + * descendants of the given root node. + * See: https://dom.spec.whatwg.org/#concept-getelementsbytagnamens + * + * @param namespace - element namespace + * @param localName - local name + * @param root - root node + */ +function node_listOfElementsWithNamespace(namespace, localName, root) { + /** + * 1. If namespace is the empty string, set it to null. + * 2. If both namespace and localName are "*" (U+002A), return a + * HTMLCollection rooted at root, whose filter matches descendant elements. + * 3. Otherwise, if namespace is "*" (U+002A), return a HTMLCollection + * rooted at root, whose filter matches descendant elements whose local + * name is localName. + * 4. Otherwise, if localName is "*" (U+002A), return a HTMLCollection + * rooted at root, whose filter matches descendant elements whose + * namespace is namespace. + * 5. Otherwise, return a HTMLCollection rooted at root, whose filter + * matches descendant elements whose namespace is namespace and local + * name is localName. + */ + if (namespace === '') + namespace = null; + if (namespace === "*" && localName === "*") { + return CreateAlgorithm_1.create_htmlCollection(root); } - } - - 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 - } - } + else if (namespace === "*") { + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + return (ele._localName === localName); + }); } - - // 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) - } + else if (localName === "*") { + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + return (ele._namespace === namespace); + }); } - }) - return max -} - -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) - } + else { + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + return (ele._localName === localName && ele._namespace === namespace); + }); } - }) - return min -} - -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 - } - - return null -} - -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 - } -} - -// 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) +exports.node_listOfElementsWithNamespace = node_listOfElementsWithNamespace; +/** + * Returns a collection of elements with the given class names which are + * descendants of the given root node. + * See: https://dom.spec.whatwg.org/#concept-getelementsbyclassname + * + * @param namespace - element namespace + * @param localName - local name + * @param root - root node + */ +function node_listOfElementsWithClassNames(classNames, root) { + /** + * 1. Let classes be the result of running the ordered set parser + * on classNames. + * 2. If classes is the empty set, return an empty HTMLCollection. + * 3. Return a HTMLCollection rooted at root, whose filter matches + * descendant elements that have all their classes in classes. + * The comparisons for the classes must be done in an ASCII case-insensitive + * manner if root’s node document’s mode is "quirks", and in a + * case-sensitive manner otherwise. + */ + var classes = OrderedSetAlgorithm_1.orderedSet_parse(classNames); + if (classes.size === 0) { + return CreateAlgorithm_1.create_htmlCollection(root, function () { return false; }); + } + var caseSensitive = (root._nodeDocument._mode !== "quirks"); + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + var eleClasses = ele.classList; + return OrderedSetAlgorithm_1.orderedSet_contains(eleClasses._tokenSet, classes, caseSensitive); + }); } - -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] - - var high = null - var low = null - - 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 the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false +exports.node_listOfElementsWithClassNames = node_listOfElementsWithClassNames; +/** + * Searches for a namespace prefix associated with the given namespace + * starting from the given element through its ancestors. + * + * @param element - an element node to start searching at + * @param namespace - namespace to search for + */ +function node_locateANamespacePrefix(element, namespace) { + /** + * 1. If element’s namespace is namespace and its namespace prefix is not + * null, then return its namespace prefix. + */ + if (element._namespace === namespace && element._namespacePrefix !== null) { + return element._namespacePrefix; } - - // 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 + /** + * 2. If element has an attribute whose namespace prefix is "xmlns" and + * value is namespace, then return element’s first such attribute’s + * local name. + */ + for (var i = 0; i < element._attributeList.length; i++) { + var attr = element._attributeList[i]; + if (attr._namespacePrefix === "xmlns" && attr._value === namespace) { + return attr._localName; + } } - } - 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) + /** + * 3. If element’s parent element is not null, then return the result of + * running locate a namespace prefix on that element using namespace. + */ + if (element._parent && util_1.Guard.isElementNode(element._parent)) { + return node_locateANamespacePrefix(element._parent, namespace); + } + /** + * 4. Return null. + */ + return null; } - -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 - } - - options = options || {} - - 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 +exports.node_locateANamespacePrefix = node_locateANamespacePrefix; +/** + * Searches for a namespace associated with the given namespace prefix + * starting from the given node through its ancestors. + * + * @param node - a node to start searching at + * @param prefix - namespace prefix to search for + */ +function node_locateANamespace(node, prefix) { + if (util_1.Guard.isElementNode(node)) { + /** + * 1. If its namespace is not null and its namespace prefix is prefix, + * then return namespace. + */ + if (node._namespace !== null && node._namespacePrefix === prefix) { + return node._namespace; + } + /** + * 2. If it has an attribute whose namespace is the XMLNS namespace, + * namespace prefix is "xmlns", and local name is prefix, or if prefix + * is null and it has an attribute whose namespace is the XMLNS namespace, + * namespace prefix is null, and local name is "xmlns", then return its + * value if it is not the empty string, and null otherwise. + */ + for (var i = 0; i < node._attributeList.length; i++) { + var attr = node._attributeList[i]; + if (attr._namespace === infra_1.namespace.XMLNS && + attr._namespacePrefix === "xmlns" && + attr._localName === prefix) { + return attr._value || null; + } + if (prefix === null && attr._namespace === infra_1.namespace.XMLNS && + attr._namespacePrefix === null && attr._localName === "xmlns") { + return attr._value || null; + } + } + /** + * 3. If its parent element is null, then return null. + */ + if (node.parentElement === null) + return null; + /** + * 4. Return the result of running locate a namespace on its parent + * element using prefix. + */ + return node_locateANamespace(node.parentElement, prefix); + } + else if (util_1.Guard.isDocumentNode(node)) { + /** + * 1. If its document element is null, then return null. + * 2. Return the result of running locate a namespace on its document + * element using prefix. + */ + if (node.documentElement === null) + return null; + return node_locateANamespace(node.documentElement, prefix); + } + else if (util_1.Guard.isDocumentTypeNode(node) || util_1.Guard.isDocumentFragmentNode(node)) { + return null; + } + else if (util_1.Guard.isAttrNode(node)) { + /** + * 1. If its element is null, then return null. + * 2. Return the result of running locate a namespace on its element + * using prefix. + */ + if (node._element === null) + return null; + return node_locateANamespace(node._element, prefix); + } + else { + /** + * 1. If its parent element is null, then return null. + * 2. Return the result of running locate a namespace on its parent + * element using prefix. + */ + if (!node._parent || !util_1.Guard.isElementNode(node._parent)) + return null; + return node_locateANamespace(node._parent, prefix); } - // 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) } - +exports.node_locateANamespace = node_locateANamespace; +//# sourceMappingURL=NodeAlgorithm.js.map /***/ }), +/* 542 */, +/* 543 */, +/* 544 */, +/* 545 */, +/* 546 */, +/* 547 */, +/* 548 */, +/* 549 */, +/* 550 */, /* 551 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -26837,7 +25557,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -26859,7 +25579,7 @@ const core = __importStar(__webpack_require__(470)); const tc = __importStar(__webpack_require__(139)); const fs_1 = __importDefault(__webpack_require__(747)); const path_1 = __importDefault(__webpack_require__(622)); -const semver_1 = __importDefault(__webpack_require__(876)); +const semver_1 = __importDefault(__webpack_require__(280)); const base_installer_1 = __webpack_require__(83); const constants_1 = __webpack_require__(211); const util_1 = __webpack_require__(322); @@ -26979,15 +25699,7 @@ exports.AdoptDistribution = AdoptDistribution; /***/ }), /* 585 */, -/* 586 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const lt = (a, b, loose) => compare(a, b, loose) < 0 -module.exports = lt - - -/***/ }), +/* 586 */, /* 587 */, /* 588 */, /* 589 */, @@ -27438,15 +26150,7 @@ exports.utf8Decode = utf8Decode; //# sourceMappingURL=index.js.map /***/ }), -/* 593 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compareBuild = __webpack_require__(16) -const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) -module.exports = rsort - - -/***/ }), +/* 593 */, /* 594 */, /* 595 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -28438,439 +27142,7 @@ module.exports = new Schema({ /***/ }), -/* 612 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - -module.exports = Yallist - -Yallist.Node = Node -Yallist.create = Yallist - -function Yallist (list) { - var self = this - if (!(self instanceof Yallist)) { - self = new Yallist() - } - - self.tail = null - self.head = null - self.length = 0 - - if (list && typeof list.forEach === 'function') { - list.forEach(function (item) { - self.push(item) - }) - } else if (arguments.length > 0) { - for (var i = 0, l = arguments.length; i < l; i++) { - self.push(arguments[i]) - } - } - - return self -} - -Yallist.prototype.removeNode = function (node) { - if (node.list !== this) { - throw new Error('removing node which does not belong to this list') - } - - var next = node.next - var prev = node.prev - - if (next) { - next.prev = prev - } - - if (prev) { - prev.next = next - } - - if (node === this.head) { - this.head = next - } - if (node === this.tail) { - this.tail = prev - } - - node.list.length-- - node.next = null - node.prev = null - node.list = null - - return next -} - -Yallist.prototype.unshiftNode = function (node) { - if (node === this.head) { - return - } - - if (node.list) { - node.list.removeNode(node) - } - - var head = this.head - node.list = this - node.next = head - if (head) { - head.prev = node - } - - this.head = node - if (!this.tail) { - this.tail = node - } - this.length++ -} - -Yallist.prototype.pushNode = function (node) { - if (node === this.tail) { - return - } - - if (node.list) { - node.list.removeNode(node) - } - - var tail = this.tail - node.list = this - node.prev = tail - if (tail) { - tail.next = node - } - - this.tail = node - if (!this.head) { - this.head = node - } - this.length++ -} - -Yallist.prototype.push = function () { - for (var i = 0, l = arguments.length; i < l; i++) { - push(this, arguments[i]) - } - return this.length -} - -Yallist.prototype.unshift = function () { - for (var i = 0, l = arguments.length; i < l; i++) { - unshift(this, arguments[i]) - } - return this.length -} - -Yallist.prototype.pop = function () { - if (!this.tail) { - return undefined - } - - var res = this.tail.value - this.tail = this.tail.prev - if (this.tail) { - this.tail.next = null - } else { - this.head = null - } - this.length-- - return res -} - -Yallist.prototype.shift = function () { - if (!this.head) { - return undefined - } - - var res = this.head.value - this.head = this.head.next - if (this.head) { - this.head.prev = null - } else { - this.tail = null - } - this.length-- - return res -} - -Yallist.prototype.forEach = function (fn, thisp) { - thisp = thisp || this - for (var walker = this.head, i = 0; walker !== null; i++) { - fn.call(thisp, walker.value, i, this) - walker = walker.next - } -} - -Yallist.prototype.forEachReverse = function (fn, thisp) { - thisp = thisp || this - for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { - fn.call(thisp, walker.value, i, this) - walker = walker.prev - } -} - -Yallist.prototype.get = function (n) { - for (var i = 0, walker = this.head; walker !== null && i < n; i++) { - // abort out of the list early if we hit a cycle - walker = walker.next - } - if (i === n && walker !== null) { - return walker.value - } -} - -Yallist.prototype.getReverse = function (n) { - for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { - // abort out of the list early if we hit a cycle - walker = walker.prev - } - if (i === n && walker !== null) { - return walker.value - } -} - -Yallist.prototype.map = function (fn, thisp) { - thisp = thisp || this - var res = new Yallist() - for (var walker = this.head; walker !== null;) { - res.push(fn.call(thisp, walker.value, this)) - walker = walker.next - } - return res -} - -Yallist.prototype.mapReverse = function (fn, thisp) { - thisp = thisp || this - var res = new Yallist() - for (var walker = this.tail; walker !== null;) { - res.push(fn.call(thisp, walker.value, this)) - walker = walker.prev - } - return res -} - -Yallist.prototype.reduce = function (fn, initial) { - var acc - var walker = this.head - if (arguments.length > 1) { - acc = initial - } else if (this.head) { - walker = this.head.next - acc = this.head.value - } else { - throw new TypeError('Reduce of empty list with no initial value') - } - - for (var i = 0; walker !== null; i++) { - acc = fn(acc, walker.value, i) - walker = walker.next - } - - return acc -} - -Yallist.prototype.reduceReverse = function (fn, initial) { - var acc - var walker = this.tail - if (arguments.length > 1) { - acc = initial - } else if (this.tail) { - walker = this.tail.prev - acc = this.tail.value - } else { - throw new TypeError('Reduce of empty list with no initial value') - } - - for (var i = this.length - 1; walker !== null; i--) { - acc = fn(acc, walker.value, i) - walker = walker.prev - } - - return acc -} - -Yallist.prototype.toArray = function () { - var arr = new Array(this.length) - for (var i = 0, walker = this.head; walker !== null; i++) { - arr[i] = walker.value - walker = walker.next - } - return arr -} - -Yallist.prototype.toArrayReverse = function () { - var arr = new Array(this.length) - for (var i = 0, walker = this.tail; walker !== null; i++) { - arr[i] = walker.value - walker = walker.prev - } - return arr -} - -Yallist.prototype.slice = function (from, to) { - to = to || this.length - if (to < 0) { - to += this.length - } - from = from || 0 - if (from < 0) { - from += this.length - } - var ret = new Yallist() - if (to < from || to < 0) { - return ret - } - if (from < 0) { - from = 0 - } - if (to > this.length) { - to = this.length - } - for (var i = 0, walker = this.head; walker !== null && i < from; i++) { - walker = walker.next - } - for (; walker !== null && i < to; i++, walker = walker.next) { - ret.push(walker.value) - } - return ret -} - -Yallist.prototype.sliceReverse = function (from, to) { - to = to || this.length - if (to < 0) { - to += this.length - } - from = from || 0 - if (from < 0) { - from += this.length - } - var ret = new Yallist() - if (to < from || to < 0) { - return ret - } - if (from < 0) { - from = 0 - } - if (to > this.length) { - to = this.length - } - for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { - walker = walker.prev - } - for (; walker !== null && i > from; i--, walker = walker.prev) { - ret.push(walker.value) - } - return ret -} - -Yallist.prototype.splice = function (start, deleteCount, ...nodes) { - if (start > this.length) { - start = this.length - 1 - } - if (start < 0) { - start = this.length + start; - } - - for (var i = 0, walker = this.head; walker !== null && i < start; i++) { - walker = walker.next - } - - var ret = [] - for (var i = 0; walker && i < deleteCount; i++) { - ret.push(walker.value) - walker = this.removeNode(walker) - } - if (walker === null) { - walker = this.tail - } - - if (walker !== this.head && walker !== this.tail) { - walker = walker.prev - } - - for (var i = 0; i < nodes.length; i++) { - walker = insert(this, walker, nodes[i]) - } - return ret; -} - -Yallist.prototype.reverse = function () { - var head = this.head - var tail = this.tail - for (var walker = head; walker !== null; walker = walker.prev) { - var p = walker.prev - walker.prev = walker.next - walker.next = p - } - this.head = tail - this.tail = head - return this -} - -function insert (self, node, value) { - var inserted = node === self.head ? - new Node(value, null, node, self) : - new Node(value, node, node.next, self) - - if (inserted.next === null) { - self.tail = inserted - } - if (inserted.prev === null) { - self.head = inserted - } - - self.length++ - - return inserted -} - -function push (self, item) { - self.tail = new Node(item, self.tail, null, self) - if (!self.head) { - self.head = self.tail - } - self.length++ -} - -function unshift (self, item) { - self.head = new Node(item, null, self.head, self) - if (!self.tail) { - self.tail = self.head - } - self.length++ -} - -function Node (value, prev, next, list) { - if (!(this instanceof Node)) { - return new Node(value, prev, next, list) - } - - this.list = list - this.value = value - - if (prev) { - prev.next = this - this.prev = prev - } else { - this.prev = null - } - - if (next) { - next.prev = this - this.next = next - } else { - this.next = null - } -} - -try { - // add if support for Symbol.iterator is present - __webpack_require__(396)(Yallist) -} catch (er) {} - - -/***/ }), +/* 612 */, /* 613 */, /* 614 */ /***/ (function(module) { @@ -29108,15 +27380,7 @@ module.exports = new Type('tag:yaml.org,2002:js/regexp', { /***/ }), -/* 630 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const rcompare = (a, b, loose) => compare(b, a, loose) -module.exports = rcompare - - -/***/ }), +/* 630 */, /* 631 */ /***/ (function(module) { @@ -29763,18 +28027,7 @@ exports.dom = DOMImpl.instance; /***/ }), /* 649 */, -/* 650 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const parse = __webpack_require__(830) -const prerelease = (version, options) => { - const parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} -module.exports = prerelease - - -/***/ }), +/* 650 */, /* 651 */, /* 652 */, /* 653 */, @@ -32731,347 +30984,7 @@ WebIDLAlgorithm_1.idl_defineConst(ElementImpl.prototype, "_nodeType", interfaces /* 699 */, /* 700 */, /* 701 */, -/* 702 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -// A linked list to keep track of recently-used-ness -const Yallist = __webpack_require__(612) - -const MAX = Symbol('max') -const LENGTH = Symbol('length') -const LENGTH_CALCULATOR = Symbol('lengthCalculator') -const ALLOW_STALE = Symbol('allowStale') -const MAX_AGE = Symbol('maxAge') -const DISPOSE = Symbol('dispose') -const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet') -const LRU_LIST = Symbol('lruList') -const CACHE = Symbol('cache') -const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet') - -const naiveLength = () => 1 - -// lruList is a yallist where the head is the youngest -// item, and the tail is the oldest. the list contains the Hit -// objects as the entries. -// Each Hit object has a reference to its Yallist.Node. This -// never changes. -// -// cache is a Map (or PseudoMap) that matches the keys to -// the Yallist.Node object. -class LRUCache { - constructor (options) { - if (typeof options === 'number') - options = { max: options } - - if (!options) - options = {} - - if (options.max && (typeof options.max !== 'number' || options.max < 0)) - throw new TypeError('max must be a non-negative number') - // Kind of weird to have a default max of Infinity, but oh well. - const max = this[MAX] = options.max || Infinity - - const lc = options.length || naiveLength - this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc - this[ALLOW_STALE] = options.stale || false - if (options.maxAge && typeof options.maxAge !== 'number') - throw new TypeError('maxAge must be a number') - this[MAX_AGE] = options.maxAge || 0 - this[DISPOSE] = options.dispose - this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false - this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false - this.reset() - } - - // resize the cache when the max changes. - set max (mL) { - if (typeof mL !== 'number' || mL < 0) - throw new TypeError('max must be a non-negative number') - - this[MAX] = mL || Infinity - trim(this) - } - get max () { - return this[MAX] - } - - set allowStale (allowStale) { - this[ALLOW_STALE] = !!allowStale - } - get allowStale () { - return this[ALLOW_STALE] - } - - set maxAge (mA) { - if (typeof mA !== 'number') - throw new TypeError('maxAge must be a non-negative number') - - this[MAX_AGE] = mA - trim(this) - } - get maxAge () { - return this[MAX_AGE] - } - - // resize the cache when the lengthCalculator changes. - set lengthCalculator (lC) { - if (typeof lC !== 'function') - lC = naiveLength - - if (lC !== this[LENGTH_CALCULATOR]) { - this[LENGTH_CALCULATOR] = lC - this[LENGTH] = 0 - this[LRU_LIST].forEach(hit => { - hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key) - this[LENGTH] += hit.length - }) - } - trim(this) - } - get lengthCalculator () { return this[LENGTH_CALCULATOR] } - - get length () { return this[LENGTH] } - get itemCount () { return this[LRU_LIST].length } - - rforEach (fn, thisp) { - thisp = thisp || this - for (let walker = this[LRU_LIST].tail; walker !== null;) { - const prev = walker.prev - forEachStep(this, fn, walker, thisp) - walker = prev - } - } - - forEach (fn, thisp) { - thisp = thisp || this - for (let walker = this[LRU_LIST].head; walker !== null;) { - const next = walker.next - forEachStep(this, fn, walker, thisp) - walker = next - } - } - - keys () { - return this[LRU_LIST].toArray().map(k => k.key) - } - - values () { - return this[LRU_LIST].toArray().map(k => k.value) - } - - reset () { - if (this[DISPOSE] && - this[LRU_LIST] && - this[LRU_LIST].length) { - this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)) - } - - this[CACHE] = new Map() // hash of items by key - this[LRU_LIST] = new Yallist() // list of items in order of use recency - this[LENGTH] = 0 // length of items in the list - } - - dump () { - return this[LRU_LIST].map(hit => - isStale(this, hit) ? false : { - k: hit.key, - v: hit.value, - e: hit.now + (hit.maxAge || 0) - }).toArray().filter(h => h) - } - - dumpLru () { - return this[LRU_LIST] - } - - set (key, value, maxAge) { - maxAge = maxAge || this[MAX_AGE] - - if (maxAge && typeof maxAge !== 'number') - throw new TypeError('maxAge must be a number') - - const now = maxAge ? Date.now() : 0 - const len = this[LENGTH_CALCULATOR](value, key) - - if (this[CACHE].has(key)) { - if (len > this[MAX]) { - del(this, this[CACHE].get(key)) - return false - } - - const node = this[CACHE].get(key) - const item = node.value - - // dispose of the old one before overwriting - // split out into 2 ifs for better coverage tracking - if (this[DISPOSE]) { - if (!this[NO_DISPOSE_ON_SET]) - this[DISPOSE](key, item.value) - } - - item.now = now - item.maxAge = maxAge - item.value = value - this[LENGTH] += len - item.length - item.length = len - this.get(key) - trim(this) - return true - } - - const hit = new Entry(key, value, len, now, maxAge) - - // oversized objects fall out of cache automatically. - if (hit.length > this[MAX]) { - if (this[DISPOSE]) - this[DISPOSE](key, value) - - return false - } - - this[LENGTH] += hit.length - this[LRU_LIST].unshift(hit) - this[CACHE].set(key, this[LRU_LIST].head) - trim(this) - return true - } - - has (key) { - if (!this[CACHE].has(key)) return false - const hit = this[CACHE].get(key).value - return !isStale(this, hit) - } - - get (key) { - return get(this, key, true) - } - - peek (key) { - return get(this, key, false) - } - - pop () { - const node = this[LRU_LIST].tail - if (!node) - return null - - del(this, node) - return node.value - } - - del (key) { - del(this, this[CACHE].get(key)) - } - - load (arr) { - // reset the cache - this.reset() - - const now = Date.now() - // A previous serialized cache has the most recent items first - for (let l = arr.length - 1; l >= 0; l--) { - const hit = arr[l] - const expiresAt = hit.e || 0 - if (expiresAt === 0) - // the item was created without expiration in a non aged cache - this.set(hit.k, hit.v) - else { - const maxAge = expiresAt - now - // dont add already expired items - if (maxAge > 0) { - this.set(hit.k, hit.v, maxAge) - } - } - } - } - - prune () { - this[CACHE].forEach((value, key) => get(this, key, false)) - } -} - -const get = (self, key, doUse) => { - const node = self[CACHE].get(key) - if (node) { - const hit = node.value - if (isStale(self, hit)) { - del(self, node) - if (!self[ALLOW_STALE]) - return undefined - } else { - if (doUse) { - if (self[UPDATE_AGE_ON_GET]) - node.value.now = Date.now() - self[LRU_LIST].unshiftNode(node) - } - } - return hit.value - } -} - -const isStale = (self, hit) => { - if (!hit || (!hit.maxAge && !self[MAX_AGE])) - return false - - const diff = Date.now() - hit.now - return hit.maxAge ? diff > hit.maxAge - : self[MAX_AGE] && (diff > self[MAX_AGE]) -} - -const trim = self => { - if (self[LENGTH] > self[MAX]) { - for (let walker = self[LRU_LIST].tail; - self[LENGTH] > self[MAX] && walker !== null;) { - // We know that we're about to delete this one, and also - // what the next least recently used key will be, so just - // go ahead and set it now. - const prev = walker.prev - del(self, walker) - walker = prev - } - } -} - -const del = (self, node) => { - if (node) { - const hit = node.value - if (self[DISPOSE]) - self[DISPOSE](hit.key, hit.value) - - self[LENGTH] -= hit.length - self[CACHE].delete(hit.key) - self[LRU_LIST].removeNode(node) - } -} - -class Entry { - constructor (key, value, length, now, maxAge) { - this.key = key - this.value = value - this.length = length - this.now = now - this.maxAge = maxAge || 0 - } -} - -const forEachStep = (self, fn, node, thisp) => { - let hit = node.value - if (isStale(self, hit)) { - del(self, node) - if (!self[ALLOW_STALE]) - hit = undefined - } - if (hit) - fn.call(thisp, hit.value, hit.key, self) -} - -module.exports = LRUCache - - -/***/ }), +/* 702 */, /* 703 */, /* 704 */ /***/ (function(__unusedmodule, exports) { @@ -33498,18 +31411,7 @@ exports.abort_signalAbort = abort_signalAbort; /* 711 */, /* 712 */, /* 713 */, -/* 714 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const parse = __webpack_require__(830) -const valid = (version, options) => { - const v = parse(version, options) - return v ? v.version : null -} -module.exports = valid - - -/***/ }), +/* 714 */, /* 715 */, /* 716 */, /* 717 */, @@ -34007,15 +31909,7 @@ exports.sanitizeInput = sanitizeInput; //# sourceMappingURL=dom.js.map /***/ }), -/* 744 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const major = (a, loose) => new SemVer(a, loose).major -module.exports = major - - -/***/ }), +/* 744 */, /* 745 */, /* 746 */, /* 747 */ @@ -34119,60 +32013,7 @@ exports.MapWriter = MapWriter; /***/ }), /* 751 */, -/* 752 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const eq = __webpack_require__(298) -const neq = __webpack_require__(85) -const gt = __webpack_require__(486) -const gte = __webpack_require__(167) -const lt = __webpack_require__(586) -const lte = __webpack_require__(898) - -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 - - -/***/ }), +/* 752 */, /* 753 */, /* 754 */, /* 755 */, @@ -35551,15 +33392,7 @@ exports.NodeIteratorImpl = NodeIteratorImpl; /***/ }), /* 801 */, /* 802 */, -/* 803 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const minor = (a, loose) => new SemVer(a, loose).minor -module.exports = minor - - -/***/ }), +/* 803 */, /* 804 */, /* 805 */, /* 806 */, @@ -35627,7 +33460,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -35654,10 +33487,12 @@ function run() { const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); const jdkFile = core.getInput(constants.INPUT_JDK_FILE); + const checkLatest = core.getInput(constants.INPUT_CHECK_LATEST); const installerOptions = { architecture, packageType, - version + version, + checkLatest: checkLatest ? false : checkLatest.toLowerCase() === 'true' }; const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile); if (!distribution) { @@ -38452,12 +36287,7 @@ exports.asciiSerializationOfAnOrigin = asciiSerializationOfAnOrigin; /* 815 */, /* 816 */, /* 817 */, -/* 818 */ -/***/ (function(module) { - -module.exports = require("tls"); - -/***/ }), +/* 818 */, /* 819 */, /* 820 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -38575,35 +36405,7 @@ WebIDLAlgorithm_1.idl_defineConst(TextImpl.prototype, "_nodeType", interfaces_1. /***/ }), /* 821 */, -/* 822 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const parse = __webpack_require__(830) -const eq = __webpack_require__(298) - -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 - - -/***/ }), +/* 822 */, /* 823 */, /* 824 */, /* 825 */, @@ -39611,45 +37413,7 @@ exports.event_deactivateAnEventHandler = event_deactivateAnEventHandler; /* 827 */, /* 828 */, /* 829 */, -/* 830 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const {MAX_LENGTH} = __webpack_require__(181) -const { re, t } = __webpack_require__(976) -const SemVer = __webpack_require__(65) - -const parseOptions = __webpack_require__(143) -const parse = (version, options) => { - options = parseOptions(options) - - 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 - - -/***/ }), +/* 830 */, /* 831 */, /* 832 */, /* 833 */, @@ -40878,211 +38642,14 @@ exports.tree_retarget = tree_retarget; //# sourceMappingURL=TreeAlgorithm.js.map /***/ }), -/* 874 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const compare = (a, b, loose) => - new SemVer(a, loose).compare(new SemVer(b, loose)) - -module.exports = compare - - -/***/ }), +/* 874 */, /* 875 */, -/* 876 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -// just pre-load all the stuff that index.js lazily exports -const internalRe = __webpack_require__(976) -module.exports = { - re: internalRe.re, - src: internalRe.src, - tokens: internalRe.t, - SEMVER_SPEC_VERSION: __webpack_require__(181).SEMVER_SPEC_VERSION, - SemVer: __webpack_require__(65), - compareIdentifiers: __webpack_require__(954).compareIdentifiers, - rcompareIdentifiers: __webpack_require__(954).rcompareIdentifiers, - parse: __webpack_require__(830), - valid: __webpack_require__(714), - clean: __webpack_require__(503), - inc: __webpack_require__(928), - diff: __webpack_require__(822), - major: __webpack_require__(744), - minor: __webpack_require__(803), - patch: __webpack_require__(489), - prerelease: __webpack_require__(650), - compare: __webpack_require__(874), - rcompare: __webpack_require__(630), - compareLoose: __webpack_require__(283), - compareBuild: __webpack_require__(16), - sort: __webpack_require__(120), - rsort: __webpack_require__(593), - gt: __webpack_require__(486), - lt: __webpack_require__(586), - eq: __webpack_require__(298), - neq: __webpack_require__(85), - gte: __webpack_require__(167), - lte: __webpack_require__(898), - cmp: __webpack_require__(752), - coerce: __webpack_require__(499), - Comparator: __webpack_require__(536), - Range: __webpack_require__(124), - satisfies: __webpack_require__(310), - toComparators: __webpack_require__(219), - maxSatisfying: __webpack_require__(14), - minSatisfying: __webpack_require__(890), - minVersion: __webpack_require__(960), - validRange: __webpack_require__(480), - outside: __webpack_require__(881), - gtr: __webpack_require__(531), - ltr: __webpack_require__(323), - intersects: __webpack_require__(259), - simplifyRange: __webpack_require__(877), - subset: __webpack_require__(999), -} - - -/***/ }), -/* 877 */ -/***/ (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__(310) -const compare = __webpack_require__(874) -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 -} - - -/***/ }), +/* 876 */, +/* 877 */, /* 878 */, /* 879 */, /* 880 */, -/* 881 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const Comparator = __webpack_require__(536) -const {ANY} = Comparator -const Range = __webpack_require__(124) -const satisfies = __webpack_require__(310) -const gt = __webpack_require__(486) -const lt = __webpack_require__(586) -const lte = __webpack_require__(898) -const gte = __webpack_require__(167) - -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 satisfies 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 - - -/***/ }), +/* 881 */, /* 882 */, /* 883 */, /* 884 */ @@ -41105,7 +38672,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -41352,36 +38919,7 @@ exports.ObjectCache = ObjectCache; //# sourceMappingURL=ObjectCache.js.map /***/ }), -/* 890 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const Range = __webpack_require__(124) -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 - - -/***/ }), +/* 890 */, /* 891 */, /* 892 */, /* 893 */, @@ -41389,15 +38927,7 @@ module.exports = minSatisfying /* 895 */, /* 896 */, /* 897 */, -/* 898 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const compare = __webpack_require__(874) -const lte = (a, b, loose) => compare(a, b, loose) <= 0 -module.exports = lte - - -/***/ }), +/* 898 */, /* 899 */, /* 900 */, /* 901 */, @@ -42217,27 +39747,7 @@ module.exports = new Type('tag:yaml.org,2002:seq', { /* 925 */, /* 926 */, /* 927 */, -/* 928 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) - -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 - - -/***/ }), +/* 928 */, /* 929 */, /* 930 */, /* 931 */, @@ -43553,106 +41063,13 @@ exports.checkBypass = checkBypass; /* 951 */, /* 952 */, /* 953 */, -/* 954 */ -/***/ (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 -} - - -/***/ }), +/* 954 */, /* 955 */, /* 956 */, /* 957 */, /* 958 */, /* 959 */, -/* 960 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const SemVer = __webpack_require__(65) -const Range = __webpack_require__(124) -const gt = __webpack_require__(486) - -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] - - let setMin = null - 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 (!setMin || gt(compver, setMin)) { - setMin = compver - } - break - case '<': - case '<=': - /* Ignore maximum versions */ - break - /* istanbul ignore next */ - default: - throw new Error(`Unexpected operation: ${comparator.operator}`) - } - }) - if (setMin && (!minver || gt(minver, setMin))) - minver = setMin - } - - if (minver && range.test(minver)) { - return minver - } - - return null -} -module.exports = minVersion - - -/***/ }), +/* 960 */, /* 961 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -43943,194 +41360,7 @@ var HowToCompare; /* 973 */, /* 974 */, /* 975 */, -/* 976 */ -/***/ (function(module, exports, __webpack_require__) { - -const { MAX_SAFE_COMPONENT_LENGTH } = __webpack_require__(181) -const debug = __webpack_require__(548) -exports = module.exports = {} - -// 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*$') - - -/***/ }), +/* 976 */, /* 977 */, /* 978 */, /* 979 */ @@ -44489,181 +41719,5 @@ var AbortControllerImpl = /** @class */ (function () { exports.AbortControllerImpl = AbortControllerImpl; //# sourceMappingURL=AbortControllerImpl.js.map -/***/ }), -/* 991 */, -/* 992 */, -/* 993 */, -/* 994 */, -/* 995 */, -/* 996 */, -/* 997 */, -/* 998 */, -/* 999 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -const Range = __webpack_require__(124) -const { ANY } = __webpack_require__(536) -const satisfies = __webpack_require__(310) -const compare = __webpack_require__(874) - -// 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.semver 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 any < or <= 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) => { - if (sub === dom) - return true - - 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 === dom) - return true - - 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 && higher !== gt) - 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 && lower !== lt) - 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 - - /***/ }) /******/ ]); \ No newline at end of file diff --git a/src/constants.ts b/src/constants.ts index 99c8351c5..63d748abf 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -4,6 +4,7 @@ export const INPUT_ARCHITECTURE = 'architecture'; export const INPUT_JAVA_PACKAGE = 'java-package'; export const INPUT_DISTRIBUTION = 'distribution'; export const INPUT_JDK_FILE = 'jdkFile'; +export const INPUT_CHECK_LATEST = 'check-latest'; export const INPUT_SERVER_ID = 'server-id'; export const INPUT_SERVER_USERNAME = 'server-username'; export const INPUT_SERVER_PASSWORD = 'server-password'; diff --git a/src/distributions/base-installer.ts b/src/distributions/base-installer.ts index 8c4698cb0..36634b9a2 100644 --- a/src/distributions/base-installer.ts +++ b/src/distributions/base-installer.ts @@ -12,6 +12,7 @@ export abstract class JavaBase { protected architecture: string; protected packageType: string; protected stable: boolean; + protected checkLatest: boolean; constructor(protected distribution: string, installerOptions: JavaInstallerOptions) { this.http = new httpm.HttpClient('actions/setup-java', undefined, { @@ -24,6 +25,7 @@ export abstract class JavaBase { )); this.architecture = installerOptions.architecture; this.packageType = installerOptions.packageType; + this.checkLatest = !!installerOptions.checkLatest; } protected abstract downloadTool(javaRelease: JavaDownloadRelease): Promise; @@ -31,13 +33,17 @@ export abstract class JavaBase { public async setupJava(): Promise { let foundJava = this.findInToolcache(); - if (foundJava) { + if (foundJava && !this.checkLatest) { core.info(`Resolved Java ${foundJava.version} from tool-cache`); } else { core.info(`Java ${this.version} was not found in tool-cache. Trying to download...`); const javaRelease = await this.findPackageForDownload(this.version); - foundJava = await this.downloadTool(javaRelease); - core.info(`Java ${foundJava.version} was downloaded`); + if (foundJava?.version != javaRelease.version) { + foundJava = await this.downloadTool(javaRelease); + core.info(`Java ${foundJava.version} was downloaded`); + } + + core.info(`Java ${foundJava.version} was resolved`); } core.info(`Setting Java ${foundJava.version} as the default`); diff --git a/src/distributions/base-models.ts b/src/distributions/base-models.ts index d7a7af760..d667377af 100644 --- a/src/distributions/base-models.ts +++ b/src/distributions/base-models.ts @@ -2,6 +2,7 @@ export interface JavaInstallerOptions { version: string; architecture: string; packageType: string; + checkLatest?: boolean; } export interface JavaInstallerResults { diff --git a/src/setup-java.ts b/src/setup-java.ts index 1641b7822..f7e6b9807 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -13,11 +13,13 @@ async function run() { const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); const jdkFile = core.getInput(constants.INPUT_JDK_FILE); + const checkLatest = core.getInput(constants.INPUT_CHECK_LATEST); const installerOptions: JavaInstallerOptions = { architecture, packageType, - version + version, + checkLatest: checkLatest ? false : checkLatest.toLowerCase() === 'true' }; const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile); From b59200979a524cd1c8c7c5bdaba649b045c13a16 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 18 Mar 2021 14:00:18 +0300 Subject: [PATCH 02/13] run prerelease script --- dist/cleanup/index.js | 8238 +++++++++++++------- dist/setup/index.js | 16897 +++++++++++++++++++++++----------------- 2 files changed, 15563 insertions(+), 9572 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index c63c2ae56..be25b9b22 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -948,9 +948,31 @@ class ExecState extends events.EventEmitter { /***/ }), /***/ 16: -/***/ (function(module) { +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +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 + + +/***/ }), + +/***/ 20: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(124) + +// 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 -module.exports = require("tls"); /***/ }), @@ -976,7 +998,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const semver = __importStar(__webpack_require__(280)); +const semver = __importStar(__webpack_require__(550)); const core_1 = __webpack_require__(470); // needs to be require for core node modules to be mocked /* eslint @typescript-eslint/no-require-imports: 0 */ @@ -1065,6 +1087,300 @@ function _readLinuxVersionFile() { exports._readLinuxVersionFile = _readLinuxVersionFile; //# sourceMappingURL=manifest.js.map +/***/ }), + +/***/ 65: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const debug = __webpack_require__(548) +const { MAX_LENGTH, MAX_SAFE_INTEGER } = __webpack_require__(181) +const { re, t } = __webpack_require__(976) + +const parseOptions = __webpack_require__(143) +const { compareIdentifiers } = __webpack_require__(760) +class SemVer { + constructor (version, options) { + options = parseOptions(options) + + 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 + + /***/ }), /***/ 82: @@ -1136,1990 +1452,1906 @@ exports.issueCommand = issueCommand; /***/ }), -/***/ 129: -/***/ (function(module) { +/***/ 120: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compareBuild = __webpack_require__(16) +const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) +module.exports = sort -module.exports = require("child_process"); /***/ }), -/***/ 139: +/***/ 124: /***/ (function(module, __unusedexports, __webpack_require__) { -// Unique ID creation requires a high quality random # generator. In node.js -// this is pretty straight-forward - we use the crypto API. +// hoisted class for cyclic dependency +class Range { + constructor (range, options) { + options = parseOptions(options) + + if (range instanceof Range) { + if ( + range.loose === !!options.loose && + range.includePrerelease === !!options.includePrerelease + ) { + return range + } else { + return new Range(range.raw, options) + } + } -var crypto = __webpack_require__(417); + 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}`) + } + + // if we have any that are not the null set, throw out null sets. + if (this.set.length > 1) { + // keep the first one, in case they're all null sets + const first = this.set[0] + this.set = this.set.filter(c => !isNullSet(c[0])) + if (this.set.length === 0) + this.set = [first] + else if (this.set.length > 1) { + // if we have any that are *, then the range is just * + for (const c of this.set) { + if (c.length === 1 && isAny(c[0])) { + this.set = [c] + break + } + } + } + } -module.exports = function nodeRNG() { - return crypto.randomBytes(16); -}; + this.format() + } + format () { + this.range = this.set + .map((comps) => { + return comps.join(' ').trim() + }) + .join('||') + .trim() + return this.range + } -/***/ }), + toString () { + return this.range + } -/***/ 141: -/***/ (function(__unusedmodule, exports, __webpack_require__) { + parseRange (range) { + range = range.trim() + + // memoize range parsing for performance. + // this is a very hot path, and fully deterministic. + const memoOpts = Object.keys(this.options).join(',') + const memoKey = `parseRange:${memoOpts}:${range}` + const cached = cache.get(memoKey) + if (cached) + return cached + + const loose = this.options.loose + // `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] + const rangeList = range + .split(' ') + .map(comp => parseComparator(comp, this.options)) + .join(' ') + .split(/\s+/) + // >=0.0.0 is equivalent to * + .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)) + + // if any comparators are the null set, then replace with JUST null set + // if more than one comparator, remove any * comparators + // also, don't include the same comparator more than once + const l = rangeList.length + const rangeMap = new Map() + for (const comp of rangeList) { + if (isNullSet(comp)) + return [comp] + rangeMap.set(comp.value, comp) + } + if (rangeMap.size > 1 && rangeMap.has('')) + rangeMap.delete('') + + const result = [...rangeMap.values()] + cache.set(memoKey, result) + return result + } -"use strict"; + 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 + } -var net = __webpack_require__(631); -var tls = __webpack_require__(16); -var http = __webpack_require__(605); -var https = __webpack_require__(211); -var events = __webpack_require__(614); -var assert = __webpack_require__(357); -var util = __webpack_require__(669); + 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 -exports.httpOverHttp = httpOverHttp; -exports.httpsOverHttp = httpsOverHttp; -exports.httpOverHttps = httpOverHttps; -exports.httpsOverHttps = httpsOverHttps; +const LRU = __webpack_require__(702) +const cache = new LRU({ max: 1000 }) +const parseOptions = __webpack_require__(143) +const Comparator = __webpack_require__(174) +const debug = __webpack_require__(548) +const SemVer = __webpack_require__(65) +const { + re, + t, + comparatorTrimReplace, + tildeTrimReplace, + caretTrimReplace +} = __webpack_require__(976) -function httpOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - return agent; -} +const isNullSet = c => c.value === '<0.0.0-0' +const isAny = c => c.value === '' -function httpsOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} +// 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() -function httpOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - return agent; + while (result && remainingComparators.length) { + result = remainingComparators.every((otherComparator) => { + return testComparator.intersects(otherComparator, options) + }) + + testComparator = remainingComparators.pop() + } + + return result } -function httpsOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; +// 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 === '*' -function TunnelingAgent(options) { - var self = this; - self.options = options || {}; - self.proxyOptions = self.options.proxy || {}; - self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; - self.requests = []; - self.sockets = []; +// ~, ~> --> * (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(' ') - self.on('free', function onFree(socket, host, port, localAddress) { - var options = toOptions(host, port, localAddress); - for (var i = 0, len = self.requests.length; i < len; ++i) { - var pending = self.requests[i]; - if (pending.host === options.host && pending.port === options.port) { - // Detect the request to connect same origin server, - // reuse the connection. - self.requests.splice(i, 1); - pending.request.onSocket(socket); - return; - } +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` } - socket.destroy(); - self.removeSocket(socket); - }); + + debug('tilde return', ret) + return ret + }) } -util.inherits(TunnelingAgent, events.EventEmitter); -TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { - var self = this; - var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); +// ^ --> * (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(' ') - if (self.sockets.length >= this.maxSockets) { - // We are over limit so we'll add it to the queue. - self.requests.push(options); - return; - } +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 we are under maxSockets create a new one. - self.createSocket(options, function(socket) { - socket.on('free', onFree); - socket.on('close', onCloseOrRemove); - socket.on('agentRemove', onCloseOrRemove); - req.onSocket(socket); - - function onFree() { - self.emit('free', socket, options); + 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` + } } - function onCloseOrRemove(err) { - self.removeSocket(socket); - socket.removeListener('free', onFree); - socket.removeListener('close', onCloseOrRemove); - socket.removeListener('agentRemove', onCloseOrRemove); - } - }); -}; + debug('caret return', ret) + return ret + }) +} -TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { - var self = this; - var placeholder = {}; - self.sockets.push(placeholder); +const replaceXRanges = (comp, options) => { + debug('replaceXRanges', comp, options) + return comp.split(/\s+/).map((comp) => { + return replaceXRange(comp, options) + }).join(' ') +} - var connectOptions = mergeOptions({}, self.proxyOptions, { - method: 'CONNECT', - path: options.host + ':' + options.port, - agent: false, - headers: { - host: options.host + ':' + options.port +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 (options.localAddress) { - connectOptions.localAddress = options.localAddress; - } - if (connectOptions.proxyAuth) { - connectOptions.headers = connectOptions.headers || {}; - connectOptions.headers['Proxy-Authorization'] = 'Basic ' + - new Buffer(connectOptions.proxyAuth).toString('base64'); - } - debug('making CONNECT request'); - var connectReq = self.request(connectOptions); - connectReq.useChunkedEncodingByDefault = false; // for v0.6 - connectReq.once('response', onResponse); // for v0.6 - connectReq.once('upgrade', onUpgrade); // for v0.6 - connectReq.once('connect', onConnect); // for v0.7 or later - connectReq.once('error', onError); - connectReq.end(); + // 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' : '' - function onResponse(res) { - // Very hacky. This is necessary to avoid http-parser leaks. - res.upgrade = true; - } + 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 - function onUpgrade(res, socket, head) { - // Hacky. - process.nextTick(function() { - onConnect(res, socket, head); - }); - } + 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 + } + } - function onConnect(res, socket, head) { - connectReq.removeAllListeners(); - socket.removeAllListeners(); + if (gtlt === '<') + pr = '-0' - if (res.statusCode !== 200) { - debug('tunneling socket could not be established, statusCode=%d', - res.statusCode); - socket.destroy(); - var error = new Error('tunneling socket could not be established, ' + - 'statusCode=' + res.statusCode); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - if (head.length > 0) { - debug('got illegal response body from proxy'); - socket.destroy(); - var error = new Error('got illegal response body from proxy'); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; + 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('tunneling connection has established'); - self.sockets[self.sockets.indexOf(placeholder)] = socket; - return cb(socket); - } - - function onError(cause) { - connectReq.removeAllListeners(); - - debug('tunneling socket could not be established, cause=%s\n', - cause.message, cause.stack); - var error = new Error('tunneling socket could not be established, ' + - 'cause=' + cause.message); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - } -}; -TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { - var pos = this.sockets.indexOf(socket) - if (pos === -1) { - return; - } - this.sockets.splice(pos, 1); + debug('xRange return', ret) - var pending = this.requests.shift(); - if (pending) { - // If we have pending requests and a socket gets closed a new one - // needs to be created to take over in the pool for the one that closed. - this.createSocket(pending, function(socket) { - pending.request.onSocket(socket); - }); - } -}; + return ret + }) +} -function createSecureSocket(options, cb) { - var self = this; - TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { - var hostHeader = options.request.getHeader('host'); - var tlsOptions = mergeOptions({}, self.options, { - socket: socket, - servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host - }); +// 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], '') +} - // 0 is dummy port for v0.6 - var secureSocket = tls.connect(0, tlsOptions); - self.sockets[self.sockets.indexOf(socket)] = secureSocket; - cb(secureSocket); - }); +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' : ''}` + } -function toOptions(host, port, localAddress) { - if (typeof host === 'string') { // since v0.10 - return { - host: host, - port: port, - localAddress: localAddress - }; + 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 host; // for v0.11 or later + + return (`${from} ${to}`).trim() } -function mergeOptions(target) { - for (var i = 1, len = arguments.length; i < len; ++i) { - var overrides = arguments[i]; - if (typeof overrides === 'object') { - var keys = Object.keys(overrides); - for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { - var k = keys[j]; - if (overrides[k] !== undefined) { - target[k] = overrides[k]; - } - } +const testSet = (set, version, options) => { + for (let i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false } } - return target; -} + 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 + } -var debug; -if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { - debug = function() { - var args = Array.prototype.slice.call(arguments); - if (typeof args[0] === 'string') { - args[0] = 'TUNNEL: ' + args[0]; - } else { - args.unshift('TUNNEL:'); + 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 + } + } } - console.error.apply(console, args); + + // Version has a -pre, but it's not one of the ones we like. + return false } -} else { - debug = function() {}; + + return true } -exports.debug = debug; // for test /***/ }), -/***/ 211: +/***/ 129: /***/ (function(module) { -module.exports = require("https"); +module.exports = require("child_process"); /***/ }), -/***/ 219: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/***/ 139: +/***/ (function(module, __unusedexports, __webpack_require__) { -"use strict"; +// Unique ID creation requires a high quality random # generator. In node.js +// this is pretty straight-forward - we use the crypto API. -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 (k !== "default" && 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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); +var crypto = __webpack_require__(417); + +module.exports = function nodeRNG() { + return crypto.randomBytes(16); }; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(__webpack_require__(470)); -const gpg = __importStar(__webpack_require__(884)); -const constants = __importStar(__webpack_require__(694)); -function run() { - return __awaiter(this, void 0, void 0, function* () { - if (core.getInput(constants.INPUT_GPG_PRIVATE_KEY, { required: false })) { - core.info('Removing private key from keychain'); - try { - const keyFingerprint = core.getState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT); - yield gpg.deleteKey(keyFingerprint); - } - catch (error) { - core.setFailed('Failed to remove private key'); - } - } - }); -} -run(); /***/ }), -/***/ 280: -/***/ (function(module, exports) { +/***/ 141: +/***/ (function(__unusedmodule, exports, __webpack_require__) { -exports = module.exports = SemVer +"use strict"; -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 () {} -} -// 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' +var net = __webpack_require__(631); +var tls = __webpack_require__(818); +var http = __webpack_require__(605); +var https = __webpack_require__(211); +var events = __webpack_require__(614); +var assert = __webpack_require__(357); +var util = __webpack_require__(669); -var MAX_LENGTH = 256 -var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 -// Max safe segment length for coercion. -var MAX_SAFE_COMPONENT_LENGTH = 16 +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; -// The actual regexps go on exports.re -var re = exports.re = [] -var src = exports.src = [] -var t = exports.tokens = {} -var R = 0 -function tok (n) { - t[n] = R++ +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; } -// The following Regular Expressions can be used for tokenizing, -// validating, and parsing SemVer version strings. +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} -// ## Numeric Identifier -// A single `0`, or a non-zero digit followed by zero or more digits. +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; +} -tok('NUMERICIDENTIFIER') -src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' -tok('NUMERICIDENTIFIERLOOSE') -src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+' +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} -// ## Non-numeric Identifier -// Zero or more digits, followed by a letter or hyphen, and then zero or -// more letters, digits, or hyphens. -tok('NONNUMERICIDENTIFIER') -src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' +function TunnelingAgent(options) { + var self = this; + self.options = options || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; -// ## Main Version -// Three dot-separated numeric identifiers. + self.on('free', function onFree(socket, host, port, localAddress) { + var options = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options.host && pending.port === options.port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } + } + socket.destroy(); + self.removeSocket(socket); + }); +} +util.inherits(TunnelingAgent, events.EventEmitter); -tok('MAINVERSION') -src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')' +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); -tok('MAINVERSIONLOOSE') -src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; + } -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. + // If we are under maxSockets create a new one. + self.createSocket(options, function(socket) { + socket.on('free', onFree); + socket.on('close', onCloseOrRemove); + socket.on('agentRemove', onCloseOrRemove); + req.onSocket(socket); -tok('PRERELEASEIDENTIFIER') -src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' + function onFree() { + self.emit('free', socket, options); + } -tok('PRERELEASEIDENTIFIERLOOSE') -src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); -tok('PRERELEASE') -src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: 'CONNECT', + path: options.host + ':' + options.port, + agent: false, + headers: { + host: options.host + ':' + options.port + } + }); + if (options.localAddress) { + connectOptions.localAddress = options.localAddress; + } + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64'); + } -tok('PRERELEASELOOSE') -src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' + debug('making CONNECT request'); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; // for v0.6 + connectReq.once('response', onResponse); // for v0.6 + connectReq.once('upgrade', onUpgrade); // for v0.6 + connectReq.once('connect', onConnect); // for v0.7 or later + connectReq.once('error', onError); + connectReq.end(); -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } -tok('BUILDIDENTIFIER') -src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); + } -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); -tok('BUILD') -src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] + - '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))' + if (res.statusCode !== 200) { + debug('tunneling socket could not be established, statusCode=%d', + res.statusCode); + socket.destroy(); + var error = new Error('tunneling socket could not be established, ' + + 'statusCode=' + res.statusCode); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + if (head.length > 0) { + debug('got illegal response body from proxy'); + socket.destroy(); + var error = new Error('got illegal response body from proxy'); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + debug('tunneling connection has established'); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + return cb(socket); + } -// ## Full Version String -// A main version, followed optionally by a pre-release version and -// build metadata. + function onError(cause) { + connectReq.removeAllListeners(); -// 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. + debug('tunneling socket could not be established, cause=%s\n', + cause.message, cause.stack); + var error = new Error('tunneling socket could not be established, ' + + 'cause=' + cause.message); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + } +}; -tok('FULL') -tok('FULLPLAIN') -src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + - src[t.PRERELEASE] + '?' + - src[t.BUILD] + '?' +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; + } + this.sockets.splice(pos, 1); -src[t.FULL] = '^' + src[t.FULLPLAIN] + '$' + var pending = this.requests.shift(); + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket); + }); + } +}; -// 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] + '?' +function createSecureSocket(options, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + var hostHeader = options.request.getHeader('host'); + var tlsOptions = mergeOptions({}, self.options, { + socket: socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host + }); -tok('LOOSE') -src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); +} -tok('GTLT') -src[t.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. -tok('XRANGEIDENTIFIERLOOSE') -src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' -tok('XRANGEIDENTIFIER') -src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' +function toOptions(host, port, localAddress) { + if (typeof host === 'string') { // since v0.10 + return { + host: host, + port: port, + localAddress: localAddress + }; + } + return host; // for v0.11 or later +} -tok('XRANGEPLAIN') -src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:' + src[t.PRERELEASE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === 'object') { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== undefined) { + target[k] = overrides[k]; + } + } + } + } + return target; +} -tok('XRANGEPLAINLOOSE') -src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:' + src[t.PRERELEASELOOSE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' -tok('XRANGE') -src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' -tok('XRANGELOOSE') -src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' +var debug; +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0]; + } else { + args.unshift('TUNNEL:'); + } + console.error.apply(console, args); + } +} else { + debug = function() {}; +} +exports.debug = debug; // for test -// 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') -// Tilde ranges. -// Meaning is "reasonably at or greater than" -tok('LONETILDE') -src[t.LONETILDE] = '(?:~>?)' +/***/ }), -tok('TILDETRIM') -src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' -re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') -var tildeTrimReplace = '$1~' +/***/ 143: +/***/ (function(module) { -tok('TILDE') -src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' -tok('TILDELOOSE') -src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' +// parse out just the options we care about so we always get a consistent +// obj with keys in a consistent order. +const opts = ['includePrerelease', 'loose', 'rtl'] +const parseOptions = options => + !options ? {} + : typeof options !== 'object' ? { loose: true } + : opts.filter(k => options[k]).reduce((options, k) => { + options[k] = true + return options + }, {}) +module.exports = parseOptions -// Caret ranges. -// Meaning is "at least and backwards compatible with" -tok('LONECARET') -src[t.LONECARET] = '(?:\\^)' -tok('CARETTRIM') -src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' -re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') -var caretTrimReplace = '$1^' +/***/ }), -tok('CARET') -src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' -tok('CARETLOOSE') -src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' +/***/ 164: +/***/ (function(module, __unusedexports, __webpack_require__) { -// 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] + ')$|^$' +const SemVer = __webpack_require__(65) +const Range = __webpack_require__(124) +const gt = __webpack_require__(486) -// 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] + ')' +const minVersion = (range, loose) => { + range = new Range(range, loose) -// this one has to use the /g flag -re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') -var comparatorTrimReplace = '$1$2$3' + let minver = new SemVer('0.0.0') + if (range.test(minver)) { + return minver + } -// 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*$' + minver = new SemVer('0.0.0-0') + if (range.test(minver)) { + return minver + } -tok('HYPHENRANGELOOSE') -src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s*$' - -// Star ranges basically just allow anything at all. -tok('STAR') -src[t.STAR] = '(<|>)?=?\\s*\\*' + minver = null + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] -// 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]) + let setMin = null + 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 (!setMin || gt(compver, setMin)) { + setMin = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error(`Unexpected operation: ${comparator.operator}`) + } + }) + if (setMin && (!minver || gt(minver, setMin))) + minver = setMin } -} -exports.parse = parse -function parse (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } + if (minver && range.test(minver)) { + return minver } - if (version instanceof SemVer) { - return version - } + return null +} +module.exports = minVersion - if (typeof version !== 'string') { - return null - } - if (version.length > MAX_LENGTH) { - return null - } +/***/ }), - var r = options.loose ? re[t.LOOSE] : re[t.FULL] - if (!r.test(version)) { - return null - } +/***/ 167: +/***/ (function(module, __unusedexports, __webpack_require__) { - try { - return new SemVer(version, options) - } catch (er) { - return null - } -} +const compare = __webpack_require__(874) +const gte = (a, b, loose) => compare(a, b, loose) >= 0 +module.exports = gte -exports.valid = valid -function valid (version, options) { - var v = parse(version, options) - return v ? v.version : null -} -exports.clean = clean -function clean (version, options) { - var s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null -} +/***/ }), -exports.SemVer = SemVer +/***/ 174: +/***/ (function(module, __unusedexports, __webpack_require__) { -function SemVer (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } +const ANY = Symbol('SemVer ANY') +// hoisted class for cyclic dependency +class Comparator { + static get ANY () { + return ANY } - if (version instanceof SemVer) { - if (version.loose === options.loose) { - return version + constructor (comp, options) { + options = parseOptions(options) + + 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 { - version = version.version + this.value = this.operator + this.semver.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('comp', this) } - if (!(this instanceof SemVer)) { - return new SemVer(version, options) - } + parse (comp) { + const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + const m = comp.match(r) - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose + if (!m) { + throw new TypeError(`Invalid comparator: ${comp}`) + } - var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]) + this.operator = m[1] !== undefined ? m[1] : '' + if (this.operator === '=') { + this.operator = '' + } - if (!m) { - throw new TypeError('Invalid Version: ' + version) + // 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) + } } - this.raw = version + toString () { + return this.value + } - // these are actually numbers - this.major = +m[1] - this.minor = +m[2] - this.patch = +m[3] + test (version) { + debug('Comparator.test', version, this.options.loose) - if (this.major > MAX_SAFE_INTEGER || this.major < 0) { - throw new TypeError('Invalid major version') - } + if (this.semver === ANY || version === ANY) { + return true + } - if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) { - throw new TypeError('Invalid minor version') - } + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } - if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) { - throw new TypeError('Invalid patch version') + return cmp(version, this.operator, this.semver, this.options) } - // numberify any prerelease numeric ids - if (!m[4]) { - this.prerelease = [] - } 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 - } + intersects (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } - return id - }) - } + } - this.build = m[5] ? m[5].split('.') : [] - this.format() -} + 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 === '>') -SemVer.prototype.format = function () { - this.version = this.major + '.' + this.minor + '.' + this.patch - if (this.prerelease.length) { - this.version += '-' + this.prerelease.join('.') + return ( + sameDirectionIncreasing || + sameDirectionDecreasing || + (sameSemVer && differentDirectionsInclusive) || + oppositeDirectionsLessThan || + oppositeDirectionsGreaterThan + ) } - return this.version } -SemVer.prototype.toString = function () { - return this.version -} +module.exports = Comparator -SemVer.prototype.compare = function (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +const parseOptions = __webpack_require__(143) +const {re, t} = __webpack_require__(976) +const cmp = __webpack_require__(752) +const debug = __webpack_require__(548) +const SemVer = __webpack_require__(65) +const Range = __webpack_require__(124) - return this.compareMain(other) || this.comparePre(other) -} -SemVer.prototype.compareMain = function (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) -} +/***/ 181: +/***/ (function(module) { -SemVer.prototype.comparePre = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } +// 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' - // 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 - } +const MAX_LENGTH = 256 +const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 - 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) +// 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 } -SemVer.prototype.compareBuild = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - 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) -} +/***/ }), -// 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 +/***/ 211: +/***/ (function(module) { - 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 +module.exports = require("https"); - default: - throw new Error('invalid increment argument: ' + release) - } - this.format() - this.raw = this.version - return this -} +/***/ }), -exports.inc = inc -function inc (version, release, loose, identifier) { - if (typeof (loose) === 'string') { - identifier = loose - loose = undefined - } +/***/ 219: +/***/ (function(__unusedmodule, exports, __webpack_require__) { - try { - return new SemVer(version, loose).inc(release, identifier).version - } catch (er) { - return null - } -} +"use strict"; -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 +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 (k !== "default" && Object.prototype.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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(__webpack_require__(470)); +const gpg = __importStar(__webpack_require__(884)); +const constants = __importStar(__webpack_require__(694)); +function run() { + return __awaiter(this, void 0, void 0, function* () { + if (core.getInput(constants.INPUT_GPG_PRIVATE_KEY, { required: false })) { + core.info('Removing private key from keychain'); + try { + const keyFingerprint = core.getState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT); + yield gpg.deleteKey(keyFingerprint); + } + catch (error) { + core.setFailed('Failed to remove private key'); + } } - } - } - return defaultResult // may be undefined - } + }); } +run(); -exports.compareIdentifiers = compareIdentifiers -var numeric = /^[0-9]+$/ -function compareIdentifiers (a, b) { - var anum = numeric.test(a) - var bnum = numeric.test(b) +/***/ }), - if (anum && bnum) { - a = +a - b = +b - } +/***/ 259: +/***/ (function(module, __unusedexports, __webpack_require__) { - return a === b ? 0 - : (anum && !bnum) ? -1 - : (bnum && !anum) ? 1 - : a < b ? -1 - : 1 +const Range = __webpack_require__(124) +const intersects = (r1, r2, options) => { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) } +module.exports = intersects -exports.rcompareIdentifiers = rcompareIdentifiers -function rcompareIdentifiers (a, b) { - return compareIdentifiers(b, a) -} -exports.major = major -function major (a, loose) { - return new SemVer(a, loose).major -} +/***/ }), -exports.minor = minor -function minor (a, loose) { - return new SemVer(a, loose).minor -} +/***/ 283: +/***/ (function(module, __unusedexports, __webpack_require__) { -exports.patch = patch -function patch (a, loose) { - return new SemVer(a, loose).patch -} +const compare = __webpack_require__(874) +const compareLoose = (a, b) => compare(a, b, true) +module.exports = compareLoose -exports.compare = compare -function compare (a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)) -} -exports.compareLoose = compareLoose -function compareLoose (a, b) { - return compare(a, b, true) -} +/***/ }), -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) -} +/***/ 298: +/***/ (function(module, __unusedexports, __webpack_require__) { -exports.rcompare = rcompare -function rcompare (a, b, loose) { - return compare(b, a, loose) -} +const compare = __webpack_require__(874) +const eq = (a, b, loose) => compare(a, b, loose) === 0 +module.exports = eq -exports.sort = sort -function sort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(a, b, loose) - }) -} -exports.rsort = rsort -function rsort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(b, a, loose) - }) -} +/***/ }), -exports.gt = gt -function gt (a, b, loose) { - return compare(a, b, loose) > 0 -} +/***/ 310: +/***/ (function(module, __unusedexports, __webpack_require__) { -exports.lt = lt -function lt (a, b, loose) { - return compare(a, b, loose) < 0 +const Range = __webpack_require__(124) +const satisfies = (version, range, options) => { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) } +module.exports = satisfies -exports.eq = eq -function eq (a, b, loose) { - return compare(a, b, loose) === 0 -} - -exports.neq = neq -function neq (a, b, loose) { - return compare(a, b, loose) !== 0 -} -exports.gte = gte -function gte (a, b, loose) { - return compare(a, b, loose) >= 0 -} +/***/ }), -exports.lte = lte -function lte (a, b, loose) { - return compare(a, b, loose) <= 0 -} +/***/ 322: +/***/ (function(__unusedmodule, exports, __webpack_require__) { -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 +"use strict"; - case '!==': - if (typeof a === 'object') - a = a.version - if (typeof b === 'object') - b = b.version - return a !== b +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 (k !== "default" && Object.prototype.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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +const os_1 = __importDefault(__webpack_require__(87)); +const path_1 = __importDefault(__webpack_require__(622)); +const fs = __importStar(__webpack_require__(747)); +const semver = __importStar(__webpack_require__(876)); +const core = __importStar(__webpack_require__(470)); +const tc = __importStar(__webpack_require__(533)); +function getTempDir() { + let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); + return tempDirectory; +} +exports.getTempDir = getTempDir; +function getBooleanInput(inputName, defaultValue = false) { + return (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'; +} +exports.getBooleanInput = getBooleanInput; +function getVersionFromToolcachePath(toolPath) { + if (toolPath) { + return path_1.default.basename(path_1.default.dirname(toolPath)); + } + return toolPath; +} +exports.getVersionFromToolcachePath = getVersionFromToolcachePath; +function extractJdkFile(toolPath, extension) { + return __awaiter(this, void 0, void 0, function* () { + if (!extension) { + extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); + if (extension.startsWith('.')) { + extension = extension.substring(1); + } + } + switch (extension) { + case 'tar.gz': + case 'tar': + return yield tc.extractTar(toolPath); + case 'zip': + return yield tc.extractZip(toolPath); + default: + return yield tc.extract7z(toolPath); + } + }); +} +exports.extractJdkFile = extractJdkFile; +function getDownloadArchiveExtension() { + return process.platform === 'win32' ? 'zip' : 'tar.gz'; +} +exports.getDownloadArchiveExtension = getDownloadArchiveExtension; +function isVersionSatisfies(range, version) { + var _a; + if (semver.valid(range)) { + // if full version with build digit is provided as a range (such as '1.2.3+4') + // we should check for exact equal via compareBuild + // since semver.satisfies doesn't handle 4th digit + const semRange = semver.parse(range); + if (semRange && ((_a = semRange.build) === null || _a === void 0 ? void 0 : _a.length) > 0) { + return semver.compareBuild(range, version) === 0; + } + } + return semver.satisfies(version, range); +} +exports.isVersionSatisfies = isVersionSatisfies; +function getToolcachePath(toolName, version, architecture) { + var _a; + const toolcacheRoot = (_a = process.env['RUNNER_TOOL_CACHE']) !== null && _a !== void 0 ? _a : ''; + const fullPath = path_1.default.join(toolcacheRoot, toolName, version, architecture); + if (fs.existsSync(fullPath)) { + return fullPath; + } + return null; +} +exports.getToolcachePath = getToolcachePath; - case '': - case '=': - case '==': - return eq(a, b, loose) - case '!=': - return neq(a, b, loose) +/***/ }), - case '>': - return gt(a, b, loose) +/***/ 323: +/***/ (function(module, __unusedexports, __webpack_require__) { - case '>=': - return gte(a, b, loose) +const outside = __webpack_require__(462) +// 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 - case '<': - return lt(a, b, loose) - case '<=': - return lte(a, b, loose) +/***/ }), - default: - throw new TypeError('Invalid operator: ' + op) - } -} +/***/ 357: +/***/ (function(module) { -exports.Comparator = Comparator -function Comparator (comp, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } +module.exports = require("assert"); - if (comp instanceof Comparator) { - if (comp.loose === !!options.loose) { - return comp - } else { - comp = comp.value - } - } +/***/ }), - if (!(this instanceof Comparator)) { - return new Comparator(comp, options) - } +/***/ 396: +/***/ (function(module) { - debug('comparator', comp, options) - this.options = options - this.loose = !!options.loose - this.parse(comp) +"use strict"; - if (this.semver === ANY) { - this.value = '' - } else { - this.value = this.operator + this.semver.version +module.exports = function (Yallist) { + Yallist.prototype[Symbol.iterator] = function* () { + for (let walker = this.head; walker; walker = walker.next) { + yield walker.value + } } - - debug('comp', this) } -var ANY = {} -Comparator.prototype.parse = function (comp) { - var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var 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) - } -} +/***/ 413: +/***/ (function(module, __unusedexports, __webpack_require__) { -Comparator.prototype.toString = function () { - return this.value -} +module.exports = __webpack_require__(141); -Comparator.prototype.test = function (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 - } - } +/***/ 417: +/***/ (function(module) { - return cmp(version, this.operator, this.semver, this.options) -} +module.exports = require("crypto"); -Comparator.prototype.intersects = function (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } +/***/ }), - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } +/***/ 431: +/***/ (function(__unusedmodule, exports, __webpack_require__) { - var rangeTmp +"use strict"; - 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) - } - - 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 +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; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); +/** + * Commands + * + * Command Format: + * ::name key=value,key=value::message + * + * Examples: + * ::warning::This is the message + * ::set-env name=MY_VAR::some value + */ +function issueCommand(command, properties, message) { + const cmd = new Command(command, properties, message); + process.stdout.write(cmd.toString() + os.EOL); } - -exports.Range = Range -function Range (range, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false +exports.issueCommand = issueCommand; +function issue(name, message = '') { + issueCommand(name, {}, message); +} +exports.issue = issue; +const CMD_STRING = '::'; +class Command { + constructor(command, properties, message) { + if (!command) { + command = 'missing.command'; + } + this.command = command; + this.properties = properties; + this.message = message; } - } - - if (range instanceof Range) { - if (range.loose === !!options.loose && - range.includePrerelease === !!options.includePrerelease) { - return range - } else { - return new Range(range.raw, options) + toString() { + let cmdStr = CMD_STRING + this.command; + if (this.properties && Object.keys(this.properties).length > 0) { + cmdStr += ' '; + let first = true; + for (const key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + const val = this.properties[key]; + if (val) { + if (first) { + first = false; + } + else { + cmdStr += ','; + } + cmdStr += `${key}=${escapeProperty(val)}`; + } + } + } + } + cmdStr += `${CMD_STRING}${escapeData(this.message)}`; + return cmdStr; } - } +} +function escapeData(s) { + return utils_1.toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A'); +} +function escapeProperty(s) { + return utils_1.toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A') + .replace(/:/g, '%3A') + .replace(/,/g, '%2C'); +} +//# sourceMappingURL=command.js.map - if (range instanceof Comparator) { - return new Range(range.value, options) - } +/***/ }), - if (!(this instanceof Range)) { - return new Range(range, options) - } +/***/ 462: +/***/ (function(module, __unusedexports, __webpack_require__) { - this.options = options - this.loose = !!options.loose - this.includePrerelease = !!options.includePrerelease +const SemVer = __webpack_require__(65) +const Comparator = __webpack_require__(174) +const {ANY} = Comparator +const Range = __webpack_require__(124) +const satisfies = __webpack_require__(310) +const gt = __webpack_require__(486) +const lt = __webpack_require__(586) +const lte = __webpack_require__(898) +const gte = __webpack_require__(167) + +const outside = (version, range, hilo, options) => { + version = new SemVer(version, options) + range = new Range(range, options) - // 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 - }) + 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 (!this.set.length) { - throw new TypeError('Invalid SemVer Range: ' + range) + // If it satisfies the range it is not outside + if (satisfies(version, range, options)) { + return false } - this.format() -} + // From now on, variable terms are as if we're in "gtr" mode. + // but note that everything is flipped for the "ltr" function. -Range.prototype.format = function () { - this.range = this.set.map(function (comps) { - return comps.join(' ').trim() - }).join('||').trim() - return this.range -} + for (let i = 0; i < range.set.length; ++i) { + const comparators = range.set[i] -Range.prototype.toString = function () { - return this.range -} + let high = null + let low = null -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]) + 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 + } + }) - // `~ 1.2.3` => `~1.2.3` - range = range.replace(re[t.TILDETRIM], tildeTrimReplace) + // If the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false + } - // `^ 1.2.3` => `^1.2.3` - range = range.replace(re[t.CARETTRIM], caretTrimReplace) + // 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 +} - // normalize spaces - range = range.split(/\s+/).join(' ') +module.exports = outside - // At this point, the range is completely trimmed and - // ready to be split into comparators. - 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) +/***/ }), - return set -} +/***/ 470: +/***/ (function(__unusedmodule, exports, __webpack_require__) { -Range.prototype.intersects = function (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') - } +"use strict"; - 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) - }) - }) - ) - }) - ) - }) +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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + 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; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const command_1 = __webpack_require__(431); +const file_command_1 = __webpack_require__(102); +const utils_1 = __webpack_require__(82); +const os = __importStar(__webpack_require__(87)); +const path = __importStar(__webpack_require__(622)); +/** + * The code to exit an action + */ +var ExitCode; +(function (ExitCode) { + /** + * A code indicating that the action was successful + */ + ExitCode[ExitCode["Success"] = 0] = "Success"; + /** + * A code indicating that the action was a failure + */ + ExitCode[ExitCode["Failure"] = 1] = "Failure"; +})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); +//----------------------------------------------------------------------- +// Variables +//----------------------------------------------------------------------- +/** + * Sets env variable for this action and future actions in the job + * @param name the name of the variable to set + * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function exportVariable(name, val) { + const convertedVal = utils_1.toCommandValue(val); + process.env[name] = convertedVal; + const filePath = process.env['GITHUB_ENV'] || ''; + if (filePath) { + const delimiter = '_GitHubActionsFileCommandDelimeter_'; + const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; + file_command_1.issueCommand('ENV', commandValue); + } + else { + command_1.issueCommand('set-env', { name }, convertedVal); + } } - -// 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) - }) - - testComparator = remainingComparators.pop() - } - - return result +exports.exportVariable = exportVariable; +/** + * Registers a secret which will get masked from logs + * @param secret value of the secret + */ +function setSecret(secret) { + command_1.issueCommand('add-mask', {}, secret); } - -// 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(' ') - }) +exports.setSecret = setSecret; +/** + * Prepends inputPath to the PATH (for this action and future actions) + * @param inputPath + */ +function addPath(inputPath) { + const filePath = process.env['GITHUB_PATH'] || ''; + if (filePath) { + file_command_1.issueCommand('PATH', inputPath); + } + else { + command_1.issueCommand('add-path', {}, inputPath); + } + process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; } - -// 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 +exports.addPath = addPath; +/** + * Gets the value of an input. The value is also trimmed. + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string + */ +function getInput(name, options) { + const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; + if (options && options.required && !val) { + throw new Error(`Input required and not supplied: ${name}`); + } + return val.trim(); } - -function isX (id) { - return !id || id.toLowerCase() === 'x' || id === '*' +exports.getInput = getInput; +/** + * Sets the value of an output. + * + * @param name name of the output to set + * @param value value to store. Non-string values will be converted to a string via JSON.stringify + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function setOutput(name, value) { + command_1.issueCommand('set-output', { name }, value); } - -// ~, ~> --> * (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(' ') +exports.setOutput = setOutput; +/** + * Enables or disables the echoing of commands into stdout for the rest of the step. + * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. + * + */ +function setCommandEcho(enabled) { + command_1.issue('echo', enabled ? 'on' : 'off'); } - -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 - }) +exports.setCommandEcho = setCommandEcho; +//----------------------------------------------------------------------- +// Results +//----------------------------------------------------------------------- +/** + * Sets the action status to failed. + * When the action exits it will be with an exit code of 1 + * @param message add error issue message + */ +function setFailed(message) { + process.exitCode = ExitCode.Failure; + error(message); } - -// ^ --> * (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(' ') +exports.setFailed = setFailed; +//----------------------------------------------------------------------- +// Logging Commands +//----------------------------------------------------------------------- +/** + * Gets whether Actions Step Debug is on or not + */ +function isDebug() { + return process.env['RUNNER_DEBUG'] === '1'; } - -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' +exports.isDebug = isDebug; +/** + * Writes debug message to user log + * @param message debug message + */ +function debug(message) { + command_1.issueCommand('debug', {}, message); +} +exports.debug = debug; +/** + * Adds an error issue + * @param message error issue message. Errors will be converted to string via toString() + */ +function error(message) { + command_1.issue('error', message instanceof Error ? message.toString() : message); +} +exports.error = error; +/** + * Adds an warning issue + * @param message warning issue message. Errors will be converted to string via toString() + */ +function warning(message) { + command_1.issue('warning', message instanceof Error ? message.toString() : message); +} +exports.warning = warning; +/** + * Writes info to log with console.log. + * @param message info message + */ +function info(message) { + process.stdout.write(message + os.EOL); +} +exports.info = info; +/** + * Begin an output group. + * + * Output until the next `groupEnd` will be foldable in this group + * + * @param name The name of the output group + */ +function startGroup(name) { + command_1.issue('group', name); +} +exports.startGroup = startGroup; +/** + * End an output group. + */ +function endGroup() { + command_1.issue('endgroup'); +} +exports.endGroup = endGroup; +/** + * Wrap an asynchronous function call in a group. + * + * Returns the same type as the function itself. + * + * @param name The name of the group + * @param fn The function to wrap in the group + */ +function group(name, fn) { + return __awaiter(this, void 0, void 0, function* () { + startGroup(name); + let result; + try { + result = yield fn(); } - } 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' + finally { + endGroup(); } - } else { - ret = '>=' + M + '.' + m + '.' + p + - ' <' + (+M + 1) + '.0.0' - } - } - - debug('caret return', ret) - return ret - }) + return result; + }); +} +exports.group = group; +//----------------------------------------------------------------------- +// Wrapper action state +//----------------------------------------------------------------------- +/** + * Saves state for current action, the state can only be retrieved by this action's post job execution. + * + * @param name name of the state to store + * @param value value to store. Non-string values will be converted to a string via JSON.stringify + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function saveState(name, value) { + command_1.issueCommand('save-state', { name }, value); +} +exports.saveState = saveState; +/** + * Gets the value of an state set by this action's main execution. + * + * @param name name of the state to get + * @returns string + */ +function getState(name) { + return process.env[`STATE_${name}`] || ''; } +exports.getState = getState; +//# sourceMappingURL=core.js.map -function replaceXRanges (comp, options) { - debug('replaceXRanges', comp, options) - return comp.split(/\s+/).map(function (comp) { - return replaceXRange(comp, options) - }).join(' ') +/***/ }), + +/***/ 480: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(124) +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 -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' : '' +/***/ 486: +/***/ (function(module, __unusedexports, __webpack_require__) { - 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 +const compare = __webpack_require__(874) +const gt = (a, b, loose) => compare(a, b, loose) > 0 +module.exports = gt - 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 - } +/***/ }), - debug('xRange return', ret) +/***/ 489: +/***/ (function(module, __unusedexports, __webpack_require__) { - return ret - }) -} +const SemVer = __webpack_require__(65) +const patch = (a, loose) => new SemVer(a, loose).patch +module.exports = patch -// 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 - } +/***/ 499: +/***/ (function(module, __unusedexports, __webpack_require__) { - return (from + ' ' + to).trim() -} +const SemVer = __webpack_require__(65) +const parse = __webpack_require__(830) +const {re, t} = __webpack_require__(976) -// if ANY of the sets match ALL of its comparators, then pass -Range.prototype.test = function (version) { - if (!version) { - return false +const coerce = (version, options) => { + if (version instanceof SemVer) { + return version } - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } + if (typeof version === 'number') { + version = String(version) } - for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true - } - } - return false -} - -function testSet (set, version, options) { - for (var i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false - } + if (typeof version !== 'string') { + return null } - 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 - } + options = options || {} - 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 - } + 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 } - - // 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 + // leave it in a clean state + re[t.COERCERTL].lastIndex = -1 } - 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) { + if (match === null) 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 -} -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 + return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) } +module.exports = coerce -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 - } - - return null -} -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 - } -} +/***/ }), -// 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) -} +/***/ 503: +/***/ (function(module, __unusedexports, __webpack_require__) { -// 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) +const parse = __webpack_require__(830) +const clean = (version, options) => { + const s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null } +module.exports = clean -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] +/***/ 531: +/***/ (function(module, __unusedexports, __webpack_require__) { - var high = null - var low = null +// Determine if version is greater than all the versions possible in the range. +const outside = __webpack_require__(462) +const gtr = (version, range, options) => outside(version, range, '>', options) +module.exports = gtr - 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 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 -} +/***/ 533: +/***/ (function(__unusedmodule, exports, __webpack_require__) { -exports.prerelease = prerelease -function prerelease (version, options) { - var parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null -} +"use strict"; -exports.intersects = intersects -function intersects (r1, r2, options) { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) -} - -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 - } - - options = options || {} - - 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 - } - // 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) -} - - -/***/ }), - -/***/ 322: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"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 (k !== "default" && 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) { @@ -3129,112 +3361,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; -const os_1 = __importDefault(__webpack_require__(87)); -const path_1 = __importDefault(__webpack_require__(622)); -const fs = __importStar(__webpack_require__(747)); -const semver = __importStar(__webpack_require__(280)); -const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(533)); -function getTempDir() { - let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); - return tempDirectory; -} -exports.getTempDir = getTempDir; -function getBooleanInput(inputName, defaultValue = false) { - return (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'; -} -exports.getBooleanInput = getBooleanInput; -function getVersionFromToolcachePath(toolPath) { - if (toolPath) { - return path_1.default.basename(path_1.default.dirname(toolPath)); - } - return toolPath; -} -exports.getVersionFromToolcachePath = getVersionFromToolcachePath; -function extractJdkFile(toolPath, extension) { - return __awaiter(this, void 0, void 0, function* () { - if (!extension) { - extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); - if (extension.startsWith('.')) { - extension = extension.substring(1); - } - } - switch (extension) { - case 'tar.gz': - case 'tar': - return yield tc.extractTar(toolPath); - case 'zip': - return yield tc.extractZip(toolPath); - default: - return yield tc.extract7z(toolPath); - } - }); -} -exports.extractJdkFile = extractJdkFile; -function getDownloadArchiveExtension() { - return process.platform === 'win32' ? 'zip' : 'tar.gz'; -} -exports.getDownloadArchiveExtension = getDownloadArchiveExtension; -function isVersionSatisfies(range, version) { - var _a; - if (semver.valid(range)) { - // if full version with build digit is provided as a range (such as '1.2.3+4') - // we should check for exact equal via compareBuild - // since semver.satisfies doesn't handle 4th digit - const semRange = semver.parse(range); - if (semRange && ((_a = semRange.build) === null || _a === void 0 ? void 0 : _a.length) > 0) { - return semver.compareBuild(range, version) === 0; - } - } - return semver.satisfies(version, range); -} -exports.isVersionSatisfies = isVersionSatisfies; -function getToolcachePath(toolName, version, architecture) { - var _a; - const toolcacheRoot = (_a = process.env['RUNNER_TOOL_CACHE']) !== null && _a !== void 0 ? _a : ''; - const fullPath = path_1.default.join(toolcacheRoot, toolName, version, architecture); - if (fs.existsSync(fullPath)) { - return fullPath; - } - return null; -} -exports.getToolcachePath = getToolcachePath; - - -/***/ }), - -/***/ 357: -/***/ (function(module) { - -module.exports = require("assert"); - -/***/ }), - -/***/ 413: -/***/ (function(module, __unusedexports, __webpack_require__) { - -module.exports = __webpack_require__(141); - - -/***/ }), - -/***/ 417: -/***/ (function(module) { - -module.exports = require("crypto"); - -/***/ }), - -/***/ 431: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; @@ -3242,886 +3368,577 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); +const core = __importStar(__webpack_require__(470)); +const io = __importStar(__webpack_require__(1)); +const fs = __importStar(__webpack_require__(747)); +const mm = __importStar(__webpack_require__(31)); const os = __importStar(__webpack_require__(87)); -const utils_1 = __webpack_require__(82); +const path = __importStar(__webpack_require__(622)); +const httpm = __importStar(__webpack_require__(539)); +const semver = __importStar(__webpack_require__(550)); +const stream = __importStar(__webpack_require__(794)); +const util = __importStar(__webpack_require__(669)); +const v4_1 = __importDefault(__webpack_require__(826)); +const exec_1 = __webpack_require__(986); +const assert_1 = __webpack_require__(357); +const retry_helper_1 = __webpack_require__(979); +class HTTPError extends Error { + constructor(httpStatusCode) { + super(`Unexpected HTTP response: ${httpStatusCode}`); + this.httpStatusCode = httpStatusCode; + Object.setPrototypeOf(this, new.target.prototype); + } +} +exports.HTTPError = HTTPError; +const IS_WINDOWS = process.platform === 'win32'; +const IS_MAC = process.platform === 'darwin'; +const userAgent = 'actions/tool-cache'; /** - * Commands - * - * Command Format: - * ::name key=value,key=value::message + * Download a tool from an url and stream it into a file * - * Examples: - * ::warning::This is the message - * ::set-env name=MY_VAR::some value + * @param url url of tool to download + * @param dest path to download tool + * @param auth authorization header + * @returns path to downloaded tool */ -function issueCommand(command, properties, message) { - const cmd = new Command(command, properties, message); - process.stdout.write(cmd.toString() + os.EOL); +function downloadTool(url, dest, auth) { + return __awaiter(this, void 0, void 0, function* () { + dest = dest || path.join(_getTempDirectory(), v4_1.default()); + yield io.mkdirP(path.dirname(dest)); + core.debug(`Downloading ${url}`); + core.debug(`Destination ${dest}`); + const maxAttempts = 3; + const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10); + const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20); + const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); + return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { + return yield downloadToolAttempt(url, dest || '', auth); + }), (err) => { + if (err instanceof HTTPError && err.httpStatusCode) { + // Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests + if (err.httpStatusCode < 500 && + err.httpStatusCode !== 408 && + err.httpStatusCode !== 429) { + return false; + } + } + // Otherwise retry + return true; + }); + }); } -exports.issueCommand = issueCommand; -function issue(name, message = '') { - issueCommand(name, {}, message); -} -exports.issue = issue; -const CMD_STRING = '::'; -class Command { - constructor(command, properties, message) { - if (!command) { - command = 'missing.command'; +exports.downloadTool = downloadTool; +function downloadToolAttempt(url, dest, auth) { + return __awaiter(this, void 0, void 0, function* () { + if (fs.existsSync(dest)) { + throw new Error(`Destination file path ${dest} already exists`); } - this.command = command; - this.properties = properties; - this.message = message; - } - toString() { - let cmdStr = CMD_STRING + this.command; - if (this.properties && Object.keys(this.properties).length > 0) { - cmdStr += ' '; - let first = true; - for (const key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - const val = this.properties[key]; - if (val) { - if (first) { - first = false; - } - else { - cmdStr += ','; - } - cmdStr += `${key}=${escapeProperty(val)}`; - } + // Get the response headers + const http = new httpm.HttpClient(userAgent, [], { + allowRetries: false + }); + let headers; + if (auth) { + core.debug('set auth'); + headers = { + authorization: auth + }; + } + const response = yield http.get(url, headers); + if (response.message.statusCode !== 200) { + const err = new HTTPError(response.message.statusCode); + core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + throw err; + } + // Download the response body + const pipeline = util.promisify(stream.pipeline); + const responseMessageFactory = _getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message); + const readStream = responseMessageFactory(); + let succeeded = false; + try { + yield pipeline(readStream, fs.createWriteStream(dest)); + core.debug('download complete'); + succeeded = true; + return dest; + } + finally { + // Error, delete dest before retry + if (!succeeded) { + core.debug('download failed'); + try { + yield io.rmRF(dest); + } + catch (err) { + core.debug(`Failed to delete '${dest}'. ${err.message}`); } } } - cmdStr += `${CMD_STRING}${escapeData(this.message)}`; - return cmdStr; - } -} -function escapeData(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A'); -} -function escapeProperty(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A') - .replace(/:/g, '%3A') - .replace(/,/g, '%2C'); -} -//# sourceMappingURL=command.js.map - -/***/ }), - -/***/ 470: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - 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; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const command_1 = __webpack_require__(431); -const file_command_1 = __webpack_require__(102); -const utils_1 = __webpack_require__(82); -const os = __importStar(__webpack_require__(87)); -const path = __importStar(__webpack_require__(622)); -/** - * The code to exit an action - */ -var ExitCode; -(function (ExitCode) { - /** - * A code indicating that the action was successful - */ - ExitCode[ExitCode["Success"] = 0] = "Success"; - /** - * A code indicating that the action was a failure - */ - ExitCode[ExitCode["Failure"] = 1] = "Failure"; -})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); -//----------------------------------------------------------------------- -// Variables -//----------------------------------------------------------------------- -/** - * Sets env variable for this action and future actions in the job - * @param name the name of the variable to set - * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify - */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function exportVariable(name, val) { - const convertedVal = utils_1.toCommandValue(val); - process.env[name] = convertedVal; - const filePath = process.env['GITHUB_ENV'] || ''; - if (filePath) { - const delimiter = '_GitHubActionsFileCommandDelimeter_'; - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); - } -} -exports.exportVariable = exportVariable; -/** - * Registers a secret which will get masked from logs - * @param secret value of the secret - */ -function setSecret(secret) { - command_1.issueCommand('add-mask', {}, secret); } -exports.setSecret = setSecret; /** - * Prepends inputPath to the PATH (for this action and future actions) - * @param inputPath + * Extract a .7z file + * + * @param file path to the .7z file + * @param dest destination directory. Optional. + * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this + * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will + * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is + * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line + * interface, it is smaller than the full command line interface, and it does support long paths. At the + * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. + * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path + * to 7zr.exe can be pass to this function. + * @returns path to the destination directory */ -function addPath(inputPath) { - const filePath = process.env['GITHUB_PATH'] || ''; - if (filePath) { - file_command_1.issueCommand('PATH', inputPath); - } - else { - command_1.issueCommand('add-path', {}, inputPath); - } - process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; +function extract7z(file, dest, _7zPath) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); + assert_1.ok(file, 'parameter "file" is required'); + dest = yield _createExtractFolder(dest); + const originalCwd = process.cwd(); + process.chdir(dest); + if (_7zPath) { + try { + const logLevel = core.isDebug() ? '-bb1' : '-bb0'; + const args = [ + 'x', + logLevel, + '-bd', + '-sccUTF-8', + file + ]; + const options = { + silent: true + }; + yield exec_1.exec(`"${_7zPath}"`, args, options); + } + finally { + process.chdir(originalCwd); + } + } + else { + const escapedScript = path + .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') + .replace(/'/g, "''") + .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; + const args = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ]; + const options = { + silent: true + }; + try { + const powershellPath = yield io.which('powershell', true); + yield exec_1.exec(`"${powershellPath}"`, args, options); + } + finally { + process.chdir(originalCwd); + } + } + return dest; + }); } -exports.addPath = addPath; +exports.extract7z = extract7z; /** - * Gets the value of an input. The value is also trimmed. + * Extract a compressed tar archive * - * @param name name of the input to get - * @param options optional. See InputOptions. - * @returns string + * @param file path to the tar + * @param dest destination directory. Optional. + * @param flags flags for the tar command to use for extraction. Defaults to 'xz' (extracting gzipped tars). Optional. + * @returns path to the destination directory */ -function getInput(name, options) { - const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; - if (options && options.required && !val) { - throw new Error(`Input required and not supplied: ${name}`); - } - return val.trim(); +function extractTar(file, dest, flags = 'xz') { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); + } + // Create dest + dest = yield _createExtractFolder(dest); + // Determine whether GNU tar + core.debug('Checking tar --version'); + let versionOutput = ''; + yield exec_1.exec('tar --version', [], { + ignoreReturnCode: true, + silent: true, + listeners: { + stdout: (data) => (versionOutput += data.toString()), + stderr: (data) => (versionOutput += data.toString()) + } + }); + core.debug(versionOutput.trim()); + const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR'); + // Initialize args + let args; + if (flags instanceof Array) { + args = flags; + } + else { + args = [flags]; + } + if (core.isDebug() && !flags.includes('v')) { + args.push('-v'); + } + let destArg = dest; + let fileArg = file; + if (IS_WINDOWS && isGnuTar) { + args.push('--force-local'); + destArg = dest.replace(/\\/g, '/'); + // Technically only the dest needs to have `/` but for aesthetic consistency + // convert slashes in the file arg too. + fileArg = file.replace(/\\/g, '/'); + } + if (isGnuTar) { + // Suppress warnings when using GNU tar to extract archives created by BSD tar + args.push('--warning=no-unknown-keyword'); + } + args.push('-C', destArg, '-f', fileArg); + yield exec_1.exec(`tar`, args); + return dest; + }); } -exports.getInput = getInput; +exports.extractTar = extractTar; /** - * Sets the value of an output. + * Extract a xar compatible archive * - * @param name name of the output to set - * @param value value to store. Non-string values will be converted to a string via JSON.stringify + * @param file path to the archive + * @param dest destination directory. Optional. + * @param flags flags for the xar. Optional. + * @returns path to the destination directory */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function setOutput(name, value) { - command_1.issueCommand('set-output', { name }, value); +function extractXar(file, dest, flags = []) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(IS_MAC, 'extractXar() not supported on current OS'); + assert_1.ok(file, 'parameter "file" is required'); + dest = yield _createExtractFolder(dest); + let args; + if (flags instanceof Array) { + args = flags; + } + else { + args = [flags]; + } + args.push('-x', '-C', dest, '-f', file); + if (core.isDebug()) { + args.push('-v'); + } + const xarPath = yield io.which('xar', true); + yield exec_1.exec(`"${xarPath}"`, _unique(args)); + return dest; + }); } -exports.setOutput = setOutput; +exports.extractXar = extractXar; /** - * Enables or disables the echoing of commands into stdout for the rest of the step. - * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. + * Extract a zip * + * @param file path to the zip + * @param dest destination directory. Optional. + * @returns path to the destination directory */ -function setCommandEcho(enabled) { - command_1.issue('echo', enabled ? 'on' : 'off'); -} -exports.setCommandEcho = setCommandEcho; -//----------------------------------------------------------------------- -// Results -//----------------------------------------------------------------------- -/** - * Sets the action status to failed. - * When the action exits it will be with an exit code of 1 - * @param message add error issue message - */ -function setFailed(message) { - process.exitCode = ExitCode.Failure; - error(message); -} -exports.setFailed = setFailed; -//----------------------------------------------------------------------- -// Logging Commands -//----------------------------------------------------------------------- -/** - * Gets whether Actions Step Debug is on or not - */ -function isDebug() { - return process.env['RUNNER_DEBUG'] === '1'; -} -exports.isDebug = isDebug; -/** - * Writes debug message to user log - * @param message debug message - */ -function debug(message) { - command_1.issueCommand('debug', {}, message); -} -exports.debug = debug; -/** - * Adds an error issue - * @param message error issue message. Errors will be converted to string via toString() - */ -function error(message) { - command_1.issue('error', message instanceof Error ? message.toString() : message); -} -exports.error = error; -/** - * Adds an warning issue - * @param message warning issue message. Errors will be converted to string via toString() - */ -function warning(message) { - command_1.issue('warning', message instanceof Error ? message.toString() : message); -} -exports.warning = warning; -/** - * Writes info to log with console.log. - * @param message info message - */ -function info(message) { - process.stdout.write(message + os.EOL); +function extractZip(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); + } + dest = yield _createExtractFolder(dest); + if (IS_WINDOWS) { + yield extractZipWin(file, dest); + } + else { + yield extractZipNix(file, dest); + } + return dest; + }); } -exports.info = info; -/** - * Begin an output group. - * - * Output until the next `groupEnd` will be foldable in this group - * - * @param name The name of the output group - */ -function startGroup(name) { - command_1.issue('group', name); +exports.extractZip = extractZip; +function extractZipWin(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + // build the powershell command + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines + const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`; + // run powershell + const powershellPath = yield io.which('powershell', true); + const args = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ]; + yield exec_1.exec(`"${powershellPath}"`, args); + }); } -exports.startGroup = startGroup; -/** - * End an output group. - */ -function endGroup() { - command_1.issue('endgroup'); +function extractZipNix(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + const unzipPath = yield io.which('unzip', true); + const args = [file]; + if (!core.isDebug()) { + args.unshift('-q'); + } + yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); + }); } -exports.endGroup = endGroup; /** - * Wrap an asynchronous function call in a group. - * - * Returns the same type as the function itself. + * Caches a directory and installs it into the tool cacheDir * - * @param name The name of the group - * @param fn The function to wrap in the group + * @param sourceDir the directory to cache into tools + * @param tool tool name + * @param version version of the tool. semver format + * @param arch architecture of the tool. Optional. Defaults to machine architecture */ -function group(name, fn) { +function cacheDir(sourceDir, tool, version, arch) { return __awaiter(this, void 0, void 0, function* () { - startGroup(name); - let result; - try { - result = yield fn(); + version = semver.clean(version) || version; + arch = arch || os.arch(); + core.debug(`Caching tool ${tool} ${version} ${arch}`); + core.debug(`source dir: ${sourceDir}`); + if (!fs.statSync(sourceDir).isDirectory()) { + throw new Error('sourceDir is not a directory'); } - finally { - endGroup(); + // Create the tool dir + const destPath = yield _createToolPath(tool, version, arch); + // copy each child item. do not move. move can fail on Windows + // due to anti-virus software having an open handle on a file. + for (const itemName of fs.readdirSync(sourceDir)) { + const s = path.join(sourceDir, itemName); + yield io.cp(s, destPath, { recursive: true }); } - return result; + // write .complete + _completeToolPath(tool, version, arch); + return destPath; }); } -exports.group = group; -//----------------------------------------------------------------------- -// Wrapper action state -//----------------------------------------------------------------------- +exports.cacheDir = cacheDir; /** - * Saves state for current action, the state can only be retrieved by this action's post job execution. + * Caches a downloaded file (GUID) and installs it + * into the tool cache with a given targetName * - * @param name name of the state to store - * @param value value to store. Non-string values will be converted to a string via JSON.stringify + * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. + * @param targetFile the name of the file name in the tools directory + * @param tool tool name + * @param version version of the tool. semver format + * @param arch architecture of the tool. Optional. Defaults to machine architecture */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); +function cacheFile(sourceFile, targetFile, tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + version = semver.clean(version) || version; + arch = arch || os.arch(); + core.debug(`Caching tool ${tool} ${version} ${arch}`); + core.debug(`source file: ${sourceFile}`); + if (!fs.statSync(sourceFile).isFile()) { + throw new Error('sourceFile is not a file'); + } + // create the tool dir + const destFolder = yield _createToolPath(tool, version, arch); + // copy instead of move. move can fail on Windows due to + // anti-virus software having an open handle on a file. + const destPath = path.join(destFolder, targetFile); + core.debug(`destination file ${destPath}`); + yield io.cp(sourceFile, destPath); + // write .complete + _completeToolPath(tool, version, arch); + return destFolder; + }); } -exports.saveState = saveState; +exports.cacheFile = cacheFile; /** - * Gets the value of an state set by this action's main execution. + * Finds the path to a tool version in the local installed tool cache * - * @param name name of the state to get - * @returns string + * @param toolName name of the tool + * @param versionSpec version of the tool + * @param arch optional arch. defaults to arch of computer */ -function getState(name) { - return process.env[`STATE_${name}`] || ''; -} -exports.getState = getState; -//# sourceMappingURL=core.js.map - -/***/ }), - -/***/ 533: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - 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 }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = __importStar(__webpack_require__(470)); -const io = __importStar(__webpack_require__(1)); -const fs = __importStar(__webpack_require__(747)); -const mm = __importStar(__webpack_require__(31)); -const os = __importStar(__webpack_require__(87)); -const path = __importStar(__webpack_require__(622)); -const httpm = __importStar(__webpack_require__(539)); -const semver = __importStar(__webpack_require__(280)); -const stream = __importStar(__webpack_require__(794)); -const util = __importStar(__webpack_require__(669)); -const v4_1 = __importDefault(__webpack_require__(826)); -const exec_1 = __webpack_require__(986); -const assert_1 = __webpack_require__(357); -const retry_helper_1 = __webpack_require__(979); -class HTTPError extends Error { - constructor(httpStatusCode) { - super(`Unexpected HTTP response: ${httpStatusCode}`); - this.httpStatusCode = httpStatusCode; - Object.setPrototypeOf(this, new.target.prototype); +function find(toolName, versionSpec, arch) { + if (!toolName) { + throw new Error('toolName parameter is required'); + } + if (!versionSpec) { + throw new Error('versionSpec parameter is required'); + } + arch = arch || os.arch(); + // attempt to resolve an explicit version + if (!_isExplicitVersion(versionSpec)) { + const localVersions = findAllVersions(toolName, arch); + const match = _evaluateVersions(localVersions, versionSpec); + versionSpec = match; + } + // check for the explicit version in the cache + let toolPath = ''; + if (versionSpec) { + versionSpec = semver.clean(versionSpec) || ''; + const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch); + core.debug(`checking cache: ${cachePath}`); + if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { + core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + toolPath = cachePath; + } + else { + core.debug('not found'); + } } + return toolPath; } -exports.HTTPError = HTTPError; -const IS_WINDOWS = process.platform === 'win32'; -const userAgent = 'actions/tool-cache'; +exports.find = find; /** - * Download a tool from an url and stream it into a file + * Finds the paths to all versions of a tool that are installed in the local tool cache * - * @param url url of tool to download - * @param dest path to download tool - * @param auth authorization header - * @returns path to downloaded tool + * @param toolName name of the tool + * @param arch optional arch. defaults to arch of computer */ -function downloadTool(url, dest, auth) { - return __awaiter(this, void 0, void 0, function* () { - dest = dest || path.join(_getTempDirectory(), v4_1.default()); - yield io.mkdirP(path.dirname(dest)); - core.debug(`Downloading ${url}`); - core.debug(`Destination ${dest}`); - const maxAttempts = 3; - const minSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MIN_SECONDS', 10); - const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20); - const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds); - return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () { - return yield downloadToolAttempt(url, dest || '', auth); - }), (err) => { - if (err instanceof HTTPError && err.httpStatusCode) { - // Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests - if (err.httpStatusCode < 500 && - err.httpStatusCode !== 408 && - err.httpStatusCode !== 429) { - return false; +function findAllVersions(toolName, arch) { + const versions = []; + arch = arch || os.arch(); + const toolPath = path.join(_getCacheDirectory(), toolName); + if (fs.existsSync(toolPath)) { + const children = fs.readdirSync(toolPath); + for (const child of children) { + if (_isExplicitVersion(child)) { + const fullPath = path.join(toolPath, child, arch || ''); + if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { + versions.push(child); } } - // Otherwise retry - return true; - }); - }); + } + } + return versions; } -exports.downloadTool = downloadTool; -function downloadToolAttempt(url, dest, auth) { +exports.findAllVersions = findAllVersions; +function getManifestFromRepo(owner, repo, auth, branch = 'master') { return __awaiter(this, void 0, void 0, function* () { - if (fs.existsSync(dest)) { - throw new Error(`Destination file path ${dest} already exists`); - } - // Get the response headers - const http = new httpm.HttpClient(userAgent, [], { - allowRetries: false - }); - let headers; + let releases = []; + const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`; + const http = new httpm.HttpClient('tool-cache'); + const headers = {}; if (auth) { core.debug('set auth'); - headers = { - authorization: auth - }; + headers.authorization = auth; } - const response = yield http.get(url, headers); - if (response.message.statusCode !== 200) { - const err = new HTTPError(response.message.statusCode); - core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); - throw err; + const response = yield http.getJson(treeUrl, headers); + if (!response.result) { + return releases; } - // Download the response body - const pipeline = util.promisify(stream.pipeline); - const responseMessageFactory = _getGlobal('TEST_DOWNLOAD_TOOL_RESPONSE_MESSAGE_FACTORY', () => response.message); - const readStream = responseMessageFactory(); - let succeeded = false; - try { - yield pipeline(readStream, fs.createWriteStream(dest)); - core.debug('download complete'); - succeeded = true; - return dest; + let manifestUrl = ''; + for (const item of response.result.tree) { + if (item.path === 'versions-manifest.json') { + manifestUrl = item.url; + break; + } } - finally { - // Error, delete dest before retry - if (!succeeded) { - core.debug('download failed'); - try { - yield io.rmRF(dest); - } - catch (err) { - core.debug(`Failed to delete '${dest}'. ${err.message}`); - } + headers['accept'] = 'application/vnd.github.VERSION.raw'; + let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody(); + if (versionsRaw) { + // shouldn't be needed but protects against invalid json saved with BOM + versionsRaw = versionsRaw.replace(/^\uFEFF/, ''); + try { + releases = JSON.parse(versionsRaw); + } + catch (_a) { + core.debug('Invalid json'); } } + return releases; }); } -/** - * Extract a .7z file - * - * @param file path to the .7z file - * @param dest destination directory. Optional. - * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this - * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will - * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is - * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line - * interface, it is smaller than the full command line interface, and it does support long paths. At the - * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. - * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path - * to 7zr.exe can be pass to this function. - * @returns path to the destination directory - */ -function extract7z(file, dest, _7zPath) { +exports.getManifestFromRepo = getManifestFromRepo; +function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) { return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); - assert_1.ok(file, 'parameter "file" is required'); - dest = yield _createExtractFolder(dest); - const originalCwd = process.cwd(); - process.chdir(dest); - if (_7zPath) { - try { - const logLevel = core.isDebug() ? '-bb1' : '-bb0'; - const args = [ - 'x', - logLevel, - '-bd', - '-sccUTF-8', - file - ]; - const options = { - silent: true - }; - yield exec_1.exec(`"${_7zPath}"`, args, options); - } - finally { - process.chdir(originalCwd); - } - } - else { - const escapedScript = path - .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') - .replace(/'/g, "''") - .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; - const args = [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ]; - const options = { - silent: true - }; - try { - const powershellPath = yield io.which('powershell', true); - yield exec_1.exec(`"${powershellPath}"`, args, options); - } - finally { - process.chdir(originalCwd); - } - } - return dest; + // wrap the internal impl + const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter); + return match; }); } -exports.extract7z = extract7z; -/** - * Extract a compressed tar archive - * - * @param file path to the tar - * @param dest destination directory. Optional. - * @param flags flags for the tar command to use for extraction. Defaults to 'xz' (extracting gzipped tars). Optional. - * @returns path to the destination directory - */ -function extractTar(file, dest, flags = 'xz') { +exports.findFromManifest = findFromManifest; +function _createExtractFolder(dest) { return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); - } - // Create dest - dest = yield _createExtractFolder(dest); - // Determine whether GNU tar - core.debug('Checking tar --version'); - let versionOutput = ''; - yield exec_1.exec('tar --version', [], { - ignoreReturnCode: true, - silent: true, - listeners: { - stdout: (data) => (versionOutput += data.toString()), - stderr: (data) => (versionOutput += data.toString()) - } - }); - core.debug(versionOutput.trim()); - const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR'); - // Initialize args - let args; - if (flags instanceof Array) { - args = flags; - } - else { - args = [flags]; - } - if (core.isDebug() && !flags.includes('v')) { - args.push('-v'); - } - let destArg = dest; - let fileArg = file; - if (IS_WINDOWS && isGnuTar) { - args.push('--force-local'); - destArg = dest.replace(/\\/g, '/'); - // Technically only the dest needs to have `/` but for aesthetic consistency - // convert slashes in the file arg too. - fileArg = file.replace(/\\/g, '/'); - } - if (isGnuTar) { - // Suppress warnings when using GNU tar to extract archives created by BSD tar - args.push('--warning=no-unknown-keyword'); + if (!dest) { + // create a temp dir + dest = path.join(_getTempDirectory(), v4_1.default()); } - args.push('-C', destArg, '-f', fileArg); - yield exec_1.exec(`tar`, args); + yield io.mkdirP(dest); return dest; }); } -exports.extractTar = extractTar; -/** - * Extract a zip - * - * @param file path to the zip - * @param dest destination directory. Optional. - * @returns path to the destination directory - */ -function extractZip(file, dest) { +function _createToolPath(tool, version, arch) { return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); - } - dest = yield _createExtractFolder(dest); - if (IS_WINDOWS) { - yield extractZipWin(file, dest); - } - else { - yield extractZipNix(file, dest); - } - return dest; + const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); + core.debug(`destination ${folderPath}`); + const markerPath = `${folderPath}.complete`; + yield io.rmRF(folderPath); + yield io.rmRF(markerPath); + yield io.mkdirP(folderPath); + return folderPath; }); } -exports.extractZip = extractZip; -function extractZipWin(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - // build the powershell command - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines - const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`; - // run powershell - const powershellPath = yield io.which('powershell', true); - const args = [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ]; - yield exec_1.exec(`"${powershellPath}"`, args); - }); +function _completeToolPath(tool, version, arch) { + const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); + const markerPath = `${folderPath}.complete`; + fs.writeFileSync(markerPath, ''); + core.debug('finished caching tool'); } -function extractZipNix(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - const unzipPath = yield io.which('unzip', true); - const args = [file]; - if (!core.isDebug()) { - args.unshift('-q'); +function _isExplicitVersion(versionSpec) { + const c = semver.clean(versionSpec) || ''; + core.debug(`isExplicit: ${c}`); + const valid = semver.valid(c) != null; + core.debug(`explicit? ${valid}`); + return valid; +} +function _evaluateVersions(versions, versionSpec) { + let version = ''; + core.debug(`evaluating ${versions.length} versions`); + versions = versions.sort((a, b) => { + if (semver.gt(a, b)) { + return 1; } - yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest }); + return -1; }); + for (let i = versions.length - 1; i >= 0; i--) { + const potential = versions[i]; + const satisfied = semver.satisfies(potential, versionSpec); + if (satisfied) { + version = potential; + break; + } + } + if (version) { + core.debug(`matched: ${version}`); + } + else { + core.debug('match not found'); + } + return version; } /** - * Caches a directory and installs it into the tool cacheDir - * - * @param sourceDir the directory to cache into tools - * @param tool tool name - * @param version version of the tool. semver format - * @param arch architecture of the tool. Optional. Defaults to machine architecture + * Gets RUNNER_TOOL_CACHE */ -function cacheDir(sourceDir, tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - version = semver.clean(version) || version; - arch = arch || os.arch(); - core.debug(`Caching tool ${tool} ${version} ${arch}`); - core.debug(`source dir: ${sourceDir}`); - if (!fs.statSync(sourceDir).isDirectory()) { - throw new Error('sourceDir is not a directory'); - } - // Create the tool dir - const destPath = yield _createToolPath(tool, version, arch); - // copy each child item. do not move. move can fail on Windows - // due to anti-virus software having an open handle on a file. - for (const itemName of fs.readdirSync(sourceDir)) { - const s = path.join(sourceDir, itemName); - yield io.cp(s, destPath, { recursive: true }); - } - // write .complete - _completeToolPath(tool, version, arch); - return destPath; - }); +function _getCacheDirectory() { + const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; + assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); + return cacheDirectory; } -exports.cacheDir = cacheDir; /** - * Caches a downloaded file (GUID) and installs it - * into the tool cache with a given targetName - * - * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. - * @param targetFile the name of the file name in the tools directory - * @param tool tool name - * @param version version of the tool. semver format - * @param arch architecture of the tool. Optional. Defaults to machine architecture + * Gets RUNNER_TEMP */ -function cacheFile(sourceFile, targetFile, tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - version = semver.clean(version) || version; - arch = arch || os.arch(); - core.debug(`Caching tool ${tool} ${version} ${arch}`); - core.debug(`source file: ${sourceFile}`); - if (!fs.statSync(sourceFile).isFile()) { - throw new Error('sourceFile is not a file'); - } - // create the tool dir - const destFolder = yield _createToolPath(tool, version, arch); - // copy instead of move. move can fail on Windows due to - // anti-virus software having an open handle on a file. - const destPath = path.join(destFolder, targetFile); - core.debug(`destination file ${destPath}`); - yield io.cp(sourceFile, destPath); - // write .complete - _completeToolPath(tool, version, arch); - return destFolder; - }); -} -exports.cacheFile = cacheFile; -/** - * Finds the path to a tool version in the local installed tool cache - * - * @param toolName name of the tool - * @param versionSpec version of the tool - * @param arch optional arch. defaults to arch of computer - */ -function find(toolName, versionSpec, arch) { - if (!toolName) { - throw new Error('toolName parameter is required'); - } - if (!versionSpec) { - throw new Error('versionSpec parameter is required'); - } - arch = arch || os.arch(); - // attempt to resolve an explicit version - if (!_isExplicitVersion(versionSpec)) { - const localVersions = findAllVersions(toolName, arch); - const match = _evaluateVersions(localVersions, versionSpec); - versionSpec = match; - } - // check for the explicit version in the cache - let toolPath = ''; - if (versionSpec) { - versionSpec = semver.clean(versionSpec) || ''; - const cachePath = path.join(_getCacheDirectory(), toolName, versionSpec, arch); - core.debug(`checking cache: ${cachePath}`); - if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { - core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); - toolPath = cachePath; - } - else { - core.debug('not found'); - } - } - return toolPath; -} -exports.find = find; -/** - * Finds the paths to all versions of a tool that are installed in the local tool cache - * - * @param toolName name of the tool - * @param arch optional arch. defaults to arch of computer - */ -function findAllVersions(toolName, arch) { - const versions = []; - arch = arch || os.arch(); - const toolPath = path.join(_getCacheDirectory(), toolName); - if (fs.existsSync(toolPath)) { - const children = fs.readdirSync(toolPath); - for (const child of children) { - if (_isExplicitVersion(child)) { - const fullPath = path.join(toolPath, child, arch || ''); - if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { - versions.push(child); - } - } - } - } - return versions; -} -exports.findAllVersions = findAllVersions; -function getManifestFromRepo(owner, repo, auth, branch = 'master') { - return __awaiter(this, void 0, void 0, function* () { - let releases = []; - const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`; - const http = new httpm.HttpClient('tool-cache'); - const headers = {}; - if (auth) { - core.debug('set auth'); - headers.authorization = auth; - } - const response = yield http.getJson(treeUrl, headers); - if (!response.result) { - return releases; - } - let manifestUrl = ''; - for (const item of response.result.tree) { - if (item.path === 'versions-manifest.json') { - manifestUrl = item.url; - break; - } - } - headers['accept'] = 'application/vnd.github.VERSION.raw'; - let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody(); - if (versionsRaw) { - // shouldn't be needed but protects against invalid json saved with BOM - versionsRaw = versionsRaw.replace(/^\uFEFF/, ''); - try { - releases = JSON.parse(versionsRaw); - } - catch (_a) { - core.debug('Invalid json'); - } - } - return releases; - }); -} -exports.getManifestFromRepo = getManifestFromRepo; -function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) { - return __awaiter(this, void 0, void 0, function* () { - // wrap the internal impl - const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter); - return match; - }); -} -exports.findFromManifest = findFromManifest; -function _createExtractFolder(dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!dest) { - // create a temp dir - dest = path.join(_getTempDirectory(), v4_1.default()); - } - yield io.mkdirP(dest); - return dest; - }); -} -function _createToolPath(tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); - core.debug(`destination ${folderPath}`); - const markerPath = `${folderPath}.complete`; - yield io.rmRF(folderPath); - yield io.rmRF(markerPath); - yield io.mkdirP(folderPath); - return folderPath; - }); -} -function _completeToolPath(tool, version, arch) { - const folderPath = path.join(_getCacheDirectory(), tool, semver.clean(version) || version, arch || ''); - const markerPath = `${folderPath}.complete`; - fs.writeFileSync(markerPath, ''); - core.debug('finished caching tool'); -} -function _isExplicitVersion(versionSpec) { - const c = semver.clean(versionSpec) || ''; - core.debug(`isExplicit: ${c}`); - const valid = semver.valid(c) != null; - core.debug(`explicit? ${valid}`); - return valid; -} -function _evaluateVersions(versions, versionSpec) { - let version = ''; - core.debug(`evaluating ${versions.length} versions`); - versions = versions.sort((a, b) => { - if (semver.gt(a, b)) { - return 1; - } - return -1; - }); - for (let i = versions.length - 1; i >= 0; i--) { - const potential = versions[i]; - const satisfied = semver.satisfies(potential, versionSpec); - if (satisfied) { - version = potential; - break; - } - } - if (version) { - core.debug(`matched: ${version}`); - } - else { - core.debug('match not found'); - } - return version; -} -/** - * Gets RUNNER_TOOL_CACHE - */ -function _getCacheDirectory() { - const cacheDirectory = process.env['RUNNER_TOOL_CACHE'] || ''; - assert_1.ok(cacheDirectory, 'Expected RUNNER_TOOL_CACHE to be defined'); - return cacheDirectory; -} -/** - * Gets RUNNER_TEMP - */ -function _getTempDirectory() { - const tempDirectory = process.env['RUNNER_TEMP'] || ''; - assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); - return tempDirectory; +function _getTempDirectory() { + const tempDirectory = process.env['RUNNER_TEMP'] || ''; + assert_1.ok(tempDirectory, 'Expected RUNNER_TEMP to be defined'); + return tempDirectory; } /** * Gets a global variable @@ -4132,6 +3949,13 @@ function _getGlobal(key, defaultValue) { /* eslint-enable @typescript-eslint/no-explicit-any */ return value !== undefined ? value : defaultValue; } +/** + * Returns an array of unique values. + * @param values Values to make unique. + */ +function _unique(values) { + return Array.from(new Set(values)); +} //# sourceMappingURL=tool-cache.js.map /***/ }), @@ -4679,10 +4503,2083 @@ exports.HttpClient = HttpClient; /***/ }), -/***/ 605: -/***/ (function(module) { +/***/ 548: +/***/ (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 + + +/***/ }), + +/***/ 550: +/***/ (function(module, exports) { + +exports = module.exports = SemVer + +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 () {} +} + +// 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' + +var MAX_LENGTH = 256 +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 + +// Max safe segment length for coercion. +var MAX_SAFE_COMPONENT_LENGTH = 16 + +// The actual regexps go on exports.re +var re = exports.re = [] +var src = exports.src = [] +var t = exports.tokens = {} +var R = 0 + +function tok (n) { + t[n] = R++ +} + +// 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. + +tok('NUMERICIDENTIFIER') +src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' +tok('NUMERICIDENTIFIERLOOSE') +src[t.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. + +tok('NONNUMERICIDENTIFIER') +src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' + +// ## Main Version +// Three dot-separated numeric identifiers. + +tok('MAINVERSION') +src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')' + +tok('MAINVERSIONLOOSE') +src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +tok('PRERELEASEIDENTIFIER') +src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' + +tok('PRERELEASEIDENTIFIERLOOSE') +src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +tok('PRERELEASE') +src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' + +tok('PRERELEASELOOSE') +src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +tok('BUILDIDENTIFIER') +src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +tok('BUILD') +src[t.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. + +tok('FULL') +tok('FULLPLAIN') +src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + + src[t.PRERELEASE] + '?' + + src[t.BUILD] + '?' + +src[t.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. +tok('LOOSEPLAIN') +src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + + src[t.PRERELEASELOOSE] + '?' + + src[t.BUILD] + '?' + +tok('LOOSE') +src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' + +tok('GTLT') +src[t.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. +tok('XRANGEIDENTIFIERLOOSE') +src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' +tok('XRANGEIDENTIFIER') +src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' + +tok('XRANGEPLAIN') +src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:' + src[t.PRERELEASE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' + +tok('XRANGEPLAINLOOSE') +src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:' + src[t.PRERELEASELOOSE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' + +tok('XRANGE') +src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' +tok('XRANGELOOSE') +src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' + +// 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') + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +tok('LONETILDE') +src[t.LONETILDE] = '(?:~>?)' + +tok('TILDETRIM') +src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' +re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') +var tildeTrimReplace = '$1~' + +tok('TILDE') +src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' +tok('TILDELOOSE') +src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +tok('LONECARET') +src[t.LONECARET] = '(?:\\^)' + +tok('CARETTRIM') +src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' +re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') +var caretTrimReplace = '$1^' + +tok('CARET') +src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' +tok('CARETLOOSE') +src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' + +// 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] + ')$|^$' + +// 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] + ')' + +// this one has to use the /g flag +re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') +var 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. +tok('HYPHENRANGE') +src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAIN] + ')' + + '\\s*$' + +tok('HYPHENRANGELOOSE') +src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s*$' + +// Star ranges basically just allow anything at all. +tok('STAR') +src[t.STAR] = '(<|>)?=?\\s*\\*' + +// 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]) + } +} + +exports.parse = parse +function 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 + } + + var 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 + } +} + +exports.valid = valid +function valid (version, options) { + var v = parse(version, options) + return v ? v.version : null +} + +exports.clean = clean +function clean (version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} + +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) + } + + if (version.length > MAX_LENGTH) { + throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') + } + + if (!(this instanceof SemVer)) { + return new SemVer(version, options) + } + + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + + var 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(function (id) { + if (/^[0-9]+$/.test(id)) { + var num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num + } + } + return id + }) + } + + this.build = m[5] ? m[5].split('.') : [] + this.format() +} + +SemVer.prototype.format = function () { + this.version = this.major + '.' + this.minor + '.' + this.patch + if (this.prerelease.length) { + this.version += '-' + this.prerelease.join('.') + } + return this.version +} + +SemVer.prototype.toString = function () { + return this.version +} + +SemVer.prototype.compare = function (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return this.compareMain(other) || this.comparePre(other) +} + +SemVer.prototype.compareMain = function (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) +} + +SemVer.prototype.comparePre = function (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 + } + + 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) +} + +SemVer.prototype.compareBuild = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + 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) +} + +// 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 + + default: + throw new Error('invalid increment argument: ' + release) + } + this.format() + this.raw = this.version + return this +} + +exports.inc = inc +function inc (version, release, loose, identifier) { + if (typeof (loose) === 'string') { + identifier = loose + loose = undefined + } + + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } +} + +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 + } + } + } + return defaultResult // may be undefined + } +} + +exports.compareIdentifiers = compareIdentifiers + +var numeric = /^[0-9]+$/ +function compareIdentifiers (a, b) { + var anum = numeric.test(a) + var 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 +} + +exports.rcompareIdentifiers = rcompareIdentifiers +function rcompareIdentifiers (a, b) { + return compareIdentifiers(b, a) +} + +exports.major = major +function major (a, loose) { + return new SemVer(a, loose).major +} + +exports.minor = minor +function minor (a, loose) { + return new SemVer(a, loose).minor +} + +exports.patch = patch +function patch (a, loose) { + return new SemVer(a, loose).patch +} + +exports.compare = compare +function compare (a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) +} + +exports.compareLoose = compareLoose +function compareLoose (a, b) { + return compare(a, b, true) +} + +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) +} + +exports.rcompare = rcompare +function rcompare (a, b, loose) { + return compare(b, a, loose) +} + +exports.sort = sort +function sort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(a, b, loose) + }) +} + +exports.rsort = rsort +function rsort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(b, a, loose) + }) +} + +exports.gt = gt +function gt (a, b, loose) { + return compare(a, b, loose) > 0 +} + +exports.lt = lt +function lt (a, b, loose) { + return compare(a, b, loose) < 0 +} + +exports.eq = eq +function eq (a, b, loose) { + return compare(a, b, loose) === 0 +} + +exports.neq = neq +function neq (a, b, loose) { + return compare(a, b, loose) !== 0 +} + +exports.gte = gte +function gte (a, b, loose) { + return compare(a, b, loose) >= 0 +} + +exports.lte = lte +function lte (a, b, loose) { + return compare(a, b, loose) <= 0 +} + +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) + + default: + throw new TypeError('Invalid operator: ' + op) + } +} + +exports.Comparator = Comparator +function Comparator (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 + } + } + + 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 + } + + debug('comp', this) +} + +var ANY = {} +Comparator.prototype.parse = function (comp) { + var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var 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) + } +} + +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 + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + return cmp(version, this.operator, this.semver, this.options) +} + +Comparator.prototype.intersects = function (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false + } + } + + var rangeTmp + + 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) + } + + 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 +} + +exports.Range = Range +function Range (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) { + return new Range(range.value, options) + } + + if (!(this instanceof Range)) { + return new Range(range, options) + } + + 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(function (range) { + return this.parseRange(range.trim()) + }, this).filter(function (c) { + // throw out any that are not relevant for whatever reason + return c.length + }) + + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range) + } + + this.format() +} + +Range.prototype.format = function () { + this.range = this.set.map(function (comps) { + return comps.join(' ').trim() + }).join('||').trim() + return this.range +} + +Range.prototype.toString = function () { + return this.range +} + +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]) + + // `~ 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. + + 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) + + return set +} + +Range.prototype.intersects = function (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + 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) + }) + + testComparator = remainingComparators.pop() + } + + 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 + } + + 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 + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false + } + } + + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true + } + } + return false +} + +function testSet (set, version, options) { + for (var 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 (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 + } + } + } + + // 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 +} + +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 +} + +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 + } + + return null +} + +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 + } +} + +// 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) +} + +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] + + var high = null + var low = null + + 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 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) +} + +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 + } + + options = options || {} + + 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 + } + // 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) +} + + +/***/ }), + +/***/ 586: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const lt = (a, b, loose) => compare(a, b, loose) < 0 +module.exports = lt + + +/***/ }), + +/***/ 593: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compareBuild = __webpack_require__(16) +const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) +module.exports = rsort + + +/***/ }), + +/***/ 605: +/***/ (function(module) { + +module.exports = require("http"); + +/***/ }), + +/***/ 612: +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + +module.exports = Yallist + +Yallist.Node = Node +Yallist.create = Yallist + +function Yallist (list) { + var self = this + if (!(self instanceof Yallist)) { + self = new Yallist() + } + + self.tail = null + self.head = null + self.length = 0 + + if (list && typeof list.forEach === 'function') { + list.forEach(function (item) { + self.push(item) + }) + } else if (arguments.length > 0) { + for (var i = 0, l = arguments.length; i < l; i++) { + self.push(arguments[i]) + } + } + + return self +} + +Yallist.prototype.removeNode = function (node) { + if (node.list !== this) { + throw new Error('removing node which does not belong to this list') + } + + var next = node.next + var prev = node.prev + + if (next) { + next.prev = prev + } + + if (prev) { + prev.next = next + } + + if (node === this.head) { + this.head = next + } + if (node === this.tail) { + this.tail = prev + } + + node.list.length-- + node.next = null + node.prev = null + node.list = null + + return next +} + +Yallist.prototype.unshiftNode = function (node) { + if (node === this.head) { + return + } + + if (node.list) { + node.list.removeNode(node) + } + + var head = this.head + node.list = this + node.next = head + if (head) { + head.prev = node + } + + this.head = node + if (!this.tail) { + this.tail = node + } + this.length++ +} + +Yallist.prototype.pushNode = function (node) { + if (node === this.tail) { + return + } + + if (node.list) { + node.list.removeNode(node) + } + + var tail = this.tail + node.list = this + node.prev = tail + if (tail) { + tail.next = node + } + + this.tail = node + if (!this.head) { + this.head = node + } + this.length++ +} + +Yallist.prototype.push = function () { + for (var i = 0, l = arguments.length; i < l; i++) { + push(this, arguments[i]) + } + return this.length +} + +Yallist.prototype.unshift = function () { + for (var i = 0, l = arguments.length; i < l; i++) { + unshift(this, arguments[i]) + } + return this.length +} + +Yallist.prototype.pop = function () { + if (!this.tail) { + return undefined + } + + var res = this.tail.value + this.tail = this.tail.prev + if (this.tail) { + this.tail.next = null + } else { + this.head = null + } + this.length-- + return res +} + +Yallist.prototype.shift = function () { + if (!this.head) { + return undefined + } + + var res = this.head.value + this.head = this.head.next + if (this.head) { + this.head.prev = null + } else { + this.tail = null + } + this.length-- + return res +} + +Yallist.prototype.forEach = function (fn, thisp) { + thisp = thisp || this + for (var walker = this.head, i = 0; walker !== null; i++) { + fn.call(thisp, walker.value, i, this) + walker = walker.next + } +} + +Yallist.prototype.forEachReverse = function (fn, thisp) { + thisp = thisp || this + for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { + fn.call(thisp, walker.value, i, this) + walker = walker.prev + } +} + +Yallist.prototype.get = function (n) { + for (var i = 0, walker = this.head; walker !== null && i < n; i++) { + // abort out of the list early if we hit a cycle + walker = walker.next + } + if (i === n && walker !== null) { + return walker.value + } +} + +Yallist.prototype.getReverse = function (n) { + for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { + // abort out of the list early if we hit a cycle + walker = walker.prev + } + if (i === n && walker !== null) { + return walker.value + } +} + +Yallist.prototype.map = function (fn, thisp) { + thisp = thisp || this + var res = new Yallist() + for (var walker = this.head; walker !== null;) { + res.push(fn.call(thisp, walker.value, this)) + walker = walker.next + } + return res +} + +Yallist.prototype.mapReverse = function (fn, thisp) { + thisp = thisp || this + var res = new Yallist() + for (var walker = this.tail; walker !== null;) { + res.push(fn.call(thisp, walker.value, this)) + walker = walker.prev + } + return res +} + +Yallist.prototype.reduce = function (fn, initial) { + var acc + var walker = this.head + if (arguments.length > 1) { + acc = initial + } else if (this.head) { + walker = this.head.next + acc = this.head.value + } else { + throw new TypeError('Reduce of empty list with no initial value') + } + + for (var i = 0; walker !== null; i++) { + acc = fn(acc, walker.value, i) + walker = walker.next + } + + return acc +} + +Yallist.prototype.reduceReverse = function (fn, initial) { + var acc + var walker = this.tail + if (arguments.length > 1) { + acc = initial + } else if (this.tail) { + walker = this.tail.prev + acc = this.tail.value + } else { + throw new TypeError('Reduce of empty list with no initial value') + } + + for (var i = this.length - 1; walker !== null; i--) { + acc = fn(acc, walker.value, i) + walker = walker.prev + } + + return acc +} + +Yallist.prototype.toArray = function () { + var arr = new Array(this.length) + for (var i = 0, walker = this.head; walker !== null; i++) { + arr[i] = walker.value + walker = walker.next + } + return arr +} + +Yallist.prototype.toArrayReverse = function () { + var arr = new Array(this.length) + for (var i = 0, walker = this.tail; walker !== null; i++) { + arr[i] = walker.value + walker = walker.prev + } + return arr +} + +Yallist.prototype.slice = function (from, to) { + to = to || this.length + if (to < 0) { + to += this.length + } + from = from || 0 + if (from < 0) { + from += this.length + } + var ret = new Yallist() + if (to < from || to < 0) { + return ret + } + if (from < 0) { + from = 0 + } + if (to > this.length) { + to = this.length + } + for (var i = 0, walker = this.head; walker !== null && i < from; i++) { + walker = walker.next + } + for (; walker !== null && i < to; i++, walker = walker.next) { + ret.push(walker.value) + } + return ret +} + +Yallist.prototype.sliceReverse = function (from, to) { + to = to || this.length + if (to < 0) { + to += this.length + } + from = from || 0 + if (from < 0) { + from += this.length + } + var ret = new Yallist() + if (to < from || to < 0) { + return ret + } + if (from < 0) { + from = 0 + } + if (to > this.length) { + to = this.length + } + for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { + walker = walker.prev + } + for (; walker !== null && i > from; i--, walker = walker.prev) { + ret.push(walker.value) + } + return ret +} + +Yallist.prototype.splice = function (start, deleteCount, ...nodes) { + if (start > this.length) { + start = this.length - 1 + } + if (start < 0) { + start = this.length + start; + } + + for (var i = 0, walker = this.head; walker !== null && i < start; i++) { + walker = walker.next + } + + var ret = [] + for (var i = 0; walker && i < deleteCount; i++) { + ret.push(walker.value) + walker = this.removeNode(walker) + } + if (walker === null) { + walker = this.tail + } + + if (walker !== this.head && walker !== this.tail) { + walker = walker.prev + } + + for (var i = 0; i < nodes.length; i++) { + walker = insert(this, walker, nodes[i]) + } + return ret; +} + +Yallist.prototype.reverse = function () { + var head = this.head + var tail = this.tail + for (var walker = head; walker !== null; walker = walker.prev) { + var p = walker.prev + walker.prev = walker.next + walker.next = p + } + this.head = tail + this.tail = head + return this +} + +function insert (self, node, value) { + var inserted = node === self.head ? + new Node(value, null, node, self) : + new Node(value, node, node.next, self) + + if (inserted.next === null) { + self.tail = inserted + } + if (inserted.prev === null) { + self.head = inserted + } + + self.length++ + + return inserted +} + +function push (self, item) { + self.tail = new Node(item, self.tail, null, self) + if (!self.head) { + self.head = self.tail + } + self.length++ +} + +function unshift (self, item) { + self.head = new Node(item, null, self.head, self) + if (!self.tail) { + self.tail = self.head + } + self.length++ +} + +function Node (value, prev, next, list) { + if (!(this instanceof Node)) { + return new Node(value, prev, next, list) + } + + this.list = list + this.value = value + + if (prev) { + prev.next = this + this.prev = prev + } else { + this.prev = null + } + + if (next) { + next.prev = this + this.next = next + } else { + this.next = null + } +} + +try { + // add if support for Symbol.iterator is present + __webpack_require__(396)(Yallist) +} catch (er) {} -module.exports = require("http"); /***/ }), @@ -4698,6 +6595,16 @@ module.exports = require("events"); module.exports = require("path"); +/***/ }), + +/***/ 630: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const rcompare = (a, b, loose) => compare(b, a, loose) +module.exports = rcompare + + /***/ }), /***/ 631: @@ -4942,6 +6849,361 @@ exports.INPUT_DEFAULT_GPG_PASSPHRASE = 'GPG_PASSPHRASE'; exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; +/***/ }), + +/***/ 702: +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + + +// A linked list to keep track of recently-used-ness +const Yallist = __webpack_require__(612) + +const MAX = Symbol('max') +const LENGTH = Symbol('length') +const LENGTH_CALCULATOR = Symbol('lengthCalculator') +const ALLOW_STALE = Symbol('allowStale') +const MAX_AGE = Symbol('maxAge') +const DISPOSE = Symbol('dispose') +const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet') +const LRU_LIST = Symbol('lruList') +const CACHE = Symbol('cache') +const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet') + +const naiveLength = () => 1 + +// lruList is a yallist where the head is the youngest +// item, and the tail is the oldest. the list contains the Hit +// objects as the entries. +// Each Hit object has a reference to its Yallist.Node. This +// never changes. +// +// cache is a Map (or PseudoMap) that matches the keys to +// the Yallist.Node object. +class LRUCache { + constructor (options) { + if (typeof options === 'number') + options = { max: options } + + if (!options) + options = {} + + if (options.max && (typeof options.max !== 'number' || options.max < 0)) + throw new TypeError('max must be a non-negative number') + // Kind of weird to have a default max of Infinity, but oh well. + const max = this[MAX] = options.max || Infinity + + const lc = options.length || naiveLength + this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc + this[ALLOW_STALE] = options.stale || false + if (options.maxAge && typeof options.maxAge !== 'number') + throw new TypeError('maxAge must be a number') + this[MAX_AGE] = options.maxAge || 0 + this[DISPOSE] = options.dispose + this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false + this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false + this.reset() + } + + // resize the cache when the max changes. + set max (mL) { + if (typeof mL !== 'number' || mL < 0) + throw new TypeError('max must be a non-negative number') + + this[MAX] = mL || Infinity + trim(this) + } + get max () { + return this[MAX] + } + + set allowStale (allowStale) { + this[ALLOW_STALE] = !!allowStale + } + get allowStale () { + return this[ALLOW_STALE] + } + + set maxAge (mA) { + if (typeof mA !== 'number') + throw new TypeError('maxAge must be a non-negative number') + + this[MAX_AGE] = mA + trim(this) + } + get maxAge () { + return this[MAX_AGE] + } + + // resize the cache when the lengthCalculator changes. + set lengthCalculator (lC) { + if (typeof lC !== 'function') + lC = naiveLength + + if (lC !== this[LENGTH_CALCULATOR]) { + this[LENGTH_CALCULATOR] = lC + this[LENGTH] = 0 + this[LRU_LIST].forEach(hit => { + hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key) + this[LENGTH] += hit.length + }) + } + trim(this) + } + get lengthCalculator () { return this[LENGTH_CALCULATOR] } + + get length () { return this[LENGTH] } + get itemCount () { return this[LRU_LIST].length } + + rforEach (fn, thisp) { + thisp = thisp || this + for (let walker = this[LRU_LIST].tail; walker !== null;) { + const prev = walker.prev + forEachStep(this, fn, walker, thisp) + walker = prev + } + } + + forEach (fn, thisp) { + thisp = thisp || this + for (let walker = this[LRU_LIST].head; walker !== null;) { + const next = walker.next + forEachStep(this, fn, walker, thisp) + walker = next + } + } + + keys () { + return this[LRU_LIST].toArray().map(k => k.key) + } + + values () { + return this[LRU_LIST].toArray().map(k => k.value) + } + + reset () { + if (this[DISPOSE] && + this[LRU_LIST] && + this[LRU_LIST].length) { + this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)) + } + + this[CACHE] = new Map() // hash of items by key + this[LRU_LIST] = new Yallist() // list of items in order of use recency + this[LENGTH] = 0 // length of items in the list + } + + dump () { + return this[LRU_LIST].map(hit => + isStale(this, hit) ? false : { + k: hit.key, + v: hit.value, + e: hit.now + (hit.maxAge || 0) + }).toArray().filter(h => h) + } + + dumpLru () { + return this[LRU_LIST] + } + + set (key, value, maxAge) { + maxAge = maxAge || this[MAX_AGE] + + if (maxAge && typeof maxAge !== 'number') + throw new TypeError('maxAge must be a number') + + const now = maxAge ? Date.now() : 0 + const len = this[LENGTH_CALCULATOR](value, key) + + if (this[CACHE].has(key)) { + if (len > this[MAX]) { + del(this, this[CACHE].get(key)) + return false + } + + const node = this[CACHE].get(key) + const item = node.value + + // dispose of the old one before overwriting + // split out into 2 ifs for better coverage tracking + if (this[DISPOSE]) { + if (!this[NO_DISPOSE_ON_SET]) + this[DISPOSE](key, item.value) + } + + item.now = now + item.maxAge = maxAge + item.value = value + this[LENGTH] += len - item.length + item.length = len + this.get(key) + trim(this) + return true + } + + const hit = new Entry(key, value, len, now, maxAge) + + // oversized objects fall out of cache automatically. + if (hit.length > this[MAX]) { + if (this[DISPOSE]) + this[DISPOSE](key, value) + + return false + } + + this[LENGTH] += hit.length + this[LRU_LIST].unshift(hit) + this[CACHE].set(key, this[LRU_LIST].head) + trim(this) + return true + } + + has (key) { + if (!this[CACHE].has(key)) return false + const hit = this[CACHE].get(key).value + return !isStale(this, hit) + } + + get (key) { + return get(this, key, true) + } + + peek (key) { + return get(this, key, false) + } + + pop () { + const node = this[LRU_LIST].tail + if (!node) + return null + + del(this, node) + return node.value + } + + del (key) { + del(this, this[CACHE].get(key)) + } + + load (arr) { + // reset the cache + this.reset() + + const now = Date.now() + // A previous serialized cache has the most recent items first + for (let l = arr.length - 1; l >= 0; l--) { + const hit = arr[l] + const expiresAt = hit.e || 0 + if (expiresAt === 0) + // the item was created without expiration in a non aged cache + this.set(hit.k, hit.v) + else { + const maxAge = expiresAt - now + // dont add already expired items + if (maxAge > 0) { + this.set(hit.k, hit.v, maxAge) + } + } + } + } + + prune () { + this[CACHE].forEach((value, key) => get(this, key, false)) + } +} + +const get = (self, key, doUse) => { + const node = self[CACHE].get(key) + if (node) { + const hit = node.value + if (isStale(self, hit)) { + del(self, node) + if (!self[ALLOW_STALE]) + return undefined + } else { + if (doUse) { + if (self[UPDATE_AGE_ON_GET]) + node.value.now = Date.now() + self[LRU_LIST].unshiftNode(node) + } + } + return hit.value + } +} + +const isStale = (self, hit) => { + if (!hit || (!hit.maxAge && !self[MAX_AGE])) + return false + + const diff = Date.now() - hit.now + return hit.maxAge ? diff > hit.maxAge + : self[MAX_AGE] && (diff > self[MAX_AGE]) +} + +const trim = self => { + if (self[LENGTH] > self[MAX]) { + for (let walker = self[LRU_LIST].tail; + self[LENGTH] > self[MAX] && walker !== null;) { + // We know that we're about to delete this one, and also + // what the next least recently used key will be, so just + // go ahead and set it now. + const prev = walker.prev + del(self, walker) + walker = prev + } + } +} + +const del = (self, node) => { + if (node) { + const hit = node.value + if (self[DISPOSE]) + self[DISPOSE](hit.key, hit.value) + + self[LENGTH] -= hit.length + self[CACHE].delete(hit.key) + self[LRU_LIST].removeNode(node) + } +} + +class Entry { + constructor (key, value, length, now, maxAge) { + this.key = key + this.value = value + this.length = length + this.now = now + this.maxAge = maxAge || 0 + } +} + +const forEachStep = (self, fn, node, thisp) => { + let hit = node.value + if (isStale(self, hit)) { + del(self, node) + if (!self[ALLOW_STALE]) + hit = undefined + } + if (hit) + fn.call(thisp, hit.value, hit.key, self) +} + +module.exports = LRUCache + + +/***/ }), + +/***/ 714: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(830) +const valid = (version, options) => { + const v = parse(version, options) + return v ? v.version : null +} +module.exports = valid + + /***/ }), /***/ 722: @@ -4971,23 +7233,228 @@ function bytesToUuid(buf, offset) { bth[buf[i++]], bth[buf[i++]] ]).join(''); } - -module.exports = bytesToUuid; + +module.exports = bytesToUuid; + + +/***/ }), + +/***/ 740: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const Range = __webpack_require__(124) +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 + + +/***/ }), + +/***/ 744: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const major = (a, loose) => new SemVer(a, loose).major +module.exports = major + + +/***/ }), + +/***/ 747: +/***/ (function(module) { + +module.exports = require("fs"); + +/***/ }), + +/***/ 752: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const eq = __webpack_require__(298) +const neq = __webpack_require__(873) +const gt = __webpack_require__(486) +const gte = __webpack_require__(167) +const lt = __webpack_require__(586) +const lte = __webpack_require__(898) + +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 + + +/***/ }), + +/***/ 760: +/***/ (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 +} + + +/***/ }), + +/***/ 794: +/***/ (function(module) { + +module.exports = require("stream"); + +/***/ }), + +/***/ 803: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const minor = (a, loose) => new SemVer(a, loose).minor +module.exports = minor + + +/***/ }), + +/***/ 811: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const Range = __webpack_require__(124) + +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 /***/ }), -/***/ 747: +/***/ 818: /***/ (function(module) { -module.exports = require("fs"); +module.exports = require("tls"); /***/ }), -/***/ 794: -/***/ (function(module) { +/***/ 822: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(830) +const eq = __webpack_require__(298) + +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 -module.exports = require("stream"); /***/ }), @@ -5025,6 +7492,174 @@ function v4(options, buf, offset) { module.exports = v4; +/***/ }), + +/***/ 830: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const {MAX_LENGTH} = __webpack_require__(181) +const { re, t } = __webpack_require__(976) +const SemVer = __webpack_require__(65) + +const parseOptions = __webpack_require__(143) +const parse = (version, options) => { + options = parseOptions(options) + + 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 + + +/***/ }), + +/***/ 873: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const neq = (a, b, loose) => compare(a, b, loose) !== 0 +module.exports = neq + + +/***/ }), + +/***/ 874: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const compare = (a, b, loose) => + new SemVer(a, loose).compare(new SemVer(b, loose)) + +module.exports = compare + + +/***/ }), + +/***/ 876: +/***/ (function(module, __unusedexports, __webpack_require__) { + +// just pre-load all the stuff that index.js lazily exports +const internalRe = __webpack_require__(976) +module.exports = { + re: internalRe.re, + src: internalRe.src, + tokens: internalRe.t, + SEMVER_SPEC_VERSION: __webpack_require__(181).SEMVER_SPEC_VERSION, + SemVer: __webpack_require__(65), + compareIdentifiers: __webpack_require__(760).compareIdentifiers, + rcompareIdentifiers: __webpack_require__(760).rcompareIdentifiers, + parse: __webpack_require__(830), + valid: __webpack_require__(714), + clean: __webpack_require__(503), + inc: __webpack_require__(928), + diff: __webpack_require__(822), + major: __webpack_require__(744), + minor: __webpack_require__(803), + patch: __webpack_require__(489), + prerelease: __webpack_require__(968), + compare: __webpack_require__(874), + rcompare: __webpack_require__(630), + compareLoose: __webpack_require__(283), + compareBuild: __webpack_require__(16), + sort: __webpack_require__(120), + rsort: __webpack_require__(593), + gt: __webpack_require__(486), + lt: __webpack_require__(586), + eq: __webpack_require__(298), + neq: __webpack_require__(873), + gte: __webpack_require__(167), + lte: __webpack_require__(898), + cmp: __webpack_require__(752), + coerce: __webpack_require__(499), + Comparator: __webpack_require__(174), + Range: __webpack_require__(124), + satisfies: __webpack_require__(310), + toComparators: __webpack_require__(20), + maxSatisfying: __webpack_require__(811), + minSatisfying: __webpack_require__(740), + minVersion: __webpack_require__(164), + validRange: __webpack_require__(480), + outside: __webpack_require__(462), + gtr: __webpack_require__(531), + ltr: __webpack_require__(323), + intersects: __webpack_require__(259), + simplifyRange: __webpack_require__(877), + subset: __webpack_require__(999), +} + + +/***/ }), + +/***/ 877: +/***/ (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__(310) +const compare = __webpack_require__(874) +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 +} + + /***/ }), /***/ 884: @@ -5047,7 +7682,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -5102,6 +7737,38 @@ function deleteKey(keyFingerprint) { exports.deleteKey = deleteKey; +/***/ }), + +/***/ 898: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const lte = (a, b, loose) => compare(a, b, loose) <= 0 +module.exports = lte + + +/***/ }), + +/***/ 928: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) + +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 + + /***/ }), /***/ 950: @@ -5167,6 +7834,208 @@ function checkBypass(reqUrl) { exports.checkBypass = checkBypass; +/***/ }), + +/***/ 968: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(830) +const prerelease = (version, options) => { + const parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} +module.exports = prerelease + + +/***/ }), + +/***/ 976: +/***/ (function(module, exports, __webpack_require__) { + +const { MAX_SAFE_COMPONENT_LENGTH } = __webpack_require__(181) +const debug = __webpack_require__(548) +exports = module.exports = {} + +// 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*$') + + /***/ }), /***/ 979: @@ -5295,6 +8164,175 @@ function exec(commandLine, args, options) { exports.exec = exec; //# sourceMappingURL=exec.js.map +/***/ }), + +/***/ 999: +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(124) +const { ANY } = __webpack_require__(174) +const satisfies = __webpack_require__(310) +const compare = __webpack_require__(874) + +// 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.semver 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 any < or <= 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) => { + if (sub === dom) + return true + + 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 === dom) + return true + + 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 && higher !== gt) + 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 && lower !== lt) + 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 + + /***/ }) /******/ }); \ No newline at end of file diff --git a/dist/setup/index.js b/dist/setup/index.js index 7e37bdb37..9c36741f7 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -486,12 +486,49 @@ exports.ASCIIAlphanumeric = /[0-9A-Za-z]/; /***/ }), /* 12 */, /* 13 */, -/* 14 */, +/* 14 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const Range = __webpack_require__(124) + +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 + + +/***/ }), /* 15 */, /* 16 */ -/***/ (function(module) { +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +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 -module.exports = require("tls"); /***/ }), /* 17 */, @@ -1637,7 +1674,7 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -const semver = __importStar(__webpack_require__(280)); +const semver = __importStar(__webpack_require__(550)); const core_1 = __webpack_require__(470); // needs to be require for core node modules to be mocked /* eslint @typescript-eslint/no-require-imports: 0 */ @@ -3481,7 +3518,299 @@ exports.parentNode_convertNodesIntoANode = parentNode_convertNodesIntoANode; /* 62 */, /* 63 */, /* 64 */, -/* 65 */, +/* 65 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const debug = __webpack_require__(548) +const { MAX_LENGTH, MAX_SAFE_INTEGER } = __webpack_require__(181) +const { re, t } = __webpack_require__(976) + +const parseOptions = __webpack_require__(143) +const { compareIdentifiers } = __webpack_require__(954) +class SemVer { + constructor (version, options) { + options = parseOptions(options) + + 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 + + +/***/ }), /* 66 */, /* 67 */, /* 68 */, @@ -3602,7 +3931,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -3622,7 +3951,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.JavaBase = void 0; const tc = __importStar(__webpack_require__(139)); const core = __importStar(__webpack_require__(470)); -const semver_1 = __importDefault(__webpack_require__(280)); +const semver_1 = __importDefault(__webpack_require__(876)); const path_1 = __importDefault(__webpack_require__(622)); const httpm = __importStar(__webpack_require__(539)); const util_1 = __webpack_require__(322); @@ -3721,7 +4050,15 @@ exports.JavaBase = JavaBase; /***/ }), /* 84 */, -/* 85 */, +/* 85 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const neq = (a, b, loose) => compare(a, b, loose) !== 0 +module.exports = neq + + +/***/ }), /* 86 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -7496,11 +7833,534 @@ util_1.applyMixin(ElementImpl_1.ElementImpl, SlotableImpl_1.SlotableImpl); /* 117 */, /* 118 */, /* 119 */, -/* 120 */, +/* 120 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compareBuild = __webpack_require__(16) +const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose)) +module.exports = sort + + +/***/ }), /* 121 */, /* 122 */, /* 123 */, -/* 124 */, +/* 124 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// hoisted class for cyclic dependency +class Range { + constructor (range, options) { + options = parseOptions(options) + + 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}`) + } + + // if we have any that are not the null set, throw out null sets. + if (this.set.length > 1) { + // keep the first one, in case they're all null sets + const first = this.set[0] + this.set = this.set.filter(c => !isNullSet(c[0])) + if (this.set.length === 0) + this.set = [first] + else if (this.set.length > 1) { + // if we have any that are *, then the range is just * + for (const c of this.set) { + if (c.length === 1 && isAny(c[0])) { + this.set = [c] + break + } + } + } + } + + this.format() + } + + format () { + this.range = this.set + .map((comps) => { + return comps.join(' ').trim() + }) + .join('||') + .trim() + return this.range + } + + toString () { + return this.range + } + + parseRange (range) { + range = range.trim() + + // memoize range parsing for performance. + // this is a very hot path, and fully deterministic. + const memoOpts = Object.keys(this.options).join(',') + const memoKey = `parseRange:${memoOpts}:${range}` + const cached = cache.get(memoKey) + if (cached) + return cached + + const loose = this.options.loose + // `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] + const rangeList = range + .split(' ') + .map(comp => parseComparator(comp, this.options)) + .join(' ') + .split(/\s+/) + // >=0.0.0 is equivalent to * + .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)) + + // if any comparators are the null set, then replace with JUST null set + // if more than one comparator, remove any * comparators + // also, don't include the same comparator more than once + const l = rangeList.length + const rangeMap = new Map() + for (const comp of rangeList) { + if (isNullSet(comp)) + return [comp] + rangeMap.set(comp.value, comp) + } + if (rangeMap.size > 1 && rangeMap.has('')) + rangeMap.delete('') + + const result = [...rangeMap.values()] + cache.set(memoKey, result) + return result + } + + 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 LRU = __webpack_require__(702) +const cache = new LRU({ max: 1000 }) + +const parseOptions = __webpack_require__(143) +const Comparator = __webpack_require__(536) +const debug = __webpack_require__(548) +const SemVer = __webpack_require__(65) +const { + re, + t, + comparatorTrimReplace, + tildeTrimReplace, + caretTrimReplace +} = __webpack_require__(976) + +const isNullSet = c => c.value === '<0.0.0-0' +const isAny = c => c.value === '' + +// 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 +} + + +/***/ }), /* 125 */, /* 126 */, /* 127 */, @@ -7579,7 +8439,7 @@ const mm = __importStar(__webpack_require__(31)); const os = __importStar(__webpack_require__(87)); const path = __importStar(__webpack_require__(622)); const httpm = __importStar(__webpack_require__(539)); -const semver = __importStar(__webpack_require__(280)); +const semver = __importStar(__webpack_require__(550)); const stream = __importStar(__webpack_require__(794)); const util = __importStar(__webpack_require__(669)); const v4_1 = __importDefault(__webpack_require__(494)); @@ -7595,6 +8455,7 @@ class HTTPError extends Error { } exports.HTTPError = HTTPError; const IS_WINDOWS = process.platform === 'win32'; +const IS_MAC = process.platform === 'darwin'; const userAgent = 'actions/tool-cache'; /** * Download a tool from an url and stream it into a file @@ -7810,6 +8671,36 @@ function extractTar(file, dest, flags = 'xz') { }); } exports.extractTar = extractTar; +/** + * Extract a xar compatible archive + * + * @param file path to the archive + * @param dest destination directory. Optional. + * @param flags flags for the xar. Optional. + * @returns path to the destination directory + */ +function extractXar(file, dest, flags = []) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(IS_MAC, 'extractXar() not supported on current OS'); + assert_1.ok(file, 'parameter "file" is required'); + dest = yield _createExtractFolder(dest); + let args; + if (flags instanceof Array) { + args = flags; + } + else { + args = [flags]; + } + args.push('-x', '-C', dest, '-f', file); + if (core.isDebug()) { + args.push('-v'); + } + const xarPath = yield io.which('xar', true); + yield exec_1.exec(`"${xarPath}"`, _unique(args)); + return dest; + }); +} +exports.extractXar = extractXar; /** * Extract a zip * @@ -8118,6 +9009,13 @@ function _getGlobal(key, defaultValue) { /* eslint-enable @typescript-eslint/no-explicit-any */ return value !== undefined ? value : defaultValue; } +/** + * Returns an array of unique values. + * @param values Values to make unique. + */ +function _unique(values) { + return Array.from(new Set(values)); +} //# sourceMappingURL=tool-cache.js.map /***/ }), @@ -8129,7 +9027,7 @@ function _getGlobal(key, defaultValue) { var net = __webpack_require__(631); -var tls = __webpack_require__(16); +var tls = __webpack_require__(818); var http = __webpack_require__(605); var https = __webpack_require__(34); var events = __webpack_require__(614); @@ -8394,7 +9292,23 @@ exports.debug = debug; // for test /***/ }), /* 142 */, -/* 143 */, +/* 143 */ +/***/ (function(module) { + +// parse out just the options we care about so we always get a consistent +// obj with keys in a consistent order. +const opts = ['includePrerelease', 'loose', 'rtl'] +const parseOptions = options => + !options ? {} + : typeof options !== 'object' ? { loose: true } + : opts.filter(k => options[k]).reduce((options, k) => { + options[k] = true + return options + }, {}) +module.exports = parseOptions + + +/***/ }), /* 144 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -8415,7 +9329,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -9293,7 +10207,15 @@ exports.CustomEventImpl = CustomEventImpl; /***/ }), /* 165 */, /* 166 */, -/* 167 */, +/* 167 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const gte = (a, b, loose) => compare(a, b, loose) >= 0 +module.exports = gte + + +/***/ }), /* 168 */, /* 169 */, /* 170 */, @@ -9994,7 +10916,29 @@ exports.shadowTree_assignASlot = shadowTree_assignASlot; //# sourceMappingURL=ShadowTreeAlgorithm.js.map /***/ }), -/* 181 */, +/* 181 */ +/***/ (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 +} + + +/***/ }), /* 182 */, /* 183 */, /* 184 */, @@ -10401,7 +11345,20 @@ exports.DOMParser = DOMParserImpl_1.DOMParserImpl; /* 216 */, /* 217 */, /* 218 */, -/* 219 */, +/* 219 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(124) + +// 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 + + +/***/ }), /* 220 */, /* 221 */, /* 222 */, @@ -10535,7 +11492,19 @@ exports.fragmentCB = builder_1.fragmentCB; /* 256 */, /* 257 */, /* 258 */, -/* 259 */, +/* 259 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(124) +const intersects = (r1, r2, options) => { + r1 = new Range(r1, options) + r2 = new Range(r2, options) + return r1.intersects(r2) +} +module.exports = intersects + + +/***/ }), /* 260 */, /* 261 */, /* 262 */, @@ -11371,2254 +12340,2000 @@ exports.sortInDescendingOrder = sortInDescendingOrder; //# sourceMappingURL=Map.js.map /***/ }), -/* 280 */ -/***/ (function(module, exports) { - -exports = module.exports = SemVer - -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 () {} -} - -// 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' - -var MAX_LENGTH = 256 -var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 - -// Max safe segment length for coercion. -var MAX_SAFE_COMPONENT_LENGTH = 16 - -// The actual regexps go on exports.re -var re = exports.re = [] -var src = exports.src = [] -var t = exports.tokens = {} -var R = 0 - -function tok (n) { - t[n] = R++ -} - -// 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. - -tok('NUMERICIDENTIFIER') -src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' -tok('NUMERICIDENTIFIERLOOSE') -src[t.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. - -tok('NONNUMERICIDENTIFIER') -src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' - -// ## Main Version -// Three dot-separated numeric identifiers. - -tok('MAINVERSION') -src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIER] + ')' - -tok('MAINVERSIONLOOSE') -src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + - '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' - -// ## Pre-release Version Identifier -// A numeric identifier, or a non-numeric identifier. - -tok('PRERELEASEIDENTIFIER') -src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' - -tok('PRERELEASEIDENTIFIERLOOSE') -src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + - '|' + src[t.NONNUMERICIDENTIFIER] + ')' - -// ## Pre-release Version -// Hyphen, followed by one or more dot-separated pre-release version -// identifiers. - -tok('PRERELEASE') -src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' - -tok('PRERELEASELOOSE') -src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + - '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' - -// ## Build Metadata Identifier -// Any combination of digits, letters, or hyphens. - -tok('BUILDIDENTIFIER') -src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' - -// ## Build Metadata -// Plus sign, followed by one or more period-separated build metadata -// identifiers. - -tok('BUILD') -src[t.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. - -tok('FULL') -tok('FULLPLAIN') -src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + - src[t.PRERELEASE] + '?' + - src[t.BUILD] + '?' - -src[t.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. -tok('LOOSEPLAIN') -src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + - src[t.PRERELEASELOOSE] + '?' + - src[t.BUILD] + '?' - -tok('LOOSE') -src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' - -tok('GTLT') -src[t.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. -tok('XRANGEIDENTIFIERLOOSE') -src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' -tok('XRANGEIDENTIFIER') -src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' - -tok('XRANGEPLAIN') -src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + - '(?:' + src[t.PRERELEASE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' - -tok('XRANGEPLAINLOOSE') -src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + - '(?:' + src[t.PRERELEASELOOSE] + ')?' + - src[t.BUILD] + '?' + - ')?)?' - -tok('XRANGE') -src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' -tok('XRANGELOOSE') -src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' - -// 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') - -// Tilde ranges. -// Meaning is "reasonably at or greater than" -tok('LONETILDE') -src[t.LONETILDE] = '(?:~>?)' - -tok('TILDETRIM') -src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' -re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') -var tildeTrimReplace = '$1~' - -tok('TILDE') -src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' -tok('TILDELOOSE') -src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' - -// Caret ranges. -// Meaning is "at least and backwards compatible with" -tok('LONECARET') -src[t.LONECARET] = '(?:\\^)' - -tok('CARETTRIM') -src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' -re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') -var caretTrimReplace = '$1^' +/* 280 */, +/* 281 */, +/* 282 */, +/* 283 */ +/***/ (function(module, __unusedexports, __webpack_require__) { -tok('CARET') -src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' -tok('CARETLOOSE') -src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' +const compare = __webpack_require__(874) +const compareLoose = (a, b) => compare(a, b, true) +module.exports = compareLoose -// 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] + ')$|^$' -// 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] + ')' +/***/ }), +/* 284 */, +/* 285 */, +/* 286 */ +/***/ (function(__unusedmodule, exports) { -// this one has to use the /g flag -re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') -var comparatorTrimReplace = '$1$2$3' +"use strict"; -// 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*$' +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Represents the state of the URL parser. + */ +var ParserState; +(function (ParserState) { + ParserState[ParserState["SchemeStart"] = 0] = "SchemeStart"; + ParserState[ParserState["Scheme"] = 1] = "Scheme"; + ParserState[ParserState["NoScheme"] = 2] = "NoScheme"; + ParserState[ParserState["SpecialRelativeOrAuthority"] = 3] = "SpecialRelativeOrAuthority"; + ParserState[ParserState["PathOrAuthority"] = 4] = "PathOrAuthority"; + ParserState[ParserState["Relative"] = 5] = "Relative"; + ParserState[ParserState["RelativeSlash"] = 6] = "RelativeSlash"; + ParserState[ParserState["SpecialAuthoritySlashes"] = 7] = "SpecialAuthoritySlashes"; + ParserState[ParserState["SpecialAuthorityIgnoreSlashes"] = 8] = "SpecialAuthorityIgnoreSlashes"; + ParserState[ParserState["Authority"] = 9] = "Authority"; + ParserState[ParserState["Host"] = 10] = "Host"; + ParserState[ParserState["Hostname"] = 11] = "Hostname"; + ParserState[ParserState["Port"] = 12] = "Port"; + ParserState[ParserState["File"] = 13] = "File"; + ParserState[ParserState["FileSlash"] = 14] = "FileSlash"; + ParserState[ParserState["FileHost"] = 15] = "FileHost"; + ParserState[ParserState["PathStart"] = 16] = "PathStart"; + ParserState[ParserState["Path"] = 17] = "Path"; + ParserState[ParserState["CannotBeABaseURLPath"] = 18] = "CannotBeABaseURLPath"; + ParserState[ParserState["Query"] = 19] = "Query"; + ParserState[ParserState["Fragment"] = 20] = "Fragment"; +})(ParserState = exports.ParserState || (exports.ParserState = {})); +exports.OpaqueOrigin = ["", "", null, null]; +//# sourceMappingURL=interfaces.js.map -tok('HYPHENRANGELOOSE') -src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s+-\\s+' + - '(' + src[t.XRANGEPLAINLOOSE] + ')' + - '\\s*$' +/***/ }), +/* 287 */, +/* 288 */, +/* 289 */, +/* 290 */, +/* 291 */, +/* 292 */, +/* 293 */, +/* 294 */, +/* 295 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { -// Star ranges basically just allow anything at all. -tok('STAR') -src[t.STAR] = '(<|>)?=?\\s*\\*' +"use strict"; -// 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]) - } +Object.defineProperty(exports, "__esModule", { value: true }); +var _1 = __webpack_require__(535); +/** + * Creates an XML builder which serializes the document in chunks. + * + * @param options - callback builder options + * + * @returns callback builder + */ +function createCB(options) { + return new _1.XMLBuilderCBImpl(options); +} +exports.createCB = createCB; +/** + * Creates an XML builder which serializes the fragment in chunks. + * + * @param options - callback builder options + * + * @returns callback builder + */ +function fragmentCB(options) { + return new _1.XMLBuilderCBImpl(options, true); } +exports.fragmentCB = fragmentCB; +//# sourceMappingURL=BuilderFunctionsCB.js.map -exports.parse = parse -function parse (version, options) { - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } +/***/ }), +/* 296 */, +/* 297 */, +/* 298 */ +/***/ (function(module, __unusedexports, __webpack_require__) { - if (version instanceof SemVer) { - return version - } +const compare = __webpack_require__(874) +const eq = (a, b, loose) => compare(a, b, loose) === 0 +module.exports = eq - if (typeof version !== 'string') { - return null - } - if (version.length > MAX_LENGTH) { - return null - } +/***/ }), +/* 299 */, +/* 300 */, +/* 301 */, +/* 302 */, +/* 303 */, +/* 304 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { - var r = options.loose ? re[t.LOOSE] : re[t.FULL] - if (!r.test(version)) { - return null - } +"use strict"; - try { - return new SemVer(version, options) - } catch (er) { - return null - } +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var DOMImpl_1 = __webpack_require__(648); +var TreeAlgorithm_1 = __webpack_require__(873); +var util_1 = __webpack_require__(918); +var ShadowTreeAlgorithm_1 = __webpack_require__(180); +var supportedTokens = new Map(); +/** + * Runs removing steps for node. + * + * @param removedNode - removed node + * @param oldParent - old parent node + */ +function dom_runRemovingSteps(removedNode, oldParent) { + // No steps defined } - -exports.valid = valid -function valid (version, options) { - var v = parse(version, options) - return v ? v.version : null +exports.dom_runRemovingSteps = dom_runRemovingSteps; +/** + * Runs cloning steps for node. + * + * @param copy - node clone + * @param node - node + * @param document - document to own the cloned node + * @param cloneChildrenFlag - whether child nodes are cloned + */ +function dom_runCloningSteps(copy, node, document, cloneChildrenFlag) { + // No steps defined } - -exports.clean = clean -function clean (version, options) { - var s = parse(version.trim().replace(/^[=v]+/, ''), options) - return s ? s.version : null +exports.dom_runCloningSteps = dom_runCloningSteps; +/** + * Runs adopting steps for node. + * + * @param node - node + * @param oldDocument - old document + */ +function dom_runAdoptingSteps(node, oldDocument) { + // No steps defined } - -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 +exports.dom_runAdoptingSteps = dom_runAdoptingSteps; +/** + * Runs attribute change steps for an element node. + * + * @param element - element node owning the attribute + * @param localName - attribute's local name + * @param oldValue - attribute's old value + * @param value - attribute's new value + * @param namespace - attribute's namespace + */ +function dom_runAttributeChangeSteps(element, localName, oldValue, value, namespace) { + var e_1, _a; + // run default steps + if (DOMImpl_1.dom.features.slots) { + updateASlotablesName.call(element, element, localName, oldValue, value, namespace); + updateASlotsName.call(element, element, localName, oldValue, value, namespace); } - } 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') - } - - if (!(this instanceof SemVer)) { - return new SemVer(version, options) - } - - debug('SemVer', version, options) - this.options = options - this.loose = !!options.loose - - var 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(function (id) { - if (/^[0-9]+$/.test(id)) { - var num = +id - if (num >= 0 && num < MAX_SAFE_INTEGER) { - return num + updateAnElementID.call(element, element, localName, value, namespace); + try { + // run custom steps + for (var _b = __values(element._attributeChangeSteps), _c = _b.next(); !_c.done; _c = _b.next()) { + var step = _c.value; + step.call(element, element, localName, oldValue, value, namespace); } - } - return id - }) - } - - this.build = m[5] ? m[5].split('.') : [] - this.format() + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } } - -SemVer.prototype.format = function () { - this.version = this.major + '.' + this.minor + '.' + this.patch - if (this.prerelease.length) { - this.version += '-' + this.prerelease.join('.') - } - return this.version +exports.dom_runAttributeChangeSteps = dom_runAttributeChangeSteps; +/** + * Runs insertion steps for a node. + * + * @param insertedNode - inserted node + */ +function dom_runInsertionSteps(insertedNode) { + // No steps defined } - -SemVer.prototype.toString = function () { - return this.version +exports.dom_runInsertionSteps = dom_runInsertionSteps; +/** + * Runs pre-removing steps for a node iterator and node. + * + * @param nodeIterator - a node iterator + * @param toBeRemoved - node to be removed + */ +function dom_runNodeIteratorPreRemovingSteps(nodeIterator, toBeRemoved) { + removeNodeIterator.call(nodeIterator, nodeIterator, toBeRemoved); } - -SemVer.prototype.compare = function (other) { - debug('SemVer.compare', this.version, this.options, other) - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - return this.compareMain(other) || this.comparePre(other) +exports.dom_runNodeIteratorPreRemovingSteps = dom_runNodeIteratorPreRemovingSteps; +/** + * Determines if there are any supported tokens defined for the given + * attribute name. + * + * @param attributeName - an attribute name + */ +function dom_hasSupportedTokens(attributeName) { + return supportedTokens.has(attributeName); } - -SemVer.prototype.compareMain = function (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) +exports.dom_hasSupportedTokens = dom_hasSupportedTokens; +/** + * Returns the set of supported tokens defined for the given attribute name. + * + * @param attributeName - an attribute name + */ +function dom_getSupportedTokens(attributeName) { + return supportedTokens.get(attributeName) || new Set(); } - -SemVer.prototype.comparePre = function (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 - } - - 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) +exports.dom_getSupportedTokens = dom_getSupportedTokens; +/** + * Runs event construction steps. + * + * @param event - an event + */ +function dom_runEventConstructingSteps(event) { + // No steps defined } - -SemVer.prototype.compareBuild = function (other) { - if (!(other instanceof SemVer)) { - other = new SemVer(other, this.options) - } - - 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) +exports.dom_runEventConstructingSteps = dom_runEventConstructingSteps; +/** + * Runs child text content change steps for a parent node. + * + * @param parent - parent node with text node child nodes + */ +function dom_runChildTextContentChangeSteps(parent) { + // No steps defined } - -// 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 - } +exports.dom_runChildTextContentChangeSteps = dom_runChildTextContentChangeSteps; +/** + * Defines pre-removing steps for a node iterator. + */ +function removeNodeIterator(nodeIterator, toBeRemovedNode) { + /** + * 1. If toBeRemovedNode is not an inclusive ancestor of nodeIterator’s + * reference, or toBeRemovedNode is nodeIterator’s root, then return. + */ + if (toBeRemovedNode === nodeIterator._root || + !TreeAlgorithm_1.tree_isAncestorOf(nodeIterator._reference, toBeRemovedNode, true)) { + return; + } + /** + * 2. If nodeIterator’s pointer before reference is true, then: + */ + if (nodeIterator._pointerBeforeReference) { + /** + * 2.1. Let next be toBeRemovedNode’s first following node that is an + * inclusive descendant of nodeIterator’s root and is not an inclusive + * descendant of toBeRemovedNode, and null if there is no such node. + */ + while (true) { + var nextNode = TreeAlgorithm_1.tree_getFollowingNode(nodeIterator._root, toBeRemovedNode); + if (nextNode !== null && + TreeAlgorithm_1.tree_isDescendantOf(nodeIterator._root, nextNode, true) && + !TreeAlgorithm_1.tree_isDescendantOf(toBeRemovedNode, nextNode, true)) { + /** + * 2.2. If next is non-null, then set nodeIterator’s reference to next + * and return. + */ + nodeIterator._reference = nextNode; + return; + } + else if (nextNode === null) { + /** + * 2.3. Otherwise, set nodeIterator’s pointer before reference to false. + */ + nodeIterator._pointerBeforeReference = false; + return; + } } - if (i === -1) { - // didn't increment anything - this.prerelease.push(0) + } + /** + * 3. Set nodeIterator’s reference to toBeRemovedNode’s parent, if + * toBeRemovedNode’s previous sibling is null, and to the inclusive + * descendant of toBeRemovedNode’s previous sibling that appears last in + * tree order otherwise. + */ + if (toBeRemovedNode._previousSibling === null) { + if (toBeRemovedNode._parent !== null) { + nodeIterator._reference = toBeRemovedNode._parent; } - } - 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] + } + else { + var referenceNode = toBeRemovedNode._previousSibling; + var childNode = TreeAlgorithm_1.tree_getFirstDescendantNode(toBeRemovedNode._previousSibling, true, false); + while (childNode !== null) { + if (childNode !== null) { + referenceNode = childNode; + } + // loop through to get the last descendant node + childNode = TreeAlgorithm_1.tree_getNextDescendantNode(toBeRemovedNode._previousSibling, childNode, true, false); } - } - break - - default: - throw new Error('invalid increment argument: ' + release) - } - this.format() - this.raw = this.version - return this -} - -exports.inc = inc -function inc (version, release, loose, identifier) { - if (typeof (loose) === 'string') { - identifier = loose - loose = undefined - } - - try { - return new SemVer(version, loose).inc(release, identifier).version - } catch (er) { - return null - } -} - -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' + nodeIterator._reference = referenceNode; } - for (var key in v1) { - if (key === 'major' || key === 'minor' || key === 'patch') { - if (v1[key] !== v2[key]) { - return prefix + key +} +/** + * Defines attribute change steps to update a slot’s name. + */ +function updateASlotsName(element, localName, oldValue, value, namespace) { + /** + * 1. If element is a slot, localName is name, and namespace is null, then: + * 1.1. If value is oldValue, then return. + * 1.2. If value is null and oldValue is the empty string, then return. + * 1.3. If value is the empty string and oldValue is null, then return. + * 1.4. If value is null or the empty string, then set element’s name to the + * empty string. + * 1.5. Otherwise, set element’s name to value. + * 1.6. Run assign slotables for a tree with element’s root. + */ + if (util_1.Guard.isSlot(element) && localName === "name" && namespace === null) { + if (value === oldValue) + return; + if (value === null && oldValue === '') + return; + if (value === '' && oldValue === null) + return; + if ((value === null || value === '')) { + element._name = ''; } - } + else { + element._name = value; + } + ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(element)); } - return defaultResult // may be undefined - } } - -exports.compareIdentifiers = compareIdentifiers - -var numeric = /^[0-9]+$/ -function compareIdentifiers (a, b) { - var anum = numeric.test(a) - var 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 +/** + * Defines attribute change steps to update a slotable’s name. + */ +function updateASlotablesName(element, localName, oldValue, value, namespace) { + /** + * 1. If localName is slot and namespace is null, then: + * 1.1. If value is oldValue, then return. + * 1.2. If value is null and oldValue is the empty string, then return. + * 1.3. If value is the empty string and oldValue is null, then return. + * 1.4. If value is null or the empty string, then set element’s name to + * the empty string. + * 1.5. Otherwise, set element’s name to value. + * 1.6. If element is assigned, then run assign slotables for element’s + * assigned slot. + * 1.7. Run assign a slot for element. + */ + if (util_1.Guard.isSlotable(element) && localName === "slot" && namespace === null) { + if (value === oldValue) + return; + if (value === null && oldValue === '') + return; + if (value === '' && oldValue === null) + return; + if ((value === null || value === '')) { + element._name = ''; + } + else { + element._name = value; + } + if (ShadowTreeAlgorithm_1.shadowTree_isAssigned(element)) { + ShadowTreeAlgorithm_1.shadowTree_assignSlotables(element._assignedSlot); + } + ShadowTreeAlgorithm_1.shadowTree_assignASlot(element); + } } - -exports.rcompareIdentifiers = rcompareIdentifiers -function rcompareIdentifiers (a, b) { - return compareIdentifiers(b, a) +/** + * Defines attribute change steps to update an element's ID. + */ +function updateAnElementID(element, localName, value, namespace) { + /** + * 1. If localName is id, namespace is null, and value is null or the empty + * string, then unset element’s ID. + * 2. Otherwise, if localName is id, namespace is null, then set element’s + * ID to value. + */ + if (localName === "id" && namespace === null) { + if (!value) + element._uniqueIdentifier = undefined; + else + element._uniqueIdentifier = value; + } } +//# sourceMappingURL=DOMAlgorithm.js.map -exports.major = major -function major (a, loose) { - return new SemVer(a, loose).major -} +/***/ }), +/* 305 */ +/***/ (function(__unusedmodule, exports) { -exports.minor = minor -function minor (a, loose) { - return new SemVer(a, loose).minor -} +"use strict"; -exports.patch = patch -function patch (a, loose) { - return new SemVer(a, loose).patch -} - -exports.compare = compare -function compare (a, b, loose) { - return new SemVer(a, loose).compare(new SemVer(b, loose)) -} - -exports.compareLoose = compareLoose -function compareLoose (a, b) { - return compare(a, b, true) -} - -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) -} - -exports.rcompare = rcompare -function rcompare (a, b, loose) { - return compare(b, a, loose) -} - -exports.sort = sort -function sort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(a, b, loose) - }) -} - -exports.rsort = rsort -function rsort (list, loose) { - return list.sort(function (a, b) { - return exports.compareBuild(b, a, loose) - }) -} +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Pre-serializes XML nodes. + */ +var BaseReader = /** @class */ (function () { + /** + * Initializes a new instance of `BaseReader`. + * + * @param builderOptions - XML builder options + */ + function BaseReader(builderOptions) { + this._builderOptions = builderOptions; + if (builderOptions.parser) { + Object.assign(this, builderOptions.parser); + } + } + BaseReader.prototype._docType = function (parent, name, publicId, systemId) { + return parent.dtd({ name: name, pubID: publicId, sysID: systemId }); + }; + BaseReader.prototype._comment = function (parent, data) { + return parent.com(data); + }; + BaseReader.prototype._text = function (parent, data) { + return parent.txt(data); + }; + BaseReader.prototype._instruction = function (parent, target, data) { + return parent.ins(target, data); + }; + BaseReader.prototype._cdata = function (parent, data) { + return parent.dat(data); + }; + BaseReader.prototype._element = function (parent, namespace, name) { + return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name)); + }; + BaseReader.prototype._attribute = function (parent, namespace, name, value) { + return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value)); + }; + /** + * Main parser function which parses the given object and returns an XMLBuilder. + * + * @param node - node to recieve parsed content + * @param obj - object to parse + */ + BaseReader.prototype.parse = function (node, obj) { + return this._parse(node, obj); + }; + /** + * Creates a DocType node. + * The node will be skipped if the function returns `undefined`. + * + * @param name - node name + * @param publicId - public identifier + * @param systemId - system identifier + */ + BaseReader.prototype.docType = function (parent, name, publicId, systemId) { + return this._docType(parent, name, publicId, systemId); + }; + /** + * Creates a comment node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.comment = function (parent, data) { + return this._comment(parent, data); + }; + /** + * Creates a text node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.text = function (parent, data) { + return this._text(parent, data); + }; + /** + * Creates a processing instruction node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param target - instruction target + * @param data - node data + */ + BaseReader.prototype.instruction = function (parent, target, data) { + return this._instruction(parent, target, data); + }; + /** + * Creates a CData section node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param data - node data + */ + BaseReader.prototype.cdata = function (parent, data) { + return this._cdata(parent, data); + }; + /** + * Creates an element node. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param namespace - node namespace + * @param name - node name + */ + BaseReader.prototype.element = function (parent, namespace, name) { + return this._element(parent, namespace, name); + }; + /** + * Creates an attribute or namespace declaration. + * The node will be skipped if the function returns `undefined`. + * + * @param parent - parent node + * @param namespace - node namespace + * @param name - node name + * @param value - node value + */ + BaseReader.prototype.attribute = function (parent, namespace, name, value) { + return this._attribute(parent, namespace, name, value); + }; + return BaseReader; +}()); +exports.BaseReader = BaseReader; +//# sourceMappingURL=BaseReader.js.map -exports.gt = gt -function gt (a, b, loose) { - return compare(a, b, loose) > 0 -} +/***/ }), +/* 306 */, +/* 307 */, +/* 308 */, +/* 309 */, +/* 310 */ +/***/ (function(module, __unusedexports, __webpack_require__) { -exports.lt = lt -function lt (a, b, loose) { - return compare(a, b, loose) < 0 +const Range = __webpack_require__(124) +const satisfies = (version, range, options) => { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) } +module.exports = satisfies -exports.eq = eq -function eq (a, b, loose) { - return compare(a, b, loose) === 0 -} -exports.neq = neq -function neq (a, b, loose) { - return compare(a, b, loose) !== 0 -} +/***/ }), +/* 311 */, +/* 312 */, +/* 313 */, +/* 314 */, +/* 315 */, +/* 316 */, +/* 317 */, +/* 318 */, +/* 319 */, +/* 320 */, +/* 321 */, +/* 322 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { -exports.gte = gte -function gte (a, b, loose) { - return compare(a, b, loose) >= 0 -} +"use strict"; -exports.lte = lte -function lte (a, b, loose) { - return compare(a, b, loose) <= 0 +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 (k !== "default" && Object.prototype.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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +const os_1 = __importDefault(__webpack_require__(87)); +const path_1 = __importDefault(__webpack_require__(622)); +const fs = __importStar(__webpack_require__(747)); +const semver = __importStar(__webpack_require__(876)); +const core = __importStar(__webpack_require__(470)); +const tc = __importStar(__webpack_require__(139)); +function getTempDir() { + let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); + return tempDirectory; } - -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) - - default: - throw new TypeError('Invalid operator: ' + op) - } +exports.getTempDir = getTempDir; +function getBooleanInput(inputName, defaultValue = false) { + return (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'; } - -exports.Comparator = Comparator -function Comparator (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 +exports.getBooleanInput = getBooleanInput; +function getVersionFromToolcachePath(toolPath) { + if (toolPath) { + return path_1.default.basename(path_1.default.dirname(toolPath)); } - } - - 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 - } - - debug('comp', this) + return toolPath; } - -var ANY = {} -Comparator.prototype.parse = function (comp) { - var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] - var 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) - } +exports.getVersionFromToolcachePath = getVersionFromToolcachePath; +function extractJdkFile(toolPath, extension) { + return __awaiter(this, void 0, void 0, function* () { + if (!extension) { + extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); + if (extension.startsWith('.')) { + extension = extension.substring(1); + } + } + switch (extension) { + case 'tar.gz': + case 'tar': + return yield tc.extractTar(toolPath); + case 'zip': + return yield tc.extractZip(toolPath); + default: + return yield tc.extract7z(toolPath); + } + }); } - -Comparator.prototype.toString = function () { - return this.value +exports.extractJdkFile = extractJdkFile; +function getDownloadArchiveExtension() { + return process.platform === 'win32' ? 'zip' : 'tar.gz'; } - -Comparator.prototype.test = function (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 +exports.getDownloadArchiveExtension = getDownloadArchiveExtension; +function isVersionSatisfies(range, version) { + var _a; + if (semver.valid(range)) { + // if full version with build digit is provided as a range (such as '1.2.3+4') + // we should check for exact equal via compareBuild + // since semver.satisfies doesn't handle 4th digit + const semRange = semver.parse(range); + if (semRange && ((_a = semRange.build) === null || _a === void 0 ? void 0 : _a.length) > 0) { + return semver.compareBuild(range, version) === 0; + } } - } - - return cmp(version, this.operator, this.semver, this.options) + return semver.satisfies(version, range); } - -Comparator.prototype.intersects = function (comp, options) { - if (!(comp instanceof Comparator)) { - throw new TypeError('a Comparator is required') - } - - if (!options || typeof options !== 'object') { - options = { - loose: !!options, - includePrerelease: false - } - } - - var rangeTmp - - 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 +exports.isVersionSatisfies = isVersionSatisfies; +function getToolcachePath(toolName, version, architecture) { + var _a; + const toolcacheRoot = (_a = process.env['RUNNER_TOOL_CACHE']) !== null && _a !== void 0 ? _a : ''; + const fullPath = path_1.default.join(toolcacheRoot, toolName, version, architecture); + if (fs.existsSync(fullPath)) { + return fullPath; } - rangeTmp = new Range(this.value, options) - return satisfies(comp.semver, rangeTmp, options) - } - - 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 + return null; } +exports.getToolcachePath = getToolcachePath; -exports.Range = Range -function Range (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) - } - } +/***/ }), +/* 323 */ +/***/ (function(module, __unusedexports, __webpack_require__) { - if (range instanceof Comparator) { - return new Range(range.value, options) - } +const outside = __webpack_require__(881) +// 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 - if (!(this instanceof Range)) { - return new Range(range, options) - } - this.options = options - this.loose = !!options.loose - this.includePrerelease = !!options.includePrerelease +/***/ }), +/* 324 */, +/* 325 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { - // 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 - }) +"use strict"; - if (!this.set.length) { - throw new TypeError('Invalid SemVer Range: ' + range) - } +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var ObjectWriter_1 = __webpack_require__(419); +var util_1 = __webpack_require__(592); +var BaseWriter_1 = __webpack_require__(462); +/** + * Serializes XML nodes into a YAML string. + */ +var YAMLWriter = /** @class */ (function (_super) { + __extends(YAMLWriter, _super); + /** + * Initializes a new instance of `YAMLWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function YAMLWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + wellFormed: false, + noDoubleEncoding: false, + indent: ' ', + newline: '\n', + offset: 0, + group: false, + verbose: false + }); + if (_this._writerOptions.indent.length < 2) { + throw new Error("YAML indententation string must be at least two characters long."); + } + if (_this._writerOptions.offset < 0) { + throw new Error("YAML offset should be zero or a positive number."); + } + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + * @param writerOptions - serialization options + */ + YAMLWriter.prototype.serialize = function (node) { + // convert to object + var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + }); + var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); + var val = objectWriter.serialize(node); + var markup = this._beginLine(this._writerOptions, 0) + '---' + this._endLine(this._writerOptions) + + this._convertObject(val, this._writerOptions, 0); + // remove trailing newline + /* istanbul ignore else */ + if (markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { + markup = markup.slice(0, -this._writerOptions.newline.length); + } + return markup; + }; + /** + * Produces an XML serialization of the given object. + * + * @param obj - object to serialize + * @param options - serialization options + * @param level - depth of the XML tree + * @param indentLeaf - indents leaf nodes + */ + YAMLWriter.prototype._convertObject = function (obj, options, level, suppressIndent) { + var e_1, _a; + var _this = this; + if (suppressIndent === void 0) { suppressIndent = false; } + var markup = ''; + if (util_1.isArray(obj)) { + try { + for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { + var val = obj_1_1.value; + markup += this._beginLine(options, level, true); + if (!util_1.isObject(val)) { + markup += this._val(val) + this._endLine(options); + } + else if (util_1.isEmpty(val)) { + markup += '""' + this._endLine(options); + } + else { + markup += this._convertObject(val, options, level, true); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); + } + finally { if (e_1) throw e_1.error; } + } + } + else /* if (isObject(obj)) */ { + util_1.forEachObject(obj, function (key, val) { + if (suppressIndent) { + markup += _this._key(key); + suppressIndent = false; + } + else { + markup += _this._beginLine(options, level) + _this._key(key); + } + if (!util_1.isObject(val)) { + markup += ' ' + _this._val(val) + _this._endLine(options); + } + else if (util_1.isEmpty(val)) { + markup += ' ""' + _this._endLine(options); + } + else { + markup += _this._endLine(options) + + _this._convertObject(val, options, level + 1); + } + }, this); + } + return markup; + }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + * @param level - current depth of the XML tree + * @param isArray - whether this line is an array item + */ + YAMLWriter.prototype._beginLine = function (options, level, isArray) { + if (isArray === void 0) { isArray = false; } + var indentLevel = options.offset + level + 1; + var chars = new Array(indentLevel).join(options.indent); + if (isArray) { + return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); + } + else { + return chars; + } + }; + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + */ + YAMLWriter.prototype._endLine = function (options) { + return options.newline; + }; + /** + * Produces a YAML key string delimited with double quotes. + */ + YAMLWriter.prototype._key = function (key) { + return "\"" + key + "\":"; + }; + /** + * Produces a YAML value string delimited with double quotes. + */ + YAMLWriter.prototype._val = function (val) { + return JSON.stringify(val); + }; + return YAMLWriter; +}(BaseWriter_1.BaseWriter)); +exports.YAMLWriter = YAMLWriter; +//# sourceMappingURL=YAMLWriter.js.map - this.format() -} +/***/ }), +/* 326 */, +/* 327 */, +/* 328 */, +/* 329 */, +/* 330 */, +/* 331 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { -Range.prototype.format = function () { - this.range = this.set.map(function (comps) { - return comps.join(' ').trim() - }).join('||').trim() - return this.range -} +"use strict"; -Range.prototype.toString = function () { - return this.range +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 (k !== "default" && Object.prototype.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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.generate = exports.createAuthenticationSettings = exports.configureAuthentication = exports.SETTINGS_FILE = exports.M2_DIR = void 0; +const path = __importStar(__webpack_require__(622)); +const core = __importStar(__webpack_require__(470)); +const io = __importStar(__webpack_require__(1)); +const fs = __importStar(__webpack_require__(747)); +const os = __importStar(__webpack_require__(87)); +const xmlbuilder2_1 = __webpack_require__(255); +const constants = __importStar(__webpack_require__(211)); +const gpg = __importStar(__webpack_require__(884)); +const util_1 = __webpack_require__(322); +exports.M2_DIR = '.m2'; +exports.SETTINGS_FILE = 'settings.xml'; +function configureAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + const id = core.getInput(constants.INPUT_SERVER_ID); + const username = core.getInput(constants.INPUT_SERVER_USERNAME); + const password = core.getInput(constants.INPUT_SERVER_PASSWORD); + const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) || path.join(os.homedir(), exports.M2_DIR); + const overwriteSettings = util_1.getBooleanInput(constants.INPUT_OVERWRITE_SETTINGS, true); + const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY) || constants.INPUT_DEFAULT_GPG_PRIVATE_KEY; + const gpgPassphrase = core.getInput(constants.INPUT_GPG_PASSPHRASE) || + (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined); + if (gpgPrivateKey) { + core.setSecret(gpgPrivateKey); + } + yield createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase); + if (gpgPrivateKey) { + core.info('Importing private gpg key'); + const keyFingerprint = (yield gpg.importKey(gpgPrivateKey)) || ''; + core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); + } + }); } - -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]) - - // `~ 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. - - 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) - - return set +exports.configureAuthentication = configureAuthentication; +function createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase = undefined) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Creating ${exports.SETTINGS_FILE} with server-id: ${id}`); + // when an alternate m2 location is specified use only that location (no .m2 directory) + // otherwise use the home/.m2/ path + yield io.mkdirP(settingsDirectory); + yield write(settingsDirectory, generate(id, username, password, gpgPassphrase), overwriteSettings); + }); } - -Range.prototype.intersects = function (range, options) { - if (!(range instanceof Range)) { - throw new TypeError('a Range is required') - } - - 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) - }) - }) - ) - }) - ) - }) +exports.createAuthenticationSettings = createAuthenticationSettings; +// only exported for testing purposes +function generate(id, username, password, gpgPassphrase) { + const xmlObj = { + settings: { + '@xmlns': 'http://maven.apache.org/SETTINGS/1.0.0', + '@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', + '@xsi:schemaLocation': 'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd', + servers: { + server: [ + { + id: id, + username: `\${env.${username}}`, + password: `\${env.${password}}` + } + ] + } + } + }; + if (gpgPassphrase) { + const gpgServer = { + id: 'gpg.passphrase', + passphrase: `\${env.${gpgPassphrase}}` + }; + xmlObj.settings.servers.server.push(gpgServer); + } + return xmlbuilder2_1.create(xmlObj).end({ + headless: true, + prettyPrint: true, + width: 80 + }); +} +exports.generate = generate; +function write(directory, settings, overwriteSettings) { + return __awaiter(this, void 0, void 0, function* () { + const location = path.join(directory, exports.SETTINGS_FILE); + const settingsExists = fs.existsSync(location); + if (settingsExists && overwriteSettings) { + core.info(`Overwriting existing file ${location}`); + } + else if (!settingsExists) { + core.info(`Writing to ${location}`); + } + else { + core.info(`Skipping generation ${location} because file already exists and overwriting is not required`); + return; + } + return fs.writeFileSync(location, settings, { + encoding: 'utf-8', + flag: 'w' + }); + }); } -// 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) - }) +/***/ }), +/* 332 */, +/* 333 */, +/* 334 */, +/* 335 */, +/* 336 */, +/* 337 */, +/* 338 */, +/* 339 */, +/* 340 */, +/* 341 */, +/* 342 */, +/* 343 */, +/* 344 */ +/***/ (function(__unusedmodule, exports) { - testComparator = remainingComparators.pop() - } +"use strict"; - return result +Object.defineProperty(exports, "__esModule", { value: true }); +var PotentialCustomElementName = /[a-z]([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*-([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*/; +var NamesWithHyphen = new Set(['annotation-xml', 'color-profile', + 'font-face', 'font-face-src', 'font-face-uri', 'font-face-format', + 'font-face-name', 'missing-glyph']); +var ElementNames = new Set(['article', 'aside', 'blockquote', + 'body', 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', + 'header', 'main', 'nav', 'p', 'section', 'span']); +var VoidElementNames = new Set(['area', 'base', 'basefont', + 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', + 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); +var ShadowHostNames = new Set(['article', 'aside', 'blockquote', 'body', + 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'main', + 'nav', 'p', 'section', 'span']); +/** + * Determines if the given string is a valid custom element name. + * + * @param name - a name string + */ +function customElement_isValidCustomElementName(name) { + if (!PotentialCustomElementName.test(name)) + return false; + if (NamesWithHyphen.has(name)) + return false; + return true; } - -// 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(' ') - }) +exports.customElement_isValidCustomElementName = customElement_isValidCustomElementName; +/** + * Determines if the given string is a valid element name. + * + * @param name - a name string + */ +function customElement_isValidElementName(name) { + return (ElementNames.has(name)); } - -// 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 +exports.customElement_isValidElementName = customElement_isValidElementName; +/** + * Determines if the given string is a void element name. + * + * @param name - a name string + */ +function customElement_isVoidElementName(name) { + return (VoidElementNames.has(name)); } - -function isX (id) { - return !id || id.toLowerCase() === 'x' || id === '*' +exports.customElement_isVoidElementName = customElement_isVoidElementName; +/** + * Determines if the given string is a valid shadow host element name. + * + * @param name - a name string + */ +function customElement_isValidShadowHostName(name) { + return (ShadowHostNames.has(name)); } - -// ~, ~> --> * (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(' ') +exports.customElement_isValidShadowHostName = customElement_isValidShadowHostName; +/** + * Enqueues an upgrade reaction for a custom element. + * + * @param element - a custom element + * @param definition - a custom element definition + */ +function customElement_enqueueACustomElementUpgradeReaction(element, definition) { + // TODO: Implement in HTML DOM } - -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 - }) +exports.customElement_enqueueACustomElementUpgradeReaction = customElement_enqueueACustomElementUpgradeReaction; +/** + * Enqueues a callback reaction for a custom element. + * + * @param element - a custom element + * @param callbackName - name of the callback + * @param args - callback arguments + */ +function customElement_enqueueACustomElementCallbackReaction(element, callbackName, args) { + // TODO: Implement in HTML DOM } - -// ^ --> * (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(' ') +exports.customElement_enqueueACustomElementCallbackReaction = customElement_enqueueACustomElementCallbackReaction; +/** + * Upgrade a custom element. + * + * @param element - a custom element + */ +function customElement_upgrade(definition, element) { + // TODO: Implement in HTML DOM +} +exports.customElement_upgrade = customElement_upgrade; +/** + * Tries to upgrade a custom element. + * + * @param element - a custom element + */ +function customElement_tryToUpgrade(element) { + // TODO: Implement in HTML DOM +} +exports.customElement_tryToUpgrade = customElement_tryToUpgrade; +/** + * Looks up a custom element definition. + * + * @param document - a document + * @param namespace - element namespace + * @param localName - element local name + * @param is - an `is` value + */ +function customElement_lookUpACustomElementDefinition(document, namespace, localName, is) { + // TODO: Implement in HTML DOM + return null; } +exports.customElement_lookUpACustomElementDefinition = customElement_lookUpACustomElementDefinition; +//# sourceMappingURL=CustomElementAlgorithm.js.map -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 +/***/ }), +/* 345 */, +/* 346 */, +/* 347 */, +/* 348 */, +/* 349 */, +/* 350 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { - 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' +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var interfaces_1 = __webpack_require__(970); +var TreeAlgorithm_1 = __webpack_require__(873); +/** + * Defines the position of a boundary point relative to another. + * + * @param bp - a boundary point + * @param relativeTo - a boundary point to compare to + */ +function boundaryPoint_position(bp, relativeTo) { + var nodeA = bp[0]; + var offsetA = bp[1]; + var nodeB = relativeTo[0]; + var offsetB = relativeTo[1]; + /** + * 1. Assert: nodeA and nodeB have the same root. + */ + console.assert(TreeAlgorithm_1.tree_rootNode(nodeA) === TreeAlgorithm_1.tree_rootNode(nodeB), "Boundary points must share the same root node."); + /** + * 2. If nodeA is nodeB, then return equal if offsetA is offsetB, before + * if offsetA is less than offsetB, and after if offsetA is greater than + * offsetB. + */ + if (nodeA === nodeB) { + if (offsetA === offsetB) { + return interfaces_1.BoundaryPosition.Equal; } - } 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 if (offsetA < offsetB) { + return interfaces_1.BoundaryPosition.Before; + } + else { + return interfaces_1.BoundaryPosition.After; } - } 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 = '' + /** + * 3. If nodeA is following nodeB, then if the position of (nodeB, offsetB) + * relative to (nodeA, offsetA) is before, return after, and if it is after, + * return before. + */ + if (TreeAlgorithm_1.tree_isFollowing(nodeB, nodeA)) { + var pos = boundaryPoint_position([nodeB, offsetB], [nodeA, offsetA]); + if (pos === interfaces_1.BoundaryPosition.Before) { + return interfaces_1.BoundaryPosition.After; + } + else if (pos === interfaces_1.BoundaryPosition.After) { + return interfaces_1.BoundaryPosition.Before; + } } - - // 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 + /** + * 4. If nodeA is an ancestor of nodeB: + */ + if (TreeAlgorithm_1.tree_isAncestorOf(nodeB, nodeA)) { + /** + * 4.1. Let child be nodeB. + * 4.2. While child is not a child of nodeA, set child to its parent. + * 4.3. If child’s index is less than offsetA, then return after. + */ + var child = nodeB; + while (!TreeAlgorithm_1.tree_isChildOf(nodeA, child)) { + /* istanbul ignore else */ + if (child._parent !== null) { + child = child._parent; + } } - } 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 (TreeAlgorithm_1.tree_index(child) < offsetA) { + return interfaces_1.BoundaryPosition.After; } - } - - 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 } - - debug('xRange return', ret) - - return ret - }) + /** + * 5. Return before. + */ + return interfaces_1.BoundaryPosition.Before; } +exports.boundaryPoint_position = boundaryPoint_position; +//# sourceMappingURL=BoundaryPointAlgorithm.js.map -// 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], '') -} +/***/ }), +/* 351 */, +/* 352 */ +/***/ (function(module, __unusedexports, __webpack_require__) { -// 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 - } +"use strict"; - 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() +var esprima; + +// Browserified version does not have esprima +// +// 1. For node.js just require module as deps +// 2. For browser try to require mudule via external AMD system. +// If not found - try to fallback to window.esprima. If not +// found too - then fail to parse. +// +try { + // workaround to exclude package from browserify list. + var _require = require; + esprima = _require('esprima'); +} catch (_) { + /* eslint-disable no-redeclare */ + /* global window */ + if (typeof window !== 'undefined') esprima = window.esprima; } -// if ANY of the sets match ALL of its comparators, then pass -Range.prototype.test = function (version) { - if (!version) { - return false - } +var Type = __webpack_require__(945); - if (typeof version === 'string') { - try { - version = new SemVer(version, this.options) - } catch (er) { - return false - } - } +function resolveJavascriptFunction(data) { + if (data === null) return false; - for (var i = 0; i < this.set.length; i++) { - if (testSet(this.set[i], version, this.options)) { - return true - } - } - return false -} + try { + var source = '(' + data + ')', + ast = esprima.parse(source, { range: true }); -function testSet (set, version, options) { - for (var i = 0; i < set.length; i++) { - if (!set[i].test(version)) { - return false + if (ast.type !== 'Program' || + ast.body.length !== 1 || + ast.body[0].type !== 'ExpressionStatement' || + (ast.body[0].expression.type !== 'ArrowFunctionExpression' && + ast.body[0].expression.type !== 'FunctionExpression')) { + return false; } + + return true; + } catch (err) { + 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 (i = 0; i < set.length; i++) { - debug(set[i].semver) - if (set[i].semver === ANY) { - continue - } +function constructJavascriptFunction(data) { + /*jslint evil:true*/ - 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 - } - } - } + var source = '(' + data + ')', + ast = esprima.parse(source, { range: true }), + params = [], + body; - // Version has a -pre, but it's not one of the ones we like. - return false + if (ast.type !== 'Program' || + ast.body.length !== 1 || + ast.body[0].type !== 'ExpressionStatement' || + (ast.body[0].expression.type !== 'ArrowFunctionExpression' && + ast.body[0].expression.type !== 'FunctionExpression')) { + throw new Error('Failed to resolve function'); } - return true -} + ast.body[0].expression.params.forEach(function (param) { + params.push(param.name); + }); -exports.satisfies = satisfies -function satisfies (version, range, options) { - try { - range = new Range(range, options) - } catch (er) { - return false + body = ast.body[0].expression.body.range; + + // Esprima's ranges include the first '{' and the last '}' characters on + // function expressions. So cut them out. + if (ast.body[0].expression.body.type === 'BlockStatement') { + /*eslint-disable no-new-func*/ + return new Function(params, source.slice(body[0] + 1, body[1] - 1)); } - return range.test(version) + // ES6 arrow functions can omit the BlockStatement. In that case, just return + // the body. + /*eslint-disable no-new-func*/ + return new Function(params, 'return ' + source.slice(body[0], body[1])); } -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 +function representJavascriptFunction(object /*, style*/) { + return object.toString(); } -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 +function isFunction(object) { + return Object.prototype.toString.call(object) === '[object Function]'; } -exports.minVersion = minVersion -function minVersion (range, loose) { - range = new Range(range, loose) +module.exports = new Type('tag:yaml.org,2002:js/function', { + kind: 'scalar', + resolve: resolveJavascriptFunction, + construct: constructJavascriptFunction, + predicate: isFunction, + represent: representJavascriptFunction +}); - 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 - } +/***/ }), +/* 353 */, +/* 354 */, +/* 355 */, +/* 356 */, +/* 357 */ +/***/ (function(module) { - minver = null - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] +module.exports = require("assert"); - 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 - } - - return null -} - -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 - } -} - -// 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) -} - -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 - } +/***/ }), +/* 358 */, +/* 359 */, +/* 360 */, +/* 361 */, +/* 362 */, +/* 363 */, +/* 364 */, +/* 365 */, +/* 366 */, +/* 367 */, +/* 368 */, +/* 369 */, +/* 370 */, +/* 371 */, +/* 372 */, +/* 373 */ +/***/ (function(module) { - // From now on, variable terms are as if we're in "gtr" mode. - // but note that everything is flipped for the "ltr" function. +module.exports = require("crypto"); - for (var i = 0; i < range.set.length; ++i) { - var comparators = range.set[i] +/***/ }), +/* 374 */, +/* 375 */, +/* 376 */, +/* 377 */, +/* 378 */, +/* 379 */, +/* 380 */, +/* 381 */, +/* 382 */, +/* 383 */, +/* 384 */, +/* 385 */, +/* 386 */ +/***/ (function(module, __unusedexports, __webpack_require__) { - var high = null - var low = null +"use strict"; - 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 the edge version comparator has a operator then our version - // isn't outside it - if (high.operator === comp || high.operator === ecomp) { - return false - } +var Type = __webpack_require__(945); - // 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 +function resolveJavascriptUndefined() { + return true; } -exports.prerelease = prerelease -function prerelease (version, options) { - var parsed = parse(version, options) - return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +function constructJavascriptUndefined() { + /*eslint-disable no-undefined*/ + return undefined; } -exports.intersects = intersects -function intersects (r1, r2, options) { - r1 = new Range(r1, options) - r2 = new Range(r2, options) - return r1.intersects(r2) +function representJavascriptUndefined() { + return ''; } -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 - } - - options = options || {} - - 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 - } - // 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) +function isUndefined(object) { + return typeof object === 'undefined'; } +module.exports = new Type('tag:yaml.org,2002:js/undefined', { + kind: 'scalar', + resolve: resolveJavascriptUndefined, + construct: constructJavascriptUndefined, + predicate: isUndefined, + represent: representJavascriptUndefined +}); -/***/ }), -/* 281 */, -/* 282 */, -/* 283 */, -/* 284 */, -/* 285 */, -/* 286 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Represents the state of the URL parser. - */ -var ParserState; -(function (ParserState) { - ParserState[ParserState["SchemeStart"] = 0] = "SchemeStart"; - ParserState[ParserState["Scheme"] = 1] = "Scheme"; - ParserState[ParserState["NoScheme"] = 2] = "NoScheme"; - ParserState[ParserState["SpecialRelativeOrAuthority"] = 3] = "SpecialRelativeOrAuthority"; - ParserState[ParserState["PathOrAuthority"] = 4] = "PathOrAuthority"; - ParserState[ParserState["Relative"] = 5] = "Relative"; - ParserState[ParserState["RelativeSlash"] = 6] = "RelativeSlash"; - ParserState[ParserState["SpecialAuthoritySlashes"] = 7] = "SpecialAuthoritySlashes"; - ParserState[ParserState["SpecialAuthorityIgnoreSlashes"] = 8] = "SpecialAuthorityIgnoreSlashes"; - ParserState[ParserState["Authority"] = 9] = "Authority"; - ParserState[ParserState["Host"] = 10] = "Host"; - ParserState[ParserState["Hostname"] = 11] = "Hostname"; - ParserState[ParserState["Port"] = 12] = "Port"; - ParserState[ParserState["File"] = 13] = "File"; - ParserState[ParserState["FileSlash"] = 14] = "FileSlash"; - ParserState[ParserState["FileHost"] = 15] = "FileHost"; - ParserState[ParserState["PathStart"] = 16] = "PathStart"; - ParserState[ParserState["Path"] = 17] = "Path"; - ParserState[ParserState["CannotBeABaseURLPath"] = 18] = "CannotBeABaseURLPath"; - ParserState[ParserState["Query"] = 19] = "Query"; - ParserState[ParserState["Fragment"] = 20] = "Fragment"; -})(ParserState = exports.ParserState || (exports.ParserState = {})); -exports.OpaqueOrigin = ["", "", null, null]; -//# sourceMappingURL=interfaces.js.map /***/ }), -/* 287 */, -/* 288 */, -/* 289 */, -/* 290 */, -/* 291 */, -/* 292 */, -/* 293 */, -/* 294 */, -/* 295 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/* 387 */, +/* 388 */, +/* 389 */, +/* 390 */, +/* 391 */, +/* 392 */ +/***/ (function(__unusedmodule, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var _1 = __webpack_require__(535); -/** - * Creates an XML builder which serializes the document in chunks. - * - * @param options - callback builder options - * - * @returns callback builder - */ -function createCB(options) { - return new _1.XMLBuilderCBImpl(options); -} -exports.createCB = createCB; /** - * Creates an XML builder which serializes the fragment in chunks. + * A namespace prefix map is a map that associates namespaceURI and namespace + * prefix lists, where namespaceURI values are the map's unique keys (which can + * include the null value representing no namespace), and ordered lists of + * associated prefix values are the map's key values. The namespace prefix map + * will be populated by previously seen namespaceURIs and all their previously + * encountered prefix associations for a given node and its ancestors. * - * @param options - callback builder options + * _Note:_ The last seen prefix for a given namespaceURI is at the end of its + * respective list. The list is searched to find potentially matching prefixes, + * and if no matches are found for the given namespaceURI, then the last prefix + * in the list is used. See copy a namespace prefix map and retrieve a preferred + * prefix string for additional details. * - * @returns callback builder + * See: https://w3c.github.io/DOM-Parsing/#the-namespace-prefix-map */ -function fragmentCB(options) { - return new _1.XMLBuilderCBImpl(options, true); -} -exports.fragmentCB = fragmentCB; -//# sourceMappingURL=BuilderFunctionsCB.js.map +var NamespacePrefixMap = /** @class */ (function () { + function NamespacePrefixMap() { + this._items = {}; + this._nullItems = []; + } + /** + * Creates a copy of the map. + */ + NamespacePrefixMap.prototype.copy = function () { + /** + * To copy a namespace prefix map map means to copy the map's keys into a + * new empty namespace prefix map, and to copy each of the values in the + * namespace prefix list associated with each keys' value into a new list + * which should be associated with the respective key in the new map. + */ + var mapCopy = new NamespacePrefixMap(); + for (var key in this._items) { + mapCopy._items[key] = this._items[key].slice(0); + } + mapCopy._nullItems = this._nullItems.slice(0); + return mapCopy; + }; + /** + * Retrieves a preferred prefix string from the namespace prefix map. + * + * @param preferredPrefix - preferred prefix string + * @param ns - namespace + */ + NamespacePrefixMap.prototype.get = function (preferredPrefix, ns) { + /** + * 1. Let candidates list be the result of retrieving a list from map where + * there exists a key in map that matches the value of ns or if there is no + * such key, then stop running these steps, and return the null value. + */ + var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); + if (candidatesList === null) { + return null; + } + /** + * 2. Otherwise, for each prefix value prefix in candidates list, iterating + * from beginning to end: + * + * _Note:_ There will always be at least one prefix value in the list. + */ + var prefix = null; + for (var i = 0; i < candidatesList.length; i++) { + prefix = candidatesList[i]; + /** + * 2.1. If prefix matches preferred prefix, then stop running these steps + * and return prefix. + */ + if (prefix === preferredPrefix) { + return prefix; + } + } + /** + * 2.2. If prefix is the last item in the candidates list, then stop + * running these steps and return prefix. + */ + return prefix; + }; + /** + * Checks if a prefix string is found in the namespace prefix map associated + * with the given namespace. + * + * @param prefix - prefix string + * @param ns - namespace + */ + NamespacePrefixMap.prototype.has = function (prefix, ns) { + /** + * 1. Let candidates list be the result of retrieving a list from map where + * there exists a key in map that matches the value of ns or if there is + * no such key, then stop running these steps, and return false. + */ + var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); + if (candidatesList === null) { + return false; + } + /** + * 2. If the value of prefix occurs at least once in candidates list, + * return true, otherwise return false. + */ + return (candidatesList.indexOf(prefix) !== -1); + }; + /** + * Checks if a prefix string is found in the namespace prefix map. + * + * @param prefix - prefix string + */ + NamespacePrefixMap.prototype.hasPrefix = function (prefix) { + if (this._nullItems.indexOf(prefix) !== -1) + return true; + for (var key in this._items) { + if (this._items[key].indexOf(prefix) !== -1) + return true; + } + return false; + }; + /** + * Adds a prefix string associated with a namespace to the prefix map. + * + * @param prefix - prefix string + * @param ns - namespace + */ + NamespacePrefixMap.prototype.set = function (prefix, ns) { + /** + * 1. Let candidates list be the result of retrieving a list from map where + * there exists a key in map that matches the value of ns or if there is + * no such key, then let candidates list be null. + */ + var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); + /** + * 2. If candidates list is null, then create a new list with prefix as the + * only item in the list, and associate that list with a new key ns in map. + * 3. Otherwise, append prefix to the end of candidates list. + * + * _Note:_ The steps in retrieve a preferred prefix string use the list to + * track the most recently used (MRU) prefix associated with a given + * namespace, which will be the prefix at the end of the list. This list + * may contain duplicates of the same prefix value seen earlier + * (and that's OK). + */ + if (ns !== null && candidatesList === null) { + this._items[ns] = [prefix]; + } + else { + candidatesList.push(prefix); + } + }; + return NamespacePrefixMap; +}()); +exports.NamespacePrefixMap = NamespacePrefixMap; +//# sourceMappingURL=NamespacePrefixMap.js.map /***/ }), -/* 296 */, -/* 297 */, -/* 298 */, -/* 299 */, -/* 300 */, -/* 301 */, -/* 302 */, -/* 303 */, -/* 304 */ +/* 393 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +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 (k !== "default" && Object.prototype.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) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var TreeAlgorithm_1 = __webpack_require__(873); -var util_1 = __webpack_require__(918); -var ShadowTreeAlgorithm_1 = __webpack_require__(180); -var supportedTokens = new Map(); -/** - * Runs removing steps for node. - * - * @param removedNode - removed node - * @param oldParent - old parent node - */ -function dom_runRemovingSteps(removedNode, oldParent) { - // No steps defined -} -exports.dom_runRemovingSteps = dom_runRemovingSteps; -/** - * Runs cloning steps for node. - * - * @param copy - node clone - * @param node - node - * @param document - document to own the cloned node - * @param cloneChildrenFlag - whether child nodes are cloned - */ -function dom_runCloningSteps(copy, node, document, cloneChildrenFlag) { - // No steps defined -} -exports.dom_runCloningSteps = dom_runCloningSteps; -/** - * Runs adopting steps for node. - * - * @param node - node - * @param oldDocument - old document - */ -function dom_runAdoptingSteps(node, oldDocument) { - // No steps defined -} -exports.dom_runAdoptingSteps = dom_runAdoptingSteps; -/** - * Runs attribute change steps for an element node. - * - * @param element - element node owning the attribute - * @param localName - attribute's local name - * @param oldValue - attribute's old value - * @param value - attribute's new value - * @param namespace - attribute's namespace - */ -function dom_runAttributeChangeSteps(element, localName, oldValue, value, namespace) { - var e_1, _a; - // run default steps - if (DOMImpl_1.dom.features.slots) { - updateASlotablesName.call(element, element, localName, oldValue, value, namespace); - updateASlotsName.call(element, element, localName, oldValue, value, namespace); - } - updateAnElementID.call(element, element, localName, value, namespace); - try { - // run custom steps - for (var _b = __values(element._attributeChangeSteps), _c = _b.next(); !_c.done; _c = _b.next()) { - var step = _c.value; - step.call(element, element, localName, oldValue, value, namespace); - } +exports.ZuluDistribution = void 0; +const core = __importStar(__webpack_require__(470)); +const tc = __importStar(__webpack_require__(139)); +const path_1 = __importDefault(__webpack_require__(622)); +const fs_1 = __importDefault(__webpack_require__(747)); +const semver_1 = __importDefault(__webpack_require__(876)); +const base_installer_1 = __webpack_require__(83); +const util_1 = __webpack_require__(322); +class ZuluDistribution extends base_installer_1.JavaBase { + constructor(installerOptions) { + super('Zulu', installerOptions); } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_1) throw e_1.error; } + findPackageForDownload(version) { + return __awaiter(this, void 0, void 0, function* () { + const availableVersionsRaw = yield this.getAvailableVersions(); + const availableVersions = availableVersionsRaw.map(item => { + return { + version: this.convertVersionToSemver(item.jdk_version), + url: item.url, + zuluVersion: this.convertVersionToSemver(item.zulu_version) + }; + }); + const satisfiedVersions = availableVersions + .filter(item => util_1.isVersionSatisfies(version, item.version)) + .sort((a, b) => { + // Azul provides two versions: jdk_version and azul_version + // we should sort by both fields by descending + return (-semver_1.default.compareBuild(a.version, b.version) || + -semver_1.default.compareBuild(a.zuluVersion, b.zuluVersion)); + }) + .map(item => { + return { + version: item.version, + url: item.url + }; + }); + const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; + if (!resolvedFullVersion) { + const availableOptions = availableVersions.map(item => item.version).join(', '); + const availableOptionsMessage = availableOptions + ? `\nAvailable versions: ${availableOptions}` + : ''; + throw new Error(`Could not find satisfied version for semver ${version}. ${availableOptionsMessage}`); + } + return resolvedFullVersion; + }); } -} -exports.dom_runAttributeChangeSteps = dom_runAttributeChangeSteps; -/** - * Runs insertion steps for a node. - * - * @param insertedNode - inserted node - */ -function dom_runInsertionSteps(insertedNode) { - // No steps defined -} -exports.dom_runInsertionSteps = dom_runInsertionSteps; -/** - * Runs pre-removing steps for a node iterator and node. - * - * @param nodeIterator - a node iterator - * @param toBeRemoved - node to be removed - */ -function dom_runNodeIteratorPreRemovingSteps(nodeIterator, toBeRemoved) { - removeNodeIterator.call(nodeIterator, nodeIterator, toBeRemoved); -} -exports.dom_runNodeIteratorPreRemovingSteps = dom_runNodeIteratorPreRemovingSteps; -/** - * Determines if there are any supported tokens defined for the given - * attribute name. - * - * @param attributeName - an attribute name - */ -function dom_hasSupportedTokens(attributeName) { - return supportedTokens.has(attributeName); -} -exports.dom_hasSupportedTokens = dom_hasSupportedTokens; -/** - * Returns the set of supported tokens defined for the given attribute name. - * - * @param attributeName - an attribute name - */ -function dom_getSupportedTokens(attributeName) { - return supportedTokens.get(attributeName) || new Set(); -} -exports.dom_getSupportedTokens = dom_getSupportedTokens; -/** - * Runs event construction steps. - * - * @param event - an event - */ -function dom_runEventConstructingSteps(event) { - // No steps defined -} -exports.dom_runEventConstructingSteps = dom_runEventConstructingSteps; -/** - * Runs child text content change steps for a parent node. - * - * @param parent - parent node with text node child nodes - */ -function dom_runChildTextContentChangeSteps(parent) { - // No steps defined -} -exports.dom_runChildTextContentChangeSteps = dom_runChildTextContentChangeSteps; -/** - * Defines pre-removing steps for a node iterator. - */ -function removeNodeIterator(nodeIterator, toBeRemovedNode) { - /** - * 1. If toBeRemovedNode is not an inclusive ancestor of nodeIterator’s - * reference, or toBeRemovedNode is nodeIterator’s root, then return. - */ - if (toBeRemovedNode === nodeIterator._root || - !TreeAlgorithm_1.tree_isAncestorOf(nodeIterator._reference, toBeRemovedNode, true)) { - return; + downloadTool(javaRelease) { + return __awaiter(this, void 0, void 0, function* () { + let extractedJavaPath; + core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); + const javaArchivePath = yield tc.downloadTool(javaRelease.url); + core.info(`Extracting Java archive...`); + let extension = util_1.getDownloadArchiveExtension(); + extractedJavaPath = yield util_1.extractJdkFile(javaArchivePath, extension); + const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; + const archivePath = path_1.default.join(extractedJavaPath, archiveName); + const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture); + return { version: javaRelease.version, path: javaPath }; + }); } - /** - * 2. If nodeIterator’s pointer before reference is true, then: - */ - if (nodeIterator._pointerBeforeReference) { - /** - * 2.1. Let next be toBeRemovedNode’s first following node that is an - * inclusive descendant of nodeIterator’s root and is not an inclusive - * descendant of toBeRemovedNode, and null if there is no such node. - */ - while (true) { - var nextNode = TreeAlgorithm_1.tree_getFollowingNode(nodeIterator._root, toBeRemovedNode); - if (nextNode !== null && - TreeAlgorithm_1.tree_isDescendantOf(nodeIterator._root, nextNode, true) && - !TreeAlgorithm_1.tree_isDescendantOf(toBeRemovedNode, nextNode, true)) { - /** - * 2.2. If next is non-null, then set nodeIterator’s reference to next - * and return. - */ - nodeIterator._reference = nextNode; - return; + getAvailableVersions() { + var _a, _b; + return __awaiter(this, void 0, void 0, function* () { + const { arch, hw_bitness, abi } = this.getArchitectureOptions(); + const [bundleType, features] = this.packageType.split('+'); + const platform = this.getPlatformOption(); + const extension = util_1.getDownloadArchiveExtension(); + const javafx = (_a = features === null || features === void 0 ? void 0 : features.includes('fx')) !== null && _a !== void 0 ? _a : false; + const releaseStatus = this.stable ? 'ga' : 'ea'; + console.time('azul-retrieve-available-versions'); + const requestArguments = [ + `os=${platform}`, + `ext=${extension}`, + `bundle_type=${bundleType}`, + `javafx=${javafx}`, + `arch=${arch}`, + `hw_bitness=${hw_bitness}`, + `release_status=${releaseStatus}`, + abi ? `abi=${abi}` : null, + features ? `features=${features}` : null + ] + .filter(Boolean) + .join('&'); + const availableVersionsUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?${requestArguments}`; + if (core.isDebug()) { + core.debug(`Gathering available versions from '${availableVersionsUrl}'`); } - else if (nextNode === null) { - /** - * 2.3. Otherwise, set nodeIterator’s pointer before reference to false. - */ - nodeIterator._pointerBeforeReference = false; - return; + const availableVersions = (_b = (yield this.http.getJson(availableVersionsUrl)).result) !== null && _b !== void 0 ? _b : []; + if (core.isDebug()) { + core.startGroup('Print information about available versions'); + console.timeEnd('azul-retrieve-available-versions'); + console.log(`Available versions: [${availableVersions.length}]`); + console.log(availableVersions.map(item => item.jdk_version.join('.')).join(', ')); + core.endGroup(); } - } - } - /** - * 3. Set nodeIterator’s reference to toBeRemovedNode’s parent, if - * toBeRemovedNode’s previous sibling is null, and to the inclusive - * descendant of toBeRemovedNode’s previous sibling that appears last in - * tree order otherwise. - */ - if (toBeRemovedNode._previousSibling === null) { - if (toBeRemovedNode._parent !== null) { - nodeIterator._reference = toBeRemovedNode._parent; - } + return availableVersions; + }); } - else { - var referenceNode = toBeRemovedNode._previousSibling; - var childNode = TreeAlgorithm_1.tree_getFirstDescendantNode(toBeRemovedNode._previousSibling, true, false); - while (childNode !== null) { - if (childNode !== null) { - referenceNode = childNode; - } - // loop through to get the last descendant node - childNode = TreeAlgorithm_1.tree_getNextDescendantNode(toBeRemovedNode._previousSibling, childNode, true, false); + getArchitectureOptions() { + if (this.architecture == 'x64') { + return { arch: 'x86', hw_bitness: '64', abi: '' }; } - nodeIterator._reference = referenceNode; - } -} -/** - * Defines attribute change steps to update a slot’s name. - */ -function updateASlotsName(element, localName, oldValue, value, namespace) { - /** - * 1. If element is a slot, localName is name, and namespace is null, then: - * 1.1. If value is oldValue, then return. - * 1.2. If value is null and oldValue is the empty string, then return. - * 1.3. If value is the empty string and oldValue is null, then return. - * 1.4. If value is null or the empty string, then set element’s name to the - * empty string. - * 1.5. Otherwise, set element’s name to value. - * 1.6. Run assign slotables for a tree with element’s root. - */ - if (util_1.Guard.isSlot(element) && localName === "name" && namespace === null) { - if (value === oldValue) - return; - if (value === null && oldValue === '') - return; - if (value === '' && oldValue === null) - return; - if ((value === null || value === '')) { - element._name = ''; + else if (this.architecture == 'x86') { + return { arch: 'x86', hw_bitness: '32', abi: '' }; } else { - element._name = value; + return { arch: this.architecture, hw_bitness: '', abi: '' }; } - ShadowTreeAlgorithm_1.shadowTree_assignSlotablesForATree(TreeAlgorithm_1.tree_rootNode(element)); } -} -/** - * Defines attribute change steps to update a slotable’s name. - */ -function updateASlotablesName(element, localName, oldValue, value, namespace) { - /** - * 1. If localName is slot and namespace is null, then: - * 1.1. If value is oldValue, then return. - * 1.2. If value is null and oldValue is the empty string, then return. - * 1.3. If value is the empty string and oldValue is null, then return. - * 1.4. If value is null or the empty string, then set element’s name to - * the empty string. - * 1.5. Otherwise, set element’s name to value. - * 1.6. If element is assigned, then run assign slotables for element’s - * assigned slot. - * 1.7. Run assign a slot for element. - */ - if (util_1.Guard.isSlotable(element) && localName === "slot" && namespace === null) { - if (value === oldValue) - return; - if (value === null && oldValue === '') - return; - if (value === '' && oldValue === null) - return; - if ((value === null || value === '')) { - element._name = ''; - } - else { - element._name = value; + getPlatformOption() { + // Azul has own platform names so need to map them + switch (process.platform) { + case 'darwin': + return 'macos'; + case 'win32': + return 'windows'; + default: + return process.platform; } - if (ShadowTreeAlgorithm_1.shadowTree_isAssigned(element)) { - ShadowTreeAlgorithm_1.shadowTree_assignSlotables(element._assignedSlot); + } + // Azul API returns jdk_version as array of digits like [11, 0, 2, 1] + convertVersionToSemver(version_array) { + const mainVersion = version_array.slice(0, 3).join('.'); + if (version_array.length > 3) { + // intentionally ignore more than 4 numbers because it is invalid semver + return `${mainVersion}+${version_array[3]}`; } - ShadowTreeAlgorithm_1.shadowTree_assignASlot(element); + return mainVersion; } } -/** - * Defines attribute change steps to update an element's ID. - */ -function updateAnElementID(element, localName, value, namespace) { - /** - * 1. If localName is id, namespace is null, and value is null or the empty - * string, then unset element’s ID. - * 2. Otherwise, if localName is id, namespace is null, then set element’s - * ID to value. - */ - if (localName === "id" && namespace === null) { - if (!value) - element._uniqueIdentifier = undefined; - else - element._uniqueIdentifier = value; +exports.ZuluDistribution = ZuluDistribution; + + +/***/ }), +/* 394 */, +/* 395 */, +/* 396 */ +/***/ (function(module) { + +"use strict"; + +module.exports = function (Yallist) { + Yallist.prototype[Symbol.iterator] = function* () { + for (let walker = this.head; walker; walker = walker.next) { + yield walker.value } + } } -//# sourceMappingURL=DOMAlgorithm.js.map + /***/ }), -/* 305 */ +/* 397 */, +/* 398 */, +/* 399 */, +/* 400 */, +/* 401 */, +/* 402 */, +/* 403 */, +/* 404 */, +/* 405 */, +/* 406 */, +/* 407 */, +/* 408 */, +/* 409 */, +/* 410 */, +/* 411 */, +/* 412 */, +/* 413 */ /***/ (function(__unusedmodule, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** - * Pre-serializes XML nodes. + * Represents an abstract range with a start and end boundary point. */ -var BaseReader = /** @class */ (function () { - /** - * Initializes a new instance of `BaseReader`. - * - * @param builderOptions - XML builder options - */ - function BaseReader(builderOptions) { - this._builderOptions = builderOptions; - if (builderOptions.parser) { - Object.assign(this, builderOptions.parser); - } +var AbstractRangeImpl = /** @class */ (function () { + function AbstractRangeImpl() { } - BaseReader.prototype._docType = function (parent, name, publicId, systemId) { - return parent.dtd({ name: name, pubID: publicId, sysID: systemId }); - }; - BaseReader.prototype._comment = function (parent, data) { - return parent.com(data); - }; - BaseReader.prototype._text = function (parent, data) { - return parent.txt(data); - }; - BaseReader.prototype._instruction = function (parent, target, data) { - return parent.ins(target, data); - }; - BaseReader.prototype._cdata = function (parent, data) { - return parent.dat(data); - }; - BaseReader.prototype._element = function (parent, namespace, name) { - return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name)); - }; - BaseReader.prototype._attribute = function (parent, namespace, name, value) { - return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value)); - }; - /** - * Main parser function which parses the given object and returns an XMLBuilder. - * - * @param node - node to recieve parsed content - * @param obj - object to parse - */ - BaseReader.prototype.parse = function (node, obj) { - return this._parse(node, obj); - }; - /** - * Creates a DocType node. - * The node will be skipped if the function returns `undefined`. - * - * @param name - node name - * @param publicId - public identifier - * @param systemId - system identifier - */ - BaseReader.prototype.docType = function (parent, name, publicId, systemId) { - return this._docType(parent, name, publicId, systemId); - }; - /** - * Creates a comment node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.comment = function (parent, data) { - return this._comment(parent, data); - }; - /** - * Creates a text node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.text = function (parent, data) { - return this._text(parent, data); - }; - /** - * Creates a processing instruction node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param target - instruction target - * @param data - node data - */ - BaseReader.prototype.instruction = function (parent, target, data) { - return this._instruction(parent, target, data); - }; - /** - * Creates a CData section node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param data - node data - */ - BaseReader.prototype.cdata = function (parent, data) { - return this._cdata(parent, data); - }; - /** - * Creates an element node. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param namespace - node namespace - * @param name - node name - */ - BaseReader.prototype.element = function (parent, namespace, name) { - return this._element(parent, namespace, name); - }; - /** - * Creates an attribute or namespace declaration. - * The node will be skipped if the function returns `undefined`. - * - * @param parent - parent node - * @param namespace - node namespace - * @param name - node name - * @param value - node value - */ - BaseReader.prototype.attribute = function (parent, namespace, name, value) { - return this._attribute(parent, namespace, name, value); - }; - return BaseReader; -}()); -exports.BaseReader = BaseReader; -//# sourceMappingURL=BaseReader.js.map - -/***/ }), -/* 306 */, -/* 307 */, -/* 308 */, -/* 309 */, -/* 310 */, -/* 311 */, -/* 312 */, -/* 313 */, -/* 314 */, -/* 315 */, -/* 316 */, -/* 317 */, -/* 318 */, -/* 319 */, -/* 320 */, -/* 321 */, -/* 322 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { + Object.defineProperty(AbstractRangeImpl.prototype, "_startNode", { + get: function () { return this._start[0]; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "_startOffset", { + get: function () { return this._start[1]; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "_endNode", { + get: function () { return this._end[0]; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "_endOffset", { + get: function () { return this._end[1]; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "_collapsed", { + get: function () { + return (this._start[0] === this._end[0] && + this._start[1] === this._end[1]); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "startContainer", { + /** @inheritdoc */ + get: function () { return this._startNode; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "startOffset", { + /** @inheritdoc */ + get: function () { return this._startOffset; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "endContainer", { + /** @inheritdoc */ + get: function () { return this._endNode; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "endOffset", { + /** @inheritdoc */ + get: function () { return this._endOffset; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AbstractRangeImpl.prototype, "collapsed", { + /** @inheritdoc */ + get: function () { return this._collapsed; }, + enumerable: true, + configurable: true + }); + return AbstractRangeImpl; +}()); +exports.AbstractRangeImpl = AbstractRangeImpl; +//# sourceMappingURL=AbstractRangeImpl.js.map + +/***/ }), +/* 414 */ +/***/ (function(module, __unusedexports, __webpack_require__) { "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 (k !== "default" && 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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; -const os_1 = __importDefault(__webpack_require__(87)); -const path_1 = __importDefault(__webpack_require__(622)); -const fs = __importStar(__webpack_require__(747)); -const semver = __importStar(__webpack_require__(280)); -const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); -function getTempDir() { - let tempDirectory = process.env['RUNNER_TEMP'] || os_1.default.tmpdir(); - return tempDirectory; -} -exports.getTempDir = getTempDir; -function getBooleanInput(inputName, defaultValue = false) { - return (core.getInput(inputName) || String(defaultValue)).toUpperCase() === 'TRUE'; -} -exports.getBooleanInput = getBooleanInput; -function getVersionFromToolcachePath(toolPath) { - if (toolPath) { - return path_1.default.basename(path_1.default.dirname(toolPath)); - } - return toolPath; + + +var yaml = __webpack_require__(9); + + +module.exports = yaml; + + +/***/ }), +/* 415 */, +/* 416 */, +/* 417 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + + +var common = __webpack_require__(740); +var Type = __webpack_require__(945); + +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + + // .2e4, .2 + // special case, seems not from spec + '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + + // 20:59 + '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + + // .inf + '|[-+]?\\.(?:inf|Inf|INF)' + + // .nan + '|\\.(?:nan|NaN|NAN))$'); + +function resolveYamlFloat(data) { + if (data === null) return false; + + if (!YAML_FLOAT_PATTERN.test(data) || + // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === '_') { + return false; + } + + return true; } -exports.getVersionFromToolcachePath = getVersionFromToolcachePath; -function extractJdkFile(toolPath, extension) { - return __awaiter(this, void 0, void 0, function* () { - if (!extension) { - extension = toolPath.endsWith('.tar.gz') ? 'tar.gz' : path_1.default.extname(toolPath); - if (extension.startsWith('.')) { - extension = extension.substring(1); - } - } - switch (extension) { - case 'tar.gz': - case 'tar': - return yield tc.extractTar(toolPath); - case 'zip': - return yield tc.extractZip(toolPath); - default: - return yield tc.extract7z(toolPath); - } + +function constructYamlFloat(data) { + var value, sign, base, digits; + + value = data.replace(/_/g, '').toLowerCase(); + sign = value[0] === '-' ? -1 : 1; + digits = []; + + if ('+-'.indexOf(value[0]) >= 0) { + value = value.slice(1); + } + + if (value === '.inf') { + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + + } else if (value === '.nan') { + return NaN; + + } else if (value.indexOf(':') >= 0) { + value.split(':').forEach(function (v) { + digits.unshift(parseFloat(v, 10)); }); + + value = 0.0; + base = 1; + + digits.forEach(function (d) { + value += d * base; + base *= 60; + }); + + return sign * value; + + } + return sign * parseFloat(value, 10); } -exports.extractJdkFile = extractJdkFile; -function getDownloadArchiveExtension() { - return process.platform === 'win32' ? 'zip' : 'tar.gz'; -} -exports.getDownloadArchiveExtension = getDownloadArchiveExtension; -function isVersionSatisfies(range, version) { - var _a; - if (semver.valid(range)) { - // if full version with build digit is provided as a range (such as '1.2.3+4') - // we should check for exact equal via compareBuild - // since semver.satisfies doesn't handle 4th digit - const semRange = semver.parse(range); - if (semRange && ((_a = semRange.build) === null || _a === void 0 ? void 0 : _a.length) > 0) { - return semver.compareBuild(range, version) === 0; - } + + +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; + +function representYamlFloat(object, style) { + var res; + + if (isNaN(object)) { + switch (style) { + case 'lowercase': return '.nan'; + case 'uppercase': return '.NAN'; + case 'camelcase': return '.NaN'; } - return semver.satisfies(version, range); -} -exports.isVersionSatisfies = isVersionSatisfies; -function getToolcachePath(toolName, version, architecture) { - var _a; - const toolcacheRoot = (_a = process.env['RUNNER_TOOL_CACHE']) !== null && _a !== void 0 ? _a : ''; - const fullPath = path_1.default.join(toolcacheRoot, toolName, version, architecture); - if (fs.existsSync(fullPath)) { - return fullPath; + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '.inf'; + case 'uppercase': return '.INF'; + case 'camelcase': return '.Inf'; } - return null; + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '-.inf'; + case 'uppercase': return '-.INF'; + case 'camelcase': return '-.Inf'; + } + } else if (common.isNegativeZero(object)) { + return '-0.0'; + } + + res = object.toString(10); + + // JS stringifier can build scientific format without dots: 5e-100, + // while YAML requres dot: 5.e-100. Fix it with simple hack + + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; } -exports.getToolcachePath = getToolcachePath; + +function isFloat(object) { + return (Object.prototype.toString.call(object) === '[object Number]') && + (object % 1 !== 0 || common.isNegativeZero(object)); +} + +module.exports = new Type('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: 'lowercase' +}); /***/ }), -/* 323 */, -/* 324 */, -/* 325 */ +/* 418 */, +/* 419 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; @@ -13648,2829 +14363,1536 @@ var __values = (this && this.__values) || function(o) { throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); -var ObjectWriter_1 = __webpack_require__(419); var util_1 = __webpack_require__(592); +var interfaces_1 = __webpack_require__(970); var BaseWriter_1 = __webpack_require__(462); /** - * Serializes XML nodes into a YAML string. + * Serializes XML nodes into objects and arrays. */ -var YAMLWriter = /** @class */ (function (_super) { - __extends(YAMLWriter, _super); +var ObjectWriter = /** @class */ (function (_super) { + __extends(ObjectWriter, _super); /** - * Initializes a new instance of `YAMLWriter`. + * Initializes a new instance of `ObjectWriter`. * * @param builderOptions - XML builder options * @param writerOptions - serialization options */ - function YAMLWriter(builderOptions, writerOptions) { + function ObjectWriter(builderOptions, writerOptions) { var _this = _super.call(this, builderOptions) || this; - // provide default options _this._writerOptions = util_1.applyDefaults(writerOptions, { + format: "object", wellFormed: false, noDoubleEncoding: false, - indent: ' ', - newline: '\n', - offset: 0, group: false, verbose: false }); - if (_this._writerOptions.indent.length < 2) { - throw new Error("YAML indententation string must be at least two characters long."); - } - if (_this._writerOptions.offset < 0) { - throw new Error("YAML offset should be zero or a positive number."); - } return _this; } /** * Produces an XML serialization of the given node. * * @param node - node to serialize - * @param writerOptions - serialization options */ - YAMLWriter.prototype.serialize = function (node) { - // convert to object - var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - }); - var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); - var val = objectWriter.serialize(node); - var markup = this._beginLine(this._writerOptions, 0) + '---' + this._endLine(this._writerOptions) + - this._convertObject(val, this._writerOptions, 0); - // remove trailing newline - /* istanbul ignore else */ - if (markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { - markup = markup.slice(0, -this._writerOptions.newline.length); - } - return markup; + ObjectWriter.prototype.serialize = function (node) { + this._currentList = []; + this._currentIndex = 0; + this._listRegister = [this._currentList]; + /** + * First pass, serialize nodes + * This creates a list of nodes grouped under node types while preserving + * insertion order. For example: + * [ + * root: [ + * node: [ + * { "@" : { "att1": "val1", "att2": "val2" } + * { "#": "node text" } + * { childNode: [] } + * { "#": "more text" } + * ], + * node: [ + * { "@" : { "att": "val" } + * { "#": [ "text line1", "text line2" ] } + * ] + * ] + * ] + */ + this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); + /** + * Second pass, process node lists. Above example becomes: + * { + * root: { + * node: [ + * { + * "@att1": "val1", + * "@att2": "val2", + * "#1": "node text", + * childNode: {}, + * "#2": "more text" + * }, + * { + * "@att": "val", + * "#": [ "text line1", "text line2" ] + * } + * ] + * } + * } + */ + return this._process(this._currentList, this._writerOptions); }; - /** - * Produces an XML serialization of the given object. - * - * @param obj - object to serialize - * @param options - serialization options - * @param level - depth of the XML tree - * @param indentLeaf - indents leaf nodes - */ - YAMLWriter.prototype._convertObject = function (obj, options, level, suppressIndent) { - var e_1, _a; - var _this = this; - if (suppressIndent === void 0) { suppressIndent = false; } - var markup = ''; - if (util_1.isArray(obj)) { - try { - for (var obj_1 = __values(obj), obj_1_1 = obj_1.next(); !obj_1_1.done; obj_1_1 = obj_1.next()) { - var val = obj_1_1.value; - markup += this._beginLine(options, level, true); - if (!util_1.isObject(val)) { - markup += this._val(val) + this._endLine(options); - } - else if (util_1.isEmpty(val)) { - markup += '""' + this._endLine(options); + ObjectWriter.prototype._process = function (items, options) { + var _a, _b, _c, _d, _e, _f, _g; + if (items.length === 0) + return {}; + // determine if there are non-unique element names + var namesSeen = {}; + var hasNonUniqueNames = false; + var textCount = 0; + var commentCount = 0; + var instructionCount = 0; + var cdataCount = 0; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + continue; + case "#": + textCount++; + break; + case "!": + commentCount++; + break; + case "?": + instructionCount++; + break; + case "$": + cdataCount++; + break; + default: + if (namesSeen[key]) { + hasNonUniqueNames = true; } else { - markup += this._convertObject(val, options, level, true); + namesSeen[key] = true; } - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); - } - finally { if (e_1) throw e_1.error; } + break; } } - else /* if (isObject(obj)) */ { - util_1.forEachObject(obj, function (key, val) { - if (suppressIndent) { - markup += _this._key(key); - suppressIndent = false; - } - else { - markup += _this._beginLine(options, level) + _this._key(key); - } - if (!util_1.isObject(val)) { - markup += ' ' + _this._val(val) + _this._endLine(options); - } - else if (util_1.isEmpty(val)) { - markup += ' ""' + _this._endLine(options); - } - else { - markup += _this._endLine(options) + - _this._convertObject(val, options, level + 1); - } - }, this); - } - return markup; - }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - * @param level - current depth of the XML tree - * @param isArray - whether this line is an array item - */ - YAMLWriter.prototype._beginLine = function (options, level, isArray) { - if (isArray === void 0) { isArray = false; } - var indentLevel = options.offset + level + 1; - var chars = new Array(indentLevel).join(options.indent); - if (isArray) { - return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); - } - else { - return chars; + var defAttrKey = this._getAttrKey(); + var defTextKey = this._getNodeKey(interfaces_1.NodeType.Text); + var defCommentKey = this._getNodeKey(interfaces_1.NodeType.Comment); + var defInstructionKey = this._getNodeKey(interfaces_1.NodeType.ProcessingInstruction); + var defCdataKey = this._getNodeKey(interfaces_1.NodeType.CData); + if (textCount === 1 && items.length === 1 && util_1.isString(items[0]["#"])) { + // special case of an element node with a single text node + return items[0]["#"]; } + else if (hasNonUniqueNames) { + var obj = {}; + // process attributes first + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + if (key === "@") { + var attrs = item["@"]; + var attrKeys = Object.keys(attrs); + if (attrKeys.length === 1) { + obj[defAttrKey + attrKeys[0]] = attrs[attrKeys[0]]; + } + else { + obj[defAttrKey] = item["@"]; + } + } + } + // list contains element nodes with non-unique names + // return an array with mixed content notation + var result = []; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + // attributes were processed above + break; + case "#": + result.push((_a = {}, _a[defTextKey] = item["#"], _a)); + break; + case "!": + result.push((_b = {}, _b[defCommentKey] = item["!"], _b)); + break; + case "?": + result.push((_c = {}, _c[defInstructionKey] = item["?"], _c)); + break; + case "$": + result.push((_d = {}, _d[defCdataKey] = item["$"], _d)); + break; + default: + // element node + var ele = item; + if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { + // group of element nodes + var eleGroup = []; + var listOfLists = ele[key]; + for (var i_1 = 0; i_1 < listOfLists.length; i_1++) { + eleGroup.push(this._process(listOfLists[i_1], options)); + } + result.push((_e = {}, _e[key] = eleGroup, _e)); + } + else { + // single element node + if (options.verbose) { + result.push((_f = {}, _f[key] = [this._process(ele[key], options)], _f)); + } + else { + result.push((_g = {}, _g[key] = this._process(ele[key], options), _g)); + } + } + break; + } + } + obj[defTextKey] = result; + return obj; + } + else { + // all element nodes have unique names + // return an object while prefixing data node keys + var textId = 1; + var commentId = 1; + var instructionId = 1; + var cdataId = 1; + var obj = {}; + for (var i = 0; i < items.length; i++) { + var item = items[i]; + var key = Object.keys(item)[0]; + switch (key) { + case "@": + var attrs = item["@"]; + var attrKeys = Object.keys(attrs); + if (!options.group || attrKeys.length === 1) { + for (var attrName in attrs) { + obj[defAttrKey + attrName] = attrs[attrName]; + } + } + else { + obj[defAttrKey] = attrs; + } + break; + case "#": + textId = this._processSpecItem(item["#"], obj, options.group, defTextKey, textCount, textId); + break; + case "!": + commentId = this._processSpecItem(item["!"], obj, options.group, defCommentKey, commentCount, commentId); + break; + case "?": + instructionId = this._processSpecItem(item["?"], obj, options.group, defInstructionKey, instructionCount, instructionId); + break; + case "$": + cdataId = this._processSpecItem(item["$"], obj, options.group, defCdataKey, cdataCount, cdataId); + break; + default: + // element node + var ele = item; + if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { + // group of element nodes + var eleGroup = []; + var listOfLists = ele[key]; + for (var i_2 = 0; i_2 < listOfLists.length; i_2++) { + eleGroup.push(this._process(listOfLists[i_2], options)); + } + obj[key] = eleGroup; + } + else { + // single element node + if (options.verbose) { + obj[key] = [this._process(ele[key], options)]; + } + else { + obj[key] = this._process(ele[key], options); + } + } + break; + } + } + return obj; + } + }; + ObjectWriter.prototype._processSpecItem = function (item, obj, group, defKey, count, id) { + var e_1, _a; + if (!group && util_1.isArray(item) && count + item.length > 2) { + try { + for (var item_1 = __values(item), item_1_1 = item_1.next(); !item_1_1.done; item_1_1 = item_1.next()) { + var subItem = item_1_1.value; + var key = defKey + (id++).toString(); + obj[key] = subItem; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (item_1_1 && !item_1_1.done && (_a = item_1.return)) _a.call(item_1); + } + finally { if (e_1) throw e_1.error; } + } + } + else { + var key = count > 1 ? defKey + (id++).toString() : defKey; + obj[key] = item; + } + return id; + }; + /** @inheritdoc */ + ObjectWriter.prototype.beginElement = function (name) { + var _a, _b; + var childItems = []; + if (this._currentList.length === 0) { + this._currentList.push((_a = {}, _a[name] = childItems, _a)); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isElementNode(lastItem, name)) { + if (lastItem[name].length !== 0 && util_1.isArray(lastItem[name][0])) { + var listOfLists = lastItem[name]; + listOfLists.push(childItems); + } + else { + lastItem[name] = [lastItem[name], childItems]; + } + } + else { + this._currentList.push((_b = {}, _b[name] = childItems, _b)); + } + } + this._currentIndex++; + if (this._listRegister.length > this._currentIndex) { + this._listRegister[this._currentIndex] = childItems; + } + else { + this._listRegister.push(childItems); + } + this._currentList = childItems; + }; + /** @inheritdoc */ + ObjectWriter.prototype.endElement = function () { + this._currentList = this._listRegister[--this._currentIndex]; + }; + /** @inheritdoc */ + ObjectWriter.prototype.attribute = function (name, value) { + var _a, _b; + if (this._currentList.length === 0) { + this._currentList.push({ "@": (_a = {}, _a[name] = value, _a) }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + /* istanbul ignore else */ + if (this._isAttrNode(lastItem)) { + lastItem["@"][name] = value; + } + else { + this._currentList.push({ "@": (_b = {}, _b[name] = value, _b) }); + } + } + }; + /** @inheritdoc */ + ObjectWriter.prototype.comment = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "!": data }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isCommentNode(lastItem)) { + if (util_1.isArray(lastItem["!"])) { + lastItem["!"].push(data); + } + else { + lastItem["!"] = [lastItem["!"], data]; + } + } + else { + this._currentList.push({ "!": data }); + } + } + }; + /** @inheritdoc */ + ObjectWriter.prototype.text = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "#": data }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isTextNode(lastItem)) { + if (util_1.isArray(lastItem["#"])) { + lastItem["#"].push(data); + } + else { + lastItem["#"] = [lastItem["#"], data]; + } + } + else { + this._currentList.push({ "#": data }); + } + } + }; + /** @inheritdoc */ + ObjectWriter.prototype.instruction = function (target, data) { + var value = (data === "" ? target : target + " " + data); + if (this._currentList.length === 0) { + this._currentList.push({ "?": value }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isInstructionNode(lastItem)) { + if (util_1.isArray(lastItem["?"])) { + lastItem["?"].push(value); + } + else { + lastItem["?"] = [lastItem["?"], value]; + } + } + else { + this._currentList.push({ "?": value }); + } + } + }; + /** @inheritdoc */ + ObjectWriter.prototype.cdata = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "$": data }); + } + else { + var lastItem = this._currentList[this._currentList.length - 1]; + if (this._isCDATANode(lastItem)) { + if (util_1.isArray(lastItem["$"])) { + lastItem["$"].push(data); + } + else { + lastItem["$"] = [lastItem["$"], data]; + } + } + else { + this._currentList.push({ "$": data }); + } + } + }; + ObjectWriter.prototype._isAttrNode = function (x) { + return "@" in x; + }; + ObjectWriter.prototype._isTextNode = function (x) { + return "#" in x; + }; + ObjectWriter.prototype._isCommentNode = function (x) { + return "!" in x; + }; + ObjectWriter.prototype._isInstructionNode = function (x) { + return "?" in x; + }; + ObjectWriter.prototype._isCDATANode = function (x) { + return "$" in x; + }; + ObjectWriter.prototype._isElementNode = function (x, name) { + return name in x; }; /** - * Produces characters to be appended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - */ - YAMLWriter.prototype._endLine = function (options) { - return options.newline; - }; - /** - * Produces a YAML key string delimited with double quotes. + * Returns an object key for an attribute or namespace declaration. */ - YAMLWriter.prototype._key = function (key) { - return "\"" + key + "\":"; + ObjectWriter.prototype._getAttrKey = function () { + return this._builderOptions.convert.att; }; /** - * Produces a YAML value string delimited with double quotes. + * Returns an object key for the given node type. + * + * @param nodeType - node type to get a key for */ - YAMLWriter.prototype._val = function (val) { - return JSON.stringify(val); + ObjectWriter.prototype._getNodeKey = function (nodeType) { + switch (nodeType) { + case interfaces_1.NodeType.Comment: + return this._builderOptions.convert.comment; + case interfaces_1.NodeType.Text: + return this._builderOptions.convert.text; + case interfaces_1.NodeType.ProcessingInstruction: + return this._builderOptions.convert.ins; + case interfaces_1.NodeType.CData: + return this._builderOptions.convert.cdata; + /* istanbul ignore next */ + default: + throw new Error("Invalid node type."); + } }; - return YAMLWriter; + return ObjectWriter; }(BaseWriter_1.BaseWriter)); -exports.YAMLWriter = YAMLWriter; -//# sourceMappingURL=YAMLWriter.js.map +exports.ObjectWriter = ObjectWriter; +//# sourceMappingURL=ObjectWriter.js.map /***/ }), -/* 326 */, -/* 327 */, -/* 328 */, -/* 329 */, -/* 330 */, -/* 331 */ +/* 420 */, +/* 421 */, +/* 422 */, +/* 423 */, +/* 424 */, +/* 425 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "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 (k !== "default" && 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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.generate = exports.createAuthenticationSettings = exports.configureAuthentication = exports.SETTINGS_FILE = exports.M2_DIR = void 0; -const path = __importStar(__webpack_require__(622)); -const core = __importStar(__webpack_require__(470)); -const io = __importStar(__webpack_require__(1)); -const fs = __importStar(__webpack_require__(747)); -const os = __importStar(__webpack_require__(87)); -const xmlbuilder2_1 = __webpack_require__(255); -const constants = __importStar(__webpack_require__(211)); -const gpg = __importStar(__webpack_require__(884)); -const util_1 = __webpack_require__(322); -exports.M2_DIR = '.m2'; -exports.SETTINGS_FILE = 'settings.xml'; -function configureAuthentication() { - return __awaiter(this, void 0, void 0, function* () { - const id = core.getInput(constants.INPUT_SERVER_ID); - const username = core.getInput(constants.INPUT_SERVER_USERNAME); - const password = core.getInput(constants.INPUT_SERVER_PASSWORD); - const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) || path.join(os.homedir(), exports.M2_DIR); - const overwriteSettings = util_1.getBooleanInput(constants.INPUT_OVERWRITE_SETTINGS, true); - const gpgPrivateKey = core.getInput(constants.INPUT_GPG_PRIVATE_KEY) || constants.INPUT_DEFAULT_GPG_PRIVATE_KEY; - const gpgPassphrase = core.getInput(constants.INPUT_GPG_PASSPHRASE) || - (gpgPrivateKey ? constants.INPUT_DEFAULT_GPG_PASSPHRASE : undefined); - if (gpgPrivateKey) { - core.setSecret(gpgPrivateKey); - } - yield createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase); - if (gpgPrivateKey) { - core.info('Importing private gpg key'); - const keyFingerprint = (yield gpg.importKey(gpgPrivateKey)) || ''; - core.saveState(constants.STATE_GPG_PRIVATE_KEY_FINGERPRINT, keyFingerprint); - } - }); -} -exports.configureAuthentication = configureAuthentication; -function createAuthenticationSettings(id, username, password, settingsDirectory, overwriteSettings, gpgPassphrase = undefined) { - return __awaiter(this, void 0, void 0, function* () { - core.info(`Creating ${exports.SETTINGS_FILE} with server-id: ${id}`); - // when an alternate m2 location is specified use only that location (no .m2 directory) - // otherwise use the home/.m2/ path - yield io.mkdirP(settingsDirectory); - yield write(settingsDirectory, generate(id, username, password, gpgPassphrase), overwriteSettings); - }); -} -exports.createAuthenticationSettings = createAuthenticationSettings; -// only exported for testing purposes -function generate(id, username, password, gpgPassphrase) { - const xmlObj = { - settings: { - '@xmlns': 'http://maven.apache.org/SETTINGS/1.0.0', - '@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', - '@xsi:schemaLocation': 'http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd', - servers: { - server: [ - { - id: id, - username: `\${env.${username}}`, - password: `\${env.${password}}` - } - ] +var DOMImpl_1 = __webpack_require__(648); +var DOMException_1 = __webpack_require__(35); +var infra_1 = __webpack_require__(23); +var algorithm_1 = __webpack_require__(163); +/** + * Represents a token set. + */ +var DOMTokenListImpl = /** @class */ (function () { + /** + * Initializes a new instance of `DOMTokenList`. + * + * @param element - associated element + * @param attribute - associated attribute + */ + function DOMTokenListImpl(element, attribute) { + /** + * 1. Let element be associated element. + * 2. Let localName be associated attribute’s local name. + * 3. Let value be the result of getting an attribute value given element + * and localName. + * 4. Run the attribute change steps for element, localName, value, value, + * and null. + */ + this._element = element; + this._attribute = attribute; + this._tokenSet = new Set(); + var localName = attribute._localName; + var value = algorithm_1.element_getAnAttributeValue(element, localName); + // define a closure to be called when the associated attribute's value changes + var thisObj = this; + function updateTokenSet(element, localName, oldValue, value, namespace) { + /** + * 1. If localName is associated attribute’s local name, namespace is null, + * and value is null, then empty token set. + * 2. Otherwise, if localName is associated attribute’s local name, + * namespace is null, then set token set to value, parsed. + */ + if (localName === thisObj._attribute._localName && namespace === null) { + if (!value) + thisObj._tokenSet.clear(); + else + thisObj._tokenSet = algorithm_1.orderedSet_parse(value); } } - }; - if (gpgPassphrase) { - const gpgServer = { - id: 'gpg.passphrase', - passphrase: `\${env.${gpgPassphrase}}` - }; - xmlObj.settings.servers.server.push(gpgServer); + // add the closure to the associated element's attribute change steps + this._element._attributeChangeSteps.push(updateTokenSet); + if (DOMImpl_1.dom.features.steps) { + algorithm_1.dom_runAttributeChangeSteps(element, localName, value, value, null); + } } - return xmlbuilder2_1.create(xmlObj).end({ - headless: true, - prettyPrint: true, - width: 80 - }); -} -exports.generate = generate; -function write(directory, settings, overwriteSettings) { - return __awaiter(this, void 0, void 0, function* () { - const location = path.join(directory, exports.SETTINGS_FILE); - const settingsExists = fs.existsSync(location); - if (settingsExists && overwriteSettings) { - core.info(`Overwriting existing file ${location}`); + Object.defineProperty(DOMTokenListImpl.prototype, "length", { + /** @inheritdoc */ + get: function () { + /** + * The length attribute' getter must return context object’s token set’s + * size. + */ + return this._tokenSet.size; + }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + DOMTokenListImpl.prototype.item = function (index) { + var e_1, _a; + /** + * 1. If index is equal to or greater than context object’s token set’s + * size, then return null. + * 2. Return context object’s token set[index]. + */ + var i = 0; + try { + for (var _b = __values(this._tokenSet), _c = _b.next(); !_c.done; _c = _b.next()) { + var token = _c.value; + if (i === index) + return token; + i++; + } } - else if (!settingsExists) { - core.info(`Writing to ${location}`); + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } } - else { - core.info(`Skipping generation ${location} because file already exists and overwriting is not required`); - return; + return null; + }; + /** @inheritdoc */ + DOMTokenListImpl.prototype.contains = function (token) { + /** + * The contains(token) method, when invoked, must return true if context + * object’s token set[token] exists, and false otherwise. + */ + return this._tokenSet.has(token); + }; + /** @inheritdoc */ + DOMTokenListImpl.prototype.add = function () { + var e_2, _a; + var tokens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tokens[_i] = arguments[_i]; } - return fs.writeFileSync(location, settings, { - encoding: 'utf-8', - flag: 'w' - }); - }); -} - - -/***/ }), -/* 332 */, -/* 333 */, -/* 334 */, -/* 335 */, -/* 336 */, -/* 337 */, -/* 338 */, -/* 339 */, -/* 340 */, -/* 341 */, -/* 342 */, -/* 343 */, -/* 344 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var PotentialCustomElementName = /[a-z]([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*-([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*/; -var NamesWithHyphen = new Set(['annotation-xml', 'color-profile', - 'font-face', 'font-face-src', 'font-face-uri', 'font-face-format', - 'font-face-name', 'missing-glyph']); -var ElementNames = new Set(['article', 'aside', 'blockquote', - 'body', 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', - 'header', 'main', 'nav', 'p', 'section', 'span']); -var VoidElementNames = new Set(['area', 'base', 'basefont', - 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', - 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); -var ShadowHostNames = new Set(['article', 'aside', 'blockquote', 'body', - 'div', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'main', - 'nav', 'p', 'section', 'span']); -/** - * Determines if the given string is a valid custom element name. - * - * @param name - a name string - */ -function customElement_isValidCustomElementName(name) { - if (!PotentialCustomElementName.test(name)) - return false; - if (NamesWithHyphen.has(name)) - return false; - return true; -} -exports.customElement_isValidCustomElementName = customElement_isValidCustomElementName; -/** - * Determines if the given string is a valid element name. - * - * @param name - a name string - */ -function customElement_isValidElementName(name) { - return (ElementNames.has(name)); -} -exports.customElement_isValidElementName = customElement_isValidElementName; -/** - * Determines if the given string is a void element name. - * - * @param name - a name string - */ -function customElement_isVoidElementName(name) { - return (VoidElementNames.has(name)); -} -exports.customElement_isVoidElementName = customElement_isVoidElementName; -/** - * Determines if the given string is a valid shadow host element name. - * - * @param name - a name string - */ -function customElement_isValidShadowHostName(name) { - return (ShadowHostNames.has(name)); -} -exports.customElement_isValidShadowHostName = customElement_isValidShadowHostName; -/** - * Enqueues an upgrade reaction for a custom element. - * - * @param element - a custom element - * @param definition - a custom element definition - */ -function customElement_enqueueACustomElementUpgradeReaction(element, definition) { - // TODO: Implement in HTML DOM -} -exports.customElement_enqueueACustomElementUpgradeReaction = customElement_enqueueACustomElementUpgradeReaction; -/** - * Enqueues a callback reaction for a custom element. - * - * @param element - a custom element - * @param callbackName - name of the callback - * @param args - callback arguments - */ -function customElement_enqueueACustomElementCallbackReaction(element, callbackName, args) { - // TODO: Implement in HTML DOM -} -exports.customElement_enqueueACustomElementCallbackReaction = customElement_enqueueACustomElementCallbackReaction; -/** - * Upgrade a custom element. - * - * @param element - a custom element - */ -function customElement_upgrade(definition, element) { - // TODO: Implement in HTML DOM -} -exports.customElement_upgrade = customElement_upgrade; -/** - * Tries to upgrade a custom element. - * - * @param element - a custom element - */ -function customElement_tryToUpgrade(element) { - // TODO: Implement in HTML DOM -} -exports.customElement_tryToUpgrade = customElement_tryToUpgrade; -/** - * Looks up a custom element definition. - * - * @param document - a document - * @param namespace - element namespace - * @param localName - element local name - * @param is - an `is` value - */ -function customElement_lookUpACustomElementDefinition(document, namespace, localName, is) { - // TODO: Implement in HTML DOM - return null; -} -exports.customElement_lookUpACustomElementDefinition = customElement_lookUpACustomElementDefinition; -//# sourceMappingURL=CustomElementAlgorithm.js.map - -/***/ }), -/* 345 */, -/* 346 */, -/* 347 */, -/* 348 */, -/* 349 */, -/* 350 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var interfaces_1 = __webpack_require__(970); -var TreeAlgorithm_1 = __webpack_require__(873); -/** - * Defines the position of a boundary point relative to another. - * - * @param bp - a boundary point - * @param relativeTo - a boundary point to compare to - */ -function boundaryPoint_position(bp, relativeTo) { - var nodeA = bp[0]; - var offsetA = bp[1]; - var nodeB = relativeTo[0]; - var offsetB = relativeTo[1]; - /** - * 1. Assert: nodeA and nodeB have the same root. - */ - console.assert(TreeAlgorithm_1.tree_rootNode(nodeA) === TreeAlgorithm_1.tree_rootNode(nodeB), "Boundary points must share the same root node."); - /** - * 2. If nodeA is nodeB, then return equal if offsetA is offsetB, before - * if offsetA is less than offsetB, and after if offsetA is greater than - * offsetB. - */ - if (nodeA === nodeB) { - if (offsetA === offsetB) { - return interfaces_1.BoundaryPosition.Equal; + try { + /** + * 1. For each token in tokens: + * 1.1. If token is the empty string, then throw a "SyntaxError" + * DOMException. + * 1.2. If token contains any ASCII whitespace, then throw an + * "InvalidCharacterError" DOMException. + * 2. For each token in tokens, append token to context object’s token set. + * 3. Run the update steps. + */ + for (var tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) { + var token = tokens_1_1.value; + if (token === '') { + throw new DOMException_1.SyntaxError("Cannot add an empty token."); + } + else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { + throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); + } + else { + this._tokenSet.add(token); + } + } } - else if (offsetA < offsetB) { - return interfaces_1.BoundaryPosition.Before; + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1); + } + finally { if (e_2) throw e_2.error; } } - else { - return interfaces_1.BoundaryPosition.After; + algorithm_1.tokenList_updateSteps(this); + }; + /** @inheritdoc */ + DOMTokenListImpl.prototype.remove = function () { + var e_3, _a; + var tokens = []; + for (var _i = 0; _i < arguments.length; _i++) { + tokens[_i] = arguments[_i]; } - } - /** - * 3. If nodeA is following nodeB, then if the position of (nodeB, offsetB) - * relative to (nodeA, offsetA) is before, return after, and if it is after, - * return before. - */ - if (TreeAlgorithm_1.tree_isFollowing(nodeB, nodeA)) { - var pos = boundaryPoint_position([nodeB, offsetB], [nodeA, offsetA]); - if (pos === interfaces_1.BoundaryPosition.Before) { - return interfaces_1.BoundaryPosition.After; + try { + /** + * 1. For each token in tokens: + * 1.1. If token is the empty string, then throw a "SyntaxError" + * DOMException. + * 1.2. If token contains any ASCII whitespace, then throw an + * "InvalidCharacterError" DOMException. + * 2. For each token in tokens, remove token from context object’s token set. + * 3. Run the update steps. + */ + for (var tokens_2 = __values(tokens), tokens_2_1 = tokens_2.next(); !tokens_2_1.done; tokens_2_1 = tokens_2.next()) { + var token = tokens_2_1.value; + if (token === '') { + throw new DOMException_1.SyntaxError("Cannot remove an empty token."); + } + else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { + throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); + } + else { + this._tokenSet.delete(token); + } + } } - else if (pos === interfaces_1.BoundaryPosition.After) { - return interfaces_1.BoundaryPosition.Before; + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2); + } + finally { if (e_3) throw e_3.error; } } - } - /** - * 4. If nodeA is an ancestor of nodeB: - */ - if (TreeAlgorithm_1.tree_isAncestorOf(nodeB, nodeA)) { + algorithm_1.tokenList_updateSteps(this); + }; + /** @inheritdoc */ + DOMTokenListImpl.prototype.toggle = function (token, force) { + if (force === void 0) { force = undefined; } /** - * 4.1. Let child be nodeB. - * 4.2. While child is not a child of nodeA, set child to its parent. - * 4.3. If child’s index is less than offsetA, then return after. + * 1. If token is the empty string, then throw a "SyntaxError" DOMException. + * 2. If token contains any ASCII whitespace, then throw an + * "InvalidCharacterError" DOMException. */ - var child = nodeB; - while (!TreeAlgorithm_1.tree_isChildOf(nodeA, child)) { - /* istanbul ignore else */ - if (child._parent !== null) { - child = child._parent; + if (token === '') { + throw new DOMException_1.SyntaxError("Cannot toggle an empty token."); + } + else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { + throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); + } + /** + * 3. If context object’s token set[token] exists, then: + */ + if (this._tokenSet.has(token)) { + /** + * 3.1. If force is either not given or is false, then remove token from + * context object’s token set, run the update steps and return false. + * 3.2. Return true. + */ + if (force === undefined || force === false) { + this._tokenSet.delete(token); + algorithm_1.tokenList_updateSteps(this); + return false; } + return true; } - if (TreeAlgorithm_1.tree_index(child) < offsetA) { - return interfaces_1.BoundaryPosition.After; + /** + * 4. Otherwise, if force not given or is true, append token to context + * object’s token set, run the update steps, and return true. + */ + if (force === undefined || force === true) { + this._tokenSet.add(token); + algorithm_1.tokenList_updateSteps(this); + return true; } - } + /** + * 5. Return false. + */ + return false; + }; + /** @inheritdoc */ + DOMTokenListImpl.prototype.replace = function (token, newToken) { + /** + * 1. If either token or newToken is the empty string, then throw a + * "SyntaxError" DOMException. + * 2. If either token or newToken contains any ASCII whitespace, then throw + * an "InvalidCharacterError" DOMException. + */ + if (token === '' || newToken === '') { + throw new DOMException_1.SyntaxError("Cannot replace an empty token."); + } + else if (infra_1.codePoint.ASCIIWhiteSpace.test(token) || infra_1.codePoint.ASCIIWhiteSpace.test(newToken)) { + throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); + } + /** + * 3. If context object’s token set does not contain token, then return + * false. + */ + if (!this._tokenSet.has(token)) + return false; + /** + * 4. Replace token in context object’s token set with newToken. + * 5. Run the update steps. + * 6. Return true. + */ + infra_1.set.replace(this._tokenSet, token, newToken); + algorithm_1.tokenList_updateSteps(this); + return true; + }; + /** @inheritdoc */ + DOMTokenListImpl.prototype.supports = function (token) { + /** + * 1. Let result be the return value of validation steps called with token. + * 2. Return result. + */ + return algorithm_1.tokenList_validationSteps(this, token); + }; + Object.defineProperty(DOMTokenListImpl.prototype, "value", { + /** @inheritdoc */ + get: function () { + /** + * The value attribute must return the result of running context object’s + * serialize steps. + */ + return algorithm_1.tokenList_serializeSteps(this); + }, + set: function (value) { + /** + * Setting the value attribute must set an attribute value for the + * associated element using associated attribute’s local name and the given + * value. + */ + algorithm_1.element_setAnAttributeValue(this._element, this._attribute._localName, value); + }, + enumerable: true, + configurable: true + }); /** - * 5. Return before. + * Returns an iterator for the token set. */ - return interfaces_1.BoundaryPosition.Before; -} -exports.boundaryPoint_position = boundaryPoint_position; -//# sourceMappingURL=BoundaryPointAlgorithm.js.map + DOMTokenListImpl.prototype[Symbol.iterator] = function () { + var it = this._tokenSet[Symbol.iterator](); + return { + next: function () { + return it.next(); + } + }; + }; + /** + * Creates a new `DOMTokenList`. + * + * @param element - associated element + * @param attribute - associated attribute + */ + DOMTokenListImpl._create = function (element, attribute) { + return new DOMTokenListImpl(element, attribute); + }; + return DOMTokenListImpl; +}()); +exports.DOMTokenListImpl = DOMTokenListImpl; +//# sourceMappingURL=DOMTokenListImpl.js.map /***/ }), -/* 351 */, -/* 352 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -var esprima; - -// Browserified version does not have esprima -// -// 1. For node.js just require module as deps -// 2. For browser try to require mudule via external AMD system. -// If not found - try to fallback to window.esprima. If not -// found too - then fail to parse. -// -try { - // workaround to exclude package from browserify list. - var _require = require; - esprima = _require('esprima'); -} catch (_) { - /* eslint-disable no-redeclare */ - /* global window */ - if (typeof window !== 'undefined') esprima = window.esprima; -} - -var Type = __webpack_require__(945); - -function resolveJavascriptFunction(data) { - if (data === null) return false; - - try { - var source = '(' + data + ')', - ast = esprima.parse(source, { range: true }); - - if (ast.type !== 'Program' || - ast.body.length !== 1 || - ast.body[0].type !== 'ExpressionStatement' || - (ast.body[0].expression.type !== 'ArrowFunctionExpression' && - ast.body[0].expression.type !== 'FunctionExpression')) { - return false; - } - - return true; - } catch (err) { - return false; - } -} - -function constructJavascriptFunction(data) { - /*jslint evil:true*/ - - var source = '(' + data + ')', - ast = esprima.parse(source, { range: true }), - params = [], - body; - - if (ast.type !== 'Program' || - ast.body.length !== 1 || - ast.body[0].type !== 'ExpressionStatement' || - (ast.body[0].expression.type !== 'ArrowFunctionExpression' && - ast.body[0].expression.type !== 'FunctionExpression')) { - throw new Error('Failed to resolve function'); - } - - ast.body[0].expression.params.forEach(function (param) { - params.push(param.name); - }); - - body = ast.body[0].expression.body.range; - - // Esprima's ranges include the first '{' and the last '}' characters on - // function expressions. So cut them out. - if (ast.body[0].expression.body.type === 'BlockStatement') { - /*eslint-disable no-new-func*/ - return new Function(params, source.slice(body[0] + 1, body[1] - 1)); - } - // ES6 arrow functions can omit the BlockStatement. In that case, just return - // the body. - /*eslint-disable no-new-func*/ - return new Function(params, 'return ' + source.slice(body[0], body[1])); -} - -function representJavascriptFunction(object /*, style*/) { - return object.toString(); -} - -function isFunction(object) { - return Object.prototype.toString.call(object) === '[object Function]'; -} - -module.exports = new Type('tag:yaml.org,2002:js/function', { - kind: 'scalar', - resolve: resolveJavascriptFunction, - construct: constructJavascriptFunction, - predicate: isFunction, - represent: representJavascriptFunction -}); - - -/***/ }), -/* 353 */, -/* 354 */, -/* 355 */, -/* 356 */, -/* 357 */ -/***/ (function(module) { - -module.exports = require("assert"); - -/***/ }), -/* 358 */, -/* 359 */, -/* 360 */, -/* 361 */, -/* 362 */, -/* 363 */, -/* 364 */, -/* 365 */, -/* 366 */, -/* 367 */, -/* 368 */, -/* 369 */, -/* 370 */, -/* 371 */, -/* 372 */, -/* 373 */ -/***/ (function(module) { - -module.exports = require("crypto"); - -/***/ }), -/* 374 */, -/* 375 */, -/* 376 */, -/* 377 */, -/* 378 */, -/* 379 */, -/* 380 */, -/* 381 */, -/* 382 */, -/* 383 */, -/* 384 */, -/* 385 */, -/* 386 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -var Type = __webpack_require__(945); - -function resolveJavascriptUndefined() { - return true; -} - -function constructJavascriptUndefined() { - /*eslint-disable no-undefined*/ - return undefined; -} - -function representJavascriptUndefined() { - return ''; -} - -function isUndefined(object) { - return typeof object === 'undefined'; -} - -module.exports = new Type('tag:yaml.org,2002:js/undefined', { - kind: 'scalar', - resolve: resolveJavascriptUndefined, - construct: constructJavascriptUndefined, - predicate: isUndefined, - represent: representJavascriptUndefined -}); - - -/***/ }), -/* 387 */, -/* 388 */, -/* 389 */, -/* 390 */, -/* 391 */, -/* 392 */ -/***/ (function(__unusedmodule, exports) { +/* 426 */, +/* 427 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +var interfaces_1 = __webpack_require__(970); +var algorithm_1 = __webpack_require__(163); +var WebIDLAlgorithm_1 = __webpack_require__(495); /** - * A namespace prefix map is a map that associates namespaceURI and namespace - * prefix lists, where namespaceURI values are the map's unique keys (which can - * include the null value representing no namespace), and ordered lists of - * associated prefix values are the map's key values. The namespace prefix map - * will be populated by previously seen namespaceURIs and all their previously - * encountered prefix associations for a given node and its ancestors. - * - * _Note:_ The last seen prefix for a given namespaceURI is at the end of its - * respective list. The list is searched to find potentially matching prefixes, - * and if no matches are found for the given namespaceURI, then the last prefix - * in the list is used. See copy a namespace prefix map and retrieve a preferred - * prefix string for additional details. - * - * See: https://w3c.github.io/DOM-Parsing/#the-namespace-prefix-map + * Represents a DOM event. */ -var NamespacePrefixMap = /** @class */ (function () { - function NamespacePrefixMap() { - this._items = {}; - this._nullItems = []; - } +var EventImpl = /** @class */ (function () { /** - * Creates a copy of the map. + * Initializes a new instance of `Event`. */ - NamespacePrefixMap.prototype.copy = function () { + function EventImpl(type, eventInit) { + this._target = null; + this._relatedTarget = null; + this._touchTargetList = []; + this._path = []; + this._currentTarget = null; + this._eventPhase = interfaces_1.EventPhase.None; + this._stopPropagationFlag = false; + this._stopImmediatePropagationFlag = false; + this._canceledFlag = false; + this._inPassiveListenerFlag = false; + this._composedFlag = false; + this._initializedFlag = false; + this._dispatchFlag = false; + this._isTrusted = false; + this._bubbles = false; + this._cancelable = false; /** - * To copy a namespace prefix map map means to copy the map's keys into a - * new empty namespace prefix map, and to copy each of the values in the - * namespace prefix list associated with each keys' value into a new list - * which should be associated with the respective key in the new map. + * When a constructor of the Event interface, or of an interface that + * inherits from the Event interface, is invoked, these steps must be run, + * given the arguments type and eventInitDict: + * 1. Let event be the result of running the inner event creation steps with + * this interface, null, now, and eventInitDict. + * 2. Initialize event’s type attribute to type. + * 3. Return event. */ - var mapCopy = new NamespacePrefixMap(); - for (var key in this._items) { - mapCopy._items[key] = this._items[key].slice(0); + this._type = type; + if (eventInit) { + this._bubbles = eventInit.bubbles || false; + this._cancelable = eventInit.cancelable || false; + this._composedFlag = eventInit.composed || false; } - mapCopy._nullItems = this._nullItems.slice(0); - return mapCopy; - }; - /** - * Retrieves a preferred prefix string from the namespace prefix map. - * - * @param preferredPrefix - preferred prefix string - * @param ns - namespace - */ - NamespacePrefixMap.prototype.get = function (preferredPrefix, ns) { + this._initializedFlag = true; + this._timeStamp = new Date().getTime(); + } + Object.defineProperty(EventImpl.prototype, "type", { + /** @inheritdoc */ + get: function () { return this._type; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "target", { + /** @inheritdoc */ + get: function () { return this._target; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "srcElement", { + /** @inheritdoc */ + get: function () { return this._target; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "currentTarget", { + /** @inheritdoc */ + get: function () { return this._currentTarget; }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.composedPath = function () { /** - * 1. Let candidates list be the result of retrieving a list from map where - * there exists a key in map that matches the value of ns or if there is no - * such key, then stop running these steps, and return the null value. + * 1. Let composedPath be an empty list. + * 2. Let path be the context object’s path. + * 3. If path is empty, then return composedPath. + * 4. Let currentTarget be the context object’s currentTarget attribute + * value. + * 5. Append currentTarget to composedPath. + * 6. Let currentTargetIndex be 0. + * 7. Let currentTargetHiddenSubtreeLevel be 0. */ - var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); - if (candidatesList === null) { - return null; + var composedPath = []; + var path = this._path; + if (path.length === 0) + return composedPath; + var currentTarget = this._currentTarget; + if (currentTarget === null) { + throw new Error("Event currentTarget is null."); } + composedPath.push(currentTarget); + var currentTargetIndex = 0; + var currentTargetHiddenSubtreeLevel = 0; /** - * 2. Otherwise, for each prefix value prefix in candidates list, iterating - * from beginning to end: - * - * _Note:_ There will always be at least one prefix value in the list. + * 8. Let index be path’s size − 1. + * 9. While index is greater than or equal to 0: */ - var prefix = null; - for (var i = 0; i < candidatesList.length; i++) { - prefix = candidatesList[i]; + var index = path.length - 1; + while (index >= 0) { /** - * 2.1. If prefix matches preferred prefix, then stop running these steps - * and return prefix. + * 9.1. If path[index]'s root-of-closed-tree is true, then increase + * currentTargetHiddenSubtreeLevel by 1. + * 9.2. If path[index]'s invocation target is currentTarget, then set + * currentTargetIndex to index and break. + * 9.3. If path[index]'s slot-in-closed-tree is true, then decrease + * currentTargetHiddenSubtreeLevel by 1. + * 9.4. Decrease index by 1. */ - if (prefix === preferredPrefix) { - return prefix; + if (path[index].rootOfClosedTree) { + currentTargetHiddenSubtreeLevel++; + } + if (path[index].invocationTarget === currentTarget) { + currentTargetIndex = index; + break; + } + if (path[index].slotInClosedTree) { + currentTargetHiddenSubtreeLevel--; } + index--; } /** - * 2.2. If prefix is the last item in the candidates list, then stop - * running these steps and return prefix. - */ - return prefix; - }; - /** - * Checks if a prefix string is found in the namespace prefix map associated - * with the given namespace. - * - * @param prefix - prefix string - * @param ns - namespace - */ - NamespacePrefixMap.prototype.has = function (prefix, ns) { + * 10. Let currentHiddenLevel and maxHiddenLevel be + * currentTargetHiddenSubtreeLevel. + */ + var currentHiddenLevel = currentTargetHiddenSubtreeLevel; + var maxHiddenLevel = currentTargetHiddenSubtreeLevel; /** - * 1. Let candidates list be the result of retrieving a list from map where - * there exists a key in map that matches the value of ns or if there is - * no such key, then stop running these steps, and return false. + * 11. Set index to currentTargetIndex − 1. + * 12. While index is greater than or equal to 0: */ - var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); - if (candidatesList === null) { - return false; + index = currentTargetIndex - 1; + while (index >= 0) { + /** + * 12.1. If path[index]'s root-of-closed-tree is true, then increase + * currentHiddenLevel by 1. + * 12.2. If currentHiddenLevel is less than or equal to maxHiddenLevel, + * then prepend path[index]'s invocation target to composedPath. + */ + if (path[index].rootOfClosedTree) { + currentHiddenLevel++; + } + if (currentHiddenLevel <= maxHiddenLevel) { + composedPath.unshift(path[index].invocationTarget); + } + /** + * 12.3. If path[index]'s slot-in-closed-tree is true, then: + */ + if (path[index].slotInClosedTree) { + /** + * 12.3.1. Decrease currentHiddenLevel by 1. + * 12.3.2. If currentHiddenLevel is less than maxHiddenLevel, then set + * maxHiddenLevel to currentHiddenLevel. + */ + currentHiddenLevel--; + if (currentHiddenLevel < maxHiddenLevel) { + maxHiddenLevel = currentHiddenLevel; + } + } + /** + * 12.4. Decrease index by 1. + */ + index--; } /** - * 2. If the value of prefix occurs at least once in candidates list, - * return true, otherwise return false. + * 13. Set currentHiddenLevel and maxHiddenLevel to + * currentTargetHiddenSubtreeLevel. */ - return (candidatesList.indexOf(prefix) !== -1); - }; - /** - * Checks if a prefix string is found in the namespace prefix map. - * - * @param prefix - prefix string - */ - NamespacePrefixMap.prototype.hasPrefix = function (prefix) { - if (this._nullItems.indexOf(prefix) !== -1) - return true; - for (var key in this._items) { - if (this._items[key].indexOf(prefix) !== -1) - return true; + currentHiddenLevel = currentTargetHiddenSubtreeLevel; + maxHiddenLevel = currentTargetHiddenSubtreeLevel; + /** + * 14. Set index to currentTargetIndex + 1. + * 15. While index is less than path’s size: + */ + index = currentTargetIndex + 1; + while (index < path.length) { + /** + * 15.1. If path[index]'s slot-in-closed-tree is true, then increase + * currentHiddenLevel by 1. + * 15.2. If currentHiddenLevel is less than or equal to maxHiddenLevel, + * then append path[index]'s invocation target to composedPath. + */ + if (path[index].slotInClosedTree) { + currentHiddenLevel++; + } + if (currentHiddenLevel <= maxHiddenLevel) { + composedPath.push(path[index].invocationTarget); + } + /** + * 15.3. If path[index]'s root-of-closed-tree is true, then: + */ + if (path[index].rootOfClosedTree) { + /** + * 15.3.1. Decrease currentHiddenLevel by 1. + * 15.3.2. If currentHiddenLevel is less than maxHiddenLevel, then set + * maxHiddenLevel to currentHiddenLevel. + */ + currentHiddenLevel--; + if (currentHiddenLevel < maxHiddenLevel) { + maxHiddenLevel = currentHiddenLevel; + } + } + /** + * 15.4. Increase index by 1. + */ + index++; } - return false; + /** + * 16. Return composedPath. + */ + return composedPath; }; - /** - * Adds a prefix string associated with a namespace to the prefix map. - * - * @param prefix - prefix string - * @param ns - namespace - */ - NamespacePrefixMap.prototype.set = function (prefix, ns) { + Object.defineProperty(EventImpl.prototype, "eventPhase", { + /** @inheritdoc */ + get: function () { return this._eventPhase; }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.stopPropagation = function () { this._stopPropagationFlag = true; }; + Object.defineProperty(EventImpl.prototype, "cancelBubble", { + /** @inheritdoc */ + get: function () { return this._stopPropagationFlag; }, + set: function (value) { if (value) + this.stopPropagation(); }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.stopImmediatePropagation = function () { + this._stopPropagationFlag = true; + this._stopImmediatePropagationFlag = true; + }; + Object.defineProperty(EventImpl.prototype, "bubbles", { + /** @inheritdoc */ + get: function () { return this._bubbles; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "cancelable", { + /** @inheritdoc */ + get: function () { return this._cancelable; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "returnValue", { + /** @inheritdoc */ + get: function () { return !this._canceledFlag; }, + set: function (value) { + if (!value) { + algorithm_1.event_setTheCanceledFlag(this); + } + }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.preventDefault = function () { + algorithm_1.event_setTheCanceledFlag(this); + }; + Object.defineProperty(EventImpl.prototype, "defaultPrevented", { + /** @inheritdoc */ + get: function () { return this._canceledFlag; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "composed", { + /** @inheritdoc */ + get: function () { return this._composedFlag; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "isTrusted", { + /** @inheritdoc */ + get: function () { return this._isTrusted; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EventImpl.prototype, "timeStamp", { + /** @inheritdoc */ + get: function () { return this._timeStamp; }, + enumerable: true, + configurable: true + }); + /** @inheritdoc */ + EventImpl.prototype.initEvent = function (type, bubbles, cancelable) { + if (bubbles === void 0) { bubbles = false; } + if (cancelable === void 0) { cancelable = false; } /** - * 1. Let candidates list be the result of retrieving a list from map where - * there exists a key in map that matches the value of ns or if there is - * no such key, then let candidates list be null. + * 1. If the context object’s dispatch flag is set, then return. */ - var candidatesList = ns === null ? this._nullItems : (this._items[ns] || null); + if (this._dispatchFlag) + return; /** - * 2. If candidates list is null, then create a new list with prefix as the - * only item in the list, and associate that list with a new key ns in map. - * 3. Otherwise, append prefix to the end of candidates list. - * - * _Note:_ The steps in retrieve a preferred prefix string use the list to - * track the most recently used (MRU) prefix associated with a given - * namespace, which will be the prefix at the end of the list. This list - * may contain duplicates of the same prefix value seen earlier - * (and that's OK). + * 2. Initialize the context object with type, bubbles, and cancelable. */ - if (ns !== null && candidatesList === null) { - this._items[ns] = [prefix]; - } - else { - candidatesList.push(prefix); - } + algorithm_1.event_initialize(this, type, bubbles, cancelable); }; - return NamespacePrefixMap; -}()); -exports.NamespacePrefixMap = NamespacePrefixMap; -//# sourceMappingURL=NamespacePrefixMap.js.map + EventImpl.NONE = 0; + EventImpl.CAPTURING_PHASE = 1; + EventImpl.AT_TARGET = 2; + EventImpl.BUBBLING_PHASE = 3; + return EventImpl; +}()); +exports.EventImpl = EventImpl; +/** + * Define constants on prototype. + */ +WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "NONE", 0); +WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "CAPTURING_PHASE", 1); +WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "AT_TARGET", 2); +WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "BUBBLING_PHASE", 3); +//# sourceMappingURL=EventImpl.js.map /***/ }), -/* 393 */ +/* 428 */, +/* 429 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "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 (k !== "default" && 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) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ZuluDistribution = void 0; -const core = __importStar(__webpack_require__(470)); -const tc = __importStar(__webpack_require__(139)); -const path_1 = __importDefault(__webpack_require__(622)); -const fs_1 = __importDefault(__webpack_require__(747)); -const semver_1 = __importDefault(__webpack_require__(280)); -const base_installer_1 = __webpack_require__(83); -const util_1 = __webpack_require__(322); -class ZuluDistribution extends base_installer_1.JavaBase { - constructor(installerOptions) { - super('Zulu', installerOptions); - } - findPackageForDownload(version) { - return __awaiter(this, void 0, void 0, function* () { - const availableVersionsRaw = yield this.getAvailableVersions(); - const availableVersions = availableVersionsRaw.map(item => { - return { - version: this.convertVersionToSemver(item.jdk_version), - url: item.url, - zuluVersion: this.convertVersionToSemver(item.zulu_version) - }; - }); - const satisfiedVersions = availableVersions - .filter(item => util_1.isVersionSatisfies(version, item.version)) - .sort((a, b) => { - // Azul provides two versions: jdk_version and azul_version - // we should sort by both fields by descending - return (-semver_1.default.compareBuild(a.version, b.version) || - -semver_1.default.compareBuild(a.zuluVersion, b.zuluVersion)); - }) - .map(item => { - return { - version: item.version, - url: item.url - }; - }); - const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; - if (!resolvedFullVersion) { - const availableOptions = availableVersions.map(item => item.version).join(', '); - const availableOptionsMessage = availableOptions - ? `\nAvailable versions: ${availableOptions}` - : ''; - throw new Error(`Could not find satisfied version for semver ${version}. ${availableOptionsMessage}`); - } - return resolvedFullVersion; - }); - } - downloadTool(javaRelease) { - return __awaiter(this, void 0, void 0, function* () { - let extractedJavaPath; - core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); - core.info(`Extracting Java archive...`); - let extension = util_1.getDownloadArchiveExtension(); - extractedJavaPath = yield util_1.extractJdkFile(javaArchivePath, extension); - const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; - const archivePath = path_1.default.join(extractedJavaPath, archiveName); - const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture); - return { version: javaRelease.version, path: javaPath }; - }); - } - getAvailableVersions() { - var _a, _b; - return __awaiter(this, void 0, void 0, function* () { - const { arch, hw_bitness, abi } = this.getArchitectureOptions(); - const [bundleType, features] = this.packageType.split('+'); - const platform = this.getPlatformOption(); - const extension = util_1.getDownloadArchiveExtension(); - const javafx = (_a = features === null || features === void 0 ? void 0 : features.includes('fx')) !== null && _a !== void 0 ? _a : false; - const releaseStatus = this.stable ? 'ga' : 'ea'; - console.time('azul-retrieve-available-versions'); - const requestArguments = [ - `os=${platform}`, - `ext=${extension}`, - `bundle_type=${bundleType}`, - `javafx=${javafx}`, - `arch=${arch}`, - `hw_bitness=${hw_bitness}`, - `release_status=${releaseStatus}`, - abi ? `abi=${abi}` : null, - features ? `features=${features}` : null - ] - .filter(Boolean) - .join('&'); - const availableVersionsUrl = `https://api.azul.com/zulu/download/community/v1.0/bundles/?${requestArguments}`; - if (core.isDebug()) { - core.debug(`Gathering available versions from '${availableVersionsUrl}'`); - } - const availableVersions = (_b = (yield this.http.getJson(availableVersionsUrl)).result) !== null && _b !== void 0 ? _b : []; - if (core.isDebug()) { - core.startGroup('Print information about available versions'); - console.timeEnd('azul-retrieve-available-versions'); - console.log(`Available versions: [${availableVersions.length}]`); - console.log(availableVersions.map(item => item.jdk_version.join('.')).join(', ')); - core.endGroup(); - } - return availableVersions; - }); - } - getArchitectureOptions() { - if (this.architecture == 'x64') { - return { arch: 'x86', hw_bitness: '64', abi: '' }; - } - else if (this.architecture == 'x86') { - return { arch: 'x86', hw_bitness: '32', abi: '' }; - } - else { - return { arch: this.architecture, hw_bitness: '', abi: '' }; - } - } - getPlatformOption() { - // Azul has own platform names so need to map them - switch (process.platform) { - case 'darwin': - return 'macos'; - case 'win32': - return 'windows'; - default: - return process.platform; - } - } - // Azul API returns jdk_version as array of digits like [11, 0, 2, 1] - convertVersionToSemver(version_array) { - const mainVersion = version_array.slice(0, 3).join('.'); - if (version_array.length > 3) { - // intentionally ignore more than 4 numbers because it is invalid semver - return `${mainVersion}+${version_array[3]}`; - } - return mainVersion; - } -} -exports.ZuluDistribution = ZuluDistribution; - - -/***/ }), -/* 394 */, -/* 395 */, -/* 396 */, -/* 397 */, -/* 398 */, -/* 399 */, -/* 400 */, -/* 401 */, -/* 402 */, -/* 403 */, -/* 404 */, -/* 405 */, -/* 406 */, -/* 407 */, -/* 408 */, -/* 409 */, -/* 410 */, -/* 411 */, -/* 412 */, -/* 413 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); +var algorithm_1 = __webpack_require__(163); /** - * Represents an abstract range with a start and end boundary point. + * Represents a mixin that allows nodes to become the contents of + * a element. This mixin is implemented by {@link Element} and + * {@link Text}. */ -var AbstractRangeImpl = /** @class */ (function () { - function AbstractRangeImpl() { +var SlotableImpl = /** @class */ (function () { + function SlotableImpl() { } - Object.defineProperty(AbstractRangeImpl.prototype, "_startNode", { - get: function () { return this._start[0]; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "_startOffset", { - get: function () { return this._start[1]; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "_endNode", { - get: function () { return this._end[0]; }, + Object.defineProperty(SlotableImpl.prototype, "_name", { + get: function () { return this.__name || ''; }, + set: function (val) { this.__name = val; }, enumerable: true, configurable: true }); - Object.defineProperty(AbstractRangeImpl.prototype, "_endOffset", { - get: function () { return this._end[1]; }, + Object.defineProperty(SlotableImpl.prototype, "_assignedSlot", { + get: function () { return this.__assignedSlot || null; }, + set: function (val) { this.__assignedSlot = val; }, enumerable: true, configurable: true }); - Object.defineProperty(AbstractRangeImpl.prototype, "_collapsed", { + Object.defineProperty(SlotableImpl.prototype, "assignedSlot", { + /** @inheritdoc */ get: function () { - return (this._start[0] === this._end[0] && - this._start[1] === this._end[1]); + return algorithm_1.shadowTree_findASlot(this, true); }, enumerable: true, configurable: true }); - Object.defineProperty(AbstractRangeImpl.prototype, "startContainer", { - /** @inheritdoc */ - get: function () { return this._startNode; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "startOffset", { - /** @inheritdoc */ - get: function () { return this._startOffset; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "endContainer", { - /** @inheritdoc */ - get: function () { return this._endNode; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "endOffset", { - /** @inheritdoc */ - get: function () { return this._endOffset; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AbstractRangeImpl.prototype, "collapsed", { - /** @inheritdoc */ - get: function () { return this._collapsed; }, - enumerable: true, - configurable: true - }); - return AbstractRangeImpl; + return SlotableImpl; }()); -exports.AbstractRangeImpl = AbstractRangeImpl; -//# sourceMappingURL=AbstractRangeImpl.js.map - -/***/ }), -/* 414 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - - -var yaml = __webpack_require__(9); - - -module.exports = yaml; - +exports.SlotableImpl = SlotableImpl; +//# sourceMappingURL=SlotableImpl.js.map /***/ }), -/* 415 */, -/* 416 */, -/* 417 */ -/***/ (function(module, __unusedexports, __webpack_require__) { +/* 430 */, +/* 431 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; - -var common = __webpack_require__(740); -var Type = __webpack_require__(945); - -var YAML_FLOAT_PATTERN = new RegExp( - // 2.5e4, 2.5 and integers - '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + - // .2e4, .2 - // special case, seems not from spec - '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + - // 20:59 - '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' + - // .inf - '|[-+]?\\.(?:inf|Inf|INF)' + - // .nan - '|\\.(?:nan|NaN|NAN))$'); - -function resolveYamlFloat(data) { - if (data === null) return false; - - if (!YAML_FLOAT_PATTERN.test(data) || - // Quick hack to not allow integers end with `_` - // Probably should update regexp & check speed - data[data.length - 1] === '_') { - return false; - } - - return true; +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; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const os = __importStar(__webpack_require__(87)); +const utils_1 = __webpack_require__(82); +/** + * Commands + * + * Command Format: + * ::name key=value,key=value::message + * + * Examples: + * ::warning::This is the message + * ::set-env name=MY_VAR::some value + */ +function issueCommand(command, properties, message) { + const cmd = new Command(command, properties, message); + process.stdout.write(cmd.toString() + os.EOL); } - -function constructYamlFloat(data) { - var value, sign, base, digits; - - value = data.replace(/_/g, '').toLowerCase(); - sign = value[0] === '-' ? -1 : 1; - digits = []; - - if ('+-'.indexOf(value[0]) >= 0) { - value = value.slice(1); - } - - if (value === '.inf') { - return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; - - } else if (value === '.nan') { - return NaN; - - } else if (value.indexOf(':') >= 0) { - value.split(':').forEach(function (v) { - digits.unshift(parseFloat(v, 10)); - }); - - value = 0.0; - base = 1; - - digits.forEach(function (d) { - value += d * base; - base *= 60; - }); - - return sign * value; - - } - return sign * parseFloat(value, 10); +exports.issueCommand = issueCommand; +function issue(name, message = '') { + issueCommand(name, {}, message); } - - -var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; - -function representYamlFloat(object, style) { - var res; - - if (isNaN(object)) { - switch (style) { - case 'lowercase': return '.nan'; - case 'uppercase': return '.NAN'; - case 'camelcase': return '.NaN'; - } - } else if (Number.POSITIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '.inf'; - case 'uppercase': return '.INF'; - case 'camelcase': return '.Inf'; +exports.issue = issue; +const CMD_STRING = '::'; +class Command { + constructor(command, properties, message) { + if (!command) { + command = 'missing.command'; + } + this.command = command; + this.properties = properties; + this.message = message; } - } else if (Number.NEGATIVE_INFINITY === object) { - switch (style) { - case 'lowercase': return '-.inf'; - case 'uppercase': return '-.INF'; - case 'camelcase': return '-.Inf'; + toString() { + let cmdStr = CMD_STRING + this.command; + if (this.properties && Object.keys(this.properties).length > 0) { + cmdStr += ' '; + let first = true; + for (const key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + const val = this.properties[key]; + if (val) { + if (first) { + first = false; + } + else { + cmdStr += ','; + } + cmdStr += `${key}=${escapeProperty(val)}`; + } + } + } + } + cmdStr += `${CMD_STRING}${escapeData(this.message)}`; + return cmdStr; } - } else if (common.isNegativeZero(object)) { - return '-0.0'; - } - - res = object.toString(10); - - // JS stringifier can build scientific format without dots: 5e-100, - // while YAML requres dot: 5.e-100. Fix it with simple hack - - return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; } - -function isFloat(object) { - return (Object.prototype.toString.call(object) === '[object Number]') && - (object % 1 !== 0 || common.isNegativeZero(object)); +function escapeData(s) { + return utils_1.toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A'); } - -module.exports = new Type('tag:yaml.org,2002:float', { - kind: 'scalar', - resolve: resolveYamlFloat, - construct: constructYamlFloat, - predicate: isFloat, - represent: representYamlFloat, - defaultStyle: 'lowercase' -}); - +function escapeProperty(s) { + return utils_1.toCommandValue(s) + .replace(/%/g, '%25') + .replace(/\r/g, '%0D') + .replace(/\n/g, '%0A') + .replace(/:/g, '%3A') + .replace(/,/g, '%2C'); +} +//# sourceMappingURL=command.js.map /***/ }), -/* 418 */, -/* 419 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/* 432 */, +/* 433 */, +/* 434 */, +/* 435 */, +/* 436 */, +/* 437 */, +/* 438 */, +/* 439 */, +/* 440 */, +/* 441 */, +/* 442 */ +/***/ (function(__unusedmodule, exports) { "use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; Object.defineProperty(exports, "__esModule", { value: true }); -var util_1 = __webpack_require__(592); -var interfaces_1 = __webpack_require__(970); -var BaseWriter_1 = __webpack_require__(462); /** - * Serializes XML nodes into objects and arrays. + * Determines if the given string is valid for a `"Name"` construct. + * + * @param name - name string to test */ -var ObjectWriter = /** @class */ (function (_super) { - __extends(ObjectWriter, _super); - /** - * Initializes a new instance of `ObjectWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function ObjectWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._writerOptions = util_1.applyDefaults(writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - group: false, - verbose: false - }); - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - */ - ObjectWriter.prototype.serialize = function (node) { - this._currentList = []; - this._currentIndex = 0; - this._listRegister = [this._currentList]; - /** - * First pass, serialize nodes - * This creates a list of nodes grouped under node types while preserving - * insertion order. For example: - * [ - * root: [ - * node: [ - * { "@" : { "att1": "val1", "att2": "val2" } - * { "#": "node text" } - * { childNode: [] } - * { "#": "more text" } - * ], - * node: [ - * { "@" : { "att": "val" } - * { "#": [ "text line1", "text line2" ] } - * ] - * ] - * ] - */ - this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); - /** - * Second pass, process node lists. Above example becomes: - * { - * root: { - * node: [ - * { - * "@att1": "val1", - * "@att2": "val2", - * "#1": "node text", - * childNode: {}, - * "#2": "more text" - * }, - * { - * "@att": "val", - * "#": [ "text line1", "text line2" ] - * } - * ] - * } - * } - */ - return this._process(this._currentList, this._writerOptions); - }; - ObjectWriter.prototype._process = function (items, options) { - var _a, _b, _c, _d, _e, _f, _g; - if (items.length === 0) - return {}; - // determine if there are non-unique element names - var namesSeen = {}; - var hasNonUniqueNames = false; - var textCount = 0; - var commentCount = 0; - var instructionCount = 0; - var cdataCount = 0; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - continue; - case "#": - textCount++; - break; - case "!": - commentCount++; - break; - case "?": - instructionCount++; - break; - case "$": - cdataCount++; - break; - default: - if (namesSeen[key]) { - hasNonUniqueNames = true; - } - else { - namesSeen[key] = true; - } - break; - } - } - var defAttrKey = this._getAttrKey(); - var defTextKey = this._getNodeKey(interfaces_1.NodeType.Text); - var defCommentKey = this._getNodeKey(interfaces_1.NodeType.Comment); - var defInstructionKey = this._getNodeKey(interfaces_1.NodeType.ProcessingInstruction); - var defCdataKey = this._getNodeKey(interfaces_1.NodeType.CData); - if (textCount === 1 && items.length === 1 && util_1.isString(items[0]["#"])) { - // special case of an element node with a single text node - return items[0]["#"]; +function xml_isName(name) { + for (var i = 0; i < name.length; i++) { + var n = name.charCodeAt(i); + // NameStartChar + if ((n >= 97 && n <= 122) || // [a-z] + (n >= 65 && n <= 90) || // [A-Z] + n === 58 || n === 95 || // ':' or '_' + (n >= 0xC0 && n <= 0xD6) || + (n >= 0xD8 && n <= 0xF6) || + (n >= 0xF8 && n <= 0x2FF) || + (n >= 0x370 && n <= 0x37D) || + (n >= 0x37F && n <= 0x1FFF) || + (n >= 0x200C && n <= 0x200D) || + (n >= 0x2070 && n <= 0x218F) || + (n >= 0x2C00 && n <= 0x2FEF) || + (n >= 0x3001 && n <= 0xD7FF) || + (n >= 0xF900 && n <= 0xFDCF) || + (n >= 0xFDF0 && n <= 0xFFFD)) { + continue; } - else if (hasNonUniqueNames) { - var obj = {}; - // process attributes first - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - if (key === "@") { - var attrs = item["@"]; - var attrKeys = Object.keys(attrs); - if (attrKeys.length === 1) { - obj[defAttrKey + attrKeys[0]] = attrs[attrKeys[0]]; - } - else { - obj[defAttrKey] = item["@"]; - } - } - } - // list contains element nodes with non-unique names - // return an array with mixed content notation - var result = []; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - // attributes were processed above - break; - case "#": - result.push((_a = {}, _a[defTextKey] = item["#"], _a)); - break; - case "!": - result.push((_b = {}, _b[defCommentKey] = item["!"], _b)); - break; - case "?": - result.push((_c = {}, _c[defInstructionKey] = item["?"], _c)); - break; - case "$": - result.push((_d = {}, _d[defCdataKey] = item["$"], _d)); - break; - default: - // element node - var ele = item; - if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { - // group of element nodes - var eleGroup = []; - var listOfLists = ele[key]; - for (var i_1 = 0; i_1 < listOfLists.length; i_1++) { - eleGroup.push(this._process(listOfLists[i_1], options)); - } - result.push((_e = {}, _e[key] = eleGroup, _e)); - } - else { - // single element node - if (options.verbose) { - result.push((_f = {}, _f[key] = [this._process(ele[key], options)], _f)); - } - else { - result.push((_g = {}, _g[key] = this._process(ele[key], options), _g)); - } - } - break; - } - } - obj[defTextKey] = result; - return obj; + else if (i !== 0 && + (n === 45 || n === 46 || // '-' or '.' + (n >= 48 && n <= 57) || // [0-9] + (n === 0xB7) || + (n >= 0x0300 && n <= 0x036F) || + (n >= 0x203F && n <= 0x2040))) { + continue; } - else { - // all element nodes have unique names - // return an object while prefixing data node keys - var textId = 1; - var commentId = 1; - var instructionId = 1; - var cdataId = 1; - var obj = {}; - for (var i = 0; i < items.length; i++) { - var item = items[i]; - var key = Object.keys(item)[0]; - switch (key) { - case "@": - var attrs = item["@"]; - var attrKeys = Object.keys(attrs); - if (!options.group || attrKeys.length === 1) { - for (var attrName in attrs) { - obj[defAttrKey + attrName] = attrs[attrName]; - } - } - else { - obj[defAttrKey] = attrs; - } - break; - case "#": - textId = this._processSpecItem(item["#"], obj, options.group, defTextKey, textCount, textId); - break; - case "!": - commentId = this._processSpecItem(item["!"], obj, options.group, defCommentKey, commentCount, commentId); - break; - case "?": - instructionId = this._processSpecItem(item["?"], obj, options.group, defInstructionKey, instructionCount, instructionId); - break; - case "$": - cdataId = this._processSpecItem(item["$"], obj, options.group, defCdataKey, cdataCount, cdataId); - break; - default: - // element node - var ele = item; - if (ele[key].length !== 0 && util_1.isArray(ele[key][0])) { - // group of element nodes - var eleGroup = []; - var listOfLists = ele[key]; - for (var i_2 = 0; i_2 < listOfLists.length; i_2++) { - eleGroup.push(this._process(listOfLists[i_2], options)); - } - obj[key] = eleGroup; - } - else { - // single element node - if (options.verbose) { - obj[key] = [this._process(ele[key], options)]; - } - else { - obj[key] = this._process(ele[key], options); - } - } - break; + if (n >= 0xD800 && n <= 0xDBFF && i < name.length - 1) { + var n2 = name.charCodeAt(i + 1); + if (n2 >= 0xDC00 && n2 <= 0xDFFF) { + n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; + i++; + if (n >= 0x10000 && n <= 0xEFFFF) { + continue; } } - return obj; } - }; - ObjectWriter.prototype._processSpecItem = function (item, obj, group, defKey, count, id) { - var e_1, _a; - if (!group && util_1.isArray(item) && count + item.length > 2) { - try { - for (var item_1 = __values(item), item_1_1 = item_1.next(); !item_1_1.done; item_1_1 = item_1.next()) { - var subItem = item_1_1.value; - var key = defKey + (id++).toString(); - obj[key] = subItem; - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (item_1_1 && !item_1_1.done && (_a = item_1.return)) _a.call(item_1); - } - finally { if (e_1) throw e_1.error; } - } + return false; + } + return true; +} +exports.xml_isName = xml_isName; +/** + * Determines if the given string is valid for a `"QName"` construct. + * + * @param name - name string to test + */ +function xml_isQName(name) { + var colonFound = false; + for (var i = 0; i < name.length; i++) { + var n = name.charCodeAt(i); + // NameStartChar + if ((n >= 97 && n <= 122) || // [a-z] + (n >= 65 && n <= 90) || // [A-Z] + n === 95 || // '_' + (n >= 0xC0 && n <= 0xD6) || + (n >= 0xD8 && n <= 0xF6) || + (n >= 0xF8 && n <= 0x2FF) || + (n >= 0x370 && n <= 0x37D) || + (n >= 0x37F && n <= 0x1FFF) || + (n >= 0x200C && n <= 0x200D) || + (n >= 0x2070 && n <= 0x218F) || + (n >= 0x2C00 && n <= 0x2FEF) || + (n >= 0x3001 && n <= 0xD7FF) || + (n >= 0xF900 && n <= 0xFDCF) || + (n >= 0xFDF0 && n <= 0xFFFD)) { + continue; } - else { - var key = count > 1 ? defKey + (id++).toString() : defKey; - obj[key] = item; + else if (i !== 0 && + (n === 45 || n === 46 || // '-' or '.' + (n >= 48 && n <= 57) || // [0-9] + (n === 0xB7) || + (n >= 0x0300 && n <= 0x036F) || + (n >= 0x203F && n <= 0x2040))) { + continue; } - return id; - }; - /** @inheritdoc */ - ObjectWriter.prototype.beginElement = function (name) { - var _a, _b; - var childItems = []; - if (this._currentList.length === 0) { - this._currentList.push((_a = {}, _a[name] = childItems, _a)); + else if (i !== 0 && n === 58) { // : + if (colonFound) + return false; // multiple colons in qname + if (i === name.length - 1) + return false; // colon at the end of qname + colonFound = true; + continue; } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isElementNode(lastItem, name)) { - if (lastItem[name].length !== 0 && util_1.isArray(lastItem[name][0])) { - var listOfLists = lastItem[name]; - listOfLists.push(childItems); - } - else { - lastItem[name] = [lastItem[name], childItems]; + if (n >= 0xD800 && n <= 0xDBFF && i < name.length - 1) { + var n2 = name.charCodeAt(i + 1); + if (n2 >= 0xDC00 && n2 <= 0xDFFF) { + n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; + i++; + if (n >= 0x10000 && n <= 0xEFFFF) { + continue; } } - else { - this._currentList.push((_b = {}, _b[name] = childItems, _b)); - } - } - this._currentIndex++; - if (this._listRegister.length > this._currentIndex) { - this._listRegister[this._currentIndex] = childItems; - } - else { - this._listRegister.push(childItems); - } - this._currentList = childItems; - }; - /** @inheritdoc */ - ObjectWriter.prototype.endElement = function () { - this._currentList = this._listRegister[--this._currentIndex]; - }; - /** @inheritdoc */ - ObjectWriter.prototype.attribute = function (name, value) { - var _a, _b; - if (this._currentList.length === 0) { - this._currentList.push({ "@": (_a = {}, _a[name] = value, _a) }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - /* istanbul ignore else */ - if (this._isAttrNode(lastItem)) { - lastItem["@"][name] = value; - } - else { - this._currentList.push({ "@": (_b = {}, _b[name] = value, _b) }); - } } - }; - /** @inheritdoc */ - ObjectWriter.prototype.comment = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "!": data }); + return false; + } + return true; +} +exports.xml_isQName = xml_isQName; +/** + * Determines if the given string contains legal characters. + * + * @param chars - sequence of characters to test + */ +function xml_isLegalChar(chars) { + for (var i = 0; i < chars.length; i++) { + var n = chars.charCodeAt(i); + // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] + if (n === 0x9 || n === 0xA || n === 0xD || + (n >= 0x20 && n <= 0xD7FF) || + (n >= 0xE000 && n <= 0xFFFD)) { + continue; } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isCommentNode(lastItem)) { - if (util_1.isArray(lastItem["!"])) { - lastItem["!"].push(data); - } - else { - lastItem["!"] = [lastItem["!"], data]; + if (n >= 0xD800 && n <= 0xDBFF && i < chars.length - 1) { + var n2 = chars.charCodeAt(i + 1); + if (n2 >= 0xDC00 && n2 <= 0xDFFF) { + n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; + i++; + if (n >= 0x10000 && n <= 0x10FFFF) { + continue; } } - else { - this._currentList.push({ "!": data }); - } } - }; - /** @inheritdoc */ - ObjectWriter.prototype.text = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "#": data }); + return false; + } + return true; +} +exports.xml_isLegalChar = xml_isLegalChar; +/** + * Determines if the given string contains legal characters for a public + * identifier. + * + * @param chars - sequence of characters to test + */ +function xml_isPubidChar(chars) { + for (var i = 0; i < chars.length; i++) { + // PubId chars are all in the ASCII range, no need to check surrogates + var n = chars.charCodeAt(i); + // #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] + if ((n >= 97 && n <= 122) || // [a-z] + (n >= 65 && n <= 90) || // [A-Z] + (n >= 39 && n <= 59) || // ['()*+,-./] | [0-9] | [:;] + n === 0x20 || n === 0xD || n === 0xA || // #x20 | #xD | #xA + (n >= 35 && n <= 37) || // [#$%] + n === 33 || // ! + n === 61 || n === 63 || n === 64 || n === 95) { // [=?@_] + continue; } else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isTextNode(lastItem)) { - if (util_1.isArray(lastItem["#"])) { - lastItem["#"].push(data); - } - else { - lastItem["#"] = [lastItem["#"], data]; - } - } - else { - this._currentList.push({ "#": data }); - } - } - }; - /** @inheritdoc */ - ObjectWriter.prototype.instruction = function (target, data) { - var value = (data === "" ? target : target + " " + data); - if (this._currentList.length === 0) { - this._currentList.push({ "?": value }); + return false; } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isInstructionNode(lastItem)) { - if (util_1.isArray(lastItem["?"])) { - lastItem["?"].push(value); - } - else { - lastItem["?"] = [lastItem["?"], value]; - } - } - else { - this._currentList.push({ "?": value }); - } - } - }; - /** @inheritdoc */ - ObjectWriter.prototype.cdata = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "$": data }); - } - else { - var lastItem = this._currentList[this._currentList.length - 1]; - if (this._isCDATANode(lastItem)) { - if (util_1.isArray(lastItem["$"])) { - lastItem["$"].push(data); - } - else { - lastItem["$"] = [lastItem["$"], data]; - } - } - else { - this._currentList.push({ "$": data }); - } - } - }; - ObjectWriter.prototype._isAttrNode = function (x) { - return "@" in x; - }; - ObjectWriter.prototype._isTextNode = function (x) { - return "#" in x; - }; - ObjectWriter.prototype._isCommentNode = function (x) { - return "!" in x; - }; - ObjectWriter.prototype._isInstructionNode = function (x) { - return "?" in x; - }; - ObjectWriter.prototype._isCDATANode = function (x) { - return "$" in x; - }; - ObjectWriter.prototype._isElementNode = function (x, name) { - return name in x; - }; - /** - * Returns an object key for an attribute or namespace declaration. - */ - ObjectWriter.prototype._getAttrKey = function () { - return this._builderOptions.convert.att; - }; - /** - * Returns an object key for the given node type. - * - * @param nodeType - node type to get a key for - */ - ObjectWriter.prototype._getNodeKey = function (nodeType) { - switch (nodeType) { - case interfaces_1.NodeType.Comment: - return this._builderOptions.convert.comment; - case interfaces_1.NodeType.Text: - return this._builderOptions.convert.text; - case interfaces_1.NodeType.ProcessingInstruction: - return this._builderOptions.convert.ins; - case interfaces_1.NodeType.CData: - return this._builderOptions.convert.cdata; - /* istanbul ignore next */ - default: - throw new Error("Invalid node type."); - } - }; - return ObjectWriter; -}(BaseWriter_1.BaseWriter)); -exports.ObjectWriter = ObjectWriter; -//# sourceMappingURL=ObjectWriter.js.map + } + return true; +} +exports.xml_isPubidChar = xml_isPubidChar; +//# sourceMappingURL=XMLAlgorithm.js.map /***/ }), -/* 420 */, -/* 421 */, -/* 422 */, -/* 423 */, -/* 424 */, -/* 425 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/* 443 */, +/* 444 */, +/* 445 */, +/* 446 */, +/* 447 */, +/* 448 */, +/* 449 */, +/* 450 */ +/***/ (function(module, __unusedexports, __webpack_require__) { "use strict"; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var DOMException_1 = __webpack_require__(35); -var infra_1 = __webpack_require__(23); -var algorithm_1 = __webpack_require__(163); -/** - * Represents a token set. - */ -var DOMTokenListImpl = /** @class */ (function () { - /** - * Initializes a new instance of `DOMTokenList`. - * - * @param element - associated element - * @param attribute - associated attribute - */ - function DOMTokenListImpl(element, attribute) { - /** - * 1. Let element be associated element. - * 2. Let localName be associated attribute’s local name. - * 3. Let value be the result of getting an attribute value given element - * and localName. - * 4. Run the attribute change steps for element, localName, value, value, - * and null. - */ - this._element = element; - this._attribute = attribute; - this._tokenSet = new Set(); - var localName = attribute._localName; - var value = algorithm_1.element_getAnAttributeValue(element, localName); - // define a closure to be called when the associated attribute's value changes - var thisObj = this; - function updateTokenSet(element, localName, oldValue, value, namespace) { - /** - * 1. If localName is associated attribute’s local name, namespace is null, - * and value is null, then empty token set. - * 2. Otherwise, if localName is associated attribute’s local name, - * namespace is null, then set token set to value, parsed. - */ - if (localName === thisObj._attribute._localName && namespace === null) { - if (!value) - thisObj._tokenSet.clear(); - else - thisObj._tokenSet = algorithm_1.orderedSet_parse(value); - } - } - // add the closure to the associated element's attribute change steps - this._element._attributeChangeSteps.push(updateTokenSet); - if (DOMImpl_1.dom.features.steps) { - algorithm_1.dom_runAttributeChangeSteps(element, localName, value, value, null); - } - } - Object.defineProperty(DOMTokenListImpl.prototype, "length", { - /** @inheritdoc */ - get: function () { - /** - * The length attribute' getter must return context object’s token set’s - * size. - */ - return this._tokenSet.size; - }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - DOMTokenListImpl.prototype.item = function (index) { - var e_1, _a; - /** - * 1. If index is equal to or greater than context object’s token set’s - * size, then return null. - * 2. Return context object’s token set[index]. - */ - var i = 0; - try { - for (var _b = __values(this._tokenSet), _c = _b.next(); !_c.done; _c = _b.next()) { - var token = _c.value; - if (i === index) - return token; - i++; - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_1) throw e_1.error; } - } - return null; - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.contains = function (token) { - /** - * The contains(token) method, when invoked, must return true if context - * object’s token set[token] exists, and false otherwise. - */ - return this._tokenSet.has(token); - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.add = function () { - var e_2, _a; - var tokens = []; - for (var _i = 0; _i < arguments.length; _i++) { - tokens[_i] = arguments[_i]; - } - try { - /** - * 1. For each token in tokens: - * 1.1. If token is the empty string, then throw a "SyntaxError" - * DOMException. - * 1.2. If token contains any ASCII whitespace, then throw an - * "InvalidCharacterError" DOMException. - * 2. For each token in tokens, append token to context object’s token set. - * 3. Run the update steps. - */ - for (var tokens_1 = __values(tokens), tokens_1_1 = tokens_1.next(); !tokens_1_1.done; tokens_1_1 = tokens_1.next()) { - var token = tokens_1_1.value; - if (token === '') { - throw new DOMException_1.SyntaxError("Cannot add an empty token."); - } - else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { - throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); - } - else { - this._tokenSet.add(token); - } - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (tokens_1_1 && !tokens_1_1.done && (_a = tokens_1.return)) _a.call(tokens_1); - } - finally { if (e_2) throw e_2.error; } - } - algorithm_1.tokenList_updateSteps(this); - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.remove = function () { - var e_3, _a; - var tokens = []; - for (var _i = 0; _i < arguments.length; _i++) { - tokens[_i] = arguments[_i]; - } - try { - /** - * 1. For each token in tokens: - * 1.1. If token is the empty string, then throw a "SyntaxError" - * DOMException. - * 1.2. If token contains any ASCII whitespace, then throw an - * "InvalidCharacterError" DOMException. - * 2. For each token in tokens, remove token from context object’s token set. - * 3. Run the update steps. - */ - for (var tokens_2 = __values(tokens), tokens_2_1 = tokens_2.next(); !tokens_2_1.done; tokens_2_1 = tokens_2.next()) { - var token = tokens_2_1.value; - if (token === '') { - throw new DOMException_1.SyntaxError("Cannot remove an empty token."); - } - else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { - throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); - } - else { - this._tokenSet.delete(token); - } - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (tokens_2_1 && !tokens_2_1.done && (_a = tokens_2.return)) _a.call(tokens_2); - } - finally { if (e_3) throw e_3.error; } - } - algorithm_1.tokenList_updateSteps(this); - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.toggle = function (token, force) { - if (force === void 0) { force = undefined; } - /** - * 1. If token is the empty string, then throw a "SyntaxError" DOMException. - * 2. If token contains any ASCII whitespace, then throw an - * "InvalidCharacterError" DOMException. - */ - if (token === '') { - throw new DOMException_1.SyntaxError("Cannot toggle an empty token."); - } - else if (infra_1.codePoint.ASCIIWhiteSpace.test(token)) { - throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); - } - /** - * 3. If context object’s token set[token] exists, then: - */ - if (this._tokenSet.has(token)) { - /** - * 3.1. If force is either not given or is false, then remove token from - * context object’s token set, run the update steps and return false. - * 3.2. Return true. - */ - if (force === undefined || force === false) { - this._tokenSet.delete(token); - algorithm_1.tokenList_updateSteps(this); - return false; - } - return true; - } - /** - * 4. Otherwise, if force not given or is true, append token to context - * object’s token set, run the update steps, and return true. - */ - if (force === undefined || force === true) { - this._tokenSet.add(token); - algorithm_1.tokenList_updateSteps(this); - return true; - } - /** - * 5. Return false. - */ - return false; - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.replace = function (token, newToken) { - /** - * 1. If either token or newToken is the empty string, then throw a - * "SyntaxError" DOMException. - * 2. If either token or newToken contains any ASCII whitespace, then throw - * an "InvalidCharacterError" DOMException. - */ - if (token === '' || newToken === '') { - throw new DOMException_1.SyntaxError("Cannot replace an empty token."); - } - else if (infra_1.codePoint.ASCIIWhiteSpace.test(token) || infra_1.codePoint.ASCIIWhiteSpace.test(newToken)) { - throw new DOMException_1.InvalidCharacterError("Token cannot contain whitespace."); - } - /** - * 3. If context object’s token set does not contain token, then return - * false. - */ - if (!this._tokenSet.has(token)) - return false; - /** - * 4. Replace token in context object’s token set with newToken. - * 5. Run the update steps. - * 6. Return true. - */ - infra_1.set.replace(this._tokenSet, token, newToken); - algorithm_1.tokenList_updateSteps(this); - return true; - }; - /** @inheritdoc */ - DOMTokenListImpl.prototype.supports = function (token) { - /** - * 1. Let result be the return value of validation steps called with token. - * 2. Return result. - */ - return algorithm_1.tokenList_validationSteps(this, token); - }; - Object.defineProperty(DOMTokenListImpl.prototype, "value", { - /** @inheritdoc */ - get: function () { - /** - * The value attribute must return the result of running context object’s - * serialize steps. - */ - return algorithm_1.tokenList_serializeSteps(this); - }, - set: function (value) { - /** - * Setting the value attribute must set an attribute value for the - * associated element using associated attribute’s local name and the given - * value. - */ - algorithm_1.element_setAnAttributeValue(this._element, this._attribute._localName, value); - }, - enumerable: true, - configurable: true - }); - /** - * Returns an iterator for the token set. - */ - DOMTokenListImpl.prototype[Symbol.iterator] = function () { - var it = this._tokenSet[Symbol.iterator](); - return { - next: function () { - return it.next(); - } - }; - }; - /** - * Creates a new `DOMTokenList`. - * - * @param element - associated element - * @param attribute - associated attribute - */ - DOMTokenListImpl._create = function (element, attribute) { - return new DOMTokenListImpl(element, attribute); - }; - return DOMTokenListImpl; -}()); -exports.DOMTokenListImpl = DOMTokenListImpl; -//# sourceMappingURL=DOMTokenListImpl.js.map + +var Type = __webpack_require__(945); + +module.exports = new Type('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function (data) { return data !== null ? data : ''; } +}); + /***/ }), -/* 426 */, -/* 427 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/* 451 */, +/* 452 */, +/* 453 */, +/* 454 */, +/* 455 */, +/* 456 */, +/* 457 */ +/***/ (function(module, __unusedexports, __webpack_require__) { "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var interfaces_1 = __webpack_require__(970); -var algorithm_1 = __webpack_require__(163); -var WebIDLAlgorithm_1 = __webpack_require__(495); -/** - * Represents a DOM event. - */ -var EventImpl = /** @class */ (function () { - /** - * Initializes a new instance of `Event`. - */ - function EventImpl(type, eventInit) { - this._target = null; - this._relatedTarget = null; - this._touchTargetList = []; - this._path = []; - this._currentTarget = null; - this._eventPhase = interfaces_1.EventPhase.None; - this._stopPropagationFlag = false; - this._stopImmediatePropagationFlag = false; - this._canceledFlag = false; - this._inPassiveListenerFlag = false; - this._composedFlag = false; - this._initializedFlag = false; - this._dispatchFlag = false; - this._isTrusted = false; - this._bubbles = false; - this._cancelable = false; - /** - * When a constructor of the Event interface, or of an interface that - * inherits from the Event interface, is invoked, these steps must be run, - * given the arguments type and eventInitDict: - * 1. Let event be the result of running the inner event creation steps with - * this interface, null, now, and eventInitDict. - * 2. Initialize event’s type attribute to type. - * 3. Return event. - */ - this._type = type; - if (eventInit) { - this._bubbles = eventInit.bubbles || false; - this._cancelable = eventInit.cancelable || false; - this._composedFlag = eventInit.composed || false; - } - this._initializedFlag = true; - this._timeStamp = new Date().getTime(); - } - Object.defineProperty(EventImpl.prototype, "type", { - /** @inheritdoc */ - get: function () { return this._type; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "target", { - /** @inheritdoc */ - get: function () { return this._target; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "srcElement", { - /** @inheritdoc */ - get: function () { return this._target; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "currentTarget", { - /** @inheritdoc */ - get: function () { return this._currentTarget; }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.composedPath = function () { - /** - * 1. Let composedPath be an empty list. - * 2. Let path be the context object’s path. - * 3. If path is empty, then return composedPath. - * 4. Let currentTarget be the context object’s currentTarget attribute - * value. - * 5. Append currentTarget to composedPath. - * 6. Let currentTargetIndex be 0. - * 7. Let currentTargetHiddenSubtreeLevel be 0. - */ - var composedPath = []; - var path = this._path; - if (path.length === 0) - return composedPath; - var currentTarget = this._currentTarget; - if (currentTarget === null) { - throw new Error("Event currentTarget is null."); - } - composedPath.push(currentTarget); - var currentTargetIndex = 0; - var currentTargetHiddenSubtreeLevel = 0; - /** - * 8. Let index be path’s size − 1. - * 9. While index is greater than or equal to 0: - */ - var index = path.length - 1; - while (index >= 0) { - /** - * 9.1. If path[index]'s root-of-closed-tree is true, then increase - * currentTargetHiddenSubtreeLevel by 1. - * 9.2. If path[index]'s invocation target is currentTarget, then set - * currentTargetIndex to index and break. - * 9.3. If path[index]'s slot-in-closed-tree is true, then decrease - * currentTargetHiddenSubtreeLevel by 1. - * 9.4. Decrease index by 1. - */ - if (path[index].rootOfClosedTree) { - currentTargetHiddenSubtreeLevel++; - } - if (path[index].invocationTarget === currentTarget) { - currentTargetIndex = index; - break; - } - if (path[index].slotInClosedTree) { - currentTargetHiddenSubtreeLevel--; - } - index--; - } - /** - * 10. Let currentHiddenLevel and maxHiddenLevel be - * currentTargetHiddenSubtreeLevel. - */ - var currentHiddenLevel = currentTargetHiddenSubtreeLevel; - var maxHiddenLevel = currentTargetHiddenSubtreeLevel; - /** - * 11. Set index to currentTargetIndex − 1. - * 12. While index is greater than or equal to 0: - */ - index = currentTargetIndex - 1; - while (index >= 0) { - /** - * 12.1. If path[index]'s root-of-closed-tree is true, then increase - * currentHiddenLevel by 1. - * 12.2. If currentHiddenLevel is less than or equal to maxHiddenLevel, - * then prepend path[index]'s invocation target to composedPath. - */ - if (path[index].rootOfClosedTree) { - currentHiddenLevel++; - } - if (currentHiddenLevel <= maxHiddenLevel) { - composedPath.unshift(path[index].invocationTarget); - } - /** - * 12.3. If path[index]'s slot-in-closed-tree is true, then: - */ - if (path[index].slotInClosedTree) { - /** - * 12.3.1. Decrease currentHiddenLevel by 1. - * 12.3.2. If currentHiddenLevel is less than maxHiddenLevel, then set - * maxHiddenLevel to currentHiddenLevel. - */ - currentHiddenLevel--; - if (currentHiddenLevel < maxHiddenLevel) { - maxHiddenLevel = currentHiddenLevel; - } - } - /** - * 12.4. Decrease index by 1. - */ - index--; - } - /** - * 13. Set currentHiddenLevel and maxHiddenLevel to - * currentTargetHiddenSubtreeLevel. - */ - currentHiddenLevel = currentTargetHiddenSubtreeLevel; - maxHiddenLevel = currentTargetHiddenSubtreeLevel; - /** - * 14. Set index to currentTargetIndex + 1. - * 15. While index is less than path’s size: - */ - index = currentTargetIndex + 1; - while (index < path.length) { - /** - * 15.1. If path[index]'s slot-in-closed-tree is true, then increase - * currentHiddenLevel by 1. - * 15.2. If currentHiddenLevel is less than or equal to maxHiddenLevel, - * then append path[index]'s invocation target to composedPath. - */ - if (path[index].slotInClosedTree) { - currentHiddenLevel++; - } - if (currentHiddenLevel <= maxHiddenLevel) { - composedPath.push(path[index].invocationTarget); - } - /** - * 15.3. If path[index]'s root-of-closed-tree is true, then: - */ - if (path[index].rootOfClosedTree) { - /** - * 15.3.1. Decrease currentHiddenLevel by 1. - * 15.3.2. If currentHiddenLevel is less than maxHiddenLevel, then set - * maxHiddenLevel to currentHiddenLevel. - */ - currentHiddenLevel--; - if (currentHiddenLevel < maxHiddenLevel) { - maxHiddenLevel = currentHiddenLevel; - } - } - /** - * 15.4. Increase index by 1. - */ - index++; - } - /** - * 16. Return composedPath. - */ - return composedPath; - }; - Object.defineProperty(EventImpl.prototype, "eventPhase", { - /** @inheritdoc */ - get: function () { return this._eventPhase; }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.stopPropagation = function () { this._stopPropagationFlag = true; }; - Object.defineProperty(EventImpl.prototype, "cancelBubble", { - /** @inheritdoc */ - get: function () { return this._stopPropagationFlag; }, - set: function (value) { if (value) - this.stopPropagation(); }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.stopImmediatePropagation = function () { - this._stopPropagationFlag = true; - this._stopImmediatePropagationFlag = true; - }; - Object.defineProperty(EventImpl.prototype, "bubbles", { - /** @inheritdoc */ - get: function () { return this._bubbles; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "cancelable", { - /** @inheritdoc */ - get: function () { return this._cancelable; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "returnValue", { - /** @inheritdoc */ - get: function () { return !this._canceledFlag; }, - set: function (value) { - if (!value) { - algorithm_1.event_setTheCanceledFlag(this); - } - }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.preventDefault = function () { - algorithm_1.event_setTheCanceledFlag(this); - }; - Object.defineProperty(EventImpl.prototype, "defaultPrevented", { - /** @inheritdoc */ - get: function () { return this._canceledFlag; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "composed", { - /** @inheritdoc */ - get: function () { return this._composedFlag; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "isTrusted", { - /** @inheritdoc */ - get: function () { return this._isTrusted; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(EventImpl.prototype, "timeStamp", { - /** @inheritdoc */ - get: function () { return this._timeStamp; }, - enumerable: true, - configurable: true - }); - /** @inheritdoc */ - EventImpl.prototype.initEvent = function (type, bubbles, cancelable) { - if (bubbles === void 0) { bubbles = false; } - if (cancelable === void 0) { cancelable = false; } - /** - * 1. If the context object’s dispatch flag is set, then return. - */ - if (this._dispatchFlag) - return; - /** - * 2. Initialize the context object with type, bubbles, and cancelable. - */ - algorithm_1.event_initialize(this, type, bubbles, cancelable); - }; - EventImpl.NONE = 0; - EventImpl.CAPTURING_PHASE = 1; - EventImpl.AT_TARGET = 2; - EventImpl.BUBBLING_PHASE = 3; - return EventImpl; -}()); -exports.EventImpl = EventImpl; -/** - * Define constants on prototype. - */ -WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "NONE", 0); -WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "CAPTURING_PHASE", 1); -WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "AT_TARGET", 2); -WebIDLAlgorithm_1.idl_defineConst(EventImpl.prototype, "BUBBLING_PHASE", 3); -//# sourceMappingURL=EventImpl.js.map -/***/ }), -/* 428 */, -/* 429 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/*eslint-disable max-len,no-use-before-define*/ -"use strict"; +var common = __webpack_require__(740); +var YAMLException = __webpack_require__(556); +var Mark = __webpack_require__(93); +var DEFAULT_SAFE_SCHEMA = __webpack_require__(723); +var DEFAULT_FULL_SCHEMA = __webpack_require__(910); -Object.defineProperty(exports, "__esModule", { value: true }); -var algorithm_1 = __webpack_require__(163); -/** - * Represents a mixin that allows nodes to become the contents of - * a element. This mixin is implemented by {@link Element} and - * {@link Text}. - */ -var SlotableImpl = /** @class */ (function () { - function SlotableImpl() { - } - Object.defineProperty(SlotableImpl.prototype, "_name", { - get: function () { return this.__name || ''; }, - set: function (val) { this.__name = val; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SlotableImpl.prototype, "_assignedSlot", { - get: function () { return this.__assignedSlot || null; }, - set: function (val) { this.__assignedSlot = val; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SlotableImpl.prototype, "assignedSlot", { - /** @inheritdoc */ - get: function () { - return algorithm_1.shadowTree_findASlot(this, true); - }, - enumerable: true, - configurable: true - }); - return SlotableImpl; -}()); -exports.SlotableImpl = SlotableImpl; -//# sourceMappingURL=SlotableImpl.js.map -/***/ }), -/* 430 */, -/* 431 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +var _hasOwnProperty = Object.prototype.hasOwnProperty; -"use strict"; -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; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const os = __importStar(__webpack_require__(87)); -const utils_1 = __webpack_require__(82); -/** - * Commands - * - * Command Format: - * ::name key=value,key=value::message - * - * Examples: - * ::warning::This is the message - * ::set-env name=MY_VAR::some value - */ -function issueCommand(command, properties, message) { - const cmd = new Command(command, properties, message); - process.stdout.write(cmd.toString() + os.EOL); +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; + + +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; + + +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; + + +function _class(obj) { return Object.prototype.toString.call(obj); } + +function is_EOL(c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); } -exports.issueCommand = issueCommand; -function issue(name, message = '') { - issueCommand(name, {}, message); + +function is_WHITE_SPACE(c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */); } -exports.issue = issue; -const CMD_STRING = '::'; -class Command { - constructor(command, properties, message) { - if (!command) { - command = 'missing.command'; - } - this.command = command; - this.properties = properties; - this.message = message; - } - toString() { - let cmdStr = CMD_STRING + this.command; - if (this.properties && Object.keys(this.properties).length > 0) { - cmdStr += ' '; - let first = true; - for (const key in this.properties) { - if (this.properties.hasOwnProperty(key)) { - const val = this.properties[key]; - if (val) { - if (first) { - first = false; - } - else { - cmdStr += ','; - } - cmdStr += `${key}=${escapeProperty(val)}`; - } - } - } - } - cmdStr += `${CMD_STRING}${escapeData(this.message)}`; - return cmdStr; - } + +function is_WS_OR_EOL(c) { + return (c === 0x09/* Tab */) || + (c === 0x20/* Space */) || + (c === 0x0A/* LF */) || + (c === 0x0D/* CR */); } -function escapeData(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A'); + +function is_FLOW_INDICATOR(c) { + return c === 0x2C/* , */ || + c === 0x5B/* [ */ || + c === 0x5D/* ] */ || + c === 0x7B/* { */ || + c === 0x7D/* } */; } -function escapeProperty(s) { - return utils_1.toCommandValue(s) - .replace(/%/g, '%25') - .replace(/\r/g, '%0D') - .replace(/\n/g, '%0A') - .replace(/:/g, '%3A') - .replace(/,/g, '%2C'); + +function fromHexCode(c) { + var lc; + + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + /*eslint-disable no-bitwise*/ + lc = c | 0x20; + + if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10; + } + + return -1; } -//# sourceMappingURL=command.js.map -/***/ }), -/* 432 */, -/* 433 */, -/* 434 */, -/* 435 */, -/* 436 */, -/* 437 */, -/* 438 */, -/* 439 */, -/* 440 */, -/* 441 */, -/* 442 */ -/***/ (function(__unusedmodule, exports) { +function escapedHexLen(c) { + if (c === 0x78/* x */) { return 2; } + if (c === 0x75/* u */) { return 4; } + if (c === 0x55/* U */) { return 8; } + return 0; +} -"use strict"; +function fromDecimalCode(c) { + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Determines if the given string is valid for a `"Name"` construct. - * - * @param name - name string to test - */ -function xml_isName(name) { - for (var i = 0; i < name.length; i++) { - var n = name.charCodeAt(i); - // NameStartChar - if ((n >= 97 && n <= 122) || // [a-z] - (n >= 65 && n <= 90) || // [A-Z] - n === 58 || n === 95 || // ':' or '_' - (n >= 0xC0 && n <= 0xD6) || - (n >= 0xD8 && n <= 0xF6) || - (n >= 0xF8 && n <= 0x2FF) || - (n >= 0x370 && n <= 0x37D) || - (n >= 0x37F && n <= 0x1FFF) || - (n >= 0x200C && n <= 0x200D) || - (n >= 0x2070 && n <= 0x218F) || - (n >= 0x2C00 && n <= 0x2FEF) || - (n >= 0x3001 && n <= 0xD7FF) || - (n >= 0xF900 && n <= 0xFDCF) || - (n >= 0xFDF0 && n <= 0xFFFD)) { - continue; - } - else if (i !== 0 && - (n === 45 || n === 46 || // '-' or '.' - (n >= 48 && n <= 57) || // [0-9] - (n === 0xB7) || - (n >= 0x0300 && n <= 0x036F) || - (n >= 0x203F && n <= 0x2040))) { - continue; - } - if (n >= 0xD800 && n <= 0xDBFF && i < name.length - 1) { - var n2 = name.charCodeAt(i + 1); - if (n2 >= 0xDC00 && n2 <= 0xDFFF) { - n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; - i++; - if (n >= 0x10000 && n <= 0xEFFFF) { - continue; - } - } - } - return false; - } - return true; -} -exports.xml_isName = xml_isName; -/** - * Determines if the given string is valid for a `"QName"` construct. - * - * @param name - name string to test - */ -function xml_isQName(name) { - var colonFound = false; - for (var i = 0; i < name.length; i++) { - var n = name.charCodeAt(i); - // NameStartChar - if ((n >= 97 && n <= 122) || // [a-z] - (n >= 65 && n <= 90) || // [A-Z] - n === 95 || // '_' - (n >= 0xC0 && n <= 0xD6) || - (n >= 0xD8 && n <= 0xF6) || - (n >= 0xF8 && n <= 0x2FF) || - (n >= 0x370 && n <= 0x37D) || - (n >= 0x37F && n <= 0x1FFF) || - (n >= 0x200C && n <= 0x200D) || - (n >= 0x2070 && n <= 0x218F) || - (n >= 0x2C00 && n <= 0x2FEF) || - (n >= 0x3001 && n <= 0xD7FF) || - (n >= 0xF900 && n <= 0xFDCF) || - (n >= 0xFDF0 && n <= 0xFFFD)) { - continue; - } - else if (i !== 0 && - (n === 45 || n === 46 || // '-' or '.' - (n >= 48 && n <= 57) || // [0-9] - (n === 0xB7) || - (n >= 0x0300 && n <= 0x036F) || - (n >= 0x203F && n <= 0x2040))) { - continue; - } - else if (i !== 0 && n === 58) { // : - if (colonFound) - return false; // multiple colons in qname - if (i === name.length - 1) - return false; // colon at the end of qname - colonFound = true; - continue; - } - if (n >= 0xD800 && n <= 0xDBFF && i < name.length - 1) { - var n2 = name.charCodeAt(i + 1); - if (n2 >= 0xDC00 && n2 <= 0xDFFF) { - n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; - i++; - if (n >= 0x10000 && n <= 0xEFFFF) { - continue; - } - } - } - return false; - } - return true; -} -exports.xml_isQName = xml_isQName; -/** - * Determines if the given string contains legal characters. - * - * @param chars - sequence of characters to test - */ -function xml_isLegalChar(chars) { - for (var i = 0; i < chars.length; i++) { - var n = chars.charCodeAt(i); - // #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] - if (n === 0x9 || n === 0xA || n === 0xD || - (n >= 0x20 && n <= 0xD7FF) || - (n >= 0xE000 && n <= 0xFFFD)) { - continue; - } - if (n >= 0xD800 && n <= 0xDBFF && i < chars.length - 1) { - var n2 = chars.charCodeAt(i + 1); - if (n2 >= 0xDC00 && n2 <= 0xDFFF) { - n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; - i++; - if (n >= 0x10000 && n <= 0x10FFFF) { - continue; - } - } - } - return false; - } - return true; -} -exports.xml_isLegalChar = xml_isLegalChar; -/** - * Determines if the given string contains legal characters for a public - * identifier. - * - * @param chars - sequence of characters to test - */ -function xml_isPubidChar(chars) { - for (var i = 0; i < chars.length; i++) { - // PubId chars are all in the ASCII range, no need to check surrogates - var n = chars.charCodeAt(i); - // #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%] - if ((n >= 97 && n <= 122) || // [a-z] - (n >= 65 && n <= 90) || // [A-Z] - (n >= 39 && n <= 59) || // ['()*+,-./] | [0-9] | [:;] - n === 0x20 || n === 0xD || n === 0xA || // #x20 | #xD | #xA - (n >= 35 && n <= 37) || // [#$%] - n === 33 || // ! - n === 61 || n === 63 || n === 64 || n === 95) { // [=?@_] - continue; - } - else { - return false; - } - } - return true; -} -exports.xml_isPubidChar = xml_isPubidChar; -//# sourceMappingURL=XMLAlgorithm.js.map - -/***/ }), -/* 443 */, -/* 444 */, -/* 445 */, -/* 446 */, -/* 447 */, -/* 448 */, -/* 449 */, -/* 450 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -var Type = __webpack_require__(945); - -module.exports = new Type('tag:yaml.org,2002:str', { - kind: 'scalar', - construct: function (data) { return data !== null ? data : ''; } -}); - - -/***/ }), -/* 451 */, -/* 452 */, -/* 453 */, -/* 454 */, -/* 455 */, -/* 456 */, -/* 457 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - - -/*eslint-disable max-len,no-use-before-define*/ - -var common = __webpack_require__(740); -var YAMLException = __webpack_require__(556); -var Mark = __webpack_require__(93); -var DEFAULT_SAFE_SCHEMA = __webpack_require__(723); -var DEFAULT_FULL_SCHEMA = __webpack_require__(910); - - -var _hasOwnProperty = Object.prototype.hasOwnProperty; - - -var CONTEXT_FLOW_IN = 1; -var CONTEXT_FLOW_OUT = 2; -var CONTEXT_BLOCK_IN = 3; -var CONTEXT_BLOCK_OUT = 4; - - -var CHOMPING_CLIP = 1; -var CHOMPING_STRIP = 2; -var CHOMPING_KEEP = 3; - - -var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; -var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; -var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; -var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; -var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; - - -function _class(obj) { return Object.prototype.toString.call(obj); } - -function is_EOL(c) { - return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); -} - -function is_WHITE_SPACE(c) { - return (c === 0x09/* Tab */) || (c === 0x20/* Space */); -} - -function is_WS_OR_EOL(c) { - return (c === 0x09/* Tab */) || - (c === 0x20/* Space */) || - (c === 0x0A/* LF */) || - (c === 0x0D/* CR */); -} - -function is_FLOW_INDICATOR(c) { - return c === 0x2C/* , */ || - c === 0x5B/* [ */ || - c === 0x5D/* ] */ || - c === 0x7B/* { */ || - c === 0x7D/* } */; -} - -function fromHexCode(c) { - var lc; - - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } - - /*eslint-disable no-bitwise*/ - lc = c | 0x20; - - if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { - return lc - 0x61 + 10; - } - - return -1; -} - -function escapedHexLen(c) { - if (c === 0x78/* x */) { return 2; } - if (c === 0x75/* u */) { return 4; } - if (c === 0x55/* U */) { return 8; } - return 0; -} - -function fromDecimalCode(c) { - if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { - return c - 0x30; - } - - return -1; + return -1; } function simpleEscapeSequence(c) { @@ -21408,7 +20830,23 @@ exports.mutation_remove = mutation_remove; //# sourceMappingURL=MutationAlgorithm.js.map /***/ }), -/* 480 */, +/* 480 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(124) +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 + + +/***/ }), /* 481 */, /* 482 */, /* 483 */ @@ -21440,7 +20878,15 @@ exports.selectors_scopeMatchASelectorsString = selectors_scopeMatchASelectorsStr /***/ }), /* 484 */, /* 485 */, -/* 486 */, +/* 486 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const gt = (a, b, loose) => compare(a, b, loose) > 0 +module.exports = gt + + +/***/ }), /* 487 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -21933,370 +21379,2089 @@ var DocumentImpl = /** @class */ (function (_super) { iterator._filter = algorithm_1.create_nodeFilter(); iterator._filter.acceptNode = filter; } - else { - iterator._filter = filter; + else { + iterator._filter = filter; + } + return iterator; + }; + /** @inheritdoc */ + DocumentImpl.prototype.createTreeWalker = function (root, whatToShow, filter) { + if (whatToShow === void 0) { whatToShow = interfaces_1.WhatToShow.All; } + if (filter === void 0) { filter = null; } + /** + * 1. Let walker be a new TreeWalker object. + * 2. Set walker’s root and walker’s current to root. + * 3. Set walker’s whatToShow to whatToShow. + * 4. Set walker’s filter to filter. + * 5. Return walker. + */ + var walker = algorithm_1.create_treeWalker(root, root); + walker._whatToShow = whatToShow; + if (util_2.isFunction(filter)) { + walker._filter = algorithm_1.create_nodeFilter(); + walker._filter.acceptNode = filter; + } + else { + walker._filter = filter; + } + return walker; + }; + /** + * Gets the parent event target for the given event. + * + * @param event - an event + */ + DocumentImpl.prototype._getTheParent = function (event) { + /** + * TODO: Implement realms + * A document’s get the parent algorithm, given an event, returns null if + * event’s type attribute value is "load" or document does not have a + * browsing context, and the document’s relevant global object otherwise. + */ + if (event._type === "load") { + return null; + } + else { + return DOMImpl_1.dom.window; + } + }; + // MIXIN: NonElementParentNode + /* istanbul ignore next */ + DocumentImpl.prototype.getElementById = function (elementId) { throw new Error("Mixin: NonElementParentNode not implemented."); }; + Object.defineProperty(DocumentImpl.prototype, "children", { + // MIXIN: DocumentOrShadowRoot + // No elements + // MIXIN: ParentNode + /* istanbul ignore next */ + get: function () { throw new Error("Mixin: ParentNode not implemented."); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "firstElementChild", { + /* istanbul ignore next */ + get: function () { throw new Error("Mixin: ParentNode not implemented."); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "lastElementChild", { + /* istanbul ignore next */ + get: function () { throw new Error("Mixin: ParentNode not implemented."); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(DocumentImpl.prototype, "childElementCount", { + /* istanbul ignore next */ + get: function () { throw new Error("Mixin: ParentNode not implemented."); }, + enumerable: true, + configurable: true + }); + /* istanbul ignore next */ + DocumentImpl.prototype.prepend = function () { + var nodes = []; + for (var _i = 0; _i < arguments.length; _i++) { + nodes[_i] = arguments[_i]; + } + throw new Error("Mixin: ParentNode not implemented."); + }; + /* istanbul ignore next */ + DocumentImpl.prototype.append = function () { + var nodes = []; + for (var _i = 0; _i < arguments.length; _i++) { + nodes[_i] = arguments[_i]; + } + throw new Error("Mixin: ParentNode not implemented."); + }; + /* istanbul ignore next */ + DocumentImpl.prototype.querySelector = function (selectors) { throw new Error("Mixin: ParentNode not implemented."); }; + /* istanbul ignore next */ + DocumentImpl.prototype.querySelectorAll = function (selectors) { throw new Error("Mixin: ParentNode not implemented."); }; + return DocumentImpl; +}(NodeImpl_1.NodeImpl)); +exports.DocumentImpl = DocumentImpl; +/** + * Initialize prototype properties + */ +WebIDLAlgorithm_1.idl_defineConst(DocumentImpl.prototype, "_nodeType", interfaces_1.NodeType.Document); +//# sourceMappingURL=DocumentImpl.js.map + +/***/ }), +/* 489 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const patch = (a, loose) => new SemVer(a, loose).patch +module.exports = patch + + +/***/ }), +/* 490 */, +/* 491 */, +/* 492 */, +/* 493 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var DOMImpl_1 = __webpack_require__(648); +var util_1 = __webpack_require__(918); +var util_2 = __webpack_require__(592); +var ElementImpl_1 = __webpack_require__(695); +var CustomElementAlgorithm_1 = __webpack_require__(344); +var TreeAlgorithm_1 = __webpack_require__(873); +var NamespaceAlgorithm_1 = __webpack_require__(664); +var DOMAlgorithm_1 = __webpack_require__(304); +var ElementAlgorithm_1 = __webpack_require__(33); +var MutationAlgorithm_1 = __webpack_require__(479); +/** + * Returns an element interface for the given name and namespace. + * + * @param name - element name + * @param namespace - namespace + */ +function document_elementInterface(name, namespace) { + return ElementImpl_1.ElementImpl; +} +exports.document_elementInterface = document_elementInterface; +/** + * Creates a new element node. + * See: https://dom.spec.whatwg.org/#internal-createelementns-steps + * + * @param document - owner document + * @param namespace - element namespace + * @param qualifiedName - qualified name + * @param options - element options + */ +function document_internalCreateElementNS(document, namespace, qualifiedName, options) { + /** + * 1. Let namespace, prefix, and localName be the result of passing + * namespace and qualifiedName to validate and extract. + * 2. Let is be null. + * 3. If options is a dictionary and options’s is is present, then set + * is to it. + * 4. Return the result of creating an element given document, localName, + * namespace, prefix, is, and with the synchronous custom elements flag set. + */ + var _a = __read(NamespaceAlgorithm_1.namespace_validateAndExtract(namespace, qualifiedName), 3), ns = _a[0], prefix = _a[1], localName = _a[2]; + var is = null; + if (options !== undefined) { + if (util_2.isString(options)) { + is = options; + } + else { + is = options.is; + } + } + return ElementAlgorithm_1.element_createAnElement(document, localName, ns, prefix, is, true); +} +exports.document_internalCreateElementNS = document_internalCreateElementNS; +/** + * Removes `node` and its subtree from its document and changes + * its owner document to `document` so that it can be inserted + * into `document`. + * + * @param node - the node to move + * @param document - document to receive the node and its subtree + */ +function document_adopt(node, document) { + var e_1, _a; + // Optimize for common case of inserting a fresh node + if (node._nodeDocument === document && node._parent === null) { + return; + } + /** + * 1. Let oldDocument be node’s node document. + * 2. If node’s parent is not null, remove node from its parent. + */ + var oldDocument = node._nodeDocument; + if (node._parent) + MutationAlgorithm_1.mutation_remove(node, node._parent); + /** + * 3. If document is not oldDocument, then: + */ + if (document !== oldDocument) { + /** + * 3.1. For each inclusiveDescendant in node’s shadow-including inclusive + * descendants: + */ + var inclusiveDescendant = TreeAlgorithm_1.tree_getFirstDescendantNode(node, true, true); + while (inclusiveDescendant !== null) { + /** + * 3.1.1. Set inclusiveDescendant’s node document to document. + * 3.1.2. If inclusiveDescendant is an element, then set the node + * document of each attribute in inclusiveDescendant’s attribute list + * to document. + */ + inclusiveDescendant._nodeDocument = document; + if (util_1.Guard.isElementNode(inclusiveDescendant)) { + try { + for (var _b = (e_1 = void 0, __values(inclusiveDescendant._attributeList._asArray())), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + attr._nodeDocument = document; + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + } + /** + * 3.2. For each inclusiveDescendant in node's shadow-including + * inclusive descendants that is custom, enqueue a custom + * element callback reaction with inclusiveDescendant, + * callback name "adoptedCallback", and an argument list + * containing oldDocument and document. + */ + if (DOMImpl_1.dom.features.customElements) { + if (util_1.Guard.isElementNode(inclusiveDescendant) && + inclusiveDescendant._customElementState === "custom") { + CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(inclusiveDescendant, "adoptedCallback", [oldDocument, document]); + } + } + /** + * 3.3. For each inclusiveDescendant in node’s shadow-including + * inclusive descendants, in shadow-including tree order, run the + * adopting steps with inclusiveDescendant and oldDocument. + */ + if (DOMImpl_1.dom.features.steps) { + DOMAlgorithm_1.dom_runAdoptingSteps(inclusiveDescendant, oldDocument); + } + inclusiveDescendant = TreeAlgorithm_1.tree_getNextDescendantNode(node, inclusiveDescendant, true, true); + } + } +} +exports.document_adopt = document_adopt; +//# sourceMappingURL=DocumentAlgorithm.js.map + +/***/ }), +/* 494 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +var rng = __webpack_require__(58); +var bytesToUuid = __webpack_require__(722); + +function v4(options, buf, offset) { + var i = buf && offset || 0; + + if (typeof(options) == 'string') { + buf = options === 'binary' ? new Array(16) : null; + options = null; + } + options = options || {}; + + var rnds = options.random || (options.rng || rng)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ++ii) { + buf[i + ii] = rnds[ii]; + } + } + + return buf || bytesToUuid(rnds); +} + +module.exports = v4; + + +/***/ }), +/* 495 */ +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Defines a WebIDL `Const` property on the given object. + * + * @param o - object on which to add the property + * @param name - property name + * @param value - property value + */ +function idl_defineConst(o, name, value) { + Object.defineProperty(o, name, { writable: false, enumerable: true, configurable: false, value: value }); +} +exports.idl_defineConst = idl_defineConst; +//# sourceMappingURL=WebIDLAlgorithm.js.map + +/***/ }), +/* 496 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +var __read = (this && this.__read) || function (o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +}; +var __spread = (this && this.__spread) || function () { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + return ar; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var util_1 = __webpack_require__(592); +/** + * Adds the given item to the end of the set. + * + * @param set - a set + * @param item - an item + */ +function append(set, item) { + set.add(item); +} +exports.append = append; +/** + * Extends a set by appending all items from another set. + * + * @param setA - a list to extend + * @param setB - a list containing items to append to `setA` + */ +function extend(setA, setB) { + setB.forEach(setA.add, setA); +} +exports.extend = extend; +/** + * Inserts the given item to the start of the set. + * + * @param set - a set + * @param item - an item + */ +function prepend(set, item) { + var cloned = new Set(set); + set.clear(); + set.add(item); + cloned.forEach(set.add, set); +} +exports.prepend = prepend; +/** + * Replaces the given item or all items matching condition with a new item. + * + * @param set - a set + * @param conditionOrItem - an item to replace or a condition matching items + * to replace + * @param item - an item + */ +function replace(set, conditionOrItem, newItem) { + var e_1, _a; + var newSet = new Set(); + try { + for (var set_1 = __values(set), set_1_1 = set_1.next(); !set_1_1.done; set_1_1 = set_1.next()) { + var oldItem = set_1_1.value; + if (util_1.isFunction(conditionOrItem)) { + if (!!conditionOrItem.call(null, oldItem)) { + newSet.add(newItem); + } + else { + newSet.add(oldItem); + } + } + else if (oldItem === conditionOrItem) { + newSet.add(newItem); + } + else { + newSet.add(oldItem); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (set_1_1 && !set_1_1.done && (_a = set_1.return)) _a.call(set_1); + } + finally { if (e_1) throw e_1.error; } + } + set.clear(); + newSet.forEach(set.add, set); +} +exports.replace = replace; +/** + * Inserts the given item before the given index. + * + * @param set - a set + * @param item - an item + */ +function insert(set, item, index) { + var e_2, _a; + var newSet = new Set(); + var i = 0; + try { + for (var set_2 = __values(set), set_2_1 = set_2.next(); !set_2_1.done; set_2_1 = set_2.next()) { + var oldItem = set_2_1.value; + if (i === index) + newSet.add(item); + newSet.add(oldItem); + i++; + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (set_2_1 && !set_2_1.done && (_a = set_2.return)) _a.call(set_2); + } + finally { if (e_2) throw e_2.error; } + } + set.clear(); + newSet.forEach(set.add, set); +} +exports.insert = insert; +/** + * Removes the given item or all items matching condition. + * + * @param set - a set + * @param conditionOrItem - an item to remove or a condition matching items + * to remove + */ +function remove(set, conditionOrItem) { + var e_3, _a, e_4, _b; + if (!util_1.isFunction(conditionOrItem)) { + set.delete(conditionOrItem); + } + else { + var toRemove = []; + try { + for (var set_3 = __values(set), set_3_1 = set_3.next(); !set_3_1.done; set_3_1 = set_3.next()) { + var item = set_3_1.value; + if (!!conditionOrItem.call(null, item)) { + toRemove.push(item); + } + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (set_3_1 && !set_3_1.done && (_a = set_3.return)) _a.call(set_3); + } + finally { if (e_3) throw e_3.error; } + } + try { + for (var toRemove_1 = __values(toRemove), toRemove_1_1 = toRemove_1.next(); !toRemove_1_1.done; toRemove_1_1 = toRemove_1.next()) { + var oldItem = toRemove_1_1.value; + set.delete(oldItem); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (toRemove_1_1 && !toRemove_1_1.done && (_b = toRemove_1.return)) _b.call(toRemove_1); + } + finally { if (e_4) throw e_4.error; } + } + } +} +exports.remove = remove; +/** + * Removes all items from the set. + */ +function empty(set) { + set.clear(); +} +exports.empty = empty; +/** + * Determines if the set contains the given item or any items matching + * condition. + * + * @param set - a set + * @param conditionOrItem - an item to a condition to match + */ +function contains(set, conditionOrItem) { + var e_5, _a; + if (!util_1.isFunction(conditionOrItem)) { + return set.has(conditionOrItem); + } + else { + try { + for (var set_4 = __values(set), set_4_1 = set_4.next(); !set_4_1.done; set_4_1 = set_4.next()) { + var oldItem = set_4_1.value; + if (!!conditionOrItem.call(null, oldItem)) { + return true; + } + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (set_4_1 && !set_4_1.done && (_a = set_4.return)) _a.call(set_4); + } + finally { if (e_5) throw e_5.error; } + } + } + return false; +} +exports.contains = contains; +/** + * Returns the count of items in the set matching the given condition. + * + * @param set - a set + * @param condition - an optional condition to match + */ +function size(set, condition) { + var e_6, _a; + if (condition === undefined) { + return set.size; + } + else { + var count = 0; + try { + for (var set_5 = __values(set), set_5_1 = set_5.next(); !set_5_1.done; set_5_1 = set_5.next()) { + var item = set_5_1.value; + if (!!condition.call(null, item)) { + count++; + } + } + } + catch (e_6_1) { e_6 = { error: e_6_1 }; } + finally { + try { + if (set_5_1 && !set_5_1.done && (_a = set_5.return)) _a.call(set_5); + } + finally { if (e_6) throw e_6.error; } + } + return count; + } +} +exports.size = size; +/** + * Determines if the set is empty. + * + * @param set - a set + */ +function isEmpty(set) { + return set.size === 0; +} +exports.isEmpty = isEmpty; +/** + * Returns an iterator for the items of the set. + * + * @param set - a set + * @param condition - an optional condition to match + */ +function forEach(set, condition) { + var set_6, set_6_1, item, e_7_1; + var e_7, _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + if (!(condition === undefined)) return [3 /*break*/, 2]; + return [5 /*yield**/, __values(set)]; + case 1: + _b.sent(); + return [3 /*break*/, 9]; + case 2: + _b.trys.push([2, 7, 8, 9]); + set_6 = __values(set), set_6_1 = set_6.next(); + _b.label = 3; + case 3: + if (!!set_6_1.done) return [3 /*break*/, 6]; + item = set_6_1.value; + if (!!!condition.call(null, item)) return [3 /*break*/, 5]; + return [4 /*yield*/, item]; + case 4: + _b.sent(); + _b.label = 5; + case 5: + set_6_1 = set_6.next(); + return [3 /*break*/, 3]; + case 6: return [3 /*break*/, 9]; + case 7: + e_7_1 = _b.sent(); + e_7 = { error: e_7_1 }; + return [3 /*break*/, 9]; + case 8: + try { + if (set_6_1 && !set_6_1.done && (_a = set_6.return)) _a.call(set_6); + } + finally { if (e_7) throw e_7.error; } + return [7 /*endfinally*/]; + case 9: return [2 /*return*/]; + } + }); +} +exports.forEach = forEach; +/** + * Creates and returns a shallow clone of set. + * + * @param set - a set + */ +function clone(set) { + return new Set(set); +} +exports.clone = clone; +/** + * Returns a new set containing items from the set sorted in ascending + * order. + * + * @param set - a set + * @param lessThanAlgo - a function that returns `true` if its first argument + * is less than its second argument, and `false` otherwise. + */ +function sortInAscendingOrder(set, lessThanAlgo) { + var list = new (Array.bind.apply(Array, __spread([void 0], set)))(); + list.sort(function (itemA, itemB) { + return lessThanAlgo.call(null, itemA, itemB) ? -1 : 1; + }); + return new Set(list); +} +exports.sortInAscendingOrder = sortInAscendingOrder; +/** + * Returns a new set containing items from the set sorted in descending + * order. + * + * @param set - a set + * @param lessThanAlgo - a function that returns `true` if its first argument + * is less than its second argument, and `false` otherwise. + */ +function sortInDescendingOrder(set, lessThanAlgo) { + var list = new (Array.bind.apply(Array, __spread([void 0], set)))(); + list.sort(function (itemA, itemB) { + return lessThanAlgo.call(null, itemA, itemB) ? 1 : -1; + }); + return new Set(list); +} +exports.sortInDescendingOrder = sortInDescendingOrder; +/** + * Determines if a set is a subset of another set. + * + * @param subset - a set + * @param superset - a superset possibly containing all items from `subset`. + */ +function isSubsetOf(subset, superset) { + var e_8, _a; + try { + for (var subset_1 = __values(subset), subset_1_1 = subset_1.next(); !subset_1_1.done; subset_1_1 = subset_1.next()) { + var item = subset_1_1.value; + if (!superset.has(item)) + return false; + } + } + catch (e_8_1) { e_8 = { error: e_8_1 }; } + finally { + try { + if (subset_1_1 && !subset_1_1.done && (_a = subset_1.return)) _a.call(subset_1); + } + finally { if (e_8) throw e_8.error; } + } + return true; +} +exports.isSubsetOf = isSubsetOf; +/** + * Determines if a set is a superset of another set. + * + * @param superset - a set + * @param subset - a subset possibly contained within `superset`. + */ +function isSupersetOf(superset, subset) { + return isSubsetOf(subset, superset); +} +exports.isSupersetOf = isSupersetOf; +/** + * Returns a new set with items that are contained in both sets. + * + * @param setA - a set + * @param setB - a set + */ +function intersection(setA, setB) { + var e_9, _a; + var newSet = new Set(); + try { + for (var setA_1 = __values(setA), setA_1_1 = setA_1.next(); !setA_1_1.done; setA_1_1 = setA_1.next()) { + var item = setA_1_1.value; + if (setB.has(item)) + newSet.add(item); + } + } + catch (e_9_1) { e_9 = { error: e_9_1 }; } + finally { + try { + if (setA_1_1 && !setA_1_1.done && (_a = setA_1.return)) _a.call(setA_1); + } + finally { if (e_9) throw e_9.error; } + } + return newSet; +} +exports.intersection = intersection; +/** + * Returns a new set with items from both sets. + * + * @param setA - a set + * @param setB - a set + */ +function union(setA, setB) { + var newSet = new Set(setA); + setB.forEach(newSet.add, newSet); + return newSet; +} +exports.union = union; +/** + * Returns a set of integers from `n` to `m` inclusive. + * + * @param n - starting number + * @param m - ending number + */ +function range(n, m) { + var newSet = new Set(); + for (var i = n; i <= m; i++) { + newSet.add(i); + } + return newSet; +} +exports.range = range; +//# sourceMappingURL=Set.js.map + +/***/ }), +/* 497 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var BaseCBWriter_1 = __webpack_require__(512); +/** + * Serializes XML nodes. + */ +var YAMLCBWriter = /** @class */ (function (_super) { + __extends(YAMLCBWriter, _super); + /** + * Initializes a new instance of `BaseCBWriter`. + * + * @param builderOptions - XML builder options + */ + function YAMLCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._rootWritten = false; + _this._additionalLevel = 0; + if (builderOptions.indent.length < 2) { + throw new Error("YAML indententation string must be at least two characters long."); + } + if (builderOptions.offset < 0) { + throw new Error("YAML offset should be zero or a positive number."); + } + return _this; + } + /** @inheritdoc */ + YAMLCBWriter.prototype.frontMatter = function () { + return this._beginLine() + "---"; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.declaration = function (version, encoding, standalone) { + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.docType = function (name, publicId, systemId) { + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.comment = function (data) { + // "!": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.comment) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.text = function (data) { + // "#": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.text) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.instruction = function (target, data) { + // "?": "target hello" + return this._beginLine() + + this._key(this._builderOptions.convert.ins) + " " + + this._val(data ? target + " " + data : target); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.cdata = function (data) { + // "$": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.cdata) + " " + + this._val(data); + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.attribute = function (name, value) { + // "@name": "val" + this._additionalLevel++; + var str = this._beginLine() + + this._key(this._builderOptions.convert.att + name) + " " + + this._val(value); + this._additionalLevel--; + return str; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.openTagBegin = function (name) { + // "node": + // "#": + // - + var str = this._beginLine() + this._key(name); + if (!this._rootWritten) { + this._rootWritten = true; + } + this.hasData = true; + this._additionalLevel++; + str += this._beginLine(true) + this._key(this._builderOptions.convert.text); + return str; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (selfClosing) { + return " " + this._val(""); + } + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.closeTag = function (name) { + this._additionalLevel--; + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + YAMLCBWriter.prototype.endElement = function (name) { }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + YAMLCBWriter.prototype._beginLine = function (suppressArray) { + if (suppressArray === void 0) { suppressArray = false; } + return (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level, suppressArray); + }; + /** + * Produces an indentation string. + * + * @param level - depth of the tree + * @param suppressArray - whether the suppress array marker + */ + YAMLCBWriter.prototype._indent = function (level, suppressArray) { + if (level + this._additionalLevel <= 0) { + return ""; + } + else { + var chars = this._writerOptions.indent.repeat(level + this._additionalLevel); + if (!suppressArray && this._rootWritten) { + return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); + } + return chars; + } + }; + /** + * Produces a YAML key string delimited with double quotes. + */ + YAMLCBWriter.prototype._key = function (key) { + return "\"" + key + "\":"; + }; + /** + * Produces a YAML value string delimited with double quotes. + */ + YAMLCBWriter.prototype._val = function (val) { + return JSON.stringify(val); + }; + return YAMLCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.YAMLCBWriter = YAMLCBWriter; +//# sourceMappingURL=YAMLCBWriter.js.map + +/***/ }), +/* 498 */, +/* 499 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const parse = __webpack_require__(830) +const {re, t} = __webpack_require__(976) + +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 + + +/***/ }), +/* 500 */, +/* 501 */ +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Appends the given item to the queue. + * + * @param list - a list + * @param item - an item + */ +function enqueue(list, item) { + list.push(item); +} +exports.enqueue = enqueue; +/** + * Removes and returns an item from the queue. + * + * @param list - a list + */ +function dequeue(list) { + return list.shift() || null; +} +exports.dequeue = dequeue; +//# sourceMappingURL=Queue.js.map + +/***/ }), +/* 502 */, +/* 503 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(830) +const clean = (version, options) => { + const s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null +} +module.exports = clean + + +/***/ }), +/* 504 */, +/* 505 */, +/* 506 */, +/* 507 */, +/* 508 */, +/* 509 */, +/* 510 */, +/* 511 */, +/* 512 */ +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Pre-serializes XML nodes. + */ +var BaseCBWriter = /** @class */ (function () { + /** + * Initializes a new instance of `BaseCBWriter`. + * + * @param builderOptions - XML builder options + */ + function BaseCBWriter(builderOptions) { + /** + * Gets the current depth of the XML tree. + */ + this.level = 0; + this._builderOptions = builderOptions; + this._writerOptions = builderOptions; + } + return BaseCBWriter; +}()); +exports.BaseCBWriter = BaseCBWriter; +//# sourceMappingURL=BaseCBWriter.js.map + +/***/ }), +/* 513 */, +/* 514 */, +/* 515 */, +/* 516 */, +/* 517 */, +/* 518 */, +/* 519 */, +/* 520 */, +/* 521 */, +/* 522 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var util_1 = __webpack_require__(592); +/** + * Parses the given byte sequence representing a JSON string into an object. + * + * @param bytes - a byte sequence + */ +function parseJSONFromBytes(bytes) { + /** + * 1. Let jsonText be the result of running UTF-8 decode on bytes. [ENCODING] + * 2. Return ? Call(%JSONParse%, undefined, « jsonText »). + */ + var jsonText = util_1.utf8Decode(bytes); + return JSON.parse.call(undefined, jsonText); +} +exports.parseJSONFromBytes = parseJSONFromBytes; +/** + * Serialize the given JavaScript value into a byte sequence. + * + * @param value - a JavaScript value + */ +function serializeJSONToBytes(value) { + /** + * 1. Let jsonString be ? Call(%JSONStringify%, undefined, « value »). + * 2. Return the result of running UTF-8 encode on jsonString. [ENCODING] + */ + var jsonString = JSON.stringify.call(undefined, value); + return util_1.utf8Encode(jsonString); +} +exports.serializeJSONToBytes = serializeJSONToBytes; +/** + * Parses the given JSON string into a Realm-independent JavaScript value. + * + * @param jsonText - a JSON string + */ +function parseJSONIntoInfraValues(jsonText) { + /** + * 1. Let jsValue be ? Call(%JSONParse%, undefined, « jsonText »). + * 2. Return the result of converting a JSON-derived JavaScript value to an + * Infra value, given jsValue. + */ + var jsValue = JSON.parse.call(undefined, jsonText); + return convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValue); +} +exports.parseJSONIntoInfraValues = parseJSONIntoInfraValues; +/** + * Parses the value into a Realm-independent JavaScript value. + * + * @param jsValue - a JavaScript value + */ +function convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValue) { + var e_1, _a; + /** + * 1. If Type(jsValue) is Null, String, or Number, then return jsValue. + */ + if (jsValue === null || util_1.isString(jsValue) || util_1.isNumber(jsValue)) + return jsValue; + /** + * 2. If IsArray(jsValue) is true, then: + * 2.1. Let result be an empty list. + * 2.2. Let length be ! ToLength(! Get(jsValue, "length")). + * 2.3. For each index of the range 0 to length − 1, inclusive: + * 2.3.1. Let indexName be ! ToString(index). + * 2.3.2. Let jsValueAtIndex be ! Get(jsValue, indexName). + * 2.3.3. Let infraValueAtIndex be the result of converting a JSON-derived + * JavaScript value to an Infra value, given jsValueAtIndex. + * 2.3.4. Append infraValueAtIndex to result. + * 2.8. Return result. + */ + if (util_1.isArray(jsValue)) { + var result = new Array(); + try { + for (var jsValue_1 = __values(jsValue), jsValue_1_1 = jsValue_1.next(); !jsValue_1_1.done; jsValue_1_1 = jsValue_1.next()) { + var jsValueAtIndex = jsValue_1_1.value; + result.push(convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValueAtIndex)); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (jsValue_1_1 && !jsValue_1_1.done && (_a = jsValue_1.return)) _a.call(jsValue_1); + } + finally { if (e_1) throw e_1.error; } + } + return result; + } + else if (util_1.isObject(jsValue)) { + /** + * 3. Let result be an empty ordered map. + * 4. For each key of ! jsValue.[[OwnPropertyKeys]](): + * 4.1. Let jsValueAtKey be ! Get(jsValue, key). + * 4.2. Let infraValueAtKey be the result of converting a JSON-derived + * JavaScript value to an Infra value, given jsValueAtKey. + * 4.3. Set result[key] to infraValueAtKey. + * 5. Return result. + */ + var result = new Map(); + for (var key in jsValue) { + /* istanbul ignore else */ + if (jsValue.hasOwnProperty(key)) { + var jsValueAtKey = jsValue[key]; + result.set(key, convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValueAtKey)); + } + } + return result; + } + /* istanbul ignore next */ + return jsValue; +} +exports.convertAJSONDerivedJavaScriptValueToAnInfraValue = convertAJSONDerivedJavaScriptValueToAnInfraValue; +//# sourceMappingURL=JSON.js.map + +/***/ }), +/* 523 */, +/* 524 */ +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Represents a cache for storing order between equal objects. + * + * This cache is used when an algorithm compares two objects and finds them to + * be equal but still needs to establish an order between those two objects. + * When two such objects `a` and `b` are passed to the `check` method, a random + * number is generated with `Math.random()`. If the random number is less than + * `0.5` it is assumed that `a < b` otherwise `a > b`. The random number along + * with `a` and `b` is stored in the cache, so that subsequent checks result + * in the same consistent result. + * + * The cache has a size limit which is defined on initialization. + */ +var CompareCache = /** @class */ (function () { + /** + * Initializes a new instance of `CompareCache`. + * + * @param limit - maximum number of items to keep in the cache. When the limit + * is exceeded the first item is removed from the cache. + */ + function CompareCache(limit) { + if (limit === void 0) { limit = 1000; } + this._items = new Map(); + this._limit = limit; + } + /** + * Compares and caches the given objects. Returns `true` if `objA < objB` and + * `false` otherwise. + * + * @param objA - an item to compare + * @param objB - an item to compare + */ + CompareCache.prototype.check = function (objA, objB) { + if (this._items.get(objA) === objB) + return true; + else if (this._items.get(objB) === objA) + return false; + var result = (Math.random() < 0.5); + if (result) { + this._items.set(objA, objB); + } + else { + this._items.set(objB, objA); + } + if (this._items.size > this._limit) { + var it_1 = this._items.keys().next(); + /* istanbul ignore else */ + if (!it_1.done) { + this._items.delete(it_1.value); + } + } + return result; + }; + return CompareCache; +}()); +exports.CompareCache = CompareCache; +//# sourceMappingURL=CompareCache.js.map + +/***/ }), +/* 525 */, +/* 526 */, +/* 527 */, +/* 528 */, +/* 529 */, +/* 530 */, +/* 531 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// Determine if version is greater than all the versions possible in the range. +const outside = __webpack_require__(881) +const gtr = (version, range, options) => outside(version, range, '>', options) +module.exports = gtr + + +/***/ }), +/* 532 */, +/* 533 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var Guard_1 = __webpack_require__(783); +/** + * Contains type casts for DOM objects. + */ +var Cast = /** @class */ (function () { + function Cast() { + } + /** + * Casts the given object to a `Node`. + * + * @param a - the object to cast + */ + Cast.asNode = function (a) { + if (Guard_1.Guard.isNode(a)) { + return a; + } + else { + throw new Error("Invalid object. Node expected."); + } + }; + return Cast; +}()); +exports.Cast = Cast; +//# sourceMappingURL=Cast.js.map + +/***/ }), +/* 534 */, +/* 535 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var XMLBuilderImpl_1 = __webpack_require__(595); +exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; +var XMLBuilderCBImpl_1 = __webpack_require__(551); +exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; +var BuilderFunctions_1 = __webpack_require__(961); +exports.builder = BuilderFunctions_1.builder; +exports.create = BuilderFunctions_1.create; +exports.fragment = BuilderFunctions_1.fragment; +exports.convert = BuilderFunctions_1.convert; +var BuilderFunctionsCB_1 = __webpack_require__(295); +exports.createCB = BuilderFunctionsCB_1.createCB; +exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; +//# sourceMappingURL=index.js.map + +/***/ }), +/* 536 */ +/***/ (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) { + options = parseOptions(options) + + 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 parseOptions = __webpack_require__(143) +const {re, t} = __webpack_require__(976) +const cmp = __webpack_require__(752) +const debug = __webpack_require__(548) +const SemVer = __webpack_require__(65) +const Range = __webpack_require__(124) + + +/***/ }), +/* 537 */, +/* 538 */, +/* 539 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const http = __webpack_require__(605); +const https = __webpack_require__(34); +const pm = __webpack_require__(950); +let tunnel; +var HttpCodes; +(function (HttpCodes) { + HttpCodes[HttpCodes["OK"] = 200] = "OK"; + HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; + HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; + HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; + HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; + HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; + HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; + HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; + HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; + HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; + HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; + HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; + HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; + HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; + HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; + HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; + HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; + HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; + HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; + HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; + HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; + HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; + HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; + HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; + HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; + HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; + HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; +})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); +var Headers; +(function (Headers) { + Headers["Accept"] = "accept"; + Headers["ContentType"] = "content-type"; +})(Headers = exports.Headers || (exports.Headers = {})); +var MediaTypes; +(function (MediaTypes) { + MediaTypes["ApplicationJson"] = "application/json"; +})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); +/** + * Returns the proxy URL, depending upon the supplied url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ +function getProxyUrl(serverUrl) { + let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); + return proxyUrl ? proxyUrl.href : ''; +} +exports.getProxyUrl = getProxyUrl; +const HttpRedirectCodes = [ + HttpCodes.MovedPermanently, + HttpCodes.ResourceMoved, + HttpCodes.SeeOther, + HttpCodes.TemporaryRedirect, + HttpCodes.PermanentRedirect +]; +const HttpResponseRetryCodes = [ + HttpCodes.BadGateway, + HttpCodes.ServiceUnavailable, + HttpCodes.GatewayTimeout +]; +const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; +const ExponentialBackoffCeiling = 10; +const ExponentialBackoffTimeSlice = 5; +class HttpClientError extends Error { + constructor(message, statusCode) { + super(message); + this.name = 'HttpClientError'; + this.statusCode = statusCode; + Object.setPrototypeOf(this, HttpClientError.prototype); + } +} +exports.HttpClientError = HttpClientError; +class HttpClientResponse { + constructor(message) { + this.message = message; + } + readBody() { + return new Promise(async (resolve, reject) => { + let output = Buffer.alloc(0); + this.message.on('data', (chunk) => { + output = Buffer.concat([output, chunk]); + }); + this.message.on('end', () => { + resolve(output.toString()); + }); + }); + } +} +exports.HttpClientResponse = HttpClientResponse; +function isHttps(requestUrl) { + let parsedUrl = new URL(requestUrl); + return parsedUrl.protocol === 'https:'; +} +exports.isHttps = isHttps; +class HttpClient { + constructor(userAgent, handlers, requestOptions) { + this._ignoreSslError = false; + this._allowRedirects = true; + this._allowRedirectDowngrade = false; + this._maxRedirects = 50; + this._allowRetries = false; + this._maxRetries = 1; + this._keepAlive = false; + this._disposed = false; + this.userAgent = userAgent; + this.handlers = handlers || []; + this.requestOptions = requestOptions; + if (requestOptions) { + if (requestOptions.ignoreSslError != null) { + this._ignoreSslError = requestOptions.ignoreSslError; + } + this._socketTimeout = requestOptions.socketTimeout; + if (requestOptions.allowRedirects != null) { + this._allowRedirects = requestOptions.allowRedirects; + } + if (requestOptions.allowRedirectDowngrade != null) { + this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + } + if (requestOptions.maxRedirects != null) { + this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + } + if (requestOptions.keepAlive != null) { + this._keepAlive = requestOptions.keepAlive; + } + if (requestOptions.allowRetries != null) { + this._allowRetries = requestOptions.allowRetries; + } + if (requestOptions.maxRetries != null) { + this._maxRetries = requestOptions.maxRetries; + } + } + } + options(requestUrl, additionalHeaders) { + return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); + } + get(requestUrl, additionalHeaders) { + return this.request('GET', requestUrl, null, additionalHeaders || {}); + } + del(requestUrl, additionalHeaders) { + return this.request('DELETE', requestUrl, null, additionalHeaders || {}); + } + post(requestUrl, data, additionalHeaders) { + return this.request('POST', requestUrl, data, additionalHeaders || {}); + } + patch(requestUrl, data, additionalHeaders) { + return this.request('PATCH', requestUrl, data, additionalHeaders || {}); + } + put(requestUrl, data, additionalHeaders) { + return this.request('PUT', requestUrl, data, additionalHeaders || {}); + } + head(requestUrl, additionalHeaders) { + return this.request('HEAD', requestUrl, null, additionalHeaders || {}); + } + sendStream(verb, requestUrl, stream, additionalHeaders) { + return this.request(verb, requestUrl, stream, additionalHeaders); + } + /** + * Gets a typed object from an endpoint + * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise + */ + async getJson(requestUrl, additionalHeaders = {}) { + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + let res = await this.get(requestUrl, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async postJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.post(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async putJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.put(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + async patchJson(requestUrl, obj, additionalHeaders = {}) { + let data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + let res = await this.patch(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + } + /** + * Makes a raw http request. + * All other methods such as get, post, patch, and request ultimately call this. + * Prefer get, del, post and patch + */ + async request(verb, requestUrl, data, headers) { + if (this._disposed) { + throw new Error('Client has already been disposed.'); } - return iterator; - }; - /** @inheritdoc */ - DocumentImpl.prototype.createTreeWalker = function (root, whatToShow, filter) { - if (whatToShow === void 0) { whatToShow = interfaces_1.WhatToShow.All; } - if (filter === void 0) { filter = null; } - /** - * 1. Let walker be a new TreeWalker object. - * 2. Set walker’s root and walker’s current to root. - * 3. Set walker’s whatToShow to whatToShow. - * 4. Set walker’s filter to filter. - * 5. Return walker. - */ - var walker = algorithm_1.create_treeWalker(root, root); - walker._whatToShow = whatToShow; - if (util_2.isFunction(filter)) { - walker._filter = algorithm_1.create_nodeFilter(); - walker._filter.acceptNode = filter; + let parsedUrl = new URL(requestUrl); + let info = this._prepareRequest(verb, parsedUrl, headers); + // Only perform retries on reads since writes may not be idempotent. + let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 + ? this._maxRetries + 1 + : 1; + let numTries = 0; + let response; + while (numTries < maxTries) { + response = await this.requestRaw(info, data); + // Check if it's an authentication challenge + if (response && + response.message && + response.message.statusCode === HttpCodes.Unauthorized) { + let authenticationHandler; + for (let i = 0; i < this.handlers.length; i++) { + if (this.handlers[i].canHandleAuthentication(response)) { + authenticationHandler = this.handlers[i]; + break; + } + } + if (authenticationHandler) { + return authenticationHandler.handleAuthentication(this, info, data); + } + else { + // We have received an unauthorized response but have no handlers to handle it. + // Let the response return to the caller. + return response; + } + } + let redirectsRemaining = this._maxRedirects; + while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && + this._allowRedirects && + redirectsRemaining > 0) { + const redirectUrl = response.message.headers['location']; + if (!redirectUrl) { + // if there's no location to redirect to, we won't + break; + } + let parsedRedirectUrl = new URL(redirectUrl); + if (parsedUrl.protocol == 'https:' && + parsedUrl.protocol != parsedRedirectUrl.protocol && + !this._allowRedirectDowngrade) { + throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); + } + // we need to finish reading the response before reassigning response + // which will leak the open socket. + await response.readBody(); + // strip authorization header if redirected to a different hostname + if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { + for (let header in headers) { + // header names are case insensitive + if (header.toLowerCase() === 'authorization') { + delete headers[header]; + } + } + } + // let's make the request with the new redirectUrl + info = this._prepareRequest(verb, parsedRedirectUrl, headers); + response = await this.requestRaw(info, data); + redirectsRemaining--; + } + if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { + // If not a retry code, return immediately instead of retrying + return response; + } + numTries += 1; + if (numTries < maxTries) { + await response.readBody(); + await this._performExponentialBackoff(numTries); + } } - else { - walker._filter = filter; + return response; + } + /** + * Needs to be called if keepAlive is set to true in request options. + */ + dispose() { + if (this._agent) { + this._agent.destroy(); } - return walker; - }; + this._disposed = true; + } /** - * Gets the parent event target for the given event. - * - * @param event - an event + * Raw request. + * @param info + * @param data */ - DocumentImpl.prototype._getTheParent = function (event) { - /** - * TODO: Implement realms - * A document’s get the parent algorithm, given an event, returns null if - * event’s type attribute value is "load" or document does not have a - * browsing context, and the document’s relevant global object otherwise. - */ - if (event._type === "load") { - return null; + requestRaw(info, data) { + return new Promise((resolve, reject) => { + let callbackForResult = function (err, res) { + if (err) { + reject(err); + } + resolve(res); + }; + this.requestRawWithCallback(info, data, callbackForResult); + }); + } + /** + * Raw request with callback. + * @param info + * @param data + * @param onResult + */ + requestRawWithCallback(info, data, onResult) { + let socket; + if (typeof data === 'string') { + info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); + } + let callbackCalled = false; + let handleResult = (err, res) => { + if (!callbackCalled) { + callbackCalled = true; + onResult(err, res); + } + }; + let req = info.httpModule.request(info.options, (msg) => { + let res = new HttpClientResponse(msg); + handleResult(null, res); + }); + req.on('socket', sock => { + socket = sock; + }); + // If we ever get disconnected, we want the socket to timeout eventually + req.setTimeout(this._socketTimeout || 3 * 60000, () => { + if (socket) { + socket.end(); + } + handleResult(new Error('Request timeout: ' + info.options.path), null); + }); + req.on('error', function (err) { + // err has statusCode property + // res should have headers + handleResult(err, null); + }); + if (data && typeof data === 'string') { + req.write(data, 'utf8'); + } + if (data && typeof data !== 'string') { + data.on('close', function () { + req.end(); + }); + data.pipe(req); } else { - return DOMImpl_1.dom.window; + req.end(); } - }; - // MIXIN: NonElementParentNode - /* istanbul ignore next */ - DocumentImpl.prototype.getElementById = function (elementId) { throw new Error("Mixin: NonElementParentNode not implemented."); }; - Object.defineProperty(DocumentImpl.prototype, "children", { - // MIXIN: DocumentOrShadowRoot - // No elements - // MIXIN: ParentNode - /* istanbul ignore next */ - get: function () { throw new Error("Mixin: ParentNode not implemented."); }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "firstElementChild", { - /* istanbul ignore next */ - get: function () { throw new Error("Mixin: ParentNode not implemented."); }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "lastElementChild", { - /* istanbul ignore next */ - get: function () { throw new Error("Mixin: ParentNode not implemented."); }, - enumerable: true, - configurable: true - }); - Object.defineProperty(DocumentImpl.prototype, "childElementCount", { - /* istanbul ignore next */ - get: function () { throw new Error("Mixin: ParentNode not implemented."); }, - enumerable: true, - configurable: true - }); - /* istanbul ignore next */ - DocumentImpl.prototype.prepend = function () { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; + } + /** + * Gets an http agent. This function is useful when you need an http agent that handles + * routing through a proxy server - depending upon the url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ + getAgent(serverUrl) { + let parsedUrl = new URL(serverUrl); + return this._getAgent(parsedUrl); + } + _prepareRequest(method, requestUrl, headers) { + const info = {}; + info.parsedUrl = requestUrl; + const usingSsl = info.parsedUrl.protocol === 'https:'; + info.httpModule = usingSsl ? https : http; + const defaultPort = usingSsl ? 443 : 80; + info.options = {}; + info.options.host = info.parsedUrl.hostname; + info.options.port = info.parsedUrl.port + ? parseInt(info.parsedUrl.port) + : defaultPort; + info.options.path = + (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); + info.options.method = method; + info.options.headers = this._mergeHeaders(headers); + if (this.userAgent != null) { + info.options.headers['user-agent'] = this.userAgent; } - throw new Error("Mixin: ParentNode not implemented."); - }; - /* istanbul ignore next */ - DocumentImpl.prototype.append = function () { - var nodes = []; - for (var _i = 0; _i < arguments.length; _i++) { - nodes[_i] = arguments[_i]; + info.options.agent = this._getAgent(info.parsedUrl); + // gives handlers an opportunity to participate + if (this.handlers) { + this.handlers.forEach(handler => { + handler.prepareRequest(info.options); + }); } - throw new Error("Mixin: ParentNode not implemented."); - }; - /* istanbul ignore next */ - DocumentImpl.prototype.querySelector = function (selectors) { throw new Error("Mixin: ParentNode not implemented."); }; - /* istanbul ignore next */ - DocumentImpl.prototype.querySelectorAll = function (selectors) { throw new Error("Mixin: ParentNode not implemented."); }; - return DocumentImpl; -}(NodeImpl_1.NodeImpl)); -exports.DocumentImpl = DocumentImpl; -/** - * Initialize prototype properties - */ -WebIDLAlgorithm_1.idl_defineConst(DocumentImpl.prototype, "_nodeType", interfaces_1.NodeType.Document); -//# sourceMappingURL=DocumentImpl.js.map - -/***/ }), -/* 489 */, -/* 490 */, -/* 491 */, -/* 492 */, -/* 493 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + return info; } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); + _mergeHeaders(headers) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + if (this.requestOptions && this.requestOptions.headers) { + return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); } - finally { if (e) throw e.error; } + return lowercaseKeys(headers || {}); } - return ar; -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; + _getExistingOrDefaultHeader(additionalHeaders, header, _default) { + const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); + let clientHeader; + if (this.requestOptions && this.requestOptions.headers) { + clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var util_1 = __webpack_require__(918); -var util_2 = __webpack_require__(592); -var ElementImpl_1 = __webpack_require__(695); -var CustomElementAlgorithm_1 = __webpack_require__(344); -var TreeAlgorithm_1 = __webpack_require__(873); -var NamespaceAlgorithm_1 = __webpack_require__(664); -var DOMAlgorithm_1 = __webpack_require__(304); -var ElementAlgorithm_1 = __webpack_require__(33); -var MutationAlgorithm_1 = __webpack_require__(479); -/** - * Returns an element interface for the given name and namespace. - * - * @param name - element name - * @param namespace - namespace - */ -function document_elementInterface(name, namespace) { - return ElementImpl_1.ElementImpl; -} -exports.document_elementInterface = document_elementInterface; -/** - * Creates a new element node. - * See: https://dom.spec.whatwg.org/#internal-createelementns-steps - * - * @param document - owner document - * @param namespace - element namespace - * @param qualifiedName - qualified name - * @param options - element options - */ -function document_internalCreateElementNS(document, namespace, qualifiedName, options) { - /** - * 1. Let namespace, prefix, and localName be the result of passing - * namespace and qualifiedName to validate and extract. - * 2. Let is be null. - * 3. If options is a dictionary and options’s is is present, then set - * is to it. - * 4. Return the result of creating an element given document, localName, - * namespace, prefix, is, and with the synchronous custom elements flag set. - */ - var _a = __read(NamespaceAlgorithm_1.namespace_validateAndExtract(namespace, qualifiedName), 3), ns = _a[0], prefix = _a[1], localName = _a[2]; - var is = null; - if (options !== undefined) { - if (util_2.isString(options)) { - is = options; + return additionalHeaders[header] || clientHeader || _default; + } + _getAgent(parsedUrl) { + let agent; + let proxyUrl = pm.getProxyUrl(parsedUrl); + let useProxy = proxyUrl && proxyUrl.hostname; + if (this._keepAlive && useProxy) { + agent = this._proxyAgent; } - else { - is = options.is; + if (this._keepAlive && !useProxy) { + agent = this._agent; + } + // if agent is already assigned use that agent. + if (!!agent) { + return agent; + } + const usingSsl = parsedUrl.protocol === 'https:'; + let maxSockets = 100; + if (!!this.requestOptions) { + maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; + } + if (useProxy) { + // If using proxy, need tunnel + if (!tunnel) { + tunnel = __webpack_require__(856); + } + const agentOptions = { + maxSockets: maxSockets, + keepAlive: this._keepAlive, + proxy: { + proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`, + host: proxyUrl.hostname, + port: proxyUrl.port + } + }; + let tunnelAgent; + const overHttps = proxyUrl.protocol === 'https:'; + if (usingSsl) { + tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; + } + else { + tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; + } + agent = tunnelAgent(agentOptions); + this._proxyAgent = agent; + } + // if reusing agent across request and tunneling agent isn't assigned create a new agent + if (this._keepAlive && !agent) { + const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; + agent = usingSsl ? new https.Agent(options) : new http.Agent(options); + this._agent = agent; + } + // if not using private agent and tunnel agent isn't setup then use global agent + if (!agent) { + agent = usingSsl ? https.globalAgent : http.globalAgent; + } + if (usingSsl && this._ignoreSslError) { + // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process + // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options + // we have to cast it to any and change it directly + agent.options = Object.assign(agent.options || {}, { + rejectUnauthorized: false + }); } + return agent; } - return ElementAlgorithm_1.element_createAnElement(document, localName, ns, prefix, is, true); -} -exports.document_internalCreateElementNS = document_internalCreateElementNS; -/** - * Removes `node` and its subtree from its document and changes - * its owner document to `document` so that it can be inserted - * into `document`. - * - * @param node - the node to move - * @param document - document to receive the node and its subtree - */ -function document_adopt(node, document) { - var e_1, _a; - // Optimize for common case of inserting a fresh node - if (node._nodeDocument === document && node._parent === null) { - return; + _performExponentialBackoff(retryNumber) { + retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); + const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); + return new Promise(resolve => setTimeout(() => resolve(), ms)); + } + static dateTimeDeserializer(key, value) { + if (typeof value === 'string') { + let a = new Date(value); + if (!isNaN(a.valueOf())) { + return a; + } + } + return value; } - /** - * 1. Let oldDocument be node’s node document. - * 2. If node’s parent is not null, remove node from its parent. - */ - var oldDocument = node._nodeDocument; - if (node._parent) - MutationAlgorithm_1.mutation_remove(node, node._parent); - /** - * 3. If document is not oldDocument, then: - */ - if (document !== oldDocument) { - /** - * 3.1. For each inclusiveDescendant in node’s shadow-including inclusive - * descendants: - */ - var inclusiveDescendant = TreeAlgorithm_1.tree_getFirstDescendantNode(node, true, true); - while (inclusiveDescendant !== null) { - /** - * 3.1.1. Set inclusiveDescendant’s node document to document. - * 3.1.2. If inclusiveDescendant is an element, then set the node - * document of each attribute in inclusiveDescendant’s attribute list - * to document. - */ - inclusiveDescendant._nodeDocument = document; - if (util_1.Guard.isElementNode(inclusiveDescendant)) { - try { - for (var _b = (e_1 = void 0, __values(inclusiveDescendant._attributeList._asArray())), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - attr._nodeDocument = document; + async _processResponse(res, options) { + return new Promise(async (resolve, reject) => { + const statusCode = res.message.statusCode; + const response = { + statusCode: statusCode, + result: null, + headers: {} + }; + // not found leads to null obj returned + if (statusCode == HttpCodes.NotFound) { + resolve(response); + } + let obj; + let contents; + // get the result from the body + try { + contents = await res.readBody(); + if (contents && contents.length > 0) { + if (options && options.deserializeDates) { + obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + else { + obj = JSON.parse(contents); } - finally { if (e_1) throw e_1.error; } + response.result = obj; } + response.headers = res.message.headers; } - /** - * 3.2. For each inclusiveDescendant in node's shadow-including - * inclusive descendants that is custom, enqueue a custom - * element callback reaction with inclusiveDescendant, - * callback name "adoptedCallback", and an argument list - * containing oldDocument and document. - */ - if (DOMImpl_1.dom.features.customElements) { - if (util_1.Guard.isElementNode(inclusiveDescendant) && - inclusiveDescendant._customElementState === "custom") { - CustomElementAlgorithm_1.customElement_enqueueACustomElementCallbackReaction(inclusiveDescendant, "adoptedCallback", [oldDocument, document]); + catch (err) { + // Invalid resource (contents not json); leaving result obj null + } + // note that 3xx redirects are handled by the http layer. + if (statusCode > 299) { + let msg; + // if exception/error in body, attempt to get better error + if (obj && obj.message) { + msg = obj.message; + } + else if (contents && contents.length > 0) { + // it may be the case that the exception is in the body message as string + msg = contents; + } + else { + msg = 'Failed request: (' + statusCode + ')'; } + let err = new HttpClientError(msg, statusCode); + err.result = response.result; + reject(err); } - /** - * 3.3. For each inclusiveDescendant in node’s shadow-including - * inclusive descendants, in shadow-including tree order, run the - * adopting steps with inclusiveDescendant and oldDocument. - */ - if (DOMImpl_1.dom.features.steps) { - DOMAlgorithm_1.dom_runAdoptingSteps(inclusiveDescendant, oldDocument); + else { + resolve(response); } - inclusiveDescendant = TreeAlgorithm_1.tree_getNextDescendantNode(node, inclusiveDescendant, true, true); - } - } -} -exports.document_adopt = document_adopt; -//# sourceMappingURL=DocumentAlgorithm.js.map - -/***/ }), -/* 494 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -var rng = __webpack_require__(58); -var bytesToUuid = __webpack_require__(722); - -function v4(options, buf, offset) { - var i = buf && offset || 0; - - if (typeof(options) == 'string') { - buf = options === 'binary' ? new Array(16) : null; - options = null; - } - options = options || {}; - - var rnds = options.random || (options.rng || rng)(); - - // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` - rnds[6] = (rnds[6] & 0x0f) | 0x40; - rnds[8] = (rnds[8] & 0x3f) | 0x80; - - // Copy bytes to buffer, if provided - if (buf) { - for (var ii = 0; ii < 16; ++ii) { - buf[i + ii] = rnds[ii]; + }); } - } - - return buf || bytesToUuid(rnds); } +exports.HttpClient = HttpClient; -module.exports = v4; - - -/***/ }), -/* 495 */ -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Defines a WebIDL `Const` property on the given object. - * - * @param o - object on which to add the property - * @param name - property name - * @param value - property value - */ -function idl_defineConst(o, name, value) { - Object.defineProperty(o, name, { writable: false, enumerable: true, configurable: false, value: value }); -} -exports.idl_defineConst = idl_defineConst; -//# sourceMappingURL=WebIDLAlgorithm.js.map /***/ }), -/* 496 */ +/* 540 */, +/* 541 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [op[0] & 2, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); @@ -22308,2043 +23473,2163 @@ var __values = (this && this.__values) || function(o) { }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; -var __spread = (this && this.__spread) || function () { - for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); - return ar; -}; Object.defineProperty(exports, "__esModule", { value: true }); -var util_1 = __webpack_require__(592); -/** - * Adds the given item to the end of the set. - * - * @param set - a set - * @param item - an item - */ -function append(set, item) { - set.add(item); -} -exports.append = append; -/** - * Extends a set by appending all items from another set. - * - * @param setA - a list to extend - * @param setB - a list containing items to append to `setA` - */ -function extend(setA, setB) { - setB.forEach(setA.add, setA); -} -exports.extend = extend; +var DOMImpl_1 = __webpack_require__(648); +var util_1 = __webpack_require__(918); +var infra_1 = __webpack_require__(23); +var CreateAlgorithm_1 = __webpack_require__(86); +var OrderedSetAlgorithm_1 = __webpack_require__(146); +var DOMAlgorithm_1 = __webpack_require__(304); +var MutationAlgorithm_1 = __webpack_require__(479); +var ElementAlgorithm_1 = __webpack_require__(33); /** - * Inserts the given item to the start of the set. + * Replaces the contents of the given node with a single text node. * - * @param set - a set - * @param item - an item + * @param string - node contents + * @param parent - a node */ -function prepend(set, item) { - var cloned = new Set(set); - set.clear(); - set.add(item); - cloned.forEach(set.add, set); +function node_stringReplaceAll(str, parent) { + /** + * 1. Let node be null. + * 2. If string is not the empty string, then set node to a new Text node + * whose data is string and node document is parent’s node document. + * 3. Replace all with node within parent. + */ + var node = null; + if (str !== '') { + node = CreateAlgorithm_1.create_text(parent._nodeDocument, str); + } + MutationAlgorithm_1.mutation_replaceAll(node, parent); } -exports.prepend = prepend; +exports.node_stringReplaceAll = node_stringReplaceAll; /** - * Replaces the given item or all items matching condition with a new item. + * Clones a node. * - * @param set - a set - * @param conditionOrItem - an item to replace or a condition matching items - * to replace - * @param item - an item + * @param node - a node to clone + * @param document - the document to own the cloned node + * @param cloneChildrenFlag - whether to clone node's children */ -function replace(set, conditionOrItem, newItem) { - var e_1, _a; - var newSet = new Set(); - try { - for (var set_1 = __values(set), set_1_1 = set_1.next(); !set_1_1.done; set_1_1 = set_1.next()) { - var oldItem = set_1_1.value; - if (util_1.isFunction(conditionOrItem)) { - if (!!conditionOrItem.call(null, oldItem)) { - newSet.add(newItem); - } - else { - newSet.add(oldItem); - } - } - else if (oldItem === conditionOrItem) { - newSet.add(newItem); +function node_clone(node, document, cloneChildrenFlag) { + var e_1, _a, e_2, _b; + if (document === void 0) { document = null; } + if (cloneChildrenFlag === void 0) { cloneChildrenFlag = false; } + /** + * 1. If document is not given, let document be node’s node document. + */ + if (document === null) + document = node._nodeDocument; + var copy; + if (util_1.Guard.isElementNode(node)) { + /** + * 2. If node is an element, then: + * 2.1. Let copy be the result of creating an element, given document, + * node’s local name, node’s namespace, node’s namespace prefix, + * and node’s is value, with the synchronous custom elements flag unset. + * 2.2. For each attribute in node’s attribute list: + * 2.2.1. Let copyAttribute be a clone of attribute. + * 2.2.2. Append copyAttribute to copy. + */ + copy = ElementAlgorithm_1.element_createAnElement(document, node._localName, node._namespace, node._namespacePrefix, node._is, false); + try { + for (var _c = __values(node._attributeList), _d = _c.next(); !_d.done; _d = _c.next()) { + var attribute = _d.value; + var copyAttribute = node_clone(attribute, document); + ElementAlgorithm_1.element_append(copyAttribute, copy); } - else { - newSet.add(oldItem); + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); } + finally { if (e_1) throw e_1.error; } } } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (set_1_1 && !set_1_1.done && (_a = set_1.return)) _a.call(set_1); + else { + /** + * 3. Otherwise, let copy be a node that implements the same interfaces as + * node, and fulfills these additional requirements, switching on node: + * - Document + * Set copy’s encoding, content type, URL, origin, type, and mode, to those + * of node. + * - DocumentType + * Set copy’s name, public ID, and system ID, to those of node. + * - Attr + * Set copy’s namespace, namespace prefix, local name, and value, to + * those of node. + * - Text + * - Comment + * Set copy’s data, to that of node. + * - ProcessingInstruction + * Set copy’s target and data to those of node. + * - Any other node + */ + if (util_1.Guard.isDocumentNode(node)) { + var doc = CreateAlgorithm_1.create_document(); + doc._encoding = node._encoding; + doc._contentType = node._contentType; + doc._URL = node._URL; + doc._origin = node._origin; + doc._type = node._type; + doc._mode = node._mode; + copy = doc; } - finally { if (e_1) throw e_1.error; } - } - set.clear(); - newSet.forEach(set.add, set); -} -exports.replace = replace; -/** - * Inserts the given item before the given index. - * - * @param set - a set - * @param item - an item - */ -function insert(set, item, index) { - var e_2, _a; - var newSet = new Set(); - var i = 0; - try { - for (var set_2 = __values(set), set_2_1 = set_2.next(); !set_2_1.done; set_2_1 = set_2.next()) { - var oldItem = set_2_1.value; - if (i === index) - newSet.add(item); - newSet.add(oldItem); - i++; + else if (util_1.Guard.isDocumentTypeNode(node)) { + var doctype = CreateAlgorithm_1.create_documentType(document, node._name, node._publicId, node._systemId); + copy = doctype; + } + else if (util_1.Guard.isAttrNode(node)) { + var attr = CreateAlgorithm_1.create_attr(document, node.localName); + attr._namespace = node._namespace; + attr._namespacePrefix = node._namespacePrefix; + attr._value = node._value; + copy = attr; + } + else if (util_1.Guard.isExclusiveTextNode(node)) { + copy = CreateAlgorithm_1.create_text(document, node._data); + } + else if (util_1.Guard.isCDATASectionNode(node)) { + copy = CreateAlgorithm_1.create_cdataSection(document, node._data); + } + else if (util_1.Guard.isCommentNode(node)) { + copy = CreateAlgorithm_1.create_comment(document, node._data); + } + else if (util_1.Guard.isProcessingInstructionNode(node)) { + copy = CreateAlgorithm_1.create_processingInstruction(document, node._target, node._data); + } + else if (util_1.Guard.isDocumentFragmentNode(node)) { + copy = CreateAlgorithm_1.create_documentFragment(document); + } + else { + copy = Object.create(node); } } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { + /** + * 4. Set copy’s node document and document to copy, if copy is a document, + * and set copy’s node document to document otherwise. + */ + if (util_1.Guard.isDocumentNode(copy)) { + copy._nodeDocument = copy; + document = copy; + } + else { + copy._nodeDocument = document; + } + /** + * 5. Run any cloning steps defined for node in other applicable + * specifications and pass copy, node, document and the clone children flag + * if set, as parameters. + */ + if (DOMImpl_1.dom.features.steps) { + DOMAlgorithm_1.dom_runCloningSteps(copy, node, document, cloneChildrenFlag); + } + /** + * 6. If the clone children flag is set, clone all the children of node and + * append them to copy, with document as specified and the clone children + * flag being set. + */ + if (cloneChildrenFlag) { try { - if (set_2_1 && !set_2_1.done && (_a = set_2.return)) _a.call(set_2); + for (var _e = __values(node._children), _f = _e.next(); !_f.done; _f = _e.next()) { + var child = _f.value; + var childCopy = node_clone(child, document, true); + MutationAlgorithm_1.mutation_append(childCopy, copy); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_f && !_f.done && (_b = _e.return)) _b.call(_e); + } + finally { if (e_2) throw e_2.error; } } - finally { if (e_2) throw e_2.error; } } - set.clear(); - newSet.forEach(set.add, set); + /** + * 7. Return copy. + */ + return copy; } -exports.insert = insert; +exports.node_clone = node_clone; /** - * Removes the given item or all items matching condition. + * Determines if two nodes can be considered equal. * - * @param set - a set - * @param conditionOrItem - an item to remove or a condition matching items - * to remove + * @param a - node to compare + * @param b - node to compare */ -function remove(set, conditionOrItem) { +function node_equals(a, b) { var e_3, _a, e_4, _b; - if (!util_1.isFunction(conditionOrItem)) { - set.delete(conditionOrItem); + /** + * 1. A and B’s nodeType attribute value is identical. + */ + if (a._nodeType !== b._nodeType) + return false; + /** + * 2. The following are also equal, depending on A: + * - DocumentType + * Its name, public ID, and system ID. + * - Element + * Its namespace, namespace prefix, local name, and its attribute list’s size. + * - Attr + * Its namespace, local name, and value. + * - ProcessingInstruction + * Its target and data. + * - Text + * - Comment + * Its data. + */ + if (util_1.Guard.isDocumentTypeNode(a) && util_1.Guard.isDocumentTypeNode(b)) { + if (a._name !== b._name || a._publicId !== b._publicId || + a._systemId !== b._systemId) + return false; } - else { - var toRemove = []; + else if (util_1.Guard.isElementNode(a) && util_1.Guard.isElementNode(b)) { + if (a._namespace !== b._namespace || a._namespacePrefix !== b._namespacePrefix || + a._localName !== b._localName || + a._attributeList.length !== b._attributeList.length) + return false; + } + else if (util_1.Guard.isAttrNode(a) && util_1.Guard.isAttrNode(b)) { + if (a._namespace !== b._namespace || a._localName !== b._localName || + a._value !== b._value) + return false; + } + else if (util_1.Guard.isProcessingInstructionNode(a) && util_1.Guard.isProcessingInstructionNode(b)) { + if (a._target !== b._target || a._data !== b._data) + return false; + } + else if (util_1.Guard.isCharacterDataNode(a) && util_1.Guard.isCharacterDataNode(b)) { + if (a._data !== b._data) + return false; + } + /** + * 3. If A is an element, each attribute in its attribute list has an attribute + * that equals an attribute in B’s attribute list. + */ + if (util_1.Guard.isElementNode(a) && util_1.Guard.isElementNode(b)) { + var attrMap = {}; try { - for (var set_3 = __values(set), set_3_1 = set_3.next(); !set_3_1.done; set_3_1 = set_3.next()) { - var item = set_3_1.value; - if (!!conditionOrItem.call(null, item)) { - toRemove.push(item); - } + for (var _c = __values(a._attributeList), _d = _c.next(); !_d.done; _d = _c.next()) { + var attrA = _d.value; + attrMap[attrA._localName] = attrA; } } catch (e_3_1) { e_3 = { error: e_3_1 }; } finally { try { - if (set_3_1 && !set_3_1.done && (_a = set_3.return)) _a.call(set_3); + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); } finally { if (e_3) throw e_3.error; } } try { - for (var toRemove_1 = __values(toRemove), toRemove_1_1 = toRemove_1.next(); !toRemove_1_1.done; toRemove_1_1 = toRemove_1.next()) { - var oldItem = toRemove_1_1.value; - set.delete(oldItem); + for (var _e = __values(b._attributeList), _f = _e.next(); !_f.done; _f = _e.next()) { + var attrB = _f.value; + var attrA = attrMap[attrB._localName]; + if (!attrA) + return false; + if (!node_equals(attrA, attrB)) + return false; } } catch (e_4_1) { e_4 = { error: e_4_1 }; } finally { try { - if (toRemove_1_1 && !toRemove_1_1.done && (_b = toRemove_1.return)) _b.call(toRemove_1); + if (_f && !_f.done && (_b = _e.return)) _b.call(_e); } finally { if (e_4) throw e_4.error; } } } + /** + * 4. A and B have the same number of children. + * 5. Each child of A equals the child of B at the identical index. + */ + if (a._children.size !== b._children.size) + return false; + var itA = a._children[Symbol.iterator](); + var itB = b._children[Symbol.iterator](); + var resultA = itA.next(); + var resultB = itB.next(); + while (!resultA.done && !resultB.done) { + var child1 = resultA.value; + var child2 = resultB.value; + if (!node_equals(child1, child2)) + return false; + resultA = itA.next(); + resultB = itB.next(); + } + return true; } -exports.remove = remove; +exports.node_equals = node_equals; /** - * Removes all items from the set. + * Returns a collection of elements with the given qualified name which are + * descendants of the given root node. + * See: https://dom.spec.whatwg.org/#concept-getelementsbytagname + * + * @param qualifiedName - qualified name + * @param root - root node */ -function empty(set) { - set.clear(); +function node_listOfElementsWithQualifiedName(qualifiedName, root) { + /** + * 1. If qualifiedName is "*" (U+002A), return a HTMLCollection rooted at + * root, whose filter matches only descendant elements. + * 2. Otherwise, if root’s node document is an HTML document, return a + * HTMLCollection rooted at root, whose filter matches the following + * descendant elements: + * 2.1. Whose namespace is the HTML namespace and whose qualified name is + * qualifiedName, in ASCII lowercase. + * 2.2. Whose namespace is not the HTML namespace and whose qualified name + * is qualifiedName. + * 3. Otherwise, return a HTMLCollection rooted at root, whose filter + * matches descendant elements whose qualified name is qualifiedName. + */ + if (qualifiedName === "*") { + return CreateAlgorithm_1.create_htmlCollection(root); + } + else if (root._nodeDocument._type === "html") { + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + if (ele._namespace === infra_1.namespace.HTML && + ele._qualifiedName === qualifiedName.toLowerCase()) { + return true; + } + else if (ele._namespace !== infra_1.namespace.HTML && + ele._qualifiedName === qualifiedName) { + return true; + } + else { + return false; + } + }); + } + else { + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + return (ele._qualifiedName === qualifiedName); + }); + } } -exports.empty = empty; +exports.node_listOfElementsWithQualifiedName = node_listOfElementsWithQualifiedName; /** - * Determines if the set contains the given item or any items matching - * condition. + * Returns a collection of elements with the given namespace which are + * descendants of the given root node. + * See: https://dom.spec.whatwg.org/#concept-getelementsbytagnamens * - * @param set - a set - * @param conditionOrItem - an item to a condition to match + * @param namespace - element namespace + * @param localName - local name + * @param root - root node */ -function contains(set, conditionOrItem) { - var e_5, _a; - if (!util_1.isFunction(conditionOrItem)) { - return set.has(conditionOrItem); +function node_listOfElementsWithNamespace(namespace, localName, root) { + /** + * 1. If namespace is the empty string, set it to null. + * 2. If both namespace and localName are "*" (U+002A), return a + * HTMLCollection rooted at root, whose filter matches descendant elements. + * 3. Otherwise, if namespace is "*" (U+002A), return a HTMLCollection + * rooted at root, whose filter matches descendant elements whose local + * name is localName. + * 4. Otherwise, if localName is "*" (U+002A), return a HTMLCollection + * rooted at root, whose filter matches descendant elements whose + * namespace is namespace. + * 5. Otherwise, return a HTMLCollection rooted at root, whose filter + * matches descendant elements whose namespace is namespace and local + * name is localName. + */ + if (namespace === '') + namespace = null; + if (namespace === "*" && localName === "*") { + return CreateAlgorithm_1.create_htmlCollection(root); + } + else if (namespace === "*") { + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + return (ele._localName === localName); + }); + } + else if (localName === "*") { + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + return (ele._namespace === namespace); + }); } else { - try { - for (var set_4 = __values(set), set_4_1 = set_4.next(); !set_4_1.done; set_4_1 = set_4.next()) { - var oldItem = set_4_1.value; - if (!!conditionOrItem.call(null, oldItem)) { - return true; - } - } + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + return (ele._localName === localName && ele._namespace === namespace); + }); + } +} +exports.node_listOfElementsWithNamespace = node_listOfElementsWithNamespace; +/** + * Returns a collection of elements with the given class names which are + * descendants of the given root node. + * See: https://dom.spec.whatwg.org/#concept-getelementsbyclassname + * + * @param namespace - element namespace + * @param localName - local name + * @param root - root node + */ +function node_listOfElementsWithClassNames(classNames, root) { + /** + * 1. Let classes be the result of running the ordered set parser + * on classNames. + * 2. If classes is the empty set, return an empty HTMLCollection. + * 3. Return a HTMLCollection rooted at root, whose filter matches + * descendant elements that have all their classes in classes. + * The comparisons for the classes must be done in an ASCII case-insensitive + * manner if root’s node document’s mode is "quirks", and in a + * case-sensitive manner otherwise. + */ + var classes = OrderedSetAlgorithm_1.orderedSet_parse(classNames); + if (classes.size === 0) { + return CreateAlgorithm_1.create_htmlCollection(root, function () { return false; }); + } + var caseSensitive = (root._nodeDocument._mode !== "quirks"); + return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { + var eleClasses = ele.classList; + return OrderedSetAlgorithm_1.orderedSet_contains(eleClasses._tokenSet, classes, caseSensitive); + }); +} +exports.node_listOfElementsWithClassNames = node_listOfElementsWithClassNames; +/** + * Searches for a namespace prefix associated with the given namespace + * starting from the given element through its ancestors. + * + * @param element - an element node to start searching at + * @param namespace - namespace to search for + */ +function node_locateANamespacePrefix(element, namespace) { + /** + * 1. If element’s namespace is namespace and its namespace prefix is not + * null, then return its namespace prefix. + */ + if (element._namespace === namespace && element._namespacePrefix !== null) { + return element._namespacePrefix; + } + /** + * 2. If element has an attribute whose namespace prefix is "xmlns" and + * value is namespace, then return element’s first such attribute’s + * local name. + */ + for (var i = 0; i < element._attributeList.length; i++) { + var attr = element._attributeList[i]; + if (attr._namespacePrefix === "xmlns" && attr._value === namespace) { + return attr._localName; } - catch (e_5_1) { e_5 = { error: e_5_1 }; } - finally { - try { - if (set_4_1 && !set_4_1.done && (_a = set_4.return)) _a.call(set_4); + } + /** + * 3. If element’s parent element is not null, then return the result of + * running locate a namespace prefix on that element using namespace. + */ + if (element._parent && util_1.Guard.isElementNode(element._parent)) { + return node_locateANamespacePrefix(element._parent, namespace); + } + /** + * 4. Return null. + */ + return null; +} +exports.node_locateANamespacePrefix = node_locateANamespacePrefix; +/** + * Searches for a namespace associated with the given namespace prefix + * starting from the given node through its ancestors. + * + * @param node - a node to start searching at + * @param prefix - namespace prefix to search for + */ +function node_locateANamespace(node, prefix) { + if (util_1.Guard.isElementNode(node)) { + /** + * 1. If its namespace is not null and its namespace prefix is prefix, + * then return namespace. + */ + if (node._namespace !== null && node._namespacePrefix === prefix) { + return node._namespace; + } + /** + * 2. If it has an attribute whose namespace is the XMLNS namespace, + * namespace prefix is "xmlns", and local name is prefix, or if prefix + * is null and it has an attribute whose namespace is the XMLNS namespace, + * namespace prefix is null, and local name is "xmlns", then return its + * value if it is not the empty string, and null otherwise. + */ + for (var i = 0; i < node._attributeList.length; i++) { + var attr = node._attributeList[i]; + if (attr._namespace === infra_1.namespace.XMLNS && + attr._namespacePrefix === "xmlns" && + attr._localName === prefix) { + return attr._value || null; + } + if (prefix === null && attr._namespace === infra_1.namespace.XMLNS && + attr._namespacePrefix === null && attr._localName === "xmlns") { + return attr._value || null; } - finally { if (e_5) throw e_5.error; } } + /** + * 3. If its parent element is null, then return null. + */ + if (node.parentElement === null) + return null; + /** + * 4. Return the result of running locate a namespace on its parent + * element using prefix. + */ + return node_locateANamespace(node.parentElement, prefix); } - return false; + else if (util_1.Guard.isDocumentNode(node)) { + /** + * 1. If its document element is null, then return null. + * 2. Return the result of running locate a namespace on its document + * element using prefix. + */ + if (node.documentElement === null) + return null; + return node_locateANamespace(node.documentElement, prefix); + } + else if (util_1.Guard.isDocumentTypeNode(node) || util_1.Guard.isDocumentFragmentNode(node)) { + return null; + } + else if (util_1.Guard.isAttrNode(node)) { + /** + * 1. If its element is null, then return null. + * 2. Return the result of running locate a namespace on its element + * using prefix. + */ + if (node._element === null) + return null; + return node_locateANamespace(node._element, prefix); + } + else { + /** + * 1. If its parent element is null, then return null. + * 2. Return the result of running locate a namespace on its parent + * element using prefix. + */ + if (!node._parent || !util_1.Guard.isElementNode(node._parent)) + return null; + return node_locateANamespace(node._parent, prefix); + } +} +exports.node_locateANamespace = node_locateANamespace; +//# sourceMappingURL=NodeAlgorithm.js.map + +/***/ }), +/* 542 */, +/* 543 */, +/* 544 */, +/* 545 */, +/* 546 */, +/* 547 */, +/* 548 */ +/***/ (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 + + +/***/ }), +/* 549 */, +/* 550 */ +/***/ (function(module, exports) { + +exports = module.exports = SemVer + +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 () {} +} + +// 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' + +var MAX_LENGTH = 256 +var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || + /* istanbul ignore next */ 9007199254740991 + +// Max safe segment length for coercion. +var MAX_SAFE_COMPONENT_LENGTH = 16 + +// The actual regexps go on exports.re +var re = exports.re = [] +var src = exports.src = [] +var t = exports.tokens = {} +var R = 0 + +function tok (n) { + t[n] = R++ +} + +// 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. + +tok('NUMERICIDENTIFIER') +src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*' +tok('NUMERICIDENTIFIERLOOSE') +src[t.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. + +tok('NONNUMERICIDENTIFIER') +src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*' + +// ## Main Version +// Three dot-separated numeric identifiers. + +tok('MAINVERSION') +src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIER] + ')' + +tok('MAINVERSIONLOOSE') +src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' + + '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')' + +// ## Pre-release Version Identifier +// A numeric identifier, or a non-numeric identifier. + +tok('PRERELEASEIDENTIFIER') +src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' + +tok('PRERELEASEIDENTIFIERLOOSE') +src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] + + '|' + src[t.NONNUMERICIDENTIFIER] + ')' + +// ## Pre-release Version +// Hyphen, followed by one or more dot-separated pre-release version +// identifiers. + +tok('PRERELEASE') +src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))' + +tok('PRERELEASELOOSE') +src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] + + '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))' + +// ## Build Metadata Identifier +// Any combination of digits, letters, or hyphens. + +tok('BUILDIDENTIFIER') +src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+' + +// ## Build Metadata +// Plus sign, followed by one or more period-separated build metadata +// identifiers. + +tok('BUILD') +src[t.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. + +tok('FULL') +tok('FULLPLAIN') +src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] + + src[t.PRERELEASE] + '?' + + src[t.BUILD] + '?' + +src[t.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. +tok('LOOSEPLAIN') +src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] + + src[t.PRERELEASELOOSE] + '?' + + src[t.BUILD] + '?' + +tok('LOOSE') +src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$' + +tok('GTLT') +src[t.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. +tok('XRANGEIDENTIFIERLOOSE') +src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*' +tok('XRANGEIDENTIFIER') +src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*' + +tok('XRANGEPLAIN') +src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' + + '(?:' + src[t.PRERELEASE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' + +tok('XRANGEPLAINLOOSE') +src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' + + '(?:' + src[t.PRERELEASELOOSE] + ')?' + + src[t.BUILD] + '?' + + ')?)?' + +tok('XRANGE') +src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$' +tok('XRANGELOOSE') +src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$' + +// 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') + +// Tilde ranges. +// Meaning is "reasonably at or greater than" +tok('LONETILDE') +src[t.LONETILDE] = '(?:~>?)' + +tok('TILDETRIM') +src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+' +re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g') +var tildeTrimReplace = '$1~' + +tok('TILDE') +src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$' +tok('TILDELOOSE') +src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$' + +// Caret ranges. +// Meaning is "at least and backwards compatible with" +tok('LONECARET') +src[t.LONECARET] = '(?:\\^)' + +tok('CARETTRIM') +src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+' +re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g') +var caretTrimReplace = '$1^' + +tok('CARET') +src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$' +tok('CARETLOOSE') +src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$' + +// 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] + ')$|^$' + +// 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] + ')' + +// this one has to use the /g flag +re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g') +var 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. +tok('HYPHENRANGE') +src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAIN] + ')' + + '\\s*$' + +tok('HYPHENRANGELOOSE') +src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s+-\\s+' + + '(' + src[t.XRANGEPLAINLOOSE] + ')' + + '\\s*$' + +// Star ranges basically just allow anything at all. +tok('STAR') +src[t.STAR] = '(<|>)?=?\\s*\\*' + +// 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]) + } } -exports.contains = contains; -/** - * Returns the count of items in the set matching the given condition. - * - * @param set - a set - * @param condition - an optional condition to match - */ -function size(set, condition) { - var e_6, _a; - if (condition === undefined) { - return set.size; - } - else { - var count = 0; - try { - for (var set_5 = __values(set), set_5_1 = set_5.next(); !set_5_1.done; set_5_1 = set_5.next()) { - var item = set_5_1.value; - if (!!condition.call(null, item)) { - count++; - } - } - } - catch (e_6_1) { e_6 = { error: e_6_1 }; } - finally { - try { - if (set_5_1 && !set_5_1.done && (_a = set_5.return)) _a.call(set_5); - } - finally { if (e_6) throw e_6.error; } - } - return count; + +exports.parse = parse +function 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 + } + + var 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 + } } -exports.size = size; -/** - * Determines if the set is empty. - * - * @param set - a set - */ -function isEmpty(set) { - return set.size === 0; -} -exports.isEmpty = isEmpty; -/** - * Returns an iterator for the items of the set. - * - * @param set - a set - * @param condition - an optional condition to match - */ -function forEach(set, condition) { - var set_6, set_6_1, item, e_7_1; - var e_7, _a; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - if (!(condition === undefined)) return [3 /*break*/, 2]; - return [5 /*yield**/, __values(set)]; - case 1: - _b.sent(); - return [3 /*break*/, 9]; - case 2: - _b.trys.push([2, 7, 8, 9]); - set_6 = __values(set), set_6_1 = set_6.next(); - _b.label = 3; - case 3: - if (!!set_6_1.done) return [3 /*break*/, 6]; - item = set_6_1.value; - if (!!!condition.call(null, item)) return [3 /*break*/, 5]; - return [4 /*yield*/, item]; - case 4: - _b.sent(); - _b.label = 5; - case 5: - set_6_1 = set_6.next(); - return [3 /*break*/, 3]; - case 6: return [3 /*break*/, 9]; - case 7: - e_7_1 = _b.sent(); - e_7 = { error: e_7_1 }; - return [3 /*break*/, 9]; - case 8: - try { - if (set_6_1 && !set_6_1.done && (_a = set_6.return)) _a.call(set_6); - } - finally { if (e_7) throw e_7.error; } - return [7 /*endfinally*/]; - case 9: return [2 /*return*/]; - } - }); -} -exports.forEach = forEach; -/** - * Creates and returns a shallow clone of set. - * - * @param set - a set - */ -function clone(set) { - return new Set(set); -} -exports.clone = clone; -/** - * Returns a new set containing items from the set sorted in ascending - * order. - * - * @param set - a set - * @param lessThanAlgo - a function that returns `true` if its first argument - * is less than its second argument, and `false` otherwise. - */ -function sortInAscendingOrder(set, lessThanAlgo) { - var list = new (Array.bind.apply(Array, __spread([void 0], set)))(); - list.sort(function (itemA, itemB) { - return lessThanAlgo.call(null, itemA, itemB) ? -1 : 1; - }); - return new Set(list); -} -exports.sortInAscendingOrder = sortInAscendingOrder; -/** - * Returns a new set containing items from the set sorted in descending - * order. - * - * @param set - a set - * @param lessThanAlgo - a function that returns `true` if its first argument - * is less than its second argument, and `false` otherwise. - */ -function sortInDescendingOrder(set, lessThanAlgo) { - var list = new (Array.bind.apply(Array, __spread([void 0], set)))(); - list.sort(function (itemA, itemB) { - return lessThanAlgo.call(null, itemA, itemB) ? 1 : -1; - }); - return new Set(list); -} -exports.sortInDescendingOrder = sortInDescendingOrder; -/** - * Determines if a set is a subset of another set. - * - * @param subset - a set - * @param superset - a superset possibly containing all items from `subset`. - */ -function isSubsetOf(subset, superset) { - var e_8, _a; - try { - for (var subset_1 = __values(subset), subset_1_1 = subset_1.next(); !subset_1_1.done; subset_1_1 = subset_1.next()) { - var item = subset_1_1.value; - if (!superset.has(item)) - return false; - } - } - catch (e_8_1) { e_8 = { error: e_8_1 }; } - finally { - try { - if (subset_1_1 && !subset_1_1.done && (_a = subset_1.return)) _a.call(subset_1); - } - finally { if (e_8) throw e_8.error; } - } - return true; + +exports.valid = valid +function valid (version, options) { + var v = parse(version, options) + return v ? v.version : null } -exports.isSubsetOf = isSubsetOf; -/** - * Determines if a set is a superset of another set. - * - * @param superset - a set - * @param subset - a subset possibly contained within `superset`. - */ -function isSupersetOf(superset, subset) { - return isSubsetOf(subset, superset); + +exports.clean = clean +function clean (version, options) { + var s = parse(version.trim().replace(/^[=v]+/, ''), options) + return s ? s.version : null } -exports.isSupersetOf = isSupersetOf; -/** - * Returns a new set with items that are contained in both sets. - * - * @param setA - a set - * @param setB - a set - */ -function intersection(setA, setB) { - var e_9, _a; - var newSet = new Set(); - try { - for (var setA_1 = __values(setA), setA_1_1 = setA_1.next(); !setA_1_1.done; setA_1_1 = setA_1.next()) { - var item = setA_1_1.value; - if (setB.has(item)) - newSet.add(item); - } - } - catch (e_9_1) { e_9 = { error: e_9_1 }; } - finally { - try { - if (setA_1_1 && !setA_1_1.done && (_a = setA_1.return)) _a.call(setA_1); - } - finally { if (e_9) throw e_9.error; } + +exports.SemVer = SemVer + +function SemVer (version, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } - return newSet; -} -exports.intersection = intersection; -/** - * Returns a new set with items from both sets. - * - * @param setA - a set - * @param setB - a set - */ -function union(setA, setB) { - var newSet = new Set(setA); - setB.forEach(newSet.add, newSet); - return newSet; -} -exports.union = union; -/** - * Returns a set of integers from `n` to `m` inclusive. - * - * @param n - starting number - * @param m - ending number - */ -function range(n, m) { - var newSet = new Set(); - for (var i = n; i <= m; i++) { - newSet.add(i); + } + if (version instanceof SemVer) { + if (version.loose === options.loose) { + return version + } else { + version = version.version } - return newSet; -} -exports.range = range; -//# sourceMappingURL=Set.js.map + } else if (typeof version !== 'string') { + throw new TypeError('Invalid Version: ' + version) + } -/***/ }), -/* 497 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { + if (version.length > MAX_LENGTH) { + throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters') + } -"use strict"; + if (!(this instanceof SemVer)) { + return new SemVer(version, options) + } -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var BaseCBWriter_1 = __webpack_require__(512); -/** - * Serializes XML nodes. - */ -var YAMLCBWriter = /** @class */ (function (_super) { - __extends(YAMLCBWriter, _super); - /** - * Initializes a new instance of `BaseCBWriter`. - * - * @param builderOptions - XML builder options - */ - function YAMLCBWriter(builderOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._rootWritten = false; - _this._additionalLevel = 0; - if (builderOptions.indent.length < 2) { - throw new Error("YAML indententation string must be at least two characters long."); - } - if (builderOptions.offset < 0) { - throw new Error("YAML offset should be zero or a positive number."); - } - return _this; - } - /** @inheritdoc */ - YAMLCBWriter.prototype.frontMatter = function () { - return this._beginLine() + "---"; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.declaration = function (version, encoding, standalone) { - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.docType = function (name, publicId, systemId) { - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.comment = function (data) { - // "!": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.comment) + " " + - this._val(data); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.text = function (data) { - // "#": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.text) + " " + - this._val(data); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.instruction = function (target, data) { - // "?": "target hello" - return this._beginLine() + - this._key(this._builderOptions.convert.ins) + " " + - this._val(data ? target + " " + data : target); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.cdata = function (data) { - // "$": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.cdata) + " " + - this._val(data); - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.attribute = function (name, value) { - // "@name": "val" - this._additionalLevel++; - var str = this._beginLine() + - this._key(this._builderOptions.convert.att + name) + " " + - this._val(value); - this._additionalLevel--; - return str; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.openTagBegin = function (name) { - // "node": - // "#": - // - - var str = this._beginLine() + this._key(name); - if (!this._rootWritten) { - this._rootWritten = true; - } - this.hasData = true; - this._additionalLevel++; - str += this._beginLine(true) + this._key(this._builderOptions.convert.text); - return str; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (selfClosing) { - return " " + this._val(""); - } - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.closeTag = function (name) { - this._additionalLevel--; - return ""; - }; - /** @inheritdoc */ - YAMLCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - YAMLCBWriter.prototype.endElement = function (name) { }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - YAMLCBWriter.prototype._beginLine = function (suppressArray) { - if (suppressArray === void 0) { suppressArray = false; } - return (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level, suppressArray); - }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - * @param suppressArray - whether the suppress array marker - */ - YAMLCBWriter.prototype._indent = function (level, suppressArray) { - if (level + this._additionalLevel <= 0) { - return ""; - } - else { - var chars = this._writerOptions.indent.repeat(level + this._additionalLevel); - if (!suppressArray && this._rootWritten) { - return chars.substr(0, chars.length - 2) + '-' + chars.substr(-1, 1); - } - return chars; + debug('SemVer', version, options) + this.options = options + this.loose = !!options.loose + + var 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(function (id) { + if (/^[0-9]+$/.test(id)) { + var num = +id + if (num >= 0 && num < MAX_SAFE_INTEGER) { + return num } - }; - /** - * Produces a YAML key string delimited with double quotes. - */ - YAMLCBWriter.prototype._key = function (key) { - return "\"" + key + "\":"; - }; - /** - * Produces a YAML value string delimited with double quotes. - */ - YAMLCBWriter.prototype._val = function (val) { - return JSON.stringify(val); - }; - return YAMLCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.YAMLCBWriter = YAMLCBWriter; -//# sourceMappingURL=YAMLCBWriter.js.map + } + return id + }) + } -/***/ }), -/* 498 */, -/* 499 */, -/* 500 */, -/* 501 */ -/***/ (function(__unusedmodule, exports) { + this.build = m[5] ? m[5].split('.') : [] + this.format() +} -"use strict"; +SemVer.prototype.format = function () { + this.version = this.major + '.' + this.minor + '.' + this.patch + if (this.prerelease.length) { + this.version += '-' + this.prerelease.join('.') + } + return this.version +} -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Appends the given item to the queue. - * - * @param list - a list - * @param item - an item - */ -function enqueue(list, item) { - list.push(item); +SemVer.prototype.toString = function () { + return this.version } -exports.enqueue = enqueue; -/** - * Removes and returns an item from the queue. - * - * @param list - a list - */ -function dequeue(list) { - return list.shift() || null; + +SemVer.prototype.compare = function (other) { + debug('SemVer.compare', this.version, this.options, other) + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } + + return this.compareMain(other) || this.comparePre(other) } -exports.dequeue = dequeue; -//# sourceMappingURL=Queue.js.map -/***/ }), -/* 502 */, -/* 503 */, -/* 504 */, -/* 505 */, -/* 506 */, -/* 507 */, -/* 508 */, -/* 509 */, -/* 510 */, -/* 511 */, -/* 512 */ -/***/ (function(__unusedmodule, exports) { +SemVer.prototype.compareMain = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } -"use strict"; + return compareIdentifiers(this.major, other.major) || + compareIdentifiers(this.minor, other.minor) || + compareIdentifiers(this.patch, other.patch) +} -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Pre-serializes XML nodes. - */ -var BaseCBWriter = /** @class */ (function () { - /** - * Initializes a new instance of `BaseCBWriter`. - * - * @param builderOptions - XML builder options - */ - function BaseCBWriter(builderOptions) { - /** - * Gets the current depth of the XML tree. - */ - this.level = 0; - this._builderOptions = builderOptions; - this._writerOptions = builderOptions; +SemVer.prototype.comparePre = function (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 + } + + 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) } - return BaseCBWriter; -}()); -exports.BaseCBWriter = BaseCBWriter; -//# sourceMappingURL=BaseCBWriter.js.map + } while (++i) +} -/***/ }), -/* 513 */, -/* 514 */, -/* 515 */, -/* 516 */, -/* 517 */, -/* 518 */, -/* 519 */, -/* 520 */, -/* 521 */, -/* 522 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +SemVer.prototype.compareBuild = function (other) { + if (!(other instanceof SemVer)) { + other = new SemVer(other, this.options) + } -"use strict"; + 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) +} -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; +// 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 + } } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var util_1 = __webpack_require__(592); -/** - * Parses the given byte sequence representing a JSON string into an object. - * - * @param bytes - a byte sequence - */ -function parseJSONFromBytes(bytes) { - /** - * 1. Let jsonText be the result of running UTF-8 decode on bytes. [ENCODING] - * 2. Return ? Call(%JSONParse%, undefined, « jsonText »). - */ - var jsonText = util_1.utf8Decode(bytes); - return JSON.parse.call(undefined, jsonText); -} -exports.parseJSONFromBytes = parseJSONFromBytes; -/** - * Serialize the given JavaScript value into a byte sequence. - * - * @param value - a JavaScript value - */ -function serializeJSONToBytes(value) { - /** - * 1. Let jsonString be ? Call(%JSONStringify%, undefined, « value »). - * 2. Return the result of running UTF-8 encode on jsonString. [ENCODING] - */ - var jsonString = JSON.stringify.call(undefined, value); - return util_1.utf8Encode(jsonString); -} -exports.serializeJSONToBytes = serializeJSONToBytes; -/** - * Parses the given JSON string into a Realm-independent JavaScript value. - * - * @param jsonText - a JSON string - */ -function parseJSONIntoInfraValues(jsonText) { - /** - * 1. Let jsValue be ? Call(%JSONParse%, undefined, « jsonText »). - * 2. Return the result of converting a JSON-derived JavaScript value to an - * Infra value, given jsValue. - */ - var jsValue = JSON.parse.call(undefined, jsonText); - return convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValue); -} -exports.parseJSONIntoInfraValues = parseJSONIntoInfraValues; -/** - * Parses the value into a Realm-independent JavaScript value. - * - * @param jsValue - a JavaScript value - */ -function convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValue) { - var e_1, _a; - /** - * 1. If Type(jsValue) is Null, String, or Number, then return jsValue. - */ - if (jsValue === null || util_1.isString(jsValue) || util_1.isNumber(jsValue)) - return jsValue; - /** - * 2. If IsArray(jsValue) is true, then: - * 2.1. Let result be an empty list. - * 2.2. Let length be ! ToLength(! Get(jsValue, "length")). - * 2.3. For each index of the range 0 to length − 1, inclusive: - * 2.3.1. Let indexName be ! ToString(index). - * 2.3.2. Let jsValueAtIndex be ! Get(jsValue, indexName). - * 2.3.3. Let infraValueAtIndex be the result of converting a JSON-derived - * JavaScript value to an Infra value, given jsValueAtIndex. - * 2.3.4. Append infraValueAtIndex to result. - * 2.8. Return result. - */ - if (util_1.isArray(jsValue)) { - var result = new Array(); - try { - for (var jsValue_1 = __values(jsValue), jsValue_1_1 = jsValue_1.next(); !jsValue_1_1.done; jsValue_1_1 = jsValue_1.next()) { - var jsValueAtIndex = jsValue_1_1.value; - result.push(convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValueAtIndex)); - } + if (i === -1) { + // didn't increment anything + this.prerelease.push(0) } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (jsValue_1_1 && !jsValue_1_1.done && (_a = jsValue_1.return)) _a.call(jsValue_1); - } - finally { if (e_1) throw e_1.error; } + } + 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] } - return result; + } + break + + default: + throw new Error('invalid increment argument: ' + release) + } + this.format() + this.raw = this.version + return this +} + +exports.inc = inc +function inc (version, release, loose, identifier) { + if (typeof (loose) === 'string') { + identifier = loose + loose = undefined + } + + try { + return new SemVer(version, loose).inc(release, identifier).version + } catch (er) { + return null + } +} + +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' } - else if (util_1.isObject(jsValue)) { - /** - * 3. Let result be an empty ordered map. - * 4. For each key of ! jsValue.[[OwnPropertyKeys]](): - * 4.1. Let jsValueAtKey be ! Get(jsValue, key). - * 4.2. Let infraValueAtKey be the result of converting a JSON-derived - * JavaScript value to an Infra value, given jsValueAtKey. - * 4.3. Set result[key] to infraValueAtKey. - * 5. Return result. - */ - var result = new Map(); - for (var key in jsValue) { - /* istanbul ignore else */ - if (jsValue.hasOwnProperty(key)) { - var jsValueAtKey = jsValue[key]; - result.set(key, convertAJSONDerivedJavaScriptValueToAnInfraValue(jsValueAtKey)); - } + for (var key in v1) { + if (key === 'major' || key === 'minor' || key === 'patch') { + if (v1[key] !== v2[key]) { + return prefix + key } - return result; + } } - /* istanbul ignore next */ - return jsValue; + return defaultResult // may be undefined + } } -exports.convertAJSONDerivedJavaScriptValueToAnInfraValue = convertAJSONDerivedJavaScriptValueToAnInfraValue; -//# sourceMappingURL=JSON.js.map -/***/ }), -/* 523 */, -/* 524 */ -/***/ (function(__unusedmodule, exports) { +exports.compareIdentifiers = compareIdentifiers -"use strict"; +var numeric = /^[0-9]+$/ +function compareIdentifiers (a, b) { + var anum = numeric.test(a) + var bnum = numeric.test(b) -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * Represents a cache for storing order between equal objects. - * - * This cache is used when an algorithm compares two objects and finds them to - * be equal but still needs to establish an order between those two objects. - * When two such objects `a` and `b` are passed to the `check` method, a random - * number is generated with `Math.random()`. If the random number is less than - * `0.5` it is assumed that `a < b` otherwise `a > b`. The random number along - * with `a` and `b` is stored in the cache, so that subsequent checks result - * in the same consistent result. - * - * The cache has a size limit which is defined on initialization. - */ -var CompareCache = /** @class */ (function () { - /** - * Initializes a new instance of `CompareCache`. - * - * @param limit - maximum number of items to keep in the cache. When the limit - * is exceeded the first item is removed from the cache. - */ - function CompareCache(limit) { - if (limit === void 0) { limit = 1000; } - this._items = new Map(); - this._limit = limit; - } - /** - * Compares and caches the given objects. Returns `true` if `objA < objB` and - * `false` otherwise. - * - * @param objA - an item to compare - * @param objB - an item to compare - */ - CompareCache.prototype.check = function (objA, objB) { - if (this._items.get(objA) === objB) - return true; - else if (this._items.get(objB) === objA) - return false; - var result = (Math.random() < 0.5); - if (result) { - this._items.set(objA, objB); - } - else { - this._items.set(objB, objA); - } - if (this._items.size > this._limit) { - var it_1 = this._items.keys().next(); - /* istanbul ignore else */ - if (!it_1.done) { - this._items.delete(it_1.value); - } - } - return result; - }; - return CompareCache; -}()); -exports.CompareCache = CompareCache; -//# sourceMappingURL=CompareCache.js.map + if (anum && bnum) { + a = +a + b = +b + } + + return a === b ? 0 + : (anum && !bnum) ? -1 + : (bnum && !anum) ? 1 + : a < b ? -1 + : 1 +} -/***/ }), -/* 525 */, -/* 526 */, -/* 527 */, -/* 528 */, -/* 529 */, -/* 530 */, -/* 531 */, -/* 532 */, -/* 533 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +exports.rcompareIdentifiers = rcompareIdentifiers +function rcompareIdentifiers (a, b) { + return compareIdentifiers(b, a) +} -"use strict"; +exports.major = major +function major (a, loose) { + return new SemVer(a, loose).major +} -Object.defineProperty(exports, "__esModule", { value: true }); -var Guard_1 = __webpack_require__(783); -/** - * Contains type casts for DOM objects. - */ -var Cast = /** @class */ (function () { - function Cast() { - } - /** - * Casts the given object to a `Node`. - * - * @param a - the object to cast - */ - Cast.asNode = function (a) { - if (Guard_1.Guard.isNode(a)) { - return a; - } - else { - throw new Error("Invalid object. Node expected."); - } - }; - return Cast; -}()); -exports.Cast = Cast; -//# sourceMappingURL=Cast.js.map +exports.minor = minor +function minor (a, loose) { + return new SemVer(a, loose).minor +} -/***/ }), -/* 534 */, -/* 535 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +exports.patch = patch +function patch (a, loose) { + return new SemVer(a, loose).patch +} -"use strict"; +exports.compare = compare +function compare (a, b, loose) { + return new SemVer(a, loose).compare(new SemVer(b, loose)) +} -Object.defineProperty(exports, "__esModule", { value: true }); -var XMLBuilderImpl_1 = __webpack_require__(595); -exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; -var XMLBuilderCBImpl_1 = __webpack_require__(551); -exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; -var BuilderFunctions_1 = __webpack_require__(961); -exports.builder = BuilderFunctions_1.builder; -exports.create = BuilderFunctions_1.create; -exports.fragment = BuilderFunctions_1.fragment; -exports.convert = BuilderFunctions_1.convert; -var BuilderFunctionsCB_1 = __webpack_require__(295); -exports.createCB = BuilderFunctionsCB_1.createCB; -exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; -//# sourceMappingURL=index.js.map +exports.compareLoose = compareLoose +function compareLoose (a, b) { + return compare(a, b, true) +} -/***/ }), -/* 536 */, -/* 537 */, -/* 538 */, -/* 539 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +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) +} -"use strict"; +exports.rcompare = rcompare +function rcompare (a, b, loose) { + return compare(b, a, loose) +} -Object.defineProperty(exports, "__esModule", { value: true }); -const http = __webpack_require__(605); -const https = __webpack_require__(34); -const pm = __webpack_require__(950); -let tunnel; -var HttpCodes; -(function (HttpCodes) { - HttpCodes[HttpCodes["OK"] = 200] = "OK"; - HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices"; - HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently"; - HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved"; - HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther"; - HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified"; - HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy"; - HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy"; - HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect"; - HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect"; - HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest"; - HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized"; - HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired"; - HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden"; - HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound"; - HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed"; - HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable"; - HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; - HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout"; - HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict"; - HttpCodes[HttpCodes["Gone"] = 410] = "Gone"; - HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests"; - HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError"; - HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented"; - HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway"; - HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable"; - HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout"; -})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); -var Headers; -(function (Headers) { - Headers["Accept"] = "accept"; - Headers["ContentType"] = "content-type"; -})(Headers = exports.Headers || (exports.Headers = {})); -var MediaTypes; -(function (MediaTypes) { - MediaTypes["ApplicationJson"] = "application/json"; -})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); -/** - * Returns the proxy URL, depending upon the supplied url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ -function getProxyUrl(serverUrl) { - let proxyUrl = pm.getProxyUrl(new URL(serverUrl)); - return proxyUrl ? proxyUrl.href : ''; +exports.sort = sort +function sort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(a, b, loose) + }) } -exports.getProxyUrl = getProxyUrl; -const HttpRedirectCodes = [ - HttpCodes.MovedPermanently, - HttpCodes.ResourceMoved, - HttpCodes.SeeOther, - HttpCodes.TemporaryRedirect, - HttpCodes.PermanentRedirect -]; -const HttpResponseRetryCodes = [ - HttpCodes.BadGateway, - HttpCodes.ServiceUnavailable, - HttpCodes.GatewayTimeout -]; -const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD']; -const ExponentialBackoffCeiling = 10; -const ExponentialBackoffTimeSlice = 5; -class HttpClientError extends Error { - constructor(message, statusCode) { - super(message); - this.name = 'HttpClientError'; - this.statusCode = statusCode; - Object.setPrototypeOf(this, HttpClientError.prototype); - } + +exports.rsort = rsort +function rsort (list, loose) { + return list.sort(function (a, b) { + return exports.compareBuild(b, a, loose) + }) } -exports.HttpClientError = HttpClientError; -class HttpClientResponse { - constructor(message) { - this.message = message; - } - readBody() { - return new Promise(async (resolve, reject) => { - let output = Buffer.alloc(0); - this.message.on('data', (chunk) => { - output = Buffer.concat([output, chunk]); - }); - this.message.on('end', () => { - resolve(output.toString()); - }); - }); - } + +exports.gt = gt +function gt (a, b, loose) { + return compare(a, b, loose) > 0 } -exports.HttpClientResponse = HttpClientResponse; -function isHttps(requestUrl) { - let parsedUrl = new URL(requestUrl); - return parsedUrl.protocol === 'https:'; + +exports.lt = lt +function lt (a, b, loose) { + return compare(a, b, loose) < 0 } -exports.isHttps = isHttps; -class HttpClient { - constructor(userAgent, handlers, requestOptions) { - this._ignoreSslError = false; - this._allowRedirects = true; - this._allowRedirectDowngrade = false; - this._maxRedirects = 50; - this._allowRetries = false; - this._maxRetries = 1; - this._keepAlive = false; - this._disposed = false; - this.userAgent = userAgent; - this.handlers = handlers || []; - this.requestOptions = requestOptions; - if (requestOptions) { - if (requestOptions.ignoreSslError != null) { - this._ignoreSslError = requestOptions.ignoreSslError; - } - this._socketTimeout = requestOptions.socketTimeout; - if (requestOptions.allowRedirects != null) { - this._allowRedirects = requestOptions.allowRedirects; - } - if (requestOptions.allowRedirectDowngrade != null) { - this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; - } - if (requestOptions.maxRedirects != null) { - this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); - } - if (requestOptions.keepAlive != null) { - this._keepAlive = requestOptions.keepAlive; - } - if (requestOptions.allowRetries != null) { - this._allowRetries = requestOptions.allowRetries; - } - if (requestOptions.maxRetries != null) { - this._maxRetries = requestOptions.maxRetries; - } - } - } - options(requestUrl, additionalHeaders) { - return this.request('OPTIONS', requestUrl, null, additionalHeaders || {}); - } - get(requestUrl, additionalHeaders) { - return this.request('GET', requestUrl, null, additionalHeaders || {}); - } - del(requestUrl, additionalHeaders) { - return this.request('DELETE', requestUrl, null, additionalHeaders || {}); - } - post(requestUrl, data, additionalHeaders) { - return this.request('POST', requestUrl, data, additionalHeaders || {}); - } - patch(requestUrl, data, additionalHeaders) { - return this.request('PATCH', requestUrl, data, additionalHeaders || {}); - } - put(requestUrl, data, additionalHeaders) { - return this.request('PUT', requestUrl, data, additionalHeaders || {}); - } - head(requestUrl, additionalHeaders) { - return this.request('HEAD', requestUrl, null, additionalHeaders || {}); - } - sendStream(verb, requestUrl, stream, additionalHeaders) { - return this.request(verb, requestUrl, stream, additionalHeaders); - } - /** - * Gets a typed object from an endpoint - * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise - */ - async getJson(requestUrl, additionalHeaders = {}) { - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - let res = await this.get(requestUrl, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async postJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.post(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async putJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.put(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - async patchJson(requestUrl, obj, additionalHeaders = {}) { - let data = JSON.stringify(obj, null, 2); - additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); - additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); - let res = await this.patch(requestUrl, data, additionalHeaders); - return this._processResponse(res, this.requestOptions); - } - /** - * Makes a raw http request. - * All other methods such as get, post, patch, and request ultimately call this. - * Prefer get, del, post and patch - */ - async request(verb, requestUrl, data, headers) { - if (this._disposed) { - throw new Error('Client has already been disposed.'); - } - let parsedUrl = new URL(requestUrl); - let info = this._prepareRequest(verb, parsedUrl, headers); - // Only perform retries on reads since writes may not be idempotent. - let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1 - ? this._maxRetries + 1 - : 1; - let numTries = 0; - let response; - while (numTries < maxTries) { - response = await this.requestRaw(info, data); - // Check if it's an authentication challenge - if (response && - response.message && - response.message.statusCode === HttpCodes.Unauthorized) { - let authenticationHandler; - for (let i = 0; i < this.handlers.length; i++) { - if (this.handlers[i].canHandleAuthentication(response)) { - authenticationHandler = this.handlers[i]; - break; - } - } - if (authenticationHandler) { - return authenticationHandler.handleAuthentication(this, info, data); - } - else { - // We have received an unauthorized response but have no handlers to handle it. - // Let the response return to the caller. - return response; - } - } - let redirectsRemaining = this._maxRedirects; - while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 && - this._allowRedirects && - redirectsRemaining > 0) { - const redirectUrl = response.message.headers['location']; - if (!redirectUrl) { - // if there's no location to redirect to, we won't - break; - } - let parsedRedirectUrl = new URL(redirectUrl); - if (parsedUrl.protocol == 'https:' && - parsedUrl.protocol != parsedRedirectUrl.protocol && - !this._allowRedirectDowngrade) { - throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.'); - } - // we need to finish reading the response before reassigning response - // which will leak the open socket. - await response.readBody(); - // strip authorization header if redirected to a different hostname - if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { - for (let header in headers) { - // header names are case insensitive - if (header.toLowerCase() === 'authorization') { - delete headers[header]; - } - } - } - // let's make the request with the new redirectUrl - info = this._prepareRequest(verb, parsedRedirectUrl, headers); - response = await this.requestRaw(info, data); - redirectsRemaining--; - } - if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) { - // If not a retry code, return immediately instead of retrying - return response; - } - numTries += 1; - if (numTries < maxTries) { - await response.readBody(); - await this._performExponentialBackoff(numTries); - } - } - return response; - } - /** - * Needs to be called if keepAlive is set to true in request options. - */ - dispose() { - if (this._agent) { - this._agent.destroy(); - } - this._disposed = true; - } - /** - * Raw request. - * @param info - * @param data - */ - requestRaw(info, data) { - return new Promise((resolve, reject) => { - let callbackForResult = function (err, res) { - if (err) { - reject(err); - } - resolve(res); - }; - this.requestRawWithCallback(info, data, callbackForResult); - }); - } - /** - * Raw request with callback. - * @param info - * @param data - * @param onResult - */ - requestRawWithCallback(info, data, onResult) { - let socket; - if (typeof data === 'string') { - info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8'); - } - let callbackCalled = false; - let handleResult = (err, res) => { - if (!callbackCalled) { - callbackCalled = true; - onResult(err, res); - } - }; - let req = info.httpModule.request(info.options, (msg) => { - let res = new HttpClientResponse(msg); - handleResult(null, res); - }); - req.on('socket', sock => { - socket = sock; - }); - // If we ever get disconnected, we want the socket to timeout eventually - req.setTimeout(this._socketTimeout || 3 * 60000, () => { - if (socket) { - socket.end(); - } - handleResult(new Error('Request timeout: ' + info.options.path), null); - }); - req.on('error', function (err) { - // err has statusCode property - // res should have headers - handleResult(err, null); - }); - if (data && typeof data === 'string') { - req.write(data, 'utf8'); - } - if (data && typeof data !== 'string') { - data.on('close', function () { - req.end(); - }); - data.pipe(req); - } - else { - req.end(); - } - } - /** - * Gets an http agent. This function is useful when you need an http agent that handles - * routing through a proxy server - depending upon the url and proxy environment variables. - * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com - */ - getAgent(serverUrl) { - let parsedUrl = new URL(serverUrl); - return this._getAgent(parsedUrl); + +exports.eq = eq +function eq (a, b, loose) { + return compare(a, b, loose) === 0 +} + +exports.neq = neq +function neq (a, b, loose) { + return compare(a, b, loose) !== 0 +} + +exports.gte = gte +function gte (a, b, loose) { + return compare(a, b, loose) >= 0 +} + +exports.lte = lte +function lte (a, b, loose) { + return compare(a, b, loose) <= 0 +} + +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) + + default: + throw new TypeError('Invalid operator: ' + op) + } +} + +exports.Comparator = Comparator +function Comparator (comp, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } - _prepareRequest(method, requestUrl, headers) { - const info = {}; - info.parsedUrl = requestUrl; - const usingSsl = info.parsedUrl.protocol === 'https:'; - info.httpModule = usingSsl ? https : http; - const defaultPort = usingSsl ? 443 : 80; - info.options = {}; - info.options.host = info.parsedUrl.hostname; - info.options.port = info.parsedUrl.port - ? parseInt(info.parsedUrl.port) - : defaultPort; - info.options.path = - (info.parsedUrl.pathname || '') + (info.parsedUrl.search || ''); - info.options.method = method; - info.options.headers = this._mergeHeaders(headers); - if (this.userAgent != null) { - info.options.headers['user-agent'] = this.userAgent; - } - info.options.agent = this._getAgent(info.parsedUrl); - // gives handlers an opportunity to participate - if (this.handlers) { - this.handlers.forEach(handler => { - handler.prepareRequest(info.options); - }); - } - return info; + } + + if (comp instanceof Comparator) { + if (comp.loose === !!options.loose) { + return comp + } else { + comp = comp.value } - _mergeHeaders(headers) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - if (this.requestOptions && this.requestOptions.headers) { - return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers)); - } - return lowercaseKeys(headers || {}); + } + + 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 + } + + debug('comp', this) +} + +var ANY = {} +Comparator.prototype.parse = function (comp) { + var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR] + var 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) + } +} + +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 + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false } - _getExistingOrDefaultHeader(additionalHeaders, header, _default) { - const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {}); - let clientHeader; - if (this.requestOptions && this.requestOptions.headers) { - clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; - } - return additionalHeaders[header] || clientHeader || _default; + } + + return cmp(version, this.operator, this.semver, this.options) +} + +Comparator.prototype.intersects = function (comp, options) { + if (!(comp instanceof Comparator)) { + throw new TypeError('a Comparator is required') + } + + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } - _getAgent(parsedUrl) { - let agent; - let proxyUrl = pm.getProxyUrl(parsedUrl); - let useProxy = proxyUrl && proxyUrl.hostname; - if (this._keepAlive && useProxy) { - agent = this._proxyAgent; - } - if (this._keepAlive && !useProxy) { - agent = this._agent; - } - // if agent is already assigned use that agent. - if (!!agent) { - return agent; - } - const usingSsl = parsedUrl.protocol === 'https:'; - let maxSockets = 100; - if (!!this.requestOptions) { - maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; - } - if (useProxy) { - // If using proxy, need tunnel - if (!tunnel) { - tunnel = __webpack_require__(856); - } - const agentOptions = { - maxSockets: maxSockets, - keepAlive: this._keepAlive, - proxy: { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`, - host: proxyUrl.hostname, - port: proxyUrl.port - } - }; - let tunnelAgent; - const overHttps = proxyUrl.protocol === 'https:'; - if (usingSsl) { - tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; - } - else { - tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; - } - agent = tunnelAgent(agentOptions); - this._proxyAgent = agent; - } - // if reusing agent across request and tunneling agent isn't assigned create a new agent - if (this._keepAlive && !agent) { - const options = { keepAlive: this._keepAlive, maxSockets: maxSockets }; - agent = usingSsl ? new https.Agent(options) : new http.Agent(options); - this._agent = agent; - } - // if not using private agent and tunnel agent isn't setup then use global agent - if (!agent) { - agent = usingSsl ? https.globalAgent : http.globalAgent; - } - if (usingSsl && this._ignoreSslError) { - // we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process - // http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options - // we have to cast it to any and change it directly - agent.options = Object.assign(agent.options || {}, { - rejectUnauthorized: false - }); - } - return agent; + } + + var rangeTmp + + if (this.operator === '') { + if (this.value === '') { + return true } - _performExponentialBackoff(retryNumber) { - retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); - const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); - return new Promise(resolve => setTimeout(() => resolve(), ms)); + rangeTmp = new Range(comp.value, options) + return satisfies(this.value, rangeTmp, options) + } else if (comp.operator === '') { + if (comp.value === '') { + return true } - static dateTimeDeserializer(key, value) { - if (typeof value === 'string') { - let a = new Date(value); - if (!isNaN(a.valueOf())) { - return a; - } - } - return value; + rangeTmp = new Range(this.value, options) + return satisfies(comp.semver, rangeTmp, options) + } + + 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 +} + +exports.Range = Range +function Range (range, options) { + if (!options || typeof options !== 'object') { + options = { + loose: !!options, + includePrerelease: false } - async _processResponse(res, options) { - return new Promise(async (resolve, reject) => { - const statusCode = res.message.statusCode; - const response = { - statusCode: statusCode, - result: null, - headers: {} - }; - // not found leads to null obj returned - if (statusCode == HttpCodes.NotFound) { - resolve(response); - } - let obj; - let contents; - // get the result from the body - try { - contents = await res.readBody(); - if (contents && contents.length > 0) { - if (options && options.deserializeDates) { - obj = JSON.parse(contents, HttpClient.dateTimeDeserializer); - } - else { - obj = JSON.parse(contents); - } - response.result = obj; - } - response.headers = res.message.headers; - } - catch (err) { - // Invalid resource (contents not json); leaving result obj null - } - // note that 3xx redirects are handled by the http layer. - if (statusCode > 299) { - let msg; - // if exception/error in body, attempt to get better error - if (obj && obj.message) { - msg = obj.message; - } - else if (contents && contents.length > 0) { - // it may be the case that the exception is in the body message as string - msg = contents; - } - else { - msg = 'Failed request: (' + statusCode + ')'; - } - let err = new HttpClientError(msg, statusCode); - err.result = response.result; - reject(err); - } - else { - resolve(response); - } - }); + } + + 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) { + return new Range(range.value, options) + } + + if (!(this instanceof Range)) { + return new Range(range, options) + } + + 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(function (range) { + return this.parseRange(range.trim()) + }, this).filter(function (c) { + // throw out any that are not relevant for whatever reason + return c.length + }) + + if (!this.set.length) { + throw new TypeError('Invalid SemVer Range: ' + range) + } + + this.format() } -exports.HttpClient = HttpClient; +Range.prototype.format = function () { + this.range = this.set.map(function (comps) { + return comps.join(' ').trim() + }).join('||').trim() + return this.range +} -/***/ }), -/* 540 */, -/* 541 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +Range.prototype.toString = function () { + return this.range +} + +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]) + + // `~ 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. + + 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) + + return set +} + +Range.prototype.intersects = function (range, options) { + if (!(range instanceof Range)) { + throw new TypeError('a Range is required') + } + + 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) + }) + + testComparator = remainingComparators.pop() + } + + 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' + } -"use strict"; + debug('tilde return', ret) + return ret + }) +} -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var DOMImpl_1 = __webpack_require__(648); -var util_1 = __webpack_require__(918); -var infra_1 = __webpack_require__(23); -var CreateAlgorithm_1 = __webpack_require__(86); -var OrderedSetAlgorithm_1 = __webpack_require__(146); -var DOMAlgorithm_1 = __webpack_require__(304); -var MutationAlgorithm_1 = __webpack_require__(479); -var ElementAlgorithm_1 = __webpack_require__(33); -/** - * Replaces the contents of the given node with a single text node. - * - * @param string - node contents - * @param parent - a node - */ -function node_stringReplaceAll(str, parent) { - /** - * 1. Let node be null. - * 2. If string is not the empty string, then set node to a new Text node - * whose data is string and node document is parent’s node document. - * 3. Replace all with node within parent. - */ - var node = null; - if (str !== '') { - node = CreateAlgorithm_1.create_text(parent._nodeDocument, str); - } - MutationAlgorithm_1.mutation_replaceAll(node, parent); +// ^ --> * (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(' ') } -exports.node_stringReplaceAll = node_stringReplaceAll; -/** - * Clones a node. - * - * @param node - a node to clone - * @param document - the document to own the cloned node - * @param cloneChildrenFlag - whether to clone node's children - */ -function node_clone(node, document, cloneChildrenFlag) { - var e_1, _a, e_2, _b; - if (document === void 0) { document = null; } - if (cloneChildrenFlag === void 0) { cloneChildrenFlag = false; } - /** - * 1. If document is not given, let document be node’s node document. - */ - if (document === null) - document = node._nodeDocument; - var copy; - if (util_1.Guard.isElementNode(node)) { - /** - * 2. If node is an element, then: - * 2.1. Let copy be the result of creating an element, given document, - * node’s local name, node’s namespace, node’s namespace prefix, - * and node’s is value, with the synchronous custom elements flag unset. - * 2.2. For each attribute in node’s attribute list: - * 2.2.1. Let copyAttribute be a clone of attribute. - * 2.2.2. Append copyAttribute to copy. - */ - copy = ElementAlgorithm_1.element_createAnElement(document, node._localName, node._namespace, node._namespacePrefix, node._is, false); - try { - for (var _c = __values(node._attributeList), _d = _c.next(); !_d.done; _d = _c.next()) { - var attribute = _d.value; - var copyAttribute = node_clone(attribute, document); - ElementAlgorithm_1.element_append(copyAttribute, copy); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_d && !_d.done && (_a = _c.return)) _a.call(_c); - } - finally { if (e_1) throw e_1.error; } - } - } - else { - /** - * 3. Otherwise, let copy be a node that implements the same interfaces as - * node, and fulfills these additional requirements, switching on node: - * - Document - * Set copy’s encoding, content type, URL, origin, type, and mode, to those - * of node. - * - DocumentType - * Set copy’s name, public ID, and system ID, to those of node. - * - Attr - * Set copy’s namespace, namespace prefix, local name, and value, to - * those of node. - * - Text - * - Comment - * Set copy’s data, to that of node. - * - ProcessingInstruction - * Set copy’s target and data to those of node. - * - Any other node - */ - if (util_1.Guard.isDocumentNode(node)) { - var doc = CreateAlgorithm_1.create_document(); - doc._encoding = node._encoding; - doc._contentType = node._contentType; - doc._URL = node._URL; - doc._origin = node._origin; - doc._type = node._type; - doc._mode = node._mode; - copy = doc; - } - else if (util_1.Guard.isDocumentTypeNode(node)) { - var doctype = CreateAlgorithm_1.create_documentType(document, node._name, node._publicId, node._systemId); - copy = doctype; - } - else if (util_1.Guard.isAttrNode(node)) { - var attr = CreateAlgorithm_1.create_attr(document, node.localName); - attr._namespace = node._namespace; - attr._namespacePrefix = node._namespacePrefix; - attr._value = node._value; - copy = attr; - } - else if (util_1.Guard.isExclusiveTextNode(node)) { - copy = CreateAlgorithm_1.create_text(document, node._data); - } - else if (util_1.Guard.isCDATASectionNode(node)) { - copy = CreateAlgorithm_1.create_cdataSection(document, node._data); - } - else if (util_1.Guard.isCommentNode(node)) { - copy = CreateAlgorithm_1.create_comment(document, node._data); - } - else if (util_1.Guard.isProcessingInstructionNode(node)) { - copy = CreateAlgorithm_1.create_processingInstruction(document, node._target, node._data); - } - else if (util_1.Guard.isDocumentFragmentNode(node)) { - copy = CreateAlgorithm_1.create_documentFragment(document); - } - else { - copy = Object.create(node); - } - } - /** - * 4. Set copy’s node document and document to copy, if copy is a document, - * and set copy’s node document to document otherwise. - */ - if (util_1.Guard.isDocumentNode(copy)) { - copy._nodeDocument = copy; - document = copy; - } - else { - copy._nodeDocument = document; - } - /** - * 5. Run any cloning steps defined for node in other applicable - * specifications and pass copy, node, document and the clone children flag - * if set, as parameters. - */ - if (DOMImpl_1.dom.features.steps) { - DOMAlgorithm_1.dom_runCloningSteps(copy, node, document, cloneChildrenFlag); - } - /** - * 6. If the clone children flag is set, clone all the children of node and - * append them to copy, with document as specified and the clone children - * flag being set. - */ - if (cloneChildrenFlag) { - try { - for (var _e = __values(node._children), _f = _e.next(); !_f.done; _f = _e.next()) { - var child = _f.value; - var childCopy = node_clone(child, document, true); - MutationAlgorithm_1.mutation_append(childCopy, copy); - } + +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' } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_f && !_f.done && (_b = _e.return)) _b.call(_e); - } - finally { if (e_2) throw e_2.error; } + } 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' + } } - /** - * 7. Return copy. - */ - return copy; + + debug('caret return', ret) + return ret + }) } -exports.node_clone = node_clone; -/** - * Determines if two nodes can be considered equal. - * - * @param a - node to compare - * @param b - node to compare - */ -function node_equals(a, b) { - var e_3, _a, e_4, _b; - /** - * 1. A and B’s nodeType attribute value is identical. - */ - if (a._nodeType !== b._nodeType) - return false; - /** - * 2. The following are also equal, depending on A: - * - DocumentType - * Its name, public ID, and system ID. - * - Element - * Its namespace, namespace prefix, local name, and its attribute list’s size. - * - Attr - * Its namespace, local name, and value. - * - ProcessingInstruction - * Its target and data. - * - Text - * - Comment - * Its data. - */ - if (util_1.Guard.isDocumentTypeNode(a) && util_1.Guard.isDocumentTypeNode(b)) { - if (a._name !== b._name || a._publicId !== b._publicId || - a._systemId !== b._systemId) - return false; - } - else if (util_1.Guard.isElementNode(a) && util_1.Guard.isElementNode(b)) { - if (a._namespace !== b._namespace || a._namespacePrefix !== b._namespacePrefix || - a._localName !== b._localName || - a._attributeList.length !== b._attributeList.length) - return false; - } - else if (util_1.Guard.isAttrNode(a) && util_1.Guard.isAttrNode(b)) { - if (a._namespace !== b._namespace || a._localName !== b._localName || - a._value !== b._value) - return false; - } - else if (util_1.Guard.isProcessingInstructionNode(a) && util_1.Guard.isProcessingInstructionNode(b)) { - if (a._target !== b._target || a._data !== b._data) - return false; - } - else if (util_1.Guard.isCharacterDataNode(a) && util_1.Guard.isCharacterDataNode(b)) { - if (a._data !== b._data) - return false; + +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 = '' } - /** - * 3. If A is an element, each attribute in its attribute list has an attribute - * that equals an attribute in B’s attribute list. - */ - if (util_1.Guard.isElementNode(a) && util_1.Guard.isElementNode(b)) { - var attrMap = {}; - try { - for (var _c = __values(a._attributeList), _d = _c.next(); !_d.done; _d = _c.next()) { - var attrA = _d.value; - attrMap[attrA._localName] = attrA; - } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_d && !_d.done && (_a = _c.return)) _a.call(_c); - } - finally { if (e_3) throw e_3.error; } - } - try { - for (var _e = __values(b._attributeList), _f = _e.next(); !_f.done; _f = _e.next()) { - var attrB = _f.value; - var attrA = attrMap[attrB._localName]; - if (!attrA) - return false; - if (!node_equals(attrA, attrB)) - return false; - } + + // 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 } - catch (e_4_1) { e_4 = { error: e_4_1 }; } - finally { - try { - if (_f && !_f.done && (_b = _e.return)) _b.call(_e); - } - finally { if (e_4) throw e_4.error; } + } 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 } - /** - * 4. A and B have the same number of children. - * 5. Each child of A equals the child of B at the identical index. - */ - if (a._children.size !== b._children.size) - return false; - var itA = a._children[Symbol.iterator](); - var itB = b._children[Symbol.iterator](); - var resultA = itA.next(); - var resultB = itB.next(); - while (!resultA.done && !resultB.done) { - var child1 = resultA.value; - var child2 = resultB.value; - if (!node_equals(child1, child2)) - return false; - resultA = itA.next(); - resultB = itB.next(); - } - return true; + + debug('xRange return', ret) + + return ret + }) } -exports.node_equals = node_equals; -/** - * Returns a collection of elements with the given qualified name which are - * descendants of the given root node. - * See: https://dom.spec.whatwg.org/#concept-getelementsbytagname - * - * @param qualifiedName - qualified name - * @param root - root node - */ -function node_listOfElementsWithQualifiedName(qualifiedName, root) { - /** - * 1. If qualifiedName is "*" (U+002A), return a HTMLCollection rooted at - * root, whose filter matches only descendant elements. - * 2. Otherwise, if root’s node document is an HTML document, return a - * HTMLCollection rooted at root, whose filter matches the following - * descendant elements: - * 2.1. Whose namespace is the HTML namespace and whose qualified name is - * qualifiedName, in ASCII lowercase. - * 2.2. Whose namespace is not the HTML namespace and whose qualified name - * is qualifiedName. - * 3. Otherwise, return a HTMLCollection rooted at root, whose filter - * matches descendant elements whose qualified name is qualifiedName. - */ - if (qualifiedName === "*") { - return CreateAlgorithm_1.create_htmlCollection(root); - } - else if (root._nodeDocument._type === "html") { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - if (ele._namespace === infra_1.namespace.HTML && - ele._qualifiedName === qualifiedName.toLowerCase()) { - return true; - } - else if (ele._namespace !== infra_1.namespace.HTML && - ele._qualifiedName === qualifiedName) { - return true; - } - else { - return false; - } - }); + +// 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 + } + + if (typeof version === 'string') { + try { + version = new SemVer(version, this.options) + } catch (er) { + return false } - else { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - return (ele._qualifiedName === qualifiedName); - }); + } + + for (var i = 0; i < this.set.length; i++) { + if (testSet(this.set[i], version, this.options)) { + return true } + } + return false } -exports.node_listOfElementsWithQualifiedName = node_listOfElementsWithQualifiedName; -/** - * Returns a collection of elements with the given namespace which are - * descendants of the given root node. - * See: https://dom.spec.whatwg.org/#concept-getelementsbytagnamens - * - * @param namespace - element namespace - * @param localName - local name - * @param root - root node - */ -function node_listOfElementsWithNamespace(namespace, localName, root) { - /** - * 1. If namespace is the empty string, set it to null. - * 2. If both namespace and localName are "*" (U+002A), return a - * HTMLCollection rooted at root, whose filter matches descendant elements. - * 3. Otherwise, if namespace is "*" (U+002A), return a HTMLCollection - * rooted at root, whose filter matches descendant elements whose local - * name is localName. - * 4. Otherwise, if localName is "*" (U+002A), return a HTMLCollection - * rooted at root, whose filter matches descendant elements whose - * namespace is namespace. - * 5. Otherwise, return a HTMLCollection rooted at root, whose filter - * matches descendant elements whose namespace is namespace and local - * name is localName. - */ - if (namespace === '') - namespace = null; - if (namespace === "*" && localName === "*") { - return CreateAlgorithm_1.create_htmlCollection(root); - } - else if (namespace === "*") { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - return (ele._localName === localName); - }); - } - else if (localName === "*") { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - return (ele._namespace === namespace); - }); + +function testSet (set, version, options) { + for (var i = 0; i < set.length; i++) { + if (!set[i].test(version)) { + return false } - else { - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - return (ele._localName === localName && ele._namespace === namespace); - }); + } + + 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 + } + } } + + // Version has a -pre, but it's not one of the ones we like. + return false + } + + return true } -exports.node_listOfElementsWithNamespace = node_listOfElementsWithNamespace; -/** - * Returns a collection of elements with the given class names which are - * descendants of the given root node. - * See: https://dom.spec.whatwg.org/#concept-getelementsbyclassname - * - * @param namespace - element namespace - * @param localName - local name - * @param root - root node - */ -function node_listOfElementsWithClassNames(classNames, root) { - /** - * 1. Let classes be the result of running the ordered set parser - * on classNames. - * 2. If classes is the empty set, return an empty HTMLCollection. - * 3. Return a HTMLCollection rooted at root, whose filter matches - * descendant elements that have all their classes in classes. - * The comparisons for the classes must be done in an ASCII case-insensitive - * manner if root’s node document’s mode is "quirks", and in a - * case-sensitive manner otherwise. - */ - var classes = OrderedSetAlgorithm_1.orderedSet_parse(classNames); - if (classes.size === 0) { - return CreateAlgorithm_1.create_htmlCollection(root, function () { return false; }); - } - var caseSensitive = (root._nodeDocument._mode !== "quirks"); - return CreateAlgorithm_1.create_htmlCollection(root, function (ele) { - var eleClasses = ele.classList; - return OrderedSetAlgorithm_1.orderedSet_contains(eleClasses._tokenSet, classes, caseSensitive); - }); + +exports.satisfies = satisfies +function satisfies (version, range, options) { + try { + range = new Range(range, options) + } catch (er) { + return false + } + return range.test(version) } -exports.node_listOfElementsWithClassNames = node_listOfElementsWithClassNames; -/** - * Searches for a namespace prefix associated with the given namespace - * starting from the given element through its ancestors. - * - * @param element - an element node to start searching at - * @param namespace - namespace to search for - */ -function node_locateANamespacePrefix(element, namespace) { - /** - * 1. If element’s namespace is namespace and its namespace prefix is not - * null, then return its namespace prefix. - */ - if (element._namespace === namespace && element._namespacePrefix !== null) { - return element._namespacePrefix; - } - /** - * 2. If element has an attribute whose namespace prefix is "xmlns" and - * value is namespace, then return element’s first such attribute’s - * local name. - */ - for (var i = 0; i < element._attributeList.length; i++) { - var attr = element._attributeList[i]; - if (attr._namespacePrefix === "xmlns" && attr._value === namespace) { - return attr._localName; - } - } - /** - * 3. If element’s parent element is not null, then return the result of - * running locate a namespace prefix on that element using namespace. - */ - if (element._parent && util_1.Guard.isElementNode(element._parent)) { - return node_locateANamespacePrefix(element._parent, namespace); + +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) + } } - /** - * 4. Return null. - */ - return null; + }) + return max } -exports.node_locateANamespacePrefix = node_locateANamespacePrefix; -/** - * Searches for a namespace associated with the given namespace prefix - * starting from the given node through its ancestors. - * - * @param node - a node to start searching at - * @param prefix - namespace prefix to search for - */ -function node_locateANamespace(node, prefix) { - if (util_1.Guard.isElementNode(node)) { - /** - * 1. If its namespace is not null and its namespace prefix is prefix, - * then return namespace. - */ - if (node._namespace !== null && node._namespacePrefix === prefix) { - return node._namespace; - } - /** - * 2. If it has an attribute whose namespace is the XMLNS namespace, - * namespace prefix is "xmlns", and local name is prefix, or if prefix - * is null and it has an attribute whose namespace is the XMLNS namespace, - * namespace prefix is null, and local name is "xmlns", then return its - * value if it is not the empty string, and null otherwise. - */ - for (var i = 0; i < node._attributeList.length; i++) { - var attr = node._attributeList[i]; - if (attr._namespace === infra_1.namespace.XMLNS && - attr._namespacePrefix === "xmlns" && - attr._localName === prefix) { - return attr._value || null; - } - if (prefix === null && attr._namespace === infra_1.namespace.XMLNS && - attr._namespacePrefix === null && attr._localName === "xmlns") { - return attr._value || null; - } - } - /** - * 3. If its parent element is null, then return null. - */ - if (node.parentElement === null) - return null; - /** - * 4. Return the result of running locate a namespace on its parent - * element using prefix. - */ - return node_locateANamespace(node.parentElement, prefix); - } - else if (util_1.Guard.isDocumentNode(node)) { - /** - * 1. If its document element is null, then return null. - * 2. Return the result of running locate a namespace on its document - * element using prefix. - */ - if (node.documentElement === null) - return null; - return node_locateANamespace(node.documentElement, prefix); + +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) + } } - else if (util_1.Guard.isDocumentTypeNode(node) || util_1.Guard.isDocumentFragmentNode(node)) { - return null; + }) + return min +} + +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 + } + + return null +} + +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 + } +} + +// 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) +} + +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] + + var high = null + var low = null + + 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 the edge version comparator has a operator then our version + // isn't outside it + if (high.operator === comp || high.operator === ecomp) { + return false } - else if (util_1.Guard.isAttrNode(node)) { - /** - * 1. If its element is null, then return null. - * 2. Return the result of running locate a namespace on its element - * using prefix. - */ - if (node._element === null) - return null; - return node_locateANamespace(node._element, prefix); + + // 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 } - else { - /** - * 1. If its parent element is null, then return null. - * 2. Return the result of running locate a namespace on its parent - * element using prefix. - */ - if (!node._parent || !util_1.Guard.isElementNode(node._parent)) - return null; - return node_locateANamespace(node._parent, prefix); + } + 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) +} + +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 + } + + options = options || {} + + 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 } + // 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) } -exports.node_locateANamespace = node_locateANamespace; -//# sourceMappingURL=NodeAlgorithm.js.map + /***/ }), -/* 542 */, -/* 543 */, -/* 544 */, -/* 545 */, -/* 546 */, -/* 547 */, -/* 548 */, -/* 549 */, -/* 550 */, /* 551 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -25557,7 +26842,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -25579,7 +26864,7 @@ const core = __importStar(__webpack_require__(470)); const tc = __importStar(__webpack_require__(139)); const fs_1 = __importDefault(__webpack_require__(747)); const path_1 = __importDefault(__webpack_require__(622)); -const semver_1 = __importDefault(__webpack_require__(280)); +const semver_1 = __importDefault(__webpack_require__(876)); const base_installer_1 = __webpack_require__(83); const constants_1 = __webpack_require__(211); const util_1 = __webpack_require__(322); @@ -25699,7 +26984,15 @@ exports.AdoptDistribution = AdoptDistribution; /***/ }), /* 585 */, -/* 586 */, +/* 586 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const lt = (a, b, loose) => compare(a, b, loose) < 0 +module.exports = lt + + +/***/ }), /* 587 */, /* 588 */, /* 589 */, @@ -26150,7 +27443,15 @@ exports.utf8Decode = utf8Decode; //# sourceMappingURL=index.js.map /***/ }), -/* 593 */, +/* 593 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compareBuild = __webpack_require__(16) +const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose)) +module.exports = rsort + + +/***/ }), /* 594 */, /* 595 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -27142,7 +28443,439 @@ module.exports = new Schema({ /***/ }), -/* 612 */, +/* 612 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + +module.exports = Yallist + +Yallist.Node = Node +Yallist.create = Yallist + +function Yallist (list) { + var self = this + if (!(self instanceof Yallist)) { + self = new Yallist() + } + + self.tail = null + self.head = null + self.length = 0 + + if (list && typeof list.forEach === 'function') { + list.forEach(function (item) { + self.push(item) + }) + } else if (arguments.length > 0) { + for (var i = 0, l = arguments.length; i < l; i++) { + self.push(arguments[i]) + } + } + + return self +} + +Yallist.prototype.removeNode = function (node) { + if (node.list !== this) { + throw new Error('removing node which does not belong to this list') + } + + var next = node.next + var prev = node.prev + + if (next) { + next.prev = prev + } + + if (prev) { + prev.next = next + } + + if (node === this.head) { + this.head = next + } + if (node === this.tail) { + this.tail = prev + } + + node.list.length-- + node.next = null + node.prev = null + node.list = null + + return next +} + +Yallist.prototype.unshiftNode = function (node) { + if (node === this.head) { + return + } + + if (node.list) { + node.list.removeNode(node) + } + + var head = this.head + node.list = this + node.next = head + if (head) { + head.prev = node + } + + this.head = node + if (!this.tail) { + this.tail = node + } + this.length++ +} + +Yallist.prototype.pushNode = function (node) { + if (node === this.tail) { + return + } + + if (node.list) { + node.list.removeNode(node) + } + + var tail = this.tail + node.list = this + node.prev = tail + if (tail) { + tail.next = node + } + + this.tail = node + if (!this.head) { + this.head = node + } + this.length++ +} + +Yallist.prototype.push = function () { + for (var i = 0, l = arguments.length; i < l; i++) { + push(this, arguments[i]) + } + return this.length +} + +Yallist.prototype.unshift = function () { + for (var i = 0, l = arguments.length; i < l; i++) { + unshift(this, arguments[i]) + } + return this.length +} + +Yallist.prototype.pop = function () { + if (!this.tail) { + return undefined + } + + var res = this.tail.value + this.tail = this.tail.prev + if (this.tail) { + this.tail.next = null + } else { + this.head = null + } + this.length-- + return res +} + +Yallist.prototype.shift = function () { + if (!this.head) { + return undefined + } + + var res = this.head.value + this.head = this.head.next + if (this.head) { + this.head.prev = null + } else { + this.tail = null + } + this.length-- + return res +} + +Yallist.prototype.forEach = function (fn, thisp) { + thisp = thisp || this + for (var walker = this.head, i = 0; walker !== null; i++) { + fn.call(thisp, walker.value, i, this) + walker = walker.next + } +} + +Yallist.prototype.forEachReverse = function (fn, thisp) { + thisp = thisp || this + for (var walker = this.tail, i = this.length - 1; walker !== null; i--) { + fn.call(thisp, walker.value, i, this) + walker = walker.prev + } +} + +Yallist.prototype.get = function (n) { + for (var i = 0, walker = this.head; walker !== null && i < n; i++) { + // abort out of the list early if we hit a cycle + walker = walker.next + } + if (i === n && walker !== null) { + return walker.value + } +} + +Yallist.prototype.getReverse = function (n) { + for (var i = 0, walker = this.tail; walker !== null && i < n; i++) { + // abort out of the list early if we hit a cycle + walker = walker.prev + } + if (i === n && walker !== null) { + return walker.value + } +} + +Yallist.prototype.map = function (fn, thisp) { + thisp = thisp || this + var res = new Yallist() + for (var walker = this.head; walker !== null;) { + res.push(fn.call(thisp, walker.value, this)) + walker = walker.next + } + return res +} + +Yallist.prototype.mapReverse = function (fn, thisp) { + thisp = thisp || this + var res = new Yallist() + for (var walker = this.tail; walker !== null;) { + res.push(fn.call(thisp, walker.value, this)) + walker = walker.prev + } + return res +} + +Yallist.prototype.reduce = function (fn, initial) { + var acc + var walker = this.head + if (arguments.length > 1) { + acc = initial + } else if (this.head) { + walker = this.head.next + acc = this.head.value + } else { + throw new TypeError('Reduce of empty list with no initial value') + } + + for (var i = 0; walker !== null; i++) { + acc = fn(acc, walker.value, i) + walker = walker.next + } + + return acc +} + +Yallist.prototype.reduceReverse = function (fn, initial) { + var acc + var walker = this.tail + if (arguments.length > 1) { + acc = initial + } else if (this.tail) { + walker = this.tail.prev + acc = this.tail.value + } else { + throw new TypeError('Reduce of empty list with no initial value') + } + + for (var i = this.length - 1; walker !== null; i--) { + acc = fn(acc, walker.value, i) + walker = walker.prev + } + + return acc +} + +Yallist.prototype.toArray = function () { + var arr = new Array(this.length) + for (var i = 0, walker = this.head; walker !== null; i++) { + arr[i] = walker.value + walker = walker.next + } + return arr +} + +Yallist.prototype.toArrayReverse = function () { + var arr = new Array(this.length) + for (var i = 0, walker = this.tail; walker !== null; i++) { + arr[i] = walker.value + walker = walker.prev + } + return arr +} + +Yallist.prototype.slice = function (from, to) { + to = to || this.length + if (to < 0) { + to += this.length + } + from = from || 0 + if (from < 0) { + from += this.length + } + var ret = new Yallist() + if (to < from || to < 0) { + return ret + } + if (from < 0) { + from = 0 + } + if (to > this.length) { + to = this.length + } + for (var i = 0, walker = this.head; walker !== null && i < from; i++) { + walker = walker.next + } + for (; walker !== null && i < to; i++, walker = walker.next) { + ret.push(walker.value) + } + return ret +} + +Yallist.prototype.sliceReverse = function (from, to) { + to = to || this.length + if (to < 0) { + to += this.length + } + from = from || 0 + if (from < 0) { + from += this.length + } + var ret = new Yallist() + if (to < from || to < 0) { + return ret + } + if (from < 0) { + from = 0 + } + if (to > this.length) { + to = this.length + } + for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) { + walker = walker.prev + } + for (; walker !== null && i > from; i--, walker = walker.prev) { + ret.push(walker.value) + } + return ret +} + +Yallist.prototype.splice = function (start, deleteCount, ...nodes) { + if (start > this.length) { + start = this.length - 1 + } + if (start < 0) { + start = this.length + start; + } + + for (var i = 0, walker = this.head; walker !== null && i < start; i++) { + walker = walker.next + } + + var ret = [] + for (var i = 0; walker && i < deleteCount; i++) { + ret.push(walker.value) + walker = this.removeNode(walker) + } + if (walker === null) { + walker = this.tail + } + + if (walker !== this.head && walker !== this.tail) { + walker = walker.prev + } + + for (var i = 0; i < nodes.length; i++) { + walker = insert(this, walker, nodes[i]) + } + return ret; +} + +Yallist.prototype.reverse = function () { + var head = this.head + var tail = this.tail + for (var walker = head; walker !== null; walker = walker.prev) { + var p = walker.prev + walker.prev = walker.next + walker.next = p + } + this.head = tail + this.tail = head + return this +} + +function insert (self, node, value) { + var inserted = node === self.head ? + new Node(value, null, node, self) : + new Node(value, node, node.next, self) + + if (inserted.next === null) { + self.tail = inserted + } + if (inserted.prev === null) { + self.head = inserted + } + + self.length++ + + return inserted +} + +function push (self, item) { + self.tail = new Node(item, self.tail, null, self) + if (!self.head) { + self.head = self.tail + } + self.length++ +} + +function unshift (self, item) { + self.head = new Node(item, null, self.head, self) + if (!self.tail) { + self.tail = self.head + } + self.length++ +} + +function Node (value, prev, next, list) { + if (!(this instanceof Node)) { + return new Node(value, prev, next, list) + } + + this.list = list + this.value = value + + if (prev) { + prev.next = this + this.prev = prev + } else { + this.prev = null + } + + if (next) { + next.prev = this + this.next = next + } else { + this.next = null + } +} + +try { + // add if support for Symbol.iterator is present + __webpack_require__(396)(Yallist) +} catch (er) {} + + +/***/ }), /* 613 */, /* 614 */ /***/ (function(module) { @@ -27380,7 +29113,15 @@ module.exports = new Type('tag:yaml.org,2002:js/regexp', { /***/ }), -/* 630 */, +/* 630 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const rcompare = (a, b, loose) => compare(b, a, loose) +module.exports = rcompare + + +/***/ }), /* 631 */ /***/ (function(module) { @@ -28027,7 +29768,18 @@ exports.dom = DOMImpl.instance; /***/ }), /* 649 */, -/* 650 */, +/* 650 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(830) +const prerelease = (version, options) => { + const parsed = parse(version, options) + return (parsed && parsed.prerelease.length) ? parsed.prerelease : null +} +module.exports = prerelease + + +/***/ }), /* 651 */, /* 652 */, /* 653 */, @@ -30984,7 +32736,347 @@ WebIDLAlgorithm_1.idl_defineConst(ElementImpl.prototype, "_nodeType", interfaces /* 699 */, /* 700 */, /* 701 */, -/* 702 */, +/* 702 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +"use strict"; + + +// A linked list to keep track of recently-used-ness +const Yallist = __webpack_require__(612) + +const MAX = Symbol('max') +const LENGTH = Symbol('length') +const LENGTH_CALCULATOR = Symbol('lengthCalculator') +const ALLOW_STALE = Symbol('allowStale') +const MAX_AGE = Symbol('maxAge') +const DISPOSE = Symbol('dispose') +const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet') +const LRU_LIST = Symbol('lruList') +const CACHE = Symbol('cache') +const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet') + +const naiveLength = () => 1 + +// lruList is a yallist where the head is the youngest +// item, and the tail is the oldest. the list contains the Hit +// objects as the entries. +// Each Hit object has a reference to its Yallist.Node. This +// never changes. +// +// cache is a Map (or PseudoMap) that matches the keys to +// the Yallist.Node object. +class LRUCache { + constructor (options) { + if (typeof options === 'number') + options = { max: options } + + if (!options) + options = {} + + if (options.max && (typeof options.max !== 'number' || options.max < 0)) + throw new TypeError('max must be a non-negative number') + // Kind of weird to have a default max of Infinity, but oh well. + const max = this[MAX] = options.max || Infinity + + const lc = options.length || naiveLength + this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc + this[ALLOW_STALE] = options.stale || false + if (options.maxAge && typeof options.maxAge !== 'number') + throw new TypeError('maxAge must be a number') + this[MAX_AGE] = options.maxAge || 0 + this[DISPOSE] = options.dispose + this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false + this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false + this.reset() + } + + // resize the cache when the max changes. + set max (mL) { + if (typeof mL !== 'number' || mL < 0) + throw new TypeError('max must be a non-negative number') + + this[MAX] = mL || Infinity + trim(this) + } + get max () { + return this[MAX] + } + + set allowStale (allowStale) { + this[ALLOW_STALE] = !!allowStale + } + get allowStale () { + return this[ALLOW_STALE] + } + + set maxAge (mA) { + if (typeof mA !== 'number') + throw new TypeError('maxAge must be a non-negative number') + + this[MAX_AGE] = mA + trim(this) + } + get maxAge () { + return this[MAX_AGE] + } + + // resize the cache when the lengthCalculator changes. + set lengthCalculator (lC) { + if (typeof lC !== 'function') + lC = naiveLength + + if (lC !== this[LENGTH_CALCULATOR]) { + this[LENGTH_CALCULATOR] = lC + this[LENGTH] = 0 + this[LRU_LIST].forEach(hit => { + hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key) + this[LENGTH] += hit.length + }) + } + trim(this) + } + get lengthCalculator () { return this[LENGTH_CALCULATOR] } + + get length () { return this[LENGTH] } + get itemCount () { return this[LRU_LIST].length } + + rforEach (fn, thisp) { + thisp = thisp || this + for (let walker = this[LRU_LIST].tail; walker !== null;) { + const prev = walker.prev + forEachStep(this, fn, walker, thisp) + walker = prev + } + } + + forEach (fn, thisp) { + thisp = thisp || this + for (let walker = this[LRU_LIST].head; walker !== null;) { + const next = walker.next + forEachStep(this, fn, walker, thisp) + walker = next + } + } + + keys () { + return this[LRU_LIST].toArray().map(k => k.key) + } + + values () { + return this[LRU_LIST].toArray().map(k => k.value) + } + + reset () { + if (this[DISPOSE] && + this[LRU_LIST] && + this[LRU_LIST].length) { + this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value)) + } + + this[CACHE] = new Map() // hash of items by key + this[LRU_LIST] = new Yallist() // list of items in order of use recency + this[LENGTH] = 0 // length of items in the list + } + + dump () { + return this[LRU_LIST].map(hit => + isStale(this, hit) ? false : { + k: hit.key, + v: hit.value, + e: hit.now + (hit.maxAge || 0) + }).toArray().filter(h => h) + } + + dumpLru () { + return this[LRU_LIST] + } + + set (key, value, maxAge) { + maxAge = maxAge || this[MAX_AGE] + + if (maxAge && typeof maxAge !== 'number') + throw new TypeError('maxAge must be a number') + + const now = maxAge ? Date.now() : 0 + const len = this[LENGTH_CALCULATOR](value, key) + + if (this[CACHE].has(key)) { + if (len > this[MAX]) { + del(this, this[CACHE].get(key)) + return false + } + + const node = this[CACHE].get(key) + const item = node.value + + // dispose of the old one before overwriting + // split out into 2 ifs for better coverage tracking + if (this[DISPOSE]) { + if (!this[NO_DISPOSE_ON_SET]) + this[DISPOSE](key, item.value) + } + + item.now = now + item.maxAge = maxAge + item.value = value + this[LENGTH] += len - item.length + item.length = len + this.get(key) + trim(this) + return true + } + + const hit = new Entry(key, value, len, now, maxAge) + + // oversized objects fall out of cache automatically. + if (hit.length > this[MAX]) { + if (this[DISPOSE]) + this[DISPOSE](key, value) + + return false + } + + this[LENGTH] += hit.length + this[LRU_LIST].unshift(hit) + this[CACHE].set(key, this[LRU_LIST].head) + trim(this) + return true + } + + has (key) { + if (!this[CACHE].has(key)) return false + const hit = this[CACHE].get(key).value + return !isStale(this, hit) + } + + get (key) { + return get(this, key, true) + } + + peek (key) { + return get(this, key, false) + } + + pop () { + const node = this[LRU_LIST].tail + if (!node) + return null + + del(this, node) + return node.value + } + + del (key) { + del(this, this[CACHE].get(key)) + } + + load (arr) { + // reset the cache + this.reset() + + const now = Date.now() + // A previous serialized cache has the most recent items first + for (let l = arr.length - 1; l >= 0; l--) { + const hit = arr[l] + const expiresAt = hit.e || 0 + if (expiresAt === 0) + // the item was created without expiration in a non aged cache + this.set(hit.k, hit.v) + else { + const maxAge = expiresAt - now + // dont add already expired items + if (maxAge > 0) { + this.set(hit.k, hit.v, maxAge) + } + } + } + } + + prune () { + this[CACHE].forEach((value, key) => get(this, key, false)) + } +} + +const get = (self, key, doUse) => { + const node = self[CACHE].get(key) + if (node) { + const hit = node.value + if (isStale(self, hit)) { + del(self, node) + if (!self[ALLOW_STALE]) + return undefined + } else { + if (doUse) { + if (self[UPDATE_AGE_ON_GET]) + node.value.now = Date.now() + self[LRU_LIST].unshiftNode(node) + } + } + return hit.value + } +} + +const isStale = (self, hit) => { + if (!hit || (!hit.maxAge && !self[MAX_AGE])) + return false + + const diff = Date.now() - hit.now + return hit.maxAge ? diff > hit.maxAge + : self[MAX_AGE] && (diff > self[MAX_AGE]) +} + +const trim = self => { + if (self[LENGTH] > self[MAX]) { + for (let walker = self[LRU_LIST].tail; + self[LENGTH] > self[MAX] && walker !== null;) { + // We know that we're about to delete this one, and also + // what the next least recently used key will be, so just + // go ahead and set it now. + const prev = walker.prev + del(self, walker) + walker = prev + } + } +} + +const del = (self, node) => { + if (node) { + const hit = node.value + if (self[DISPOSE]) + self[DISPOSE](hit.key, hit.value) + + self[LENGTH] -= hit.length + self[CACHE].delete(hit.key) + self[LRU_LIST].removeNode(node) + } +} + +class Entry { + constructor (key, value, length, now, maxAge) { + this.key = key + this.value = value + this.length = length + this.now = now + this.maxAge = maxAge || 0 + } +} + +const forEachStep = (self, fn, node, thisp) => { + let hit = node.value + if (isStale(self, hit)) { + del(self, node) + if (!self[ALLOW_STALE]) + hit = undefined + } + if (hit) + fn.call(thisp, hit.value, hit.key, self) +} + +module.exports = LRUCache + + +/***/ }), /* 703 */, /* 704 */ /***/ (function(__unusedmodule, exports) { @@ -31411,7 +33503,18 @@ exports.abort_signalAbort = abort_signalAbort; /* 711 */, /* 712 */, /* 713 */, -/* 714 */, +/* 714 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(830) +const valid = (version, options) => { + const v = parse(version, options) + return v ? v.version : null +} +module.exports = valid + + +/***/ }), /* 715 */, /* 716 */, /* 717 */, @@ -31909,7 +34012,15 @@ exports.sanitizeInput = sanitizeInput; //# sourceMappingURL=dom.js.map /***/ }), -/* 744 */, +/* 744 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const major = (a, loose) => new SemVer(a, loose).major +module.exports = major + + +/***/ }), /* 745 */, /* 746 */, /* 747 */ @@ -32013,7 +34124,60 @@ exports.MapWriter = MapWriter; /***/ }), /* 751 */, -/* 752 */, +/* 752 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const eq = __webpack_require__(298) +const neq = __webpack_require__(85) +const gt = __webpack_require__(486) +const gte = __webpack_require__(167) +const lt = __webpack_require__(586) +const lte = __webpack_require__(898) + +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 + + +/***/ }), /* 753 */, /* 754 */, /* 755 */, @@ -33392,7 +35556,15 @@ exports.NodeIteratorImpl = NodeIteratorImpl; /***/ }), /* 801 */, /* 802 */, -/* 803 */, +/* 803 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const minor = (a, loose) => new SemVer(a, loose).minor +module.exports = minor + + +/***/ }), /* 804 */, /* 805 */, /* 806 */, @@ -33460,7 +35632,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -36287,7 +38459,12 @@ exports.asciiSerializationOfAnOrigin = asciiSerializationOfAnOrigin; /* 815 */, /* 816 */, /* 817 */, -/* 818 */, +/* 818 */ +/***/ (function(module) { + +module.exports = require("tls"); + +/***/ }), /* 819 */, /* 820 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -36405,7 +38582,35 @@ WebIDLAlgorithm_1.idl_defineConst(TextImpl.prototype, "_nodeType", interfaces_1. /***/ }), /* 821 */, -/* 822 */, +/* 822 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const parse = __webpack_require__(830) +const eq = __webpack_require__(298) + +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 + + +/***/ }), /* 823 */, /* 824 */, /* 825 */, @@ -37413,7 +39618,45 @@ exports.event_deactivateAnEventHandler = event_deactivateAnEventHandler; /* 827 */, /* 828 */, /* 829 */, -/* 830 */, +/* 830 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const {MAX_LENGTH} = __webpack_require__(181) +const { re, t } = __webpack_require__(976) +const SemVer = __webpack_require__(65) + +const parseOptions = __webpack_require__(143) +const parse = (version, options) => { + options = parseOptions(options) + + 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 + + +/***/ }), /* 831 */, /* 832 */, /* 833 */, @@ -38642,14 +40885,211 @@ exports.tree_retarget = tree_retarget; //# sourceMappingURL=TreeAlgorithm.js.map /***/ }), -/* 874 */, +/* 874 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const compare = (a, b, loose) => + new SemVer(a, loose).compare(new SemVer(b, loose)) + +module.exports = compare + + +/***/ }), /* 875 */, -/* 876 */, -/* 877 */, +/* 876 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +// just pre-load all the stuff that index.js lazily exports +const internalRe = __webpack_require__(976) +module.exports = { + re: internalRe.re, + src: internalRe.src, + tokens: internalRe.t, + SEMVER_SPEC_VERSION: __webpack_require__(181).SEMVER_SPEC_VERSION, + SemVer: __webpack_require__(65), + compareIdentifiers: __webpack_require__(954).compareIdentifiers, + rcompareIdentifiers: __webpack_require__(954).rcompareIdentifiers, + parse: __webpack_require__(830), + valid: __webpack_require__(714), + clean: __webpack_require__(503), + inc: __webpack_require__(928), + diff: __webpack_require__(822), + major: __webpack_require__(744), + minor: __webpack_require__(803), + patch: __webpack_require__(489), + prerelease: __webpack_require__(650), + compare: __webpack_require__(874), + rcompare: __webpack_require__(630), + compareLoose: __webpack_require__(283), + compareBuild: __webpack_require__(16), + sort: __webpack_require__(120), + rsort: __webpack_require__(593), + gt: __webpack_require__(486), + lt: __webpack_require__(586), + eq: __webpack_require__(298), + neq: __webpack_require__(85), + gte: __webpack_require__(167), + lte: __webpack_require__(898), + cmp: __webpack_require__(752), + coerce: __webpack_require__(499), + Comparator: __webpack_require__(536), + Range: __webpack_require__(124), + satisfies: __webpack_require__(310), + toComparators: __webpack_require__(219), + maxSatisfying: __webpack_require__(14), + minSatisfying: __webpack_require__(890), + minVersion: __webpack_require__(960), + validRange: __webpack_require__(480), + outside: __webpack_require__(881), + gtr: __webpack_require__(531), + ltr: __webpack_require__(323), + intersects: __webpack_require__(259), + simplifyRange: __webpack_require__(877), + subset: __webpack_require__(999), +} + + +/***/ }), +/* 877 */ +/***/ (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__(310) +const compare = __webpack_require__(874) +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 +} + + +/***/ }), /* 878 */, /* 879 */, /* 880 */, -/* 881 */, +/* 881 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const Comparator = __webpack_require__(536) +const {ANY} = Comparator +const Range = __webpack_require__(124) +const satisfies = __webpack_require__(310) +const gt = __webpack_require__(486) +const lt = __webpack_require__(586) +const lte = __webpack_require__(898) +const gte = __webpack_require__(167) + +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 satisfies 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 + + +/***/ }), /* 882 */, /* 883 */, /* 884 */ @@ -38672,7 +41112,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -38919,7 +41359,36 @@ exports.ObjectCache = ObjectCache; //# sourceMappingURL=ObjectCache.js.map /***/ }), -/* 890 */, +/* 890 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const Range = __webpack_require__(124) +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 + + +/***/ }), /* 891 */, /* 892 */, /* 893 */, @@ -38927,7 +41396,15 @@ exports.ObjectCache = ObjectCache; /* 895 */, /* 896 */, /* 897 */, -/* 898 */, +/* 898 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const compare = __webpack_require__(874) +const lte = (a, b, loose) => compare(a, b, loose) <= 0 +module.exports = lte + + +/***/ }), /* 899 */, /* 900 */, /* 901 */, @@ -39747,7 +42224,27 @@ module.exports = new Type('tag:yaml.org,2002:seq', { /* 925 */, /* 926 */, /* 927 */, -/* 928 */, +/* 928 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) + +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 + + +/***/ }), /* 929 */, /* 930 */, /* 931 */, @@ -41063,13 +43560,106 @@ exports.checkBypass = checkBypass; /* 951 */, /* 952 */, /* 953 */, -/* 954 */, +/* 954 */ +/***/ (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 +} + + +/***/ }), /* 955 */, /* 956 */, /* 957 */, /* 958 */, /* 959 */, -/* 960 */, +/* 960 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const SemVer = __webpack_require__(65) +const Range = __webpack_require__(124) +const gt = __webpack_require__(486) + +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] + + let setMin = null + 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 (!setMin || gt(compver, setMin)) { + setMin = compver + } + break + case '<': + case '<=': + /* Ignore maximum versions */ + break + /* istanbul ignore next */ + default: + throw new Error(`Unexpected operation: ${comparator.operator}`) + } + }) + if (setMin && (!minver || gt(minver, setMin))) + minver = setMin + } + + if (minver && range.test(minver)) { + return minver + } + + return null +} +module.exports = minVersion + + +/***/ }), /* 961 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -41360,7 +43950,194 @@ var HowToCompare; /* 973 */, /* 974 */, /* 975 */, -/* 976 */, +/* 976 */ +/***/ (function(module, exports, __webpack_require__) { + +const { MAX_SAFE_COMPONENT_LENGTH } = __webpack_require__(181) +const debug = __webpack_require__(548) +exports = module.exports = {} + +// 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*$') + + +/***/ }), /* 977 */, /* 978 */, /* 979 */ @@ -41719,5 +44496,181 @@ var AbortControllerImpl = /** @class */ (function () { exports.AbortControllerImpl = AbortControllerImpl; //# sourceMappingURL=AbortControllerImpl.js.map +/***/ }), +/* 991 */, +/* 992 */, +/* 993 */, +/* 994 */, +/* 995 */, +/* 996 */, +/* 997 */, +/* 998 */, +/* 999 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +const Range = __webpack_require__(124) +const { ANY } = __webpack_require__(536) +const satisfies = __webpack_require__(310) +const compare = __webpack_require__(874) + +// 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.semver 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 any < or <= 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) => { + if (sub === dom) + return true + + 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 === dom) + return true + + 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 && higher !== gt) + 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 && lower !== lt) + 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 + + /***/ }) /******/ ]); \ No newline at end of file From 9887b5cf979ae339ab0caaa4e21dcc834b99514e Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 18 Mar 2021 15:47:15 +0300 Subject: [PATCH 03/13] resolving comments --- __tests__/distributors/base-installer.test.ts | 11 +++++------ dist/setup/index.js | 14 ++++++++++---- src/distributions/base-installer.ts | 7 +++++-- src/setup-java.ts | 6 +++--- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index 3fd28f53d..ab963cd63 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -225,24 +225,23 @@ describe('setupJava', () => { mockJavaBase = new EmptyJavaBase(input); await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); expect(spyGetToolcachePath).toHaveBeenCalled(); - expect(spyCoreInfo).toHaveBeenCalledWith( - `Java ${input.version} was not found in tool-cache. Trying to download...` - ); + expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve latest version remotely'); + expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...'); expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${installedJavaVersion} was downloaded`); }); it.each([ [ { version: '11', architecture: 'x86', packageType: 'jre' }, - { path: `toolcache/Java_Empty_jre/11.0.9/x86`, version: '11.0.9' } + { path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'), version: '11.0.9' } ], [ { version: '11', architecture: 'x64', packageType: 'jdk' }, - { path: `toolcache/Java_Empty_jdk/11.0.9/x64`, version: '11.0.9' } + { path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64'), version: '11.0.9' } ], [ { version: '11', architecture: 'x64', packageType: 'jre' }, - { path: `toolcache/Java_Empty_jre/11.0.9/x64`, version: '11.0.9' } + { path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x64'), version: '11.0.9' } ] ])('download java with configuration %s', async (input, expected) => { mockJavaBase = new EmptyJavaBase(input); diff --git a/dist/setup/index.js b/dist/setup/index.js index 9c36741f7..e676f8e8d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -3957,6 +3957,7 @@ const httpm = __importStar(__webpack_require__(539)); const util_1 = __webpack_require__(322); class JavaBase { constructor(distribution, installerOptions) { + var _a; this.distribution = distribution; this.http = new httpm.HttpClient('actions/setup-java', undefined, { allowRetries: true, @@ -3965,7 +3966,7 @@ class JavaBase { ({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version)); this.architecture = installerOptions.architecture; this.packageType = installerOptions.packageType; - this.checkLatest = !!installerOptions.checkLatest; + this.checkLatest = (_a = installerOptions.checkLatest) !== null && _a !== void 0 ? _a : false; } setupJava() { return __awaiter(this, void 0, void 0, function* () { @@ -3974,12 +3975,16 @@ class JavaBase { core.info(`Resolved Java ${foundJava.version} from tool-cache`); } else { - core.info(`Java ${this.version} was not found in tool-cache. Trying to download...`); + core.info('Trying to resolve latest version remotely'); const javaRelease = yield this.findPackageForDownload(this.version); + core.info('Trying to download...'); if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) != javaRelease.version) { foundJava = yield this.downloadTool(javaRelease); core.info(`Java ${foundJava.version} was downloaded`); } + else { + core.info('latest version was resolved locally'); + } core.info(`Java ${foundJava.version} was resolved`); } core.info(`Setting Java ${foundJava.version} as the default`); @@ -35648,6 +35653,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(__webpack_require__(470)); const auth = __importStar(__webpack_require__(331)); +const util_1 = __webpack_require__(322); const constants = __importStar(__webpack_require__(211)); const path = __importStar(__webpack_require__(622)); const distribution_factory_1 = __webpack_require__(24); @@ -35659,12 +35665,12 @@ function run() { const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); const jdkFile = core.getInput(constants.INPUT_JDK_FILE); - const checkLatest = core.getInput(constants.INPUT_CHECK_LATEST); + const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false); const installerOptions = { architecture, packageType, version, - checkLatest: checkLatest ? false : checkLatest.toLowerCase() === 'true' + checkLatest }; const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile); if (!distribution) { diff --git a/src/distributions/base-installer.ts b/src/distributions/base-installer.ts index 36634b9a2..474415671 100644 --- a/src/distributions/base-installer.ts +++ b/src/distributions/base-installer.ts @@ -25,7 +25,7 @@ export abstract class JavaBase { )); this.architecture = installerOptions.architecture; this.packageType = installerOptions.packageType; - this.checkLatest = !!installerOptions.checkLatest; + this.checkLatest = installerOptions.checkLatest ?? false; } protected abstract downloadTool(javaRelease: JavaDownloadRelease): Promise; @@ -36,11 +36,14 @@ export abstract class JavaBase { if (foundJava && !this.checkLatest) { core.info(`Resolved Java ${foundJava.version} from tool-cache`); } else { - core.info(`Java ${this.version} was not found in tool-cache. Trying to download...`); + core.info('Trying to resolve latest version remotely'); const javaRelease = await this.findPackageForDownload(this.version); + core.info('Trying to download...'); if (foundJava?.version != javaRelease.version) { foundJava = await this.downloadTool(javaRelease); core.info(`Java ${foundJava.version} was downloaded`); + } else { + core.info('latest version was resolved locally'); } core.info(`Java ${foundJava.version} was resolved`); diff --git a/src/setup-java.ts b/src/setup-java.ts index f7e6b9807..92a861979 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -1,6 +1,6 @@ import * as core from '@actions/core'; import * as auth from './auth'; - +import { getBooleanInput } from './util'; import * as constants from './constants'; import * as path from 'path'; import { getJavaDistribution } from './distributions/distribution-factory'; @@ -13,13 +13,13 @@ async function run() { const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); const jdkFile = core.getInput(constants.INPUT_JDK_FILE); - const checkLatest = core.getInput(constants.INPUT_CHECK_LATEST); + const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false); const installerOptions: JavaInstallerOptions = { architecture, packageType, version, - checkLatest: checkLatest ? false : checkLatest.toLowerCase() === 'true' + checkLatest }; const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile); From 94a128fb67f07b19bacfe2b8abe084eda7f008c2 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 18 Mar 2021 15:54:22 +0300 Subject: [PATCH 04/13] fixing tests --- __tests__/distributors/base-installer.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index ab963cd63..b1a8935f9 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -20,7 +20,7 @@ class EmptyJavaBase extends JavaBase { protected async downloadTool(javaRelease: JavaDownloadRelease): Promise { return { version: '11.0.9', - path: `toolcache/${this.toolcacheFolderName}/11.0.9/${this.architecture}` + path: path.join('toolcache', this.toolcacheFolderName, '11.0.9', this.architecture); }; } From d87fc52c90640aae1fdac3a024801a04d2933656 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Thu, 18 Mar 2021 16:14:15 +0300 Subject: [PATCH 05/13] fix spelling --- __tests__/distributors/base-installer.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index b1a8935f9..6eb3300ed 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -20,7 +20,7 @@ class EmptyJavaBase extends JavaBase { protected async downloadTool(javaRelease: JavaDownloadRelease): Promise { return { version: '11.0.9', - path: path.join('toolcache', this.toolcacheFolderName, '11.0.9', this.architecture); + path: path.join('toolcache', this.toolcacheFolderName, '11.0.9', this.architecture) }; } From 2c10c084ccf2c02db30baab2e5b37a517e5f2ac0 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Fri, 19 Mar 2021 10:14:59 +0300 Subject: [PATCH 06/13] improve core.info messages --- .github/workflows/e2e-versions.yml | 20 +---- __tests__/distributors/base-installer.test.ts | 86 ++++++++++++------- src/distributions/base-installer.ts | 15 ++-- 3 files changed, 67 insertions(+), 54 deletions(-) diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index d283e078b..dff64f04f 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -70,8 +70,8 @@ jobs: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" shell: bash - setup-java-major-minor-versions-with-check-latest: - name: ${{ matrix.distribution }} ${{ matrix.version }} (jdk-x64) - ${{ matrix.os }} + setup-java-check-latest: + name: ${{ matrix.distribution }} ${{ matrix.version }} - check-latest flag - ${{ matrix.os }} needs: setup-java-major-versions runs-on: ${{ matrix.os }} strategy: @@ -79,20 +79,6 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] distribution: ['adopt', 'zulu'] - version: - - '11.0' - - '8.0.282' - - '11.0.2+7' - include: - - distribution: 'adopt' - version: '12.0.2+10.1' - os: macos-latest - - distribution: 'adopt' - version: '12.0.2+10.1' - os: windows-latest - - distribution: 'adopt' - version: '12.0.2+10.1' - os: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 @@ -100,8 +86,8 @@ jobs: uses: ./ id: setup-java with: - java-version: ${{ matrix.version }} distribution: ${{ matrix.distribution }} + java-version: 11 check-latest: true - name: Verify Java run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index 6eb3300ed..e55179cb3 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -85,7 +85,7 @@ describe('findInToolcache', () => { [{ version: '8', architecture: 'x64', packageType: 'jdk' }, null], [{ version: '11', architecture: 'x86', packageType: 'jdk' }, null], [{ version: '11', architecture: 'x86', packageType: 'jre' }, null] - ])(`should find java for path %o -> %o`, (input, expected) => { + ])(`should find java for path %s -> %s`, (input, expected) => { spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); spyGetToolcachePath.mockImplementation( (toolname: string, javaVersion: string, architecture: string) => { @@ -134,10 +134,10 @@ describe('findInToolcache', () => { }); describe('setupJava', () => { - const actualJavaVersion = '11.0.8'; - const installedJavaVersion = '11.0.9'; - const javaPath = path.join('Java_Empty_jdk', actualJavaVersion, 'x86'); - const javaPathInstalled = path.join('toolcache', 'Java_Empty_jdk', installedJavaVersion, 'x86'); + const actualJavaVersion = '11.0.9'; + const installedJavaVersion = '11.0.8'; + const javaPath = path.join('Java_Empty_jdk', installedJavaVersion, 'x86'); + const javaPathInstalled = path.join('toolcache', 'Java_Empty_jdk', actualJavaVersion, 'x86'); let mockJavaBase: EmptyJavaBase; @@ -159,12 +159,12 @@ describe('setupJava', () => { return ''; } - return semver.satisfies(actualJavaVersion, semverVersion) ? javaPath : ''; + return semver.satisfies(installedJavaVersion, semverVersion) ? javaPath : ''; } ); spyTcFindAllVersions = jest.spyOn(tc, 'findAllVersions'); - spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); + spyTcFindAllVersions.mockReturnValue([installedJavaVersion]); // Spy on core methods spyCoreDebug = jest.spyOn(core, 'debug'); @@ -192,64 +192,90 @@ describe('setupJava', () => { it.each([ [ { version: '11', architecture: 'x86', packageType: 'jdk' }, - { version: actualJavaVersion, path: javaPath } + { version: installedJavaVersion, path: javaPath } ], [ { version: '11.0', architecture: 'x86', packageType: 'jdk' }, - { version: actualJavaVersion, path: javaPath } + { version: installedJavaVersion, path: javaPath } ], [ { version: '11.0.8', architecture: 'x86', packageType: 'jdk' }, - { version: actualJavaVersion, path: javaPath } + { version: installedJavaVersion, path: javaPath } ] - ])('should find java locally for %o', (input, expected) => { + ])('should find java locally for %s', (input, expected) => { mockJavaBase = new EmptyJavaBase(input); expect(mockJavaBase.setupJava()).resolves.toEqual(expected); expect(spyGetToolcachePath).toHaveBeenCalled(); + expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${expected.version} from tool-cache`); + expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`) + expect(spyCoreInfo).not.toHaveBeenCalledWith('Trying to resolve the latest version from remote'); + expect(spyCoreInfo).not.toHaveBeenCalledWith('Trying to download...'); }); it.each([ [ - { version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: true }, - { version: installedJavaVersion, path: javaPathInstalled } + { version: '11', architecture: 'x86', packageType: 'jre' }, + { path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'), version: '11.0.9' } ], [ - { version: '11.0', architecture: 'x86', packageType: 'jdk', checkLatest: true }, - { version: installedJavaVersion, path: javaPathInstalled } + { version: '11', architecture: 'x64', packageType: 'jdk' }, + { path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64'), version: '11.0.9' } ], [ - { version: '11.0.x', architecture: 'x86', packageType: 'jdk', checkLatest: true }, - { version: installedJavaVersion, path: javaPathInstalled } + { version: '11', architecture: 'x64', packageType: 'jre' }, + { path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x64'), version: '11.0.9' } ] - ])('should check the latest java version for %o', async (input, expected) => { + ])('download java with configuration %s', async (input, expected) => { mockJavaBase = new EmptyJavaBase(input); await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); expect(spyGetToolcachePath).toHaveBeenCalled(); - expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve latest version remotely'); + expect(spyCoreAddPath).toHaveBeenCalled(); + expect(spyCoreExportVariable).toHaveBeenCalled(); + expect(spyCoreSetOutput).toHaveBeenCalled(); + expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote'); + expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`); expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...'); - expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${installedJavaVersion} was downloaded`); + expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${expected.version} was downloaded`); + expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`) }); it.each([ [ - { version: '11', architecture: 'x86', packageType: 'jre' }, - { path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'), version: '11.0.9' } + { version: '11.0.9', architecture: 'x86', packageType: 'jdk', checkLatest: true }, + { version: '11.0.9', path: javaPathInstalled } ], + ])('should check the latest java version for %s and resolve locally', async (input, expected) => { + mockJavaBase = new EmptyJavaBase(input); + mockJavaBase['findInToolcache'] = () => ({ version: '11.0.9', path: expected.path }); + await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); + expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote'); + expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`); + expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${expected.version} from tool-cache`); + expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`) + }); + + it.each([ [ - { version: '11', architecture: 'x64', packageType: 'jdk' }, - { path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64'), version: '11.0.9' } + { version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: true }, + { version: actualJavaVersion, path: javaPathInstalled } ], [ - { version: '11', architecture: 'x64', packageType: 'jre' }, - { path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x64'), version: '11.0.9' } + { version: '11.0', architecture: 'x86', packageType: 'jdk', checkLatest: true }, + { version: actualJavaVersion, path: javaPathInstalled } + ], + [ + { version: '11.0.x', architecture: 'x86', packageType: 'jdk', checkLatest: true }, + { version: actualJavaVersion, path: javaPathInstalled } ] - ])('download java with configuration %s', async (input, expected) => { + ])('should check the latest java version for %s and download', async (input, expected) => { mockJavaBase = new EmptyJavaBase(input); await expect(mockJavaBase.setupJava()).resolves.toEqual(expected); expect(spyGetToolcachePath).toHaveBeenCalled(); - expect(spyCoreAddPath).toHaveBeenCalled(); - expect(spyCoreExportVariable).toHaveBeenCalled(); - expect(spyCoreSetOutput).toHaveBeenCalled(); + expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote'); + expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${actualJavaVersion}`); + expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...'); + expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${actualJavaVersion} was downloaded`); + expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`) }); it.each([ diff --git a/src/distributions/base-installer.ts b/src/distributions/base-installer.ts index 474415671..f40f69e2c 100644 --- a/src/distributions/base-installer.ts +++ b/src/distributions/base-installer.ts @@ -36,17 +36,18 @@ export abstract class JavaBase { if (foundJava && !this.checkLatest) { core.info(`Resolved Java ${foundJava.version} from tool-cache`); } else { - core.info('Trying to resolve latest version remotely'); + core.info('Trying to resolve the latest version from remote'); const javaRelease = await this.findPackageForDownload(this.version); - core.info('Trying to download...'); - if (foundJava?.version != javaRelease.version) { + core.info(`Resolved latest version as ${javaRelease.version}`); + core.info(foundJava?.version ?? ''); + core.info(javaRelease.version ?? ''); + if (foundJava?.version === javaRelease.version) { + core.info(`Resolved Java ${foundJava.version} from tool-cache`); + } else { + core.info('Trying to download...'); foundJava = await this.downloadTool(javaRelease); core.info(`Java ${foundJava.version} was downloaded`); - } else { - core.info('latest version was resolved locally'); } - - core.info(`Java ${foundJava.version} was resolved`); } core.info(`Setting Java ${foundJava.version} as the default`); From 02e59d3b987ea14c5fb061f288f00912af6edbc0 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Fri, 19 Mar 2021 15:48:20 +0300 Subject: [PATCH 07/13] run format --- __tests__/distributors/base-installer.test.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index e55179cb3..e57a5fe4b 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -207,8 +207,10 @@ describe('setupJava', () => { expect(mockJavaBase.setupJava()).resolves.toEqual(expected); expect(spyGetToolcachePath).toHaveBeenCalled(); expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${expected.version} from tool-cache`); - expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`) - expect(spyCoreInfo).not.toHaveBeenCalledWith('Trying to resolve the latest version from remote'); + expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`); + expect(spyCoreInfo).not.toHaveBeenCalledWith( + 'Trying to resolve the latest version from remote' + ); expect(spyCoreInfo).not.toHaveBeenCalledWith('Trying to download...'); }); @@ -236,14 +238,14 @@ describe('setupJava', () => { expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`); expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...'); expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${expected.version} was downloaded`); - expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`) + expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`); }); it.each([ [ { version: '11.0.9', architecture: 'x86', packageType: 'jdk', checkLatest: true }, { version: '11.0.9', path: javaPathInstalled } - ], + ] ])('should check the latest java version for %s and resolve locally', async (input, expected) => { mockJavaBase = new EmptyJavaBase(input); mockJavaBase['findInToolcache'] = () => ({ version: '11.0.9', path: expected.path }); @@ -251,7 +253,7 @@ describe('setupJava', () => { expect(spyCoreInfo).toHaveBeenCalledWith('Trying to resolve the latest version from remote'); expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${expected.version}`); expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved Java ${expected.version} from tool-cache`); - expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`) + expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`); }); it.each([ @@ -275,7 +277,7 @@ describe('setupJava', () => { expect(spyCoreInfo).toHaveBeenCalledWith(`Resolved latest version as ${actualJavaVersion}`); expect(spyCoreInfo).toHaveBeenCalledWith('Trying to download...'); expect(spyCoreInfo).toHaveBeenCalledWith(`Java ${actualJavaVersion} was downloaded`); - expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`) + expect(spyCoreInfo).toHaveBeenCalledWith(`Setting Java ${expected.version} as the default`); }); it.each([ From 1088d2a5a6c3e5860945281e24e7d1c64da84f6f Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Fri, 19 Mar 2021 16:09:18 +0300 Subject: [PATCH 08/13] run prerelease --- dist/setup/index.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index e676f8e8d..962be35c9 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -3969,23 +3969,26 @@ class JavaBase { this.checkLatest = (_a = installerOptions.checkLatest) !== null && _a !== void 0 ? _a : false; } setupJava() { + var _a, _b; return __awaiter(this, void 0, void 0, function* () { let foundJava = this.findInToolcache(); if (foundJava && !this.checkLatest) { core.info(`Resolved Java ${foundJava.version} from tool-cache`); } else { - core.info('Trying to resolve latest version remotely'); + core.info('Trying to resolve the latest version from remote'); const javaRelease = yield this.findPackageForDownload(this.version); - core.info('Trying to download...'); - if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) != javaRelease.version) { - foundJava = yield this.downloadTool(javaRelease); - core.info(`Java ${foundJava.version} was downloaded`); + core.info(`Resolved latest version as ${javaRelease.version}`); + core.info((_a = foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) !== null && _a !== void 0 ? _a : ''); + core.info((_b = javaRelease.version) !== null && _b !== void 0 ? _b : ''); + if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) { + core.info(`Resolved Java ${foundJava.version} from tool-cache`); } else { - core.info('latest version was resolved locally'); + core.info('Trying to download...'); + foundJava = yield this.downloadTool(javaRelease); + core.info(`Java ${foundJava.version} was downloaded`); } - core.info(`Java ${foundJava.version} was resolved`); } core.info(`Setting Java ${foundJava.version} as the default`); this.setJavaDefault(foundJava.version, foundJava.path); From 7a20e304b5bd56e5ddb87e05a2374d3cac1f4a01 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Fri, 19 Mar 2021 16:19:21 +0300 Subject: [PATCH 09/13] change version to fix test --- .github/workflows/e2e-versions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index dff64f04f..07e38c302 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -90,7 +90,7 @@ jobs: java-version: 11 check-latest: true - name: Verify Java - run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" + run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" shell: bash setup-java-ea-versions-zulu: From 6e6487b787797b591d9a9b72e9b5a9f8aada4ae2 Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Mon, 22 Mar 2021 12:14:18 +0300 Subject: [PATCH 10/13] resolve comment for check-latest --- .../distributors/adopt-installer.test.ts | 23 ++++--- __tests__/distributors/base-installer.test.ts | 37 +++++++----- .../distributors/local-installer.test.ts | 60 +++++++++++++++---- __tests__/distributors/zulu-installer.test.ts | 30 ++++++---- dist/setup/index.js | 3 +- src/distributions/base-installer.ts | 2 +- src/distributions/base-models.ts | 2 +- 7 files changed, 105 insertions(+), 52 deletions(-) diff --git a/__tests__/distributors/adopt-installer.test.ts b/__tests__/distributors/adopt-installer.test.ts index 4b4a3c0d8..9e2825e87 100644 --- a/__tests__/distributors/adopt-installer.test.ts +++ b/__tests__/distributors/adopt-installer.test.ts @@ -27,19 +27,19 @@ describe('getAvailableVersions', () => { it.each([ [ - { version: '11', architecture: 'x64', packageType: 'jdk' }, + { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, 'os=mac&architecture=x64&image_type=jdk&release_type=ga&page_size=20&page=0' ], [ - { version: '11', architecture: 'x86', packageType: 'jdk' }, + { version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false }, 'os=mac&architecture=x86&image_type=jdk&release_type=ga&page_size=20&page=0' ], [ - { version: '11', architecture: 'x64', packageType: 'jre' }, + { version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false }, 'os=mac&architecture=x64&image_type=jre&release_type=ga&page_size=20&page=0' ], [ - { version: '11-ea', architecture: 'x64', packageType: 'jdk' }, + { version: '11-ea', architecture: 'x64', packageType: 'jdk', checkLatest: false }, 'os=mac&architecture=x64&image_type=jdk&release_type=ea&page_size=20&page=0' ] ])( @@ -79,7 +79,8 @@ describe('getAvailableVersions', () => { const distribution = new AdoptDistribution({ version: '11', architecture: 'x64', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); const availableVersions = await distribution['getAvailableVersions'](); expect(availableVersions).not.toBeNull(); @@ -104,7 +105,8 @@ describe('findPackageForDownload', () => { const distribution = new AdoptDistribution({ version: '11', architecture: 'x64', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); distribution['getAvailableVersions'] = async () => manifestData; const resolvedVersion = await distribution['findPackageForDownload'](input); @@ -115,7 +117,8 @@ describe('findPackageForDownload', () => { const distribution = new AdoptDistribution({ version: '11', architecture: 'x64', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); distribution['getAvailableVersions'] = async () => manifestData; await expect(distribution['findPackageForDownload']('9.0.8')).rejects.toThrowError( @@ -127,7 +130,8 @@ describe('findPackageForDownload', () => { const distribution = new AdoptDistribution({ version: '11', architecture: 'x64', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); distribution['getAvailableVersions'] = async () => manifestData; await expect(distribution['findPackageForDownload']('7.x')).rejects.toThrowError( @@ -139,7 +143,8 @@ describe('findPackageForDownload', () => { const distribution = new AdoptDistribution({ version: '11', architecture: 'x64', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); distribution['getAvailableVersions'] = async () => []; await expect(distribution['findPackageForDownload']('11')).rejects.toThrowError( diff --git a/__tests__/distributors/base-installer.test.ts b/__tests__/distributors/base-installer.test.ts index e57a5fe4b..a36393a85 100644 --- a/__tests__/distributors/base-installer.test.ts +++ b/__tests__/distributors/base-installer.test.ts @@ -58,15 +58,15 @@ describe('findInToolcache', () => { it.each([ [ - { version: '11', architecture: 'x64', packageType: 'jdk' }, + { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.0', architecture: 'x64', packageType: 'jdk' }, + { version: '11.0', architecture: 'x64', packageType: 'jdk', checkLatest: false }, { version: actualJavaVersion, path: javaPath } ], [ - { version: '11.0.8', architecture: 'x64', packageType: 'jdk' }, + { version: '11.0.8', architecture: 'x64', packageType: 'jdk', checkLatest: false }, { version: actualJavaVersion, path: javaPath } ], [ @@ -81,10 +81,10 @@ describe('findInToolcache', () => { { version: '11.0.8', architecture: 'x64', packageType: 'jdk', checkLatest: true }, { version: actualJavaVersion, path: javaPath } ], - [{ version: '11', architecture: 'x64', packageType: 'jre' }, null], - [{ version: '8', architecture: 'x64', packageType: 'jdk' }, null], - [{ version: '11', architecture: 'x86', packageType: 'jdk' }, null], - [{ version: '11', architecture: 'x86', packageType: 'jre' }, null] + [{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false }, null], + [{ version: '8', architecture: 'x64', packageType: 'jdk', checkLatest: false }, null], + [{ version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false }, null], + [{ version: '11', architecture: 'x86', packageType: 'jre', checkLatest: false }, null] ])(`should find java for path %s -> %s`, (input, expected) => { spyTcFindAllVersions.mockReturnValue([actualJavaVersion]); spyGetToolcachePath.mockImplementation( @@ -127,7 +127,12 @@ describe('findInToolcache', () => { (toolname: string, javaVersion: string, architecture: string) => `/hostedtoolcache/${toolname}/${javaVersion}/${architecture}` ); - mockJavaBase = new EmptyJavaBase({ version: input, architecture: 'x64', packageType: 'jdk' }); + mockJavaBase = new EmptyJavaBase({ + version: input, + architecture: 'x64', + packageType: 'jdk', + checkLatest: false + }); const foundVersion = mockJavaBase['findInToolcache'](); expect(foundVersion?.version).toEqual(expected); }); @@ -191,15 +196,15 @@ describe('setupJava', () => { it.each([ [ - { version: '11', architecture: 'x86', packageType: 'jdk' }, + { version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false }, { version: installedJavaVersion, path: javaPath } ], [ - { version: '11.0', architecture: 'x86', packageType: 'jdk' }, + { version: '11.0', architecture: 'x86', packageType: 'jdk', checkLatest: false }, { version: installedJavaVersion, path: javaPath } ], [ - { version: '11.0.8', architecture: 'x86', packageType: 'jdk' }, + { version: '11.0.8', architecture: 'x86', packageType: 'jdk', checkLatest: false }, { version: installedJavaVersion, path: javaPath } ] ])('should find java locally for %s', (input, expected) => { @@ -216,15 +221,15 @@ describe('setupJava', () => { it.each([ [ - { version: '11', architecture: 'x86', packageType: 'jre' }, + { version: '11', architecture: 'x86', packageType: 'jre', checkLatest: false }, { path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'), version: '11.0.9' } ], [ - { version: '11', architecture: 'x64', packageType: 'jdk' }, + { version: '11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, { path: path.join('toolcache', 'Java_Empty_jdk', '11.0.9', 'x64'), version: '11.0.9' } ], [ - { version: '11', architecture: 'x64', packageType: 'jre' }, + { version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false }, { path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x64'), version: '11.0.9' } ] ])('download java with configuration %s', async (input, expected) => { @@ -281,8 +286,8 @@ describe('setupJava', () => { }); it.each([ - [{ version: '15', architecture: 'x86', packageType: 'jre' }], - [{ version: '11.0.7', architecture: 'x64', packageType: 'jre' }] + [{ version: '15', architecture: 'x86', packageType: 'jre', checkLatest: false }], + [{ version: '11.0.7', architecture: 'x64', packageType: 'jre', checkLatest: false }] ])('should throw an error for Available version not found for %s', async input => { mockJavaBase = new EmptyJavaBase(input); await expect(mockJavaBase.setupJava()).rejects.toThrowError('Available version not found'); diff --git a/__tests__/distributors/local-installer.test.ts b/__tests__/distributors/local-installer.test.ts index c3b085bfa..c1618971b 100644 --- a/__tests__/distributors/local-installer.test.ts +++ b/__tests__/distributors/local-installer.test.ts @@ -93,7 +93,12 @@ describe('setupJava', () => { }); it('java is resolved from toolcache, jdkfile is untouched', async () => { - const inputs = { version: actualJavaVersion, architecture: 'x86', packageType: 'jdk' }; + const inputs = { + version: actualJavaVersion, + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }; const jdkFile = 'not_existing_one'; const expected = { version: actualJavaVersion, @@ -110,7 +115,12 @@ describe('setupJava', () => { }); it("java is resolved from toolcache, jdkfile doesn't exist", async () => { - const inputs = { version: actualJavaVersion, architecture: 'x86', packageType: 'jdk' }; + const inputs = { + version: actualJavaVersion, + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }; const jdkFile = undefined; const expected = { version: actualJavaVersion, @@ -127,7 +137,12 @@ describe('setupJava', () => { }); it('java is unpacked from jdkfile', async () => { - const inputs = { version: '11.0.289', architecture: 'x86', packageType: 'jdk' }; + const inputs = { + version: '11.0.289', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }; const jdkFile = expectedJdkFile; const expected = { version: '11.0.289', @@ -147,7 +162,12 @@ describe('setupJava', () => { }); it('jdk file is not found', async () => { - const inputs = { version: '11.0.289', architecture: 'x86', packageType: 'jdk' }; + const inputs = { + version: '11.0.289', + architecture: 'x86', + packageType: 'jdk', + checkLatest: false + }; const jdkFile = 'not_existing_one'; const expected = { javaVersion: '11.0.289', @@ -170,10 +190,22 @@ describe('setupJava', () => { }); it.each([ - [{ version: '8.0.289', architecture: 'x64', packageType: 'jdk' }, 'otherJdkFile'], - [{ version: '11.0.289', architecture: 'x64', packageType: 'jdk' }, 'otherJdkFile'], - [{ version: '12.0.289', architecture: 'x64', packageType: 'jdk' }, 'otherJdkFile'], - [{ version: '11.1.11', architecture: 'x64', packageType: 'jdk' }, 'not_existing_one'] + [ + { version: '8.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false }, + 'otherJdkFile' + ], + [ + { version: '11.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false }, + 'otherJdkFile' + ], + [ + { version: '12.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false }, + 'otherJdkFile' + ], + [ + { version: '11.1.11', architecture: 'x64', packageType: 'jdk', checkLatest: false }, + 'not_existing_one' + ] ])( `Throw an error if jdkfile has wrong path, inputs %s, jdkfile %s, real name ${expectedJdkFile}`, async (inputs, jdkFile) => { @@ -186,9 +218,15 @@ describe('setupJava', () => { ); it.each([ - [{ version: '8.0.289', architecture: 'x64', packageType: 'jdk' }, ''], - [{ version: '7.0.289', architecture: 'x64', packageType: 'jdk' }, undefined], - [{ version: '11.0.289', architecture: 'x64', packageType: 'jdk' }, undefined] + [{ version: '8.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false }, ''], + [ + { version: '7.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false }, + undefined + ], + [ + { version: '11.0.289', architecture: 'x64', packageType: 'jdk', checkLatest: false }, + undefined + ] ])('Throw an error if jdkfile is not specified, inputs %s', async (inputs, jdkFile) => { mockJavaBase = new LocalDistribution(inputs, jdkFile); await expect(mockJavaBase.setupJava()).rejects.toThrowError("'jdkFile' is not specified"); diff --git a/__tests__/distributors/zulu-installer.test.ts b/__tests__/distributors/zulu-installer.test.ts index fe5958a92..666cd90d2 100644 --- a/__tests__/distributors/zulu-installer.test.ts +++ b/__tests__/distributors/zulu-installer.test.ts @@ -30,27 +30,27 @@ describe('getAvailableVersions', () => { it.each([ [ - { version: '11', architecture: 'x86', packageType: 'jdk' }, + { version: '11', architecture: 'x86', packageType: 'jdk', checkLatest: false }, '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ga' ], [ - { version: '11-ea', architecture: 'x86', packageType: 'jdk' }, + { version: '11-ea', architecture: 'x86', packageType: 'jdk', checkLatest: false }, '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=32&release_status=ea' ], [ - { version: '8', architecture: 'x64', packageType: 'jdk' }, + { version: '8', architecture: 'x64', packageType: 'jdk', checkLatest: false }, '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=false&arch=x86&hw_bitness=64&release_status=ga' ], [ - { version: '8', architecture: 'x64', packageType: 'jre' }, + { version: '8', architecture: 'x64', packageType: 'jre', checkLatest: false }, '?os=macos&ext=tar.gz&bundle_type=jre&javafx=false&arch=x86&hw_bitness=64&release_status=ga' ], [ - { version: '8', architecture: 'x64', packageType: 'jdk+fx' }, + { version: '8', architecture: 'x64', packageType: 'jdk+fx', checkLatest: false }, '?os=macos&ext=tar.gz&bundle_type=jdk&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' ], [ - { version: '8', architecture: 'x64', packageType: 'jre+fx' }, + { version: '8', architecture: 'x64', packageType: 'jre+fx', checkLatest: false }, '?os=macos&ext=tar.gz&bundle_type=jre&javafx=true&arch=x86&hw_bitness=64&release_status=ga&features=fx' ] ])('build correct url for %s -> %s', async (input, parsedUrl) => { @@ -68,7 +68,8 @@ describe('getAvailableVersions', () => { const distribution = new ZuluDistribution({ version: '11', architecture: 'x86', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); const availableVersions = await distribution['getAvailableVersions'](); expect(availableVersions).toHaveLength(manifestData.length); @@ -85,7 +86,8 @@ describe('getArchitectureOptions', () => { const distribution = new ZuluDistribution({ version: '11', architecture: input.architecture, - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); expect(distribution['getArchitectureOptions']()).toEqual(expected); }); @@ -108,7 +110,8 @@ describe('findPackageForDownload', () => { const distribution = new ZuluDistribution({ version: input, architecture: 'x86', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); distribution['getAvailableVersions'] = async () => manifestData; const result = await distribution['findPackageForDownload'](distribution['version']); @@ -119,7 +122,8 @@ describe('findPackageForDownload', () => { const distribution = new ZuluDistribution({ version: '', architecture: 'x86', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); distribution['getAvailableVersions'] = async () => manifestData; const result = await distribution['findPackageForDownload']('11.0.5'); @@ -132,7 +136,8 @@ describe('findPackageForDownload', () => { const distribution = new ZuluDistribution({ version: '18', architecture: 'x86', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); await expect( distribution['findPackageForDownload'](distribution['version']) @@ -151,7 +156,8 @@ describe('convertVersionToSemver', () => { const distribution = new ZuluDistribution({ version: '18', architecture: 'x86', - packageType: 'jdk' + packageType: 'jdk', + checkLatest: false }); const actual = distribution['convertVersionToSemver'](input); expect(actual).toBe(expected); diff --git a/dist/setup/index.js b/dist/setup/index.js index fc2e9c52c..f329f2d56 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -3959,7 +3959,6 @@ const util_1 = __webpack_require__(322); const constants_1 = __webpack_require__(211); class JavaBase { constructor(distribution, installerOptions) { - var _a; this.distribution = distribution; this.http = new httpm.HttpClient('actions/setup-java', undefined, { allowRetries: true, @@ -3968,7 +3967,7 @@ class JavaBase { ({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version)); this.architecture = installerOptions.architecture; this.packageType = installerOptions.packageType; - this.checkLatest = (_a = installerOptions.checkLatest) !== null && _a !== void 0 ? _a : false; + this.checkLatest = installerOptions.checkLatest; } setupJava() { var _a, _b; diff --git a/src/distributions/base-installer.ts b/src/distributions/base-installer.ts index c15b4875d..9c9ea3a3d 100644 --- a/src/distributions/base-installer.ts +++ b/src/distributions/base-installer.ts @@ -27,7 +27,7 @@ export abstract class JavaBase { )); this.architecture = installerOptions.architecture; this.packageType = installerOptions.packageType; - this.checkLatest = installerOptions.checkLatest ?? false; + this.checkLatest = installerOptions.checkLatest; } protected abstract downloadTool(javaRelease: JavaDownloadRelease): Promise; diff --git a/src/distributions/base-models.ts b/src/distributions/base-models.ts index d667377af..82344d585 100644 --- a/src/distributions/base-models.ts +++ b/src/distributions/base-models.ts @@ -2,7 +2,7 @@ export interface JavaInstallerOptions { version: string; architecture: string; packageType: string; - checkLatest?: boolean; + checkLatest: boolean; } export interface JavaInstallerResults { From 87ce60218663ca56bfa1dc3b194ed7d46a2d585b Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Tue, 23 Mar 2021 17:46:29 +0300 Subject: [PATCH 11/13] Update README.md --- README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 84429bd1a..4d2440b52 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,24 @@ Currently, the following distributions are supported: **NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions. -#### Testing against different Java versions +### Check latest +In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local cache. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Java is always used. +The local version of Java in cache gets updated on weekly basis. For information regarding locally cached versions of Java on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments). + +If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, the latest version of Java will be downloaded. Set `check-latest` to `true` if you want the most up-to-date version of Java to always be used. Setting `check-latest` to `true` has performance implications as downloading versions of Java is slower than using cached versions. + +```yaml +steps: +- uses: actions/checkout@v2 +- uses: actions/setup-java@v2-preview + with: + distribution: 'adopt' + java-version: '11' + check-latest: true +- run: java -cp java HelloWorldApp +``` + +### Testing against different Java versions ```yaml jobs: build: @@ -90,7 +107,6 @@ jobs: - [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven) - [Publishing using Gradle](docs/advanced-usage.md#Publishing-using-Gradle) - ## License The scripts and documentation in this project are released under the [MIT License](LICENSE) From 0ebe88be8c79b4fdaa3266921360692a6962a119 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Tue, 23 Mar 2021 18:39:46 +0300 Subject: [PATCH 12/13] added hosted tool cache section --- README.md | 5 ++++- docs/advanced-usage.md | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d2440b52..d4b36d0ea 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,12 @@ Currently, the following distributions are supported: ### Check latest In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local cache. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Java is always used. -The local version of Java in cache gets updated on weekly basis. For information regarding locally cached versions of Java on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments). If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, the latest version of Java will be downloaded. Set `check-latest` to `true` if you want the most up-to-date version of Java to always be used. Setting `check-latest` to `true` has performance implications as downloading versions of Java is slower than using cached versions. +For Java distributions that are not cached on Hosted images, `check-latest` always behaves as `true` and downloads Java on-flight. Check out [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache) for more details about pre-cached Java versions. + + ```yaml steps: - uses: actions/checkout@v2 @@ -106,6 +108,7 @@ jobs: - [Testing against different platforms](docs/advanced-usage.md#Testing-against-different-platforms) - [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven) - [Publishing using Gradle](docs/advanced-usage.md#Publishing-using-Gradle) +- [Hosted Tool Cache](#Hosted-Tool-Cache) ## License diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index c78ca6811..ca106a44b 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -9,6 +9,7 @@ - [Testing against different platforms](#Testing-against-different-platforms) - [Publishing using Apache Maven](#Publishing-using-Apache-Maven) - [Publishing using Gradle](#Publishing-using-Gradle) +- [Hosted Tool Cache](#Hosted-Tool-Cache) See [action.yml](../action.yml) for more details on task inputs. @@ -291,3 +292,10 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} ``` + +## Hosted Tool Cache +GitHub Hosted Runners have a tools cache that comes with some Java versions installed. This tools cache helps speed up runs and tool setup by not requiring any new downloads. There is an environment variable called `RUNNER_TOOL_CACHE` on each runner that describes the location of this tools cache and there is where you will find Java installed. `setup-java` works by taking a specific version of Java in this tools cache and adding it to PATH. + +Currently, LTS versions of Adopt OpenJDK (`adopt`) are cached on the GitHub Hosted Runners. + +The tools cache gets updated on weekly basis. For information regarding locally cached versions of Java on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments). From b6340505ac264b005266978d2c63695fef41390c Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Tue, 23 Mar 2021 19:37:08 +0300 Subject: [PATCH 13/13] Apply suggestions from code review Co-authored-by: Konrad Pabjan --- README.md | 4 ++-- docs/advanced-usage.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d4b36d0ea..b1942bc3d 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Currently, the following distributions are supported: **NOTE:** The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions. ### Check latest -In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local cache. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer stability and if you want to ensure a specific version of Java is always used. +In the basic examples above, the `check-latest` flag defaults to `false`. When set to `false`, the action tries to first resolve a version of Java from the local tool cache on the runner. If unable to find a specific version in the cache, the action will download a version of Java. Use the default or set `check-latest` to `false` if you prefer a faster more consistent setup experience that prioritizes trying to use the cached versions at the expense of newer versions sometimes being available for download. If `check-latest` is set to `true`, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, the latest version of Java will be downloaded. Set `check-latest` to `true` if you want the most up-to-date version of Java to always be used. Setting `check-latest` to `true` has performance implications as downloading versions of Java is slower than using cached versions. @@ -108,7 +108,7 @@ jobs: - [Testing against different platforms](docs/advanced-usage.md#Testing-against-different-platforms) - [Publishing using Apache Maven](docs/advanced-usage.md#Publishing-using-Apache-Maven) - [Publishing using Gradle](docs/advanced-usage.md#Publishing-using-Gradle) -- [Hosted Tool Cache](#Hosted-Tool-Cache) +- [Hosted Tool Cache](docs/advanced-usage.md#Hosted-Tool-Cache) ## License diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index ca106a44b..214005e0c 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -294,8 +294,8 @@ jobs: ``` ## Hosted Tool Cache -GitHub Hosted Runners have a tools cache that comes with some Java versions installed. This tools cache helps speed up runs and tool setup by not requiring any new downloads. There is an environment variable called `RUNNER_TOOL_CACHE` on each runner that describes the location of this tools cache and there is where you will find Java installed. `setup-java` works by taking a specific version of Java in this tools cache and adding it to PATH. +GitHub Hosted Runners have a tool cache that comes with some Java versions pre-installed. This tool cache helps speed up runs and tool setup by not requiring any new downloads. There is an environment variable called `RUNNER_TOOL_CACHE` on each runner that describes the location of this tools cache and this is where you can find the pre-installed versions of Java. `setup-java` works by taking a specific version of Java in this tool cache and adding it to PATH if the version, architecture and distribution match. Currently, LTS versions of Adopt OpenJDK (`adopt`) are cached on the GitHub Hosted Runners. -The tools cache gets updated on weekly basis. For information regarding locally cached versions of Java on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments). +The tools cache gets updated on a weekly basis. For information regarding locally cached versions of Java on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments).