From 1fbc280dd38b22467539cc8657713c4f8121a229 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 17 Nov 2022 13:10:21 +0100 Subject: [PATCH 01/49] log versions --- src/setup-java.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/setup-java.ts b/src/setup-java.ts index 048c5dd6b..282c9b6df 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -10,7 +10,8 @@ import { JavaInstallerOptions } from './distributions/base-models'; async function run() { try { - const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION, { required: true }); + const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION); + core.info(versions) const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); From 4966150d90b15df305f9f3fc88ffbf10df45f425 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 17 Nov 2022 13:11:27 +0100 Subject: [PATCH 02/49] build --- dist/cleanup/index.js | 996 +- dist/setup/index.js | 23293 ++++++++++++++++++++-------------------- src/setup-java.ts | 2 +- 3 files changed, 12146 insertions(+), 12145 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 82e686514..459a71bcd 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -68164,187 +68164,187 @@ try { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -/** - * @fileoverview this file provides methods handling dependency cache - */ -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.save = exports.restore = void 0; -const path_1 = __nccwpck_require__(1017); -const os_1 = __importDefault(__nccwpck_require__(2037)); -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const glob = __importStar(__nccwpck_require__(8090)); -const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'; -const CACHE_MATCHED_KEY = 'cache-matched-key'; -const CACHE_KEY_PREFIX = 'setup-java'; -const supportedPackageManager = [ - { - id: 'maven', - path: [path_1.join(os_1.default.homedir(), '.m2', 'repository')], - // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven - pattern: ['**/pom.xml'] - }, - { - id: 'gradle', - path: [path_1.join(os_1.default.homedir(), '.gradle', 'caches'), path_1.join(os_1.default.homedir(), '.gradle', 'wrapper')], - // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle - pattern: [ - '**/*.gradle*', - '**/gradle-wrapper.properties', - 'buildSrc/**/Versions.kt', - 'buildSrc/**/Dependencies.kt', - 'gradle/*.versions.toml' - ] - }, - { - id: 'sbt', - path: [ - path_1.join(os_1.default.homedir(), '.ivy2', 'cache'), - path_1.join(os_1.default.homedir(), '.sbt'), - getCoursierCachePath(), - // Some files should not be cached to avoid resolution problems. - // In particular the resolution of snapshots (ideological gap between maven/ivy). - '!' + path_1.join(os_1.default.homedir(), '.sbt', '*.lock'), - '!' + path_1.join(os_1.default.homedir(), '**', 'ivydata-*.properties') - ], - pattern: ['**/*.sbt', '**/project/build.properties', '**/project/**.{scala,sbt}'] - } -]; -function getCoursierCachePath() { - if (os_1.default.type() === 'Linux') - return path_1.join(os_1.default.homedir(), '.cache', 'coursier'); - if (os_1.default.type() === 'Darwin') - return path_1.join(os_1.default.homedir(), 'Library', 'Caches', 'Coursier'); - return path_1.join(os_1.default.homedir(), 'AppData', 'Local', 'Coursier', 'Cache'); -} -function findPackageManager(id) { - const packageManager = supportedPackageManager.find(packageManager => packageManager.id === id); - if (packageManager === undefined) { - throw new Error(`unknown package manager specified: ${id}`); - } - return packageManager; -} -/** - * A function that generates a cache key to use. - * Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". - * If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-). - * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key} - */ -function computeCacheKey(packageManager) { - return __awaiter(this, void 0, void 0, function* () { - const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); - return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; - }); -} -/** - * Restore the dependency cache - * @param id ID of the package manager, should be "maven" or "gradle" - */ -function restore(id) { - return __awaiter(this, void 0, void 0, function* () { - const packageManager = findPackageManager(id); - const primaryKey = yield computeCacheKey(packageManager); - core.debug(`primary key is ${primaryKey}`); - core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey); - if (primaryKey.endsWith('-')) { - throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); - } - // No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269) - const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey); - if (matchedKey) { - core.saveState(CACHE_MATCHED_KEY, matchedKey); - core.setOutput('cache-hit', matchedKey === primaryKey); - core.info(`Cache restored from key: ${matchedKey}`); - } - else { - core.setOutput('cache-hit', false); - core.info(`${packageManager.id} cache is not found`); - } - }); -} -exports.restore = restore; -/** - * Save the dependency cache - * @param id ID of the package manager, should be "maven" or "gradle" - */ -function save(id) { - return __awaiter(this, void 0, void 0, function* () { - const packageManager = findPackageManager(id); - const matchedKey = core.getState(CACHE_MATCHED_KEY); - // Inputs are re-evaluated before the post action, so we want the original key used for restore - const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); - if (!primaryKey) { - core.warning('Error retrieving key from state.'); - return; - } - else if (matchedKey === primaryKey) { - // no change in target directories - core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); - return; - } - try { - yield cache.saveCache(packageManager.path, primaryKey); - core.info(`Cache saved with the key: ${primaryKey}`); - } - catch (error) { - if (error.name === cache.ReserveCacheError.name) { - core.info(error.message); - } - else { - if (isProbablyGradleDaemonProblem(packageManager, error)) { - core.warning('Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.'); - } - throw error; - } - } - }); -} -exports.save = save; -/** - * @param packageManager the specified package manager by user - * @param error the error thrown by the saveCache - * @returns true if the given error seems related to the {@link https://github.com/actions/cache/issues/454|running Gradle Daemon issue}. - * @see {@link https://github.com/actions/cache/issues/454#issuecomment-840493935|why --no-daemon is necessary} - */ -function isProbablyGradleDaemonProblem(packageManager, error) { - if (packageManager.id !== 'gradle' || process.env['RUNNER_OS'] !== 'Windows') { - return false; - } - const message = error.message || ''; - return message.startsWith('Tar failed with error: '); -} + +/** + * @fileoverview this file provides methods handling dependency cache + */ +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.save = exports.restore = void 0; +const path_1 = __nccwpck_require__(1017); +const os_1 = __importDefault(__nccwpck_require__(2037)); +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const glob = __importStar(__nccwpck_require__(8090)); +const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'; +const CACHE_MATCHED_KEY = 'cache-matched-key'; +const CACHE_KEY_PREFIX = 'setup-java'; +const supportedPackageManager = [ + { + id: 'maven', + path: [path_1.join(os_1.default.homedir(), '.m2', 'repository')], + // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven + pattern: ['**/pom.xml'] + }, + { + id: 'gradle', + path: [path_1.join(os_1.default.homedir(), '.gradle', 'caches'), path_1.join(os_1.default.homedir(), '.gradle', 'wrapper')], + // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle + pattern: [ + '**/*.gradle*', + '**/gradle-wrapper.properties', + 'buildSrc/**/Versions.kt', + 'buildSrc/**/Dependencies.kt', + 'gradle/*.versions.toml' + ] + }, + { + id: 'sbt', + path: [ + path_1.join(os_1.default.homedir(), '.ivy2', 'cache'), + path_1.join(os_1.default.homedir(), '.sbt'), + getCoursierCachePath(), + // Some files should not be cached to avoid resolution problems. + // In particular the resolution of snapshots (ideological gap between maven/ivy). + '!' + path_1.join(os_1.default.homedir(), '.sbt', '*.lock'), + '!' + path_1.join(os_1.default.homedir(), '**', 'ivydata-*.properties') + ], + pattern: ['**/*.sbt', '**/project/build.properties', '**/project/**.{scala,sbt}'] + } +]; +function getCoursierCachePath() { + if (os_1.default.type() === 'Linux') + return path_1.join(os_1.default.homedir(), '.cache', 'coursier'); + if (os_1.default.type() === 'Darwin') + return path_1.join(os_1.default.homedir(), 'Library', 'Caches', 'Coursier'); + return path_1.join(os_1.default.homedir(), 'AppData', 'Local', 'Coursier', 'Cache'); +} +function findPackageManager(id) { + const packageManager = supportedPackageManager.find(packageManager => packageManager.id === id); + if (packageManager === undefined) { + throw new Error(`unknown package manager specified: ${id}`); + } + return packageManager; +} +/** + * A function that generates a cache key to use. + * Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". + * If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-). + * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key} + */ +function computeCacheKey(packageManager) { + return __awaiter(this, void 0, void 0, function* () { + const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); + return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; + }); +} +/** + * Restore the dependency cache + * @param id ID of the package manager, should be "maven" or "gradle" + */ +function restore(id) { + return __awaiter(this, void 0, void 0, function* () { + const packageManager = findPackageManager(id); + const primaryKey = yield computeCacheKey(packageManager); + core.debug(`primary key is ${primaryKey}`); + core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey); + if (primaryKey.endsWith('-')) { + throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); + } + // No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269) + const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey); + if (matchedKey) { + core.saveState(CACHE_MATCHED_KEY, matchedKey); + core.setOutput('cache-hit', matchedKey === primaryKey); + core.info(`Cache restored from key: ${matchedKey}`); + } + else { + core.setOutput('cache-hit', false); + core.info(`${packageManager.id} cache is not found`); + } + }); +} +exports.restore = restore; +/** + * Save the dependency cache + * @param id ID of the package manager, should be "maven" or "gradle" + */ +function save(id) { + return __awaiter(this, void 0, void 0, function* () { + const packageManager = findPackageManager(id); + const matchedKey = core.getState(CACHE_MATCHED_KEY); + // Inputs are re-evaluated before the post action, so we want the original key used for restore + const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); + if (!primaryKey) { + core.warning('Error retrieving key from state.'); + return; + } + else if (matchedKey === primaryKey) { + // no change in target directories + core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); + return; + } + try { + yield cache.saveCache(packageManager.path, primaryKey); + core.info(`Cache saved with the key: ${primaryKey}`); + } + catch (error) { + if (error.name === cache.ReserveCacheError.name) { + core.info(error.message); + } + else { + if (isProbablyGradleDaemonProblem(packageManager, error)) { + core.warning('Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.'); + } + throw error; + } + } + }); +} +exports.save = save; +/** + * @param packageManager the specified package manager by user + * @param error the error thrown by the saveCache + * @returns true if the given error seems related to the {@link https://github.com/actions/cache/issues/454|running Gradle Daemon issue}. + * @see {@link https://github.com/actions/cache/issues/454#issuecomment-840493935|why --no-daemon is necessary} + */ +function isProbablyGradleDaemonProblem(packageManager, error) { + if (packageManager.id !== 'gradle' || process.env['RUNNER_OS'] !== 'Windows') { + return false; + } + const message = error.message || ''; + return message.startsWith('Tar failed with error: '); +} /***/ }), @@ -68353,99 +68353,99 @@ function isProbablyGradleDaemonProblem(packageManager, error) { /***/ (function(__unused_webpack_module, exports, __nccwpck_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()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.run = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const gpg = __importStar(__nccwpck_require__(3759)); -const constants = __importStar(__nccwpck_require__(9042)); -const util_1 = __nccwpck_require__(2629); -const cache_1 = __nccwpck_require__(4810); -function removePrivateKeyFromKeychain() { - 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 due to: ${error.message}`); - } - } - }); -} -/** - * Check given input and run a save process for the specified package manager - * @returns Promise that will be resolved when the save process finishes - */ -function saveCache() { - return __awaiter(this, void 0, void 0, function* () { - const jobStatus = util_1.isJobStatusSuccess(); - const cache = core.getInput(constants.INPUT_CACHE); - return jobStatus && cache ? cache_1.save(cache) : Promise.resolve(); - }); -} -/** - * The save process is best-effort, and it should not make the workflow fail - * even though this process throws an error. - * @param promise the promise to ignore error from - * @returns Promise that will ignore error reported by the given promise - */ -function ignoreError(promise) { - return __awaiter(this, void 0, void 0, function* () { - return new Promise(resolve => { - promise - .catch(error => { - core.warning(error); - resolve(void 0); - }) - .then(resolve); - }); - }); -} -function run() { - return __awaiter(this, void 0, void 0, function* () { - yield removePrivateKeyFromKeychain(); - yield ignoreError(saveCache()); - }); -} -exports.run = run; -if (require.main === require.cache[eval('__filename')]) { - run(); -} -else { - // https://nodejs.org/api/modules.html#modules_accessing_the_main_module - core.info('the script is loaded as a module, so skipping the execution'); -} + +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.run = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const gpg = __importStar(__nccwpck_require__(3759)); +const constants = __importStar(__nccwpck_require__(9042)); +const util_1 = __nccwpck_require__(2629); +const cache_1 = __nccwpck_require__(4810); +function removePrivateKeyFromKeychain() { + 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 due to: ${error.message}`); + } + } + }); +} +/** + * Check given input and run a save process for the specified package manager + * @returns Promise that will be resolved when the save process finishes + */ +function saveCache() { + return __awaiter(this, void 0, void 0, function* () { + const jobStatus = util_1.isJobStatusSuccess(); + const cache = core.getInput(constants.INPUT_CACHE); + return jobStatus && cache ? cache_1.save(cache) : Promise.resolve(); + }); +} +/** + * The save process is best-effort, and it should not make the workflow fail + * even though this process throws an error. + * @param promise the promise to ignore error from + * @returns Promise that will ignore error reported by the given promise + */ +function ignoreError(promise) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise(resolve => { + promise + .catch(error => { + core.warning(error); + resolve(void 0); + }) + .then(resolve); + }); + }); +} +function run() { + return __awaiter(this, void 0, void 0, function* () { + yield removePrivateKeyFromKeychain(); + yield ignoreError(saveCache()); + }); +} +exports.run = run; +if (require.main === require.cache[eval('__filename')]) { + run(); +} +else { + // https://nodejs.org/api/modules.html#modules_accessing_the_main_module + core.info('the script is loaded as a module, so skipping the execution'); +} /***/ }), @@ -68454,33 +68454,33 @@ else { /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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.INPUT_CACHE = 'cache'; -exports.INPUT_JOB_STATUS = 'job-status'; -exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; -exports.M2_DIR = '.m2'; -exports.MVN_SETTINGS_FILE = 'settings.xml'; -exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; -exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; -exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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.INPUT_CACHE = 'cache'; +exports.INPUT_JOB_STATUS = 'job-status'; +exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; +exports.M2_DIR = '.m2'; +exports.MVN_SETTINGS_FILE = 'settings.xml'; +exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; +exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; +exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; /***/ }), @@ -68489,74 +68489,74 @@ exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; /***/ (function(__unused_webpack_module, exports, __nccwpck_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()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.deleteKey = exports.importKey = exports.PRIVATE_KEY_FILE = void 0; -const fs = __importStar(__nccwpck_require__(7147)); -const path = __importStar(__nccwpck_require__(1017)); -const io = __importStar(__nccwpck_require__(7436)); -const exec = __importStar(__nccwpck_require__(1514)); -const util = __importStar(__nccwpck_require__(2629)); -exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); -const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; -function importKey(privateKey) { - return __awaiter(this, void 0, void 0, function* () { - fs.writeFileSync(exports.PRIVATE_KEY_FILE, privateKey, { - encoding: 'utf-8', - flag: 'w' - }); - let output = ''; - const options = { - silent: true, - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }; - yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); - yield io.rmRF(exports.PRIVATE_KEY_FILE); - const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); - return match && match[0]; - }); -} -exports.importKey = importKey; -function deleteKey(keyFingerprint) { - return __awaiter(this, void 0, void 0, function* () { - yield exec.exec('gpg', ['--batch', '--yes', '--delete-secret-and-public-key', keyFingerprint], { - silent: true - }); - }); -} -exports.deleteKey = deleteKey; + +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.deleteKey = exports.importKey = exports.PRIVATE_KEY_FILE = void 0; +const fs = __importStar(__nccwpck_require__(7147)); +const path = __importStar(__nccwpck_require__(1017)); +const io = __importStar(__nccwpck_require__(7436)); +const exec = __importStar(__nccwpck_require__(1514)); +const util = __importStar(__nccwpck_require__(2629)); +exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); +const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; +function importKey(privateKey) { + return __awaiter(this, void 0, void 0, function* () { + fs.writeFileSync(exports.PRIVATE_KEY_FILE, privateKey, { + encoding: 'utf-8', + flag: 'w' + }); + let output = ''; + const options = { + silent: true, + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }; + yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); + yield io.rmRF(exports.PRIVATE_KEY_FILE); + const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); + return match && match[0]; + }); +} +exports.importKey = importKey; +function deleteKey(keyFingerprint) { + return __awaiter(this, void 0, void 0, function* () { + yield exec.exec('gpg', ['--batch', '--yes', '--delete-secret-and-public-key', keyFingerprint], { + silent: true + }); + }); +} +exports.deleteKey = deleteKey; /***/ }), @@ -68565,135 +68565,135 @@ exports.deleteKey = deleteKey; /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; -const os_1 = __importDefault(__nccwpck_require__(2037)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const fs = __importStar(__nccwpck_require__(7147)); -const semver = __importStar(__nccwpck_require__(1383)); -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const tc = __importStar(__nccwpck_require__(7784)); -const constants_1 = __nccwpck_require__(9042); -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; -function isJobStatusSuccess() { - const jobStatus = core.getInput(constants_1.INPUT_JOB_STATUS); - return jobStatus === 'success'; -} -exports.isJobStatusSuccess = isJobStatusSuccess; -function isGhes() { - const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; -} -exports.isGhes = isGhes; -function isCacheFeatureAvailable() { - if (!cache.isFeatureAvailable()) { - if (isGhes()) { - throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'); - } - else { - core.warning('The runner was not able to contact the cache service. Caching will be skipped'); - } - return false; - } - return true; -} -exports.isCacheFeatureAvailable = isCacheFeatureAvailable; + +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.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +const os_1 = __importDefault(__nccwpck_require__(2037)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const fs = __importStar(__nccwpck_require__(7147)); +const semver = __importStar(__nccwpck_require__(1383)); +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const constants_1 = __nccwpck_require__(9042); +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; +function isJobStatusSuccess() { + const jobStatus = core.getInput(constants_1.INPUT_JOB_STATUS); + return jobStatus === 'success'; +} +exports.isJobStatusSuccess = isJobStatusSuccess; +function isGhes() { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} +exports.isGhes = isGhes; +function isCacheFeatureAvailable() { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'); + } + else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + return false; + } + return true; +} +exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index 2820ec370..6e0d413f1 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -92435,4466 +92435,4458 @@ module.exports = v4; /***/ }), -/***/ 2839: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - module.exports = { - Disconnected: 1, - Preceding: 2, - Following: 4, - Contains: 8, - ContainedBy: 16, - ImplementationSpecific: 32 - }; - -}).call(this); - - -/***/ }), - -/***/ 9267: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - module.exports = { - Element: 1, - Attribute: 2, - Text: 3, - CData: 4, - EntityReference: 5, - EntityDeclaration: 6, - ProcessingInstruction: 7, - Comment: 8, - Document: 9, - DocType: 10, - DocumentFragment: 11, - NotationDeclaration: 12, - Declaration: 201, - Raw: 202, - AttributeDeclaration: 203, - ElementDeclaration: 204, - Dummy: 205 - }; - -}).call(this); - - -/***/ }), - -/***/ 8229: -/***/ (function(module) { +/***/ 5696: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -// Generated by CoffeeScript 1.12.7 -(function() { - var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject, - slice = [].slice, - hasProp = {}.hasOwnProperty; +"use strict"; - assign = function() { - var i, key, len, source, sources, target; - target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : []; - if (isFunction(Object.assign)) { - Object.assign.apply(null, arguments); - } else { - for (i = 0, len = sources.length; i < len; i++) { - source = sources[i]; - if (source != null) { - for (key in source) { - if (!hasProp.call(source, key)) continue; - target[key] = source[key]; - } +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(6417); +var util_1 = __nccwpck_require__(6195); +var util_2 = __nccwpck_require__(5282); +var _1 = __nccwpck_require__(4260); +var dom_1 = __nccwpck_require__(770); +/** @inheritdoc */ +function builder(p1, p2) { + var options = formatBuilderOptions(isXMLBuilderCreateOptions(p1) ? p1 : interfaces_1.DefaultBuilderOptions); + var nodes = util_2.Guard.isNode(p1) || util_1.isArray(p1) ? p1 : p2; + if (nodes === undefined) { + throw new Error("Invalid arguments."); + } + if (util_1.isArray(nodes)) { + var builders = []; + for (var i = 0; i < nodes.length; i++) { + var builder_1 = new _1.XMLBuilderImpl(nodes[i]); + builder_1.set(options); + builders.push(builder_1); } - } + return builders; } - return target; - }; - - isFunction = function(val) { - return !!val && Object.prototype.toString.call(val) === '[object Function]'; - }; - - isObject = function(val) { - var ref; - return !!val && ((ref = typeof val) === 'function' || ref === 'object'); - }; - - isArray = function(val) { - if (isFunction(Array.isArray)) { - return Array.isArray(val); - } else { - return Object.prototype.toString.call(val) === '[object Array]'; + else { + var builder_2 = new _1.XMLBuilderImpl(nodes); + builder_2.set(options); + return builder_2; } - }; - - isEmpty = function(val) { - var key; - if (isArray(val)) { - return !val.length; - } else { - for (key in val) { - if (!hasProp.call(val, key)) continue; +} +exports.builder = builder; +/** @inheritdoc */ +function create(p1, p2) { + var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? + p1 : interfaces_1.DefaultBuilderOptions); + var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; + var doc = dom_1.createDocument(); + setOptions(doc, options); + var builder = new _1.XMLBuilderImpl(doc); + if (contents !== undefined) { + // parse contents + builder.ele(contents); + } + return builder; +} +exports.create = create; +/** @inheritdoc */ +function fragment(p1, p2) { + var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? + p1 : interfaces_1.DefaultBuilderOptions); + var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; + var doc = dom_1.createDocument(); + setOptions(doc, options, true); + var builder = new _1.XMLBuilderImpl(doc.createDocumentFragment()); + if (contents !== undefined) { + // parse contents + builder.ele(contents); + } + return builder; +} +exports.fragment = fragment; +/** @inheritdoc */ +function convert(p1, p2, p3) { + var builderOptions; + var contents; + var convertOptions; + if (isXMLBuilderCreateOptions(p1) && p2 !== undefined) { + builderOptions = p1; + contents = p2; + convertOptions = p3; + } + else { + builderOptions = interfaces_1.DefaultBuilderOptions; + contents = p1; + convertOptions = p2 || undefined; + } + return create(builderOptions, contents).end(convertOptions); +} +exports.convert = convert; +function isXMLBuilderCreateOptions(obj) { + if (!util_1.isPlainObject(obj)) return false; - } - return true; + for (var key in obj) { + /* istanbul ignore else */ + if (obj.hasOwnProperty(key)) { + if (!interfaces_1.XMLBuilderOptionKeys.has(key)) + return false; + } } - }; - - isPlainObject = function(val) { - var ctor, proto; - return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object)); - }; - - getValue = function(obj) { - if (isFunction(obj.valueOf)) { - return obj.valueOf(); - } else { - return obj; + return true; +} +function formatBuilderOptions(createOptions) { + if (createOptions === void 0) { createOptions = {}; } + var options = util_1.applyDefaults(createOptions, interfaces_1.DefaultBuilderOptions); + if (options.convert.att.length === 0 || + options.convert.ins.length === 0 || + options.convert.text.length === 0 || + options.convert.cdata.length === 0 || + options.convert.comment.length === 0) { + throw new Error("JS object converter strings cannot be zero length."); } - }; + return options; +} +function setOptions(doc, options, isFragment) { + var docWithSettings = doc; + docWithSettings._xmlBuilderOptions = options; + docWithSettings._isFragment = isFragment; +} +//# sourceMappingURL=BuilderFunctions.js.map - module.exports.assign = assign; +/***/ }), - module.exports.isFunction = isFunction; +/***/ 268: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - module.exports.isObject = isObject; +"use strict"; - module.exports.isArray = isArray; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var _1 = __nccwpck_require__(4260); +/** + * 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 - module.exports.isEmpty = isEmpty; +/***/ }), - module.exports.isPlainObject = isPlainObject; +/***/ 1438: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - module.exports.getValue = getValue; +"use strict"; -}).call(this); - - -/***/ }), - -/***/ 9766: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - module.exports = { - None: 0, - OpenTag: 1, - InsideTag: 2, - CloseTag: 3 - }; - -}).call(this); - - -/***/ }), - -/***/ 8376: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLAttribute, XMLNode; - - NodeType = __nccwpck_require__(9267); - - XMLNode = __nccwpck_require__(7608); - - module.exports = XMLAttribute = (function() { - function XMLAttribute(parent, name, value) { - this.parent = parent; - if (this.parent) { - this.options = this.parent.options; - this.stringify = this.parent.stringify; - } - if (name == null) { - throw new Error("Missing attribute name. " + this.debugInfo(name)); - } - this.name = this.stringify.name(name); - this.value = this.stringify.attValue(value); - this.type = NodeType.Attribute; - this.isId = false; - this.schemaTypeInfo = null; - } - - Object.defineProperty(XMLAttribute.prototype, 'nodeType', { - get: function() { - return this.type; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'ownerElement', { - get: function() { - return this.parent; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'textContent', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'prefix', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'localName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLAttribute.prototype, 'specified', { - get: function() { - return true; - } - }); - - XMLAttribute.prototype.clone = function() { - return Object.create(this); - }; - - XMLAttribute.prototype.toString = function(options) { - return this.options.writer.attribute(this, this.options.writer.filterOptions(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); }; - - XMLAttribute.prototype.debugInfo = function(name) { - name = name || this.name; - if (name == null) { - return "parent: <" + this.parent.name + ">"; - } else { - return "attribute: {" + name + "}, parent: <" + this.parent.name + ">"; - } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLAttribute.prototype.isEqualNode = function(node) { - if (node.namespaceURI !== this.namespaceURI) { - return false; - } - if (node.prefix !== this.prefix) { - return false; - } - if (node.localName !== this.localName) { - return false; - } - if (node.value !== this.value) { - return false; - } - return 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 }; + } }; - - return XMLAttribute; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 333: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLCData, XMLCharacterData, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - NodeType = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); - - module.exports = XMLCData = (function(superClass) { - extend(XMLCData, superClass); - - function XMLCData(parent, text) { - XMLCData.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing CDATA text. " + this.debugInfo()); - } - this.name = "#cdata-section"; - this.type = NodeType.CData; - this.value = this.stringify.cdata(text); + 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); } - - XMLCData.prototype.clone = function() { - return Object.create(this); - }; - - XMLCData.prototype.toString = function(options) { - return this.options.writer.cdata(this, this.options.writer.filterOptions(options)); - }; - - return XMLCData; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 7709: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLCharacterData, XMLNode, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - XMLNode = __nccwpck_require__(7608); - - module.exports = XMLCharacterData = (function(superClass) { - extend(XMLCharacterData, superClass); - - function XMLCharacterData(parent) { - XMLCharacterData.__super__.constructor.call(this, parent); - this.value = ''; + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } } - - Object.defineProperty(XMLCharacterData.prototype, 'data', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); - - Object.defineProperty(XMLCharacterData.prototype, 'length', { - get: function() { - return this.value.length; - } - }); - - Object.defineProperty(XMLCharacterData.prototype, 'textContent', { - get: function() { - return this.value; - }, - set: function(value) { - return this.value = value || ''; - } - }); - - XMLCharacterData.prototype.clone = function() { - return Object.create(this); - }; - - XMLCharacterData.prototype.substringData = function(offset, count) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + return ar; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(6417); +var util_1 = __nccwpck_require__(6195); +var BuilderFunctions_1 = __nccwpck_require__(5696); +var algorithm_1 = __nccwpck_require__(61); +var infra_1 = __nccwpck_require__(4251); +var NamespacePrefixMap_1 = __nccwpck_require__(283); +var LocalNameSet_1 = __nccwpck_require__(9049); +var util_2 = __nccwpck_require__(5282); +var XMLCBWriter_1 = __nccwpck_require__(7572); +var JSONCBWriter_1 = __nccwpck_require__(7525); +var YAMLCBWriter_1 = __nccwpck_require__(2444); +var events_1 = __nccwpck_require__(2361); +/** + * Represents a readable XML document stream. + */ +var XMLBuilderCBImpl = /** @class */ (function (_super) { + __extends(XMLBuilderCBImpl, _super); + /** + * Initializes a new instance of `XMLStream`. + * + * @param options - stream writer options + * @param fragment - whether to create fragment stream or a document stream + * + * @returns XML stream + */ + function XMLBuilderCBImpl(options, fragment) { + if (fragment === void 0) { fragment = false; } + var _this = _super.call(this) || this; + _this._hasDeclaration = false; + _this._docTypeName = ""; + _this._hasDocumentElement = false; + _this._currentElementSerialized = false; + _this._openTags = []; + _this._ended = false; + _this._fragment = fragment; + // provide default options + _this._options = util_1.applyDefaults(options || {}, interfaces_1.DefaultXMLBuilderCBOptions); + _this._builderOptions = { + defaultNamespace: _this._options.defaultNamespace, + namespaceAlias: _this._options.namespaceAlias + }; + if (_this._options.format === "json") { + _this._writer = new JSONCBWriter_1.JSONCBWriter(_this._options); + } + else if (_this._options.format === "yaml") { + _this._writer = new YAMLCBWriter_1.YAMLCBWriter(_this._options); + } + else { + _this._writer = new XMLCBWriter_1.XMLCBWriter(_this._options); + } + // automatically create listeners for callbacks passed via options + if (_this._options.data !== undefined) { + _this.on("data", _this._options.data); + } + if (_this._options.end !== undefined) { + _this.on("end", _this._options.end); + } + if (_this._options.error !== undefined) { + _this.on("error", _this._options.error); + } + _this._prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); + _this._prefixMap.set("xml", infra_1.namespace.XML); + _this._prefixIndex = { value: 1 }; + _this._push(_this._writer.frontMatter()); + return _this; + } + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.ele = function (p1, p2, p3) { + var e_1, _a; + // parse if JS object or XML or JSON string + if (util_1.isObject(p1) || (util_1.isString(p1) && (/^\s*/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._push(this._writer.text(markup)); + return this; }; - - XMLCharacterData.prototype.replaceData = function(offset, count, arg) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.ins = function (target, content) { + if (content === void 0) { content = ''; } + this._serializeOpenTag(true); + var node; + try { + node = BuilderFunctions_1.fragment(this._builderOptions).ins(target, content).first().node; + } + catch (err) { + /* istanbul ignore next */ + this.emit("error", err); + /* istanbul ignore next */ + return this; + } + if (this._options.wellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { + this.emit("error", new Error("Processing instruction target contains invalid characters (well-formed required).")); + return this; + } + if (this._options.wellFormed && !algorithm_1.xml_isLegalChar(node.data)) { + this.emit("error", Error("Processing instruction data contains invalid characters (well-formed required).")); + return this; + } + this._push(this._writer.instruction(node.target, node.data)); + return this; }; - - XMLCharacterData.prototype.isEqualNode = function(node) { - if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { - return false; - } - if (node.data !== this.data) { - return false; - } - return true; + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.dat = function (content) { + this._serializeOpenTag(true); + var node; + try { + node = BuilderFunctions_1.fragment(this._builderOptions).dat(content).first().node; + } + catch (err) { + this.emit("error", err); + return this; + } + this._push(this._writer.cdata(node.data)); + return this; }; - - return XMLCharacterData; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 4407: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLCharacterData, XMLComment, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - NodeType = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); - - module.exports = XMLComment = (function(superClass) { - extend(XMLComment, superClass); - - function XMLComment(parent, text) { - XMLComment.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing comment text. " + this.debugInfo()); - } - this.name = "#comment"; - this.type = NodeType.Comment; - this.value = this.stringify.comment(text); - } - - XMLComment.prototype.clone = function() { - return Object.create(this); - }; - - XMLComment.prototype.toString = function(options) { - return this.options.writer.comment(this, this.options.writer.filterOptions(options)); - }; - - return XMLComment; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 7465: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList; - - XMLDOMErrorHandler = __nccwpck_require__(6744); - - XMLDOMStringList = __nccwpck_require__(7028); - - module.exports = XMLDOMConfiguration = (function() { - function XMLDOMConfiguration() { - var clonedSelf; - this.defaultParams = { - "canonical-form": false, - "cdata-sections": false, - "comments": false, - "datatype-normalization": false, - "element-content-whitespace": true, - "entities": true, - "error-handler": new XMLDOMErrorHandler(), - "infoset": true, - "validate-if-schema": false, - "namespaces": true, - "namespace-declarations": true, - "normalize-characters": false, - "schema-location": '', - "schema-type": '', - "split-cdata-sections": true, - "validate": false, - "well-formed": true - }; - this.params = clonedSelf = Object.create(this.defaultParams); - } - - Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', { - get: function() { - return new XMLDOMStringList(Object.keys(this.defaultParams)); - } - }); - - XMLDOMConfiguration.prototype.getParameter = function(name) { - if (this.params.hasOwnProperty(name)) { - return this.params[name]; - } else { - return null; - } - }; - - XMLDOMConfiguration.prototype.canSetParameter = function(name, value) { - return true; - }; - - XMLDOMConfiguration.prototype.setParameter = function(name, value) { - if (value != null) { - return this.params[name] = value; - } else { - return delete this.params[name]; - } - }; - - return XMLDOMConfiguration; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 6744: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLDOMErrorHandler; - - module.exports = XMLDOMErrorHandler = (function() { - function XMLDOMErrorHandler() {} - - XMLDOMErrorHandler.prototype.handleError = function(error) { - throw new Error(error); - }; - - return XMLDOMErrorHandler; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 8310: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLDOMImplementation; - - module.exports = XMLDOMImplementation = (function() { - function XMLDOMImplementation() {} - - XMLDOMImplementation.prototype.hasFeature = function(feature, version) { - return true; - }; - - XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) { - throw new Error("This DOM method is not implemented."); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.dec = function (options) { + if (options === void 0) { options = { version: "1.0" }; } + if (this._fragment) { + this.emit("error", Error("Cannot insert an XML declaration into a document fragment.")); + return this; + } + if (this._hasDeclaration) { + this.emit("error", Error("XML declaration is already inserted.")); + return this; + } + this._push(this._writer.declaration(options.version || "1.0", options.encoding, options.standalone)); + this._hasDeclaration = true; + return this; }; - - XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) { - throw new Error("This DOM method is not implemented."); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.dtd = function (options) { + if (this._fragment) { + this.emit("error", Error("Cannot insert a DocType declaration into a document fragment.")); + return this; + } + if (this._docTypeName !== "") { + this.emit("error", new Error("DocType declaration is already inserted.")); + return this; + } + if (this._hasDocumentElement) { + this.emit("error", new Error("Cannot insert DocType declaration after document element.")); + return this; + } + var node; + try { + node = BuilderFunctions_1.create().dtd(options).first().node; + } + catch (err) { + this.emit("error", err); + return this; + } + if (this._options.wellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { + this.emit("error", new Error("DocType public identifier does not match PubidChar construct (well-formed required).")); + return this; + } + if (this._options.wellFormed && + (!algorithm_1.xml_isLegalChar(node.systemId) || + (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { + this.emit("error", new Error("DocType system identifier contains invalid characters (well-formed required).")); + return this; + } + this._docTypeName = options.name; + this._push(this._writer.docType(options.name, node.publicId, node.systemId)); + return this; }; - - XMLDOMImplementation.prototype.createHTMLDocument = function(title) { - throw new Error("This DOM method is not implemented."); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.up = function () { + this._serializeOpenTag(false); + this._serializeCloseTag(); + return this; }; - - XMLDOMImplementation.prototype.getFeature = function(feature, version) { - throw new Error("This DOM method is not implemented."); + /** @inheritdoc */ + XMLBuilderCBImpl.prototype.end = function () { + this._serializeOpenTag(false); + while (this._openTags.length > 0) { + this._serializeCloseTag(); + } + this._push(null); + return this; }; - - return XMLDOMImplementation; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 7028: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLDOMStringList; - - module.exports = XMLDOMStringList = (function() { - function XMLDOMStringList(arr) { - this.arr = arr || []; - } - - Object.defineProperty(XMLDOMStringList.prototype, 'length', { - get: function() { - return this.arr.length; - } - }); - - XMLDOMStringList.prototype.item = function(index) { - return this.arr[index] || null; - }; - - XMLDOMStringList.prototype.contains = function(str) { - return this.arr.indexOf(str) !== -1; - }; - - return XMLDOMStringList; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 1015: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLDTDAttList, XMLNode, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDAttList = (function(superClass) { - extend(XMLDTDAttList, superClass); - - function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { - XMLDTDAttList.__super__.constructor.call(this, parent); - if (elementName == null) { - throw new Error("Missing DTD element name. " + this.debugInfo()); - } - if (attributeName == null) { - throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName)); - } - if (!attributeType) { - throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName)); - } - if (!defaultValueType) { - throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName)); - } - if (defaultValueType.indexOf('#') !== 0) { - defaultValueType = '#' + defaultValueType; - } - if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) { - throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName)); - } - if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) { - throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName)); - } - this.elementName = this.stringify.name(elementName); - this.type = NodeType.AttributeDeclaration; - this.attributeName = this.stringify.name(attributeName); - this.attributeType = this.stringify.dtdAttType(attributeType); - if (defaultValue) { - this.defaultValue = this.stringify.dtdAttDefault(defaultValue); - } - this.defaultValueType = defaultValueType; - } - - XMLDTDAttList.prototype.toString = function(options) { - return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options)); - }; - - return XMLDTDAttList; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 2421: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLDTDElement, XMLNode, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDElement = (function(superClass) { - extend(XMLDTDElement, superClass); - - function XMLDTDElement(parent, name, value) { - XMLDTDElement.__super__.constructor.call(this, parent); - if (name == null) { - throw new Error("Missing DTD element name. " + this.debugInfo()); - } - if (!value) { - value = '(#PCDATA)'; - } - if (Array.isArray(value)) { - value = '(' + value.join(',') + ')'; - } - this.name = this.stringify.name(name); - this.type = NodeType.ElementDeclaration; - this.value = this.stringify.dtdElementValue(value); - } - - XMLDTDElement.prototype.toString = function(options) { - return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options)); - }; - - return XMLDTDElement; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 53: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLDTDEntity, XMLNode, isObject, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - isObject = (__nccwpck_require__(8229).isObject); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDEntity = (function(superClass) { - extend(XMLDTDEntity, superClass); - - function XMLDTDEntity(parent, pe, name, value) { - XMLDTDEntity.__super__.constructor.call(this, parent); - if (name == null) { - throw new Error("Missing DTD entity name. " + this.debugInfo(name)); - } - if (value == null) { - throw new Error("Missing DTD entity value. " + this.debugInfo(name)); - } - this.pe = !!pe; - this.name = this.stringify.name(name); - this.type = NodeType.EntityDeclaration; - if (!isObject(value)) { - this.value = this.stringify.dtdEntityValue(value); - this.internal = true; - } else { - if (!value.pubID && !value.sysID) { - throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name)); - } - if (value.pubID && !value.sysID) { - throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name)); + /** + * Serializes the opening tag of an element node. + * + * @param hasChildren - whether the element node has child nodes + */ + XMLBuilderCBImpl.prototype._serializeOpenTag = function (hasChildren) { + if (this._currentElementSerialized) + return; + if (this._currentElement === undefined) + return; + var node = this._currentElement.node; + if (this._options.wellFormed && (node.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(node.localName))) { + this.emit("error", new Error("Node local name contains invalid characters (well-formed required).")); + return; } - this.internal = false; - if (value.pubID != null) { - this.pubID = this.stringify.dtdPubID(value.pubID); + var qualifiedName = ""; + var ignoreNamespaceDefinitionAttribute = false; + var map = this._prefixMap.copy(); + var localPrefixesMap = {}; + var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); + var inheritedNS = this._openTags.length === 0 ? null : this._openTags[this._openTags.length - 1][1]; + var ns = node.namespaceURI; + if (ns === null) + ns = inheritedNS; + if (inheritedNS === ns) { + if (localDefaultNamespace !== null) { + ignoreNamespaceDefinitionAttribute = true; + } + if (ns === infra_1.namespace.XML) { + qualifiedName = "xml:" + node.localName; + } + else { + qualifiedName = node.localName; + } + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); } - if (value.sysID != null) { - this.sysID = this.stringify.dtdSysID(value.sysID); + else { + var prefix = node.prefix; + var candidatePrefix = null; + if (prefix !== null || ns !== localDefaultNamespace) { + candidatePrefix = map.get(prefix, ns); + } + if (prefix === "xmlns") { + if (this._options.wellFormed) { + this.emit("error", new Error("An element cannot have the 'xmlns' prefix (well-formed required).")); + return; + } + candidatePrefix = prefix; + } + if (candidatePrefix !== null) { + qualifiedName = candidatePrefix + ':' + node.localName; + if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { + inheritedNS = localDefaultNamespace || null; + } + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + } + else if (prefix !== null) { + if (prefix in localPrefixesMap) { + prefix = this._generatePrefix(ns, map, this._prefixIndex); + } + map.set(prefix, ns); + qualifiedName += prefix + ':' + node.localName; + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + this._push(this._writer.attribute("xmlns:" + prefix, this._serializeAttributeValue(ns, this._options.wellFormed))); + if (localDefaultNamespace !== null) { + inheritedNS = localDefaultNamespace || null; + } + } + else if (localDefaultNamespace === null || + (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { + ignoreNamespaceDefinitionAttribute = true; + qualifiedName += node.localName; + inheritedNS = ns; + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + this._push(this._writer.attribute("xmlns", this._serializeAttributeValue(ns, this._options.wellFormed))); + } + else { + qualifiedName += node.localName; + inheritedNS = ns; + this._writer.beginElement(qualifiedName); + this._push(this._writer.openTagBegin(qualifiedName)); + } } - if (value.nData != null) { - this.nData = this.stringify.dtdNData(value.nData); + this._serializeAttributes(node, map, this._prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, this._options.wellFormed); + var isHTML = (ns === infra_1.namespace.HTML); + if (isHTML && !hasChildren && + XMLBuilderCBImpl._VoidElementNames.has(node.localName)) { + this._push(this._writer.openTagEnd(qualifiedName, true, true)); + this._writer.endElement(qualifiedName); } - if (this.pe && this.nData) { - throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name)); + else if (!isHTML && !hasChildren) { + this._push(this._writer.openTagEnd(qualifiedName, true, false)); + this._writer.endElement(qualifiedName); } - } - } - - Object.defineProperty(XMLDTDEntity.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'notationName', { - get: function() { - return this.nData || null; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', { - get: function() { - return null; - } - }); - - XMLDTDEntity.prototype.toString = function(options) { - return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options)); + else { + this._push(this._writer.openTagEnd(qualifiedName, false, false)); + } + this._currentElementSerialized = true; + /** + * Save qualified name, original inherited ns, original prefix map, and + * hasChildren flag. + */ + this._openTags.push([qualifiedName, inheritedNS, this._prefixMap, hasChildren]); + /** + * New values of inherited namespace and prefix map will be used while + * serializing child nodes. They will be returned to their original values + * when this node is closed using the _openTags array item we saved above. + */ + if (this._isPrefixMapModified(this._prefixMap, map)) { + this._prefixMap = map; + } + /** + * Calls following this will either serialize child nodes or close this tag. + */ + this._writer.level++; }; - - return XMLDTDEntity; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 2837: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLDTDNotation, XMLNode, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDTDNotation = (function(superClass) { - extend(XMLDTDNotation, superClass); - - function XMLDTDNotation(parent, name, value) { - XMLDTDNotation.__super__.constructor.call(this, parent); - if (name == null) { - throw new Error("Missing DTD notation name. " + this.debugInfo(name)); - } - if (!value.pubID && !value.sysID) { - throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name)); - } - this.name = this.stringify.name(name); - this.type = NodeType.NotationDeclaration; - if (value.pubID != null) { - this.pubID = this.stringify.dtdPubID(value.pubID); - } - if (value.sysID != null) { - this.sysID = this.stringify.dtdSysID(value.sysID); - } - } - - Object.defineProperty(XMLDTDNotation.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); - - Object.defineProperty(XMLDTDNotation.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); - - XMLDTDNotation.prototype.toString = function(options) { - return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options)); + /** + * Serializes the closing tag of an element node. + */ + XMLBuilderCBImpl.prototype._serializeCloseTag = function () { + this._writer.level--; + var lastEle = this._openTags.pop(); + /* istanbul ignore next */ + if (lastEle === undefined) { + this.emit("error", new Error("Last element is undefined.")); + return; + } + var _a = __read(lastEle, 4), qualifiedName = _a[0], ns = _a[1], map = _a[2], hasChildren = _a[3]; + /** + * Restore original values of inherited namespace and prefix map. + */ + this._prefixMap = map; + if (!hasChildren) + return; + this._push(this._writer.closeTag(qualifiedName)); + this._writer.endElement(qualifiedName); }; - - return XMLDTDNotation; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 6364: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLDeclaration, XMLNode, isObject, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - isObject = (__nccwpck_require__(8229).isObject); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - module.exports = XMLDeclaration = (function(superClass) { - extend(XMLDeclaration, superClass); - - function XMLDeclaration(parent, version, encoding, standalone) { - var ref; - XMLDeclaration.__super__.constructor.call(this, parent); - if (isObject(version)) { - ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone; - } - if (!version) { - version = '1.0'; - } - this.type = NodeType.Declaration; - this.version = this.stringify.xmlVersion(version); - if (encoding != null) { - this.encoding = this.stringify.xmlEncoding(encoding); - } - if (standalone != null) { - this.standalone = this.stringify.xmlStandalone(standalone); - } - } - - XMLDeclaration.prototype.toString = function(options) { - return this.options.writer.declaration(this, this.options.writer.filterOptions(options)); + /** + * Pushes data to internal buffer. + * + * @param data - data + */ + XMLBuilderCBImpl.prototype._push = function (data) { + if (data === null) { + this._ended = true; + this.emit("end"); + } + else if (this._ended) { + this.emit("error", new Error("Cannot push to ended stream.")); + } + else if (data.length !== 0) { + this._writer.hasData = true; + this.emit("data", data, this._writer.level); + } }; - - return XMLDeclaration; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 1801: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - isObject = (__nccwpck_require__(8229).isObject); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - XMLDTDAttList = __nccwpck_require__(1015); - - XMLDTDEntity = __nccwpck_require__(53); - - XMLDTDElement = __nccwpck_require__(2421); - - XMLDTDNotation = __nccwpck_require__(2837); - - XMLNamedNodeMap = __nccwpck_require__(4361); - - module.exports = XMLDocType = (function(superClass) { - extend(XMLDocType, superClass); - - function XMLDocType(parent, pubID, sysID) { - var child, i, len, ref, ref1, ref2; - XMLDocType.__super__.constructor.call(this, parent); - this.type = NodeType.DocType; - if (parent.children) { - ref = parent.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - if (child.type === NodeType.Element) { - this.name = child.name; - break; - } + /** + * Reads and serializes an XML tree. + * + * @param node - root node + */ + XMLBuilderCBImpl.prototype._fromNode = function (node) { + var e_2, _a, e_3, _b; + if (util_2.Guard.isElementNode(node)) { + var name = node.prefix ? node.prefix + ":" + node.localName : node.localName; + if (node.namespaceURI !== null) { + this.ele(node.namespaceURI, name); + } + else { + this.ele(name); + } + try { + for (var _c = __values(node.attributes), _d = _c.next(); !_d.done; _d = _c.next()) { + var attr = _d.value; + var name_1 = attr.prefix ? attr.prefix + ":" + attr.localName : attr.localName; + if (attr.namespaceURI !== null) { + this.att(attr.namespaceURI, name_1, attr.value); + } + else { + this.att(name_1, attr.value); + } + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + } + finally { if (e_2) throw e_2.error; } + } + try { + for (var _e = __values(node.childNodes), _f = _e.next(); !_f.done; _f = _e.next()) { + var child = _f.value; + this._fromNode(child); + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_f && !_f.done && (_b = _e.return)) _b.call(_e); + } + finally { if (e_3) throw e_3.error; } + } + this.up(); } - } - this.documentObject = parent; - if (isObject(pubID)) { - ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID; - } - if (sysID == null) { - ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1]; - } - if (pubID != null) { - this.pubID = this.stringify.dtdPubID(pubID); - } - if (sysID != null) { - this.sysID = this.stringify.dtdSysID(sysID); - } - } - - Object.defineProperty(XMLDocType.prototype, 'entities', { - get: function() { - var child, i, len, nodes, ref; - nodes = {}; - ref = this.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - if ((child.type === NodeType.EntityDeclaration) && !child.pe) { - nodes[child.name] = child; - } + else if (util_2.Guard.isExclusiveTextNode(node) && node.data) { + this.txt(node.data); } - return new XMLNamedNodeMap(nodes); - } - }); - - Object.defineProperty(XMLDocType.prototype, 'notations', { - get: function() { - var child, i, len, nodes, ref; - nodes = {}; - ref = this.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - if (child.type === NodeType.NotationDeclaration) { - nodes[child.name] = child; - } + else if (util_2.Guard.isCommentNode(node)) { + this.com(node.data); + } + else if (util_2.Guard.isCDATASectionNode(node)) { + this.dat(node.data); + } + else if (util_2.Guard.isProcessingInstructionNode(node)) { + this.ins(node.target, node.data); } - return new XMLNamedNodeMap(nodes); - } - }); - - Object.defineProperty(XMLDocType.prototype, 'publicId', { - get: function() { - return this.pubID; - } - }); - - Object.defineProperty(XMLDocType.prototype, 'systemId', { - get: function() { - return this.sysID; - } - }); - - Object.defineProperty(XMLDocType.prototype, 'internalSubset', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - - XMLDocType.prototype.element = function(name, value) { - var child; - child = new XMLDTDElement(this, name, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - var child; - child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.entity = function(name, value) { - var child; - child = new XMLDTDEntity(this, false, name, value); - this.children.push(child); - return this; - }; - - XMLDocType.prototype.pEntity = function(name, value) { - var child; - child = new XMLDTDEntity(this, true, name, value); - this.children.push(child); - return this; }; - - XMLDocType.prototype.notation = function(name, value) { - var child; - child = new XMLDTDNotation(this, name, value); - this.children.push(child); - return this; + /** + * 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 + */ + XMLBuilderCBImpl.prototype._serializeAttributes = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed) { + var e_4, _a; + var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; + try { + 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) { + this._push(this._writer.attribute(attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); + continue; + } + if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { + this.emit("error", new Error("Element contains duplicate attributes (well-formed required).")); + return; + } + if (requireWellFormed && localNameSet) + localNameSet.set(attr.namespaceURI, attr.localName); + var attributeNamespace = attr.namespaceURI; + var candidatePrefix = null; + if (attributeNamespace !== null) { + candidatePrefix = map.get(attr.prefix, attributeNamespace); + if (attributeNamespace === infra_1.namespace.XMLNS) { + 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; + if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { + this.emit("error", new Error("XMLNS namespace is reserved (well-formed required).")); + return; + } + if (requireWellFormed && attr.value === '') { + this.emit("error", new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).")); + return; + } + if (attr.prefix === 'xmlns') + candidatePrefix = 'xmlns'; + /** + * _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 { + candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); + } + this._push(this._writer.attribute("xmlns:" + candidatePrefix, this._serializeAttributeValue(attributeNamespace, this._options.wellFormed))); + } + } + if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || + !algorithm_1.xml_isName(attr.localName) || + (attr.localName === "xmlns" && attributeNamespace === null))) { + this.emit("error", new Error("Attribute local name contains invalid characters (well-formed required).")); + return; + } + this._push(this._writer.attribute((candidatePrefix !== null ? candidatePrefix + ":" : "") + attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); + } + } + 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; } + } }; - - XMLDocType.prototype.toString = function(options) { - return this.options.writer.docType(this, this.options.writer.filterOptions(options)); - }; - - XMLDocType.prototype.ele = function(name, value) { - return this.element(name, value); - }; - - XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { - return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); - }; - - XMLDocType.prototype.ent = function(name, value) { - return this.entity(name, value); - }; - - XMLDocType.prototype.pent = function(name, value) { - return this.pEntity(name, value); + /** + * Produces an XML serialization of an attribute value. + * + * @param value - attribute value + * @param requireWellFormed - whether to check conformance + */ + XMLBuilderCBImpl.prototype._serializeAttributeValue = function (value, requireWellFormed) { + if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { + this.emit("error", new Error("Invalid characters in attribute value.")); + return ""; + } + if (value === null) + return ""; + if (this._options.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; + } }; - - XMLDocType.prototype.not = function(name, value) { - return this.notation(name, value); + /** + * 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 + */ + XMLBuilderCBImpl.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { + var e_5, _a; + var defaultNamespaceAttrValue = null; + try { + for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + var attributeNamespace = attr.namespaceURI; + var attributePrefix = attr.prefix; + if (attributeNamespace === infra_1.namespace.XMLNS) { + if (attributePrefix === null) { + defaultNamespaceAttrValue = attr.value; + continue; + } + else { + var prefixDefinition = attr.localName; + var namespaceDefinition = attr.value; + if (namespaceDefinition === infra_1.namespace.XML) { + continue; + } + if (namespaceDefinition === '') { + namespaceDefinition = null; + } + if (map.has(prefixDefinition, namespaceDefinition)) { + continue; + } + map.set(prefixDefinition, namespaceDefinition); + localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; + } + } + } + } + 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; } + } + return defaultNamespaceAttrValue; }; - - XMLDocType.prototype.up = function() { - return this.root() || this.documentObject; + /** + * 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 + */ + XMLBuilderCBImpl.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { + var generatedPrefix = "ns" + prefixIndex.value; + prefixIndex.value++; + prefixMap.set(generatedPrefix, newNamespace); + return generatedPrefix; }; - - XMLDocType.prototype.isEqualNode = function(node) { - if (!XMLDocType.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { - return false; - } - if (node.name !== this.name) { - return false; - } - if (node.publicId !== this.publicId) { - return false; - } - if (node.systemId !== this.systemId) { + /** + * Determines if the namespace prefix map was modified from its original. + * + * @param originalMap - original namespace prefix map + * @param newMap - new namespace prefix map + */ + XMLBuilderCBImpl.prototype._isPrefixMapModified = function (originalMap, newMap) { + var items1 = originalMap._items; + var items2 = newMap._items; + var nullItems1 = originalMap._nullItems; + var nullItems2 = newMap._nullItems; + for (var key in items2) { + var arr1 = items1[key]; + if (arr1 === undefined) + return true; + var arr2 = items2[key]; + if (arr1.length !== arr2.length) + return true; + for (var i = 0; i < arr1.length; i++) { + if (arr1[i] !== arr2[i]) + return true; + } + } + if (nullItems1.length !== nullItems2.length) + return true; + for (var i = 0; i < nullItems1.length; i++) { + if (nullItems1[i] !== nullItems2[i]) + return true; + } return false; - } - return true; }; - - return XMLDocType; - - })(XMLNode); - -}).call(this); - + XMLBuilderCBImpl._VoidElementNames = new Set(['area', 'base', 'basefont', + 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', + 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); + return XMLBuilderCBImpl; +}(events_1.EventEmitter)); +exports.XMLBuilderCBImpl = XMLBuilderCBImpl; +//# sourceMappingURL=XMLBuilderCBImpl.js.map /***/ }), -/***/ 3730: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - isPlainObject = (__nccwpck_require__(8229).isPlainObject); - - XMLDOMImplementation = __nccwpck_require__(8310); - - XMLDOMConfiguration = __nccwpck_require__(7465); - - XMLNode = __nccwpck_require__(7608); - - NodeType = __nccwpck_require__(9267); - - XMLStringifier = __nccwpck_require__(8594); - - XMLStringWriter = __nccwpck_require__(5913); +/***/ 8248: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - module.exports = XMLDocument = (function(superClass) { - extend(XMLDocument, superClass); +"use strict"; - function XMLDocument(options) { - XMLDocument.__super__.constructor.call(this, null); - this.name = "#document"; - this.type = NodeType.Document; - this.documentURI = null; - this.domConfig = new XMLDOMConfiguration(); - options || (options = {}); - if (!options.writer) { - options.writer = new XMLStringWriter(); - } - this.options = options; - this.stringify = new XMLStringifier(options); +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); } - - Object.defineProperty(XMLDocument.prototype, 'implementation', { - value: new XMLDOMImplementation() - }); - - Object.defineProperty(XMLDocument.prototype, 'doctype', { - get: function() { - var child, i, len, ref; - ref = this.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - if (child.type === NodeType.DocType) { - return child; - } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); } - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'documentElement', { - get: function() { - return this.rootObject || null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'inputEncoding', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', { - get: function() { - return false; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].encoding; - } else { - return null; - } - } - }); - - Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].standalone === 'yes'; - } else { - return false; - } - } - }); - - Object.defineProperty(XMLDocument.prototype, 'xmlVersion', { - get: function() { - if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { - return this.children[0].version; - } else { - return "1.0"; + 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 }; } - } - }); - - Object.defineProperty(XMLDocument.prototype, 'URL', { - get: function() { - return this.documentURI; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'origin', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'compatMode', { - get: function() { - return null; - } - }); - - Object.defineProperty(XMLDocument.prototype, 'characterSet', { - get: function() { - return null; - } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var interfaces_1 = __nccwpck_require__(6417); +var util_1 = __nccwpck_require__(6195); +var writers_1 = __nccwpck_require__(7476); +var interfaces_2 = __nccwpck_require__(7305); +var util_2 = __nccwpck_require__(5282); +var algorithm_1 = __nccwpck_require__(61); +var dom_1 = __nccwpck_require__(770); +var infra_1 = __nccwpck_require__(4251); +var readers_1 = __nccwpck_require__(560); +/** + * Represents a wrapper that extends XML nodes to implement easy to use and + * chainable document builder methods. + */ +var XMLBuilderImpl = /** @class */ (function () { + /** + * Initializes a new instance of `XMLBuilderNodeImpl`. + * + * @param domNode - the DOM node to wrap + */ + function XMLBuilderImpl(domNode) { + this._domNode = domNode; + } + Object.defineProperty(XMLBuilderImpl.prototype, "node", { + /** @inheritdoc */ + get: function () { return this._domNode; }, + enumerable: true, + configurable: true }); - - Object.defineProperty(XMLDocument.prototype, 'contentType', { - get: function() { - return null; - } + Object.defineProperty(XMLBuilderImpl.prototype, "options", { + /** @inheritdoc */ + get: function () { return this._options; }, + enumerable: true, + configurable: true }); - - XMLDocument.prototype.end = function(writer) { - var writerOptions; - writerOptions = {}; - if (!writer) { - writer = this.options.writer; - } else if (isPlainObject(writer)) { - writerOptions = writer; - writer = this.options.writer; - } - return writer.document(this, writer.filterOptions(writerOptions)); - }; - - XMLDocument.prototype.toString = function(options) { - return this.options.writer.document(this, this.options.writer.filterOptions(options)); - }; - - XMLDocument.prototype.createElement = function(tagName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createDocumentFragment = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createTextNode = function(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createComment = function(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createCDATASection = function(data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createProcessingInstruction = function(target, data) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createAttribute = function(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createEntityReference = function(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.getElementsByTagName = function(tagname) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.importNode = function(importedNode, deep) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.getElementById = function(elementId) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLDocument.prototype.adoptNode = function(source) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderImpl.prototype.set = function (options) { + this._options = util_1.applyDefaults(util_1.applyDefaults(this._options, options, true), // apply user settings + interfaces_1.DefaultBuilderOptions); // provide defaults + return this; }; - - XMLDocument.prototype.normalizeDocument = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + XMLBuilderImpl.prototype.ele = function (p1, p2, p3) { + var _a, _b, _c; + var namespace; + var name; + var attributes; + if (util_1.isObject(p1)) { + // ele(obj: ExpandObject) + return new readers_1.ObjectReader(this._options).parse(this, p1); + } + else if (p1 !== null && /^\s*= 0) { - this.up(); - } - return this.onEnd(); - }; - - XMLDocumentCB.prototype.openCurrent = function() { - if (this.currentNode) { - this.currentNode.children = true; - return this.openNode(this.currentNode); - } - }; - - XMLDocumentCB.prototype.openNode = function(node) { - var att, chunk, name, ref1; - if (!node.isOpen) { - if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) { - this.root = node; + else if (util_2.Guard.isDocumentFragmentNode(importedNode)) { + try { + // import child nodes + for (var _c = __values(importedNode.childNodes), _d = _c.next(); !_d.done; _d = _c.next()) { + var childNode = _d.value; + var clone = hostDoc.importNode(childNode, true); + hostNode.appendChild(clone); + if (util_2.Guard.isElementNode(clone)) { + var _e = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _e[0]; + var namespace = hostNode.lookupNamespaceURI(prefix); + new XMLBuilderImpl(clone)._updateNamespace(namespace); + } + } + } + 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; } + } } - chunk = ''; - if (node.type === NodeType.Element) { - this.writerOptions.state = WriterState.OpenTag; - chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name; - ref1 = node.attribs; - for (name in ref1) { - if (!hasProp.call(ref1, name)) continue; - att = ref1[name]; - chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel); - } - chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel); - this.writerOptions.state = WriterState.InsideTag; - } else { - this.writerOptions.state = WriterState.OpenTag; - chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ''; - } - chunk += this.writer.endline(node, this.writerOptions, this.currentLevel); + else { + // import node + var clone = hostDoc.importNode(importedNode, true); + hostNode.appendChild(clone); + if (util_2.Guard.isElementNode(clone)) { + var _f = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _f[0]; + var namespace = hostNode.lookupNamespaceURI(prefix); + new XMLBuilderImpl(clone)._updateNamespace(namespace); + } } - this.onData(chunk, this.currentLevel); - return node.isOpen = true; - } + return this; }; - - XMLDocumentCB.prototype.closeNode = function(node) { - var chunk; - if (!node.isClosed) { - chunk = ''; - this.writerOptions.state = WriterState.CloseTag; - if (node.type === NodeType.Element) { - chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '' + this.writer.endline(node, this.writerOptions, this.currentLevel); - } else { - chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel); + /** @inheritdoc */ + XMLBuilderImpl.prototype.doc = function () { + if (this._doc._isFragment) { + var node = this.node; + while (node && node.nodeType !== interfaces_2.NodeType.DocumentFragment) { + node = node.parentNode; + } + /* istanbul ignore next */ + if (node === null) { + throw new Error("Node has no parent node while searching for document fragment ancestor. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); + } + else { + return new XMLBuilderImpl(this._doc); } - this.writerOptions.state = WriterState.None; - this.onData(chunk, this.currentLevel); - return node.isClosed = true; - } }; - - XMLDocumentCB.prototype.onData = function(chunk, level) { - this.documentStarted = true; - return this.onDataCallback(chunk, level + 1); + /** @inheritdoc */ + XMLBuilderImpl.prototype.root = function () { + var ele = this._doc.documentElement; + if (!ele) { + throw new Error("Document root element is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(ele); }; - - XMLDocumentCB.prototype.onEnd = function() { - this.documentCompleted = true; - return this.onEndCallback(); + /** @inheritdoc */ + XMLBuilderImpl.prototype.up = function () { + var parent = this._domNode.parentNode; + if (!parent) { + throw new Error("Parent node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(parent); }; - - XMLDocumentCB.prototype.debugInfo = function(name) { - if (name == null) { - return ""; - } else { - return "node: <" + name + ">"; - } + /** @inheritdoc */ + XMLBuilderImpl.prototype.prev = function () { + var node = this._domNode.previousSibling; + if (!node) { + throw new Error("Previous sibling node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); }; - - XMLDocumentCB.prototype.ele = function() { - return this.element.apply(this, arguments); + /** @inheritdoc */ + XMLBuilderImpl.prototype.next = function () { + var node = this._domNode.nextSibling; + if (!node) { + throw new Error("Next sibling node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); }; - - XMLDocumentCB.prototype.nod = function(name, attributes, text) { - return this.node(name, attributes, text); + /** @inheritdoc */ + XMLBuilderImpl.prototype.first = function () { + var node = this._domNode.firstChild; + if (!node) { + throw new Error("First child node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); }; - - XMLDocumentCB.prototype.txt = function(value) { - return this.text(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.last = function () { + var node = this._domNode.lastChild; + if (!node) { + throw new Error("Last child node is null. " + this._debugInfo()); + } + return new XMLBuilderImpl(node); }; - - XMLDocumentCB.prototype.dat = function(value) { - return this.cdata(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.each = function (callback, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = this._getFirstDescendantNode(this._domNode, self, recursive); + while (result[0]) { + var nextResult = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + callback.call(thisArg, new XMLBuilderImpl(result[0]), result[1], result[2]); + result = nextResult; + } + return this; }; - - XMLDocumentCB.prototype.com = function(value) { - return this.comment(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.map = function (callback, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = []; + this.each(function (node, index, level) { + return result.push(callback.call(thisArg, node, index, level)); + }, self, recursive); + return result; }; - - XMLDocumentCB.prototype.ins = function(target, value) { - return this.instruction(target, value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.reduce = function (callback, initialValue, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var value = initialValue; + this.each(function (node, index, level) { + return value = callback.call(thisArg, value, node, index, level); + }, self, recursive); + return value; }; - - XMLDocumentCB.prototype.dec = function(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); - }; - - XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) { - return this.doctype(root, pubID, sysID); - }; - - XMLDocumentCB.prototype.e = function(name, attributes, text) { - return this.element(name, attributes, text); + /** @inheritdoc */ + XMLBuilderImpl.prototype.find = function (predicate, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = this._getFirstDescendantNode(this._domNode, self, recursive); + while (result[0]) { + var builder = new XMLBuilderImpl(result[0]); + if (predicate.call(thisArg, builder, result[1], result[2])) { + return builder; + } + result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + } + return undefined; }; - - XMLDocumentCB.prototype.n = function(name, attributes, text) { - return this.node(name, attributes, text); + /** @inheritdoc */ + XMLBuilderImpl.prototype.filter = function (predicate, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = []; + this.each(function (node, index, level) { + if (predicate.call(thisArg, node, index, level)) { + result.push(node); + } + }, self, recursive); + return result; }; - - XMLDocumentCB.prototype.t = function(value) { - return this.text(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.every = function (predicate, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = this._getFirstDescendantNode(this._domNode, self, recursive); + while (result[0]) { + var builder = new XMLBuilderImpl(result[0]); + if (!predicate.call(thisArg, builder, result[1], result[2])) { + return false; + } + result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + } + return true; }; - - XMLDocumentCB.prototype.d = function(value) { - return this.cdata(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.some = function (predicate, self, recursive, thisArg) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = this._getFirstDescendantNode(this._domNode, self, recursive); + while (result[0]) { + var builder = new XMLBuilderImpl(result[0]); + if (predicate.call(thisArg, builder, result[1], result[2])) { + return true; + } + result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + } + return false; }; - - XMLDocumentCB.prototype.c = function(value) { - return this.comment(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.toArray = function (self, recursive) { + if (self === void 0) { self = false; } + if (recursive === void 0) { recursive = false; } + var result = []; + this.each(function (node) { return result.push(node); }, self, recursive); + return result; }; - - XMLDocumentCB.prototype.r = function(value) { - return this.raw(value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.toString = function (writerOptions) { + writerOptions = writerOptions || {}; + if (writerOptions.format === undefined) { + writerOptions.format = "xml"; + } + return this._serialize(writerOptions); }; - - XMLDocumentCB.prototype.i = function(target, value) { - return this.instruction(target, value); + /** @inheritdoc */ + XMLBuilderImpl.prototype.toObject = function (writerOptions) { + writerOptions = writerOptions || {}; + if (writerOptions.format === undefined) { + writerOptions.format = "object"; + } + return this._serialize(writerOptions); }; - - XMLDocumentCB.prototype.att = function() { - if (this.currentNode && this.currentNode.type === NodeType.DocType) { - return this.attList.apply(this, arguments); - } else { - return this.attribute.apply(this, arguments); - } + /** @inheritdoc */ + XMLBuilderImpl.prototype.end = function (writerOptions) { + writerOptions = writerOptions || {}; + if (writerOptions.format === undefined) { + writerOptions.format = "xml"; + } + return this.doc()._serialize(writerOptions); }; - - XMLDocumentCB.prototype.a = function() { - if (this.currentNode && this.currentNode.type === NodeType.DocType) { - return this.attList.apply(this, arguments); - } else { - return this.attribute.apply(this, arguments); - } + /** + * Gets the next descendant of the given node of the tree rooted at `root` + * in depth-first pre-order. Returns a three-tuple with + * [descendant, descendant_index, descendant_level]. + * + * @param root - root node of the tree + * @param self - whether to visit the current node along with child nodes + * @param recursive - whether to visit all descendant nodes in tree-order or + * only the immediate child nodes + */ + XMLBuilderImpl.prototype._getFirstDescendantNode = function (root, self, recursive) { + if (self) + return [this._domNode, 0, 0]; + else if (recursive) + return this._getNextDescendantNode(root, root, recursive, 0, 0); + else + return [this._domNode.firstChild, 0, 1]; }; - - XMLDocumentCB.prototype.ent = function(name, value) { - return this.entity(name, value); + /** + * Gets the next descendant of the given node of the tree rooted at `root` + * in depth-first pre-order. Returns a three-tuple with + * [descendant, descendant_index, descendant_level]. + * + * @param root - root node of the tree + * @param node - current node + * @param recursive - whether to visit all descendant nodes in tree-order or + * only the immediate child nodes + * @param index - child node index + * @param level - current depth of the XML tree + */ + XMLBuilderImpl.prototype._getNextDescendantNode = function (root, node, recursive, index, level) { + if (recursive) { + // traverse child nodes + if (node.firstChild) + return [node.firstChild, 0, level + 1]; + if (node === root) + return [null, -1, -1]; + // traverse siblings + if (node.nextSibling) + return [node.nextSibling, index + 1, level]; + // traverse parent's next sibling + var parent = node.parentNode; + while (parent && parent !== root) { + if (parent.nextSibling) + return [parent.nextSibling, algorithm_1.tree_index(parent.nextSibling), level - 1]; + parent = parent.parentNode; + level--; + } + } + else { + if (root === node) + return [node.firstChild, 0, level + 1]; + else + return [node.nextSibling, index + 1, level]; + } + return [null, -1, -1]; }; - - XMLDocumentCB.prototype.pent = function(name, value) { - return this.pEntity(name, value); + /** + * Converts the node into its string or object representation. + * + * @param options - serialization options + */ + XMLBuilderImpl.prototype._serialize = function (writerOptions) { + if (writerOptions.format === "xml") { + var writer = new writers_1.XMLWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "map") { + var writer = new writers_1.MapWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "object") { + var writer = new writers_1.ObjectWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "json") { + var writer = new writers_1.JSONWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else if (writerOptions.format === "yaml") { + var writer = new writers_1.YAMLWriter(this._options, writerOptions); + return writer.serialize(this.node); + } + else { + throw new Error("Invalid writer format: " + writerOptions.format + ". " + this._debugInfo()); + } }; - - XMLDocumentCB.prototype.not = function(name, value) { - return this.notation(name, value); + /** + * Extracts a namespace and name from the given string. + * + * @param namespace - namespace + * @param name - a string containing both a name and namespace separated by an + * `'@'` character + * @param ele - `true` if this is an element namespace; otherwise `false` + */ + XMLBuilderImpl.prototype._extractNamespace = function (namespace, name, ele) { + // extract from name + var atIndex = name.indexOf("@"); + if (atIndex > 0) { + if (namespace === undefined) + namespace = name.slice(atIndex + 1); + name = name.slice(0, atIndex); + } + if (namespace === undefined) { + // look-up default namespace + namespace = (ele ? this._options.defaultNamespace.ele : this._options.defaultNamespace.att); + } + else if (namespace !== null && namespace[0] === "@") { + // look-up namespace aliases + var alias = namespace.slice(1); + namespace = this._options.namespaceAlias[alias]; + if (namespace === undefined) { + throw new Error("Namespace alias `" + alias + "` is not defined. " + this._debugInfo()); + } + } + return [namespace, name]; }; + /** + * Updates the element's namespace. + * + * @param ns - new namespace + */ + XMLBuilderImpl.prototype._updateNamespace = function (ns) { + var e_2, _a, e_3, _b; + var ele = this._domNode; + if (util_2.Guard.isElementNode(ele) && ns !== null && ele.namespaceURI !== ns) { + var _c = __read(algorithm_1.namespace_extractQName(ele.prefix ? ele.prefix + ':' + ele.localName : ele.localName), 2), elePrefix = _c[0], eleLocalName = _c[1]; + // re-create the element node if its namespace changed + // we can't simply change the namespaceURI since its read-only + var newEle = algorithm_1.create_element(this._doc, eleLocalName, ns, elePrefix); + try { + for (var _d = __values(ele.attributes), _e = _d.next(); !_e.done; _e = _d.next()) { + var attr = _e.value; + var attrQName = attr.prefix ? attr.prefix + ':' + attr.localName : attr.localName; + var _f = __read(algorithm_1.namespace_extractQName(attrQName), 1), attrPrefix = _f[0]; + var newAttrNS = attr.namespaceURI; + if (newAttrNS === null && attrPrefix !== null) { + newAttrNS = ele.lookupNamespaceURI(attrPrefix); + } + if (newAttrNS === null) { + newEle.setAttribute(attrQName, attr.value); + } + else { + newEle.setAttributeNS(newAttrNS, attrQName, attr.value); + } + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_e && !_e.done && (_a = _d.return)) _a.call(_d); + } + finally { if (e_2) throw e_2.error; } + } + // replace the new node in parent node + var parent = ele.parentNode; + /* istanbul ignore next */ + if (parent === null) { + throw new Error("Parent node is null." + this._debugInfo()); + } + parent.replaceChild(newEle, ele); + this._domNode = newEle; + try { + // check child nodes + for (var _g = __values(ele.childNodes), _h = _g.next(); !_h.done; _h = _g.next()) { + var childNode = _h.value; + var newChildNode = childNode.cloneNode(true); + newEle.appendChild(newChildNode); + if (util_2.Guard.isElementNode(newChildNode)) { + var _j = __read(algorithm_1.namespace_extractQName(newChildNode.prefix ? newChildNode.prefix + ':' + newChildNode.localName : newChildNode.localName), 1), newChildNodePrefix = _j[0]; + var newChildNodeNS = newEle.lookupNamespaceURI(newChildNodePrefix); + new XMLBuilderImpl(newChildNode)._updateNamespace(newChildNodeNS); + } + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (_h && !_h.done && (_b = _g.return)) _b.call(_g); + } + finally { if (e_3) throw e_3.error; } + } + } + }; + Object.defineProperty(XMLBuilderImpl.prototype, "_doc", { + /** + * Returns the document owning this node. + */ + get: function () { + var node = this.node; + if (util_2.Guard.isDocumentNode(node)) { + return node; + } + else { + var docNode = node.ownerDocument; + /* istanbul ignore next */ + if (!docNode) + throw new Error("Owner document is null. " + this._debugInfo()); + return docNode; + } + }, + enumerable: true, + configurable: true + }); + /** + * Returns debug information for this node. + * + * @param name - node name + */ + XMLBuilderImpl.prototype._debugInfo = function (name) { + var node = this.node; + var parentNode = node.parentNode; + name = name || node.nodeName; + var parentName = parentNode ? parentNode.nodeName : ''; + if (!parentName) { + return "node: <" + name + ">"; + } + else { + return "node: <" + name + ">, parent: <" + parentName + ">"; + } + }; + Object.defineProperty(XMLBuilderImpl.prototype, "_options", { + /** + * Gets or sets builder options. + */ + get: function () { + var doc = this._doc; + /* istanbul ignore next */ + if (doc._xmlBuilderOptions === undefined) { + throw new Error("Builder options is not set."); + } + return doc._xmlBuilderOptions; + }, + set: function (value) { + var doc = this._doc; + doc._xmlBuilderOptions = value; + }, + enumerable: true, + configurable: true + }); + return XMLBuilderImpl; +}()); +exports.XMLBuilderImpl = XMLBuilderImpl; +//# sourceMappingURL=XMLBuilderImpl.js.map - return XMLDocumentCB; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 3590: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLDummy, XMLNode, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - XMLNode = __nccwpck_require__(7608); +/***/ }), - NodeType = __nccwpck_require__(9267); +/***/ 770: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - module.exports = XMLDummy = (function(superClass) { - extend(XMLDummy, superClass); +"use strict"; - function XMLDummy(parent) { - XMLDummy.__super__.constructor.call(this, parent); - this.type = NodeType.Dummy; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var dom_1 = __nccwpck_require__(4646); +var dom_2 = __nccwpck_require__(633); +var util_1 = __nccwpck_require__(6195); +dom_2.dom.setFeatures(false); +/** + * Creates an XML document without any child nodes. + */ +function createDocument() { + var impl = new dom_1.DOMImplementation(); + var doc = impl.createDocument(null, 'root', null); + /* istanbul ignore else */ + if (doc.documentElement) { + doc.removeChild(doc.documentElement); } + return doc; +} +exports.createDocument = createDocument; +/** + * Sanitizes input strings with user supplied replacement characters. + * + * @param str - input string + * @param replacement - replacement character or function + */ +function sanitizeInput(str, replacement) { + if (str == null) { + return str; + } + else if (replacement === undefined) { + return str + ""; + } + else { + var result = ""; + str = str + ""; + for (var i = 0; i < str.length; i++) { + var n = str.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)) { + // valid character - not surrogate pair + result += str.charAt(i); + } + else if (n >= 0xD800 && n <= 0xDBFF && i < str.length - 1) { + var n2 = str.charCodeAt(i + 1); + if (n2 >= 0xDC00 && n2 <= 0xDFFF) { + // valid surrogate pair + n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; + result += String.fromCodePoint(n); + i++; + } + else { + // invalid lone surrogate + result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); + } + } + else { + // invalid character + result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); + } + } + return result; + } +} +exports.sanitizeInput = sanitizeInput; +//# sourceMappingURL=dom.js.map - XMLDummy.prototype.clone = function() { - return Object.create(this); - }; - - XMLDummy.prototype.toString = function(options) { - return ''; - }; - - return XMLDummy; +/***/ }), - })(XMLNode); +/***/ 4260: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -}).call(this); +"use strict"; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var XMLBuilderImpl_1 = __nccwpck_require__(8248); +exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; +var XMLBuilderCBImpl_1 = __nccwpck_require__(1438); +exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; +var BuilderFunctions_1 = __nccwpck_require__(5696); +exports.builder = BuilderFunctions_1.builder; +exports.create = BuilderFunctions_1.create; +exports.fragment = BuilderFunctions_1.fragment; +exports.convert = BuilderFunctions_1.convert; +var BuilderFunctionsCB_1 = __nccwpck_require__(268); +exports.createCB = BuilderFunctionsCB_1.createCB; +exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; +//# sourceMappingURL=index.js.map /***/ }), -/***/ 9437: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { +/***/ 151: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject, ref, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; +"use strict"; - ref = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var builder_1 = __nccwpck_require__(4260); +exports.builder = builder_1.builder; +exports.create = builder_1.create; +exports.fragment = builder_1.fragment; +exports.convert = builder_1.convert; +exports.createCB = builder_1.createCB; +exports.fragmentCB = builder_1.fragmentCB; +//# sourceMappingURL=index.js.map - XMLNode = __nccwpck_require__(7608); +/***/ }), - NodeType = __nccwpck_require__(9267); - - XMLAttribute = __nccwpck_require__(8376); - - XMLNamedNodeMap = __nccwpck_require__(4361); +/***/ 6417: +/***/ ((__unused_webpack_module, exports) => { - module.exports = XMLElement = (function(superClass) { - extend(XMLElement, superClass); +"use strict"; - function XMLElement(parent, name, attributes) { - var child, j, len, ref1; - XMLElement.__super__.constructor.call(this, parent); - if (name == null) { - throw new Error("Missing element name. " + this.debugInfo()); - } - this.name = this.stringify.name(name); - this.type = NodeType.Element; - this.attribs = {}; - this.schemaTypeInfo = null; - if (attributes != null) { - this.attribute(attributes); - } - if (parent.type === NodeType.Document) { - this.isRoot = true; - this.documentObject = parent; - parent.rootObject = this; - if (parent.children) { - ref1 = parent.children; - for (j = 0, len = ref1.length; j < len; j++) { - child = ref1[j]; - if (child.type === NodeType.DocType) { - child.name = this.name; - break; - } - } - } - } +Object.defineProperty(exports, "__esModule", ({ value: true })); +/** + * Defines default values for builder options. + */ +exports.DefaultBuilderOptions = { + version: "1.0", + encoding: undefined, + standalone: undefined, + keepNullNodes: false, + keepNullAttributes: false, + ignoreConverters: false, + convert: { + att: "@", + ins: "?", + text: "#", + cdata: "$", + comment: "!" + }, + defaultNamespace: { + ele: undefined, + att: undefined + }, + namespaceAlias: { + html: "http://www.w3.org/1999/xhtml", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/", + mathml: "http://www.w3.org/1998/Math/MathML", + svg: "http://www.w3.org/2000/svg", + xlink: "http://www.w3.org/1999/xlink" + }, + invalidCharReplacement: undefined, + parser: undefined +}; +/** + * Contains keys of `XMLBuilderOptions`. + */ +exports.XMLBuilderOptionKeys = new Set(Object.keys(exports.DefaultBuilderOptions)); +/** + * Defines default values for builder options. + */ +exports.DefaultXMLBuilderCBOptions = { + format: "xml", + wellFormed: false, + prettyPrint: false, + indent: " ", + newline: "\n", + offset: 0, + width: 0, + allowEmptyTags: false, + spaceBeforeSlash: false, + keepNullNodes: false, + keepNullAttributes: false, + ignoreConverters: false, + convert: { + att: "@", + ins: "?", + text: "#", + cdata: "$", + comment: "!" + }, + defaultNamespace: { + ele: undefined, + att: undefined + }, + namespaceAlias: { + html: "http://www.w3.org/1999/xhtml", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/", + mathml: "http://www.w3.org/1998/Math/MathML", + svg: "http://www.w3.org/2000/svg", + xlink: "http://www.w3.org/1999/xlink" } +}; +//# sourceMappingURL=interfaces.js.map - Object.defineProperty(XMLElement.prototype, 'tagName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLElement.prototype, 'namespaceURI', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLElement.prototype, 'prefix', { - get: function() { - return ''; - } - }); - - Object.defineProperty(XMLElement.prototype, 'localName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLElement.prototype, 'id', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +/***/ }), - Object.defineProperty(XMLElement.prototype, 'className', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +/***/ 3396: +/***/ ((__unused_webpack_module, exports) => { - Object.defineProperty(XMLElement.prototype, 'classList', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +"use strict"; - Object.defineProperty(XMLElement.prototype, 'attributes', { - get: function() { - if (!this.attributeMap || !this.attributeMap.nodes) { - this.attributeMap = new XMLNamedNodeMap(this.attribs); +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); } - return this.attributeMap; - } - }); - - XMLElement.prototype.clone = function() { - var att, attName, clonedSelf, ref1; - clonedSelf = Object.create(this); - if (clonedSelf.isRoot) { - clonedSelf.documentObject = null; - } - clonedSelf.attribs = {}; - ref1 = this.attribs; - for (attName in ref1) { - if (!hasProp.call(ref1, attName)) continue; - att = ref1[attName]; - clonedSelf.attribs[attName] = att.clone(); - } - clonedSelf.children = []; - this.children.forEach(function(child) { - var clonedChild; - clonedChild = child.clone(); - clonedChild.parent = clonedSelf; - return clonedSelf.children.push(clonedChild); - }); - return clonedSelf; + } + BaseReader.prototype._docType = function (parent, name, publicId, systemId) { + return parent.dtd({ name: name, pubID: publicId, sysID: systemId }); }; - - XMLElement.prototype.attribute = function(name, value) { - var attName, attValue; - if (name != null) { - name = getValue(name); - } - if (isObject(name)) { - for (attName in name) { - if (!hasProp.call(name, attName)) continue; - attValue = name[attName]; - this.attribute(attName, attValue); - } - } else { - if (isFunction(value)) { - value = value.apply(); - } - if (this.options.keepNullAttributes && (value == null)) { - this.attribs[name] = new XMLAttribute(this, name, ""); - } else if (value != null) { - this.attribs[name] = new XMLAttribute(this, name, value); - } - } - return this; + BaseReader.prototype._comment = function (parent, data) { + return parent.com(data); }; - - XMLElement.prototype.removeAttribute = function(name) { - var attName, j, len; - if (name == null) { - throw new Error("Missing attribute name. " + this.debugInfo()); - } - name = getValue(name); - if (Array.isArray(name)) { - for (j = 0, len = name.length; j < len; j++) { - attName = name[j]; - delete this.attribs[attName]; - } - } else { - delete this.attribs[name]; - } - return this; + BaseReader.prototype._text = function (parent, data) { + return parent.txt(data); }; - - XMLElement.prototype.toString = function(options) { - return this.options.writer.element(this, this.options.writer.filterOptions(options)); + BaseReader.prototype._instruction = function (parent, target, data) { + return parent.ins(target, data); }; - - XMLElement.prototype.att = function(name, value) { - return this.attribute(name, value); + BaseReader.prototype._cdata = function (parent, data) { + return parent.dat(data); }; - - XMLElement.prototype.a = function(name, value) { - return this.attribute(name, value); - }; - - XMLElement.prototype.getAttribute = function(name) { - if (this.attribs.hasOwnProperty(name)) { - return this.attribs[name].value; - } else { - return null; - } + BaseReader.prototype._element = function (parent, namespace, name) { + return (namespace === undefined ? parent.ele(name) : parent.ele(namespace, name)); }; - - XMLElement.prototype.setAttribute = function(name, value) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + BaseReader.prototype._attribute = function (parent, namespace, name, value) { + return (namespace === undefined ? parent.att(name, value) : parent.att(namespace, name, value)); }; - - XMLElement.prototype.getAttributeNode = function(name) { - if (this.attribs.hasOwnProperty(name)) { - return this.attribs[name]; - } else { - return null; - } + /** + * 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); }; - - XMLElement.prototype.setAttributeNode = function(newAttr) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * 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); }; - - XMLElement.prototype.removeAttributeNode = function(oldAttr) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * 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); }; - - XMLElement.prototype.getElementsByTagName = function(name) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * 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); }; - - XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * 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); }; - - XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * 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); }; - - XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * 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); }; - - XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** + * 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 - XMLElement.prototype.setAttributeNodeNS = function(newAttr) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +/***/ }), - XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +/***/ 3518: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLElement.prototype.hasAttribute = function(name) { - return this.attribs.hasOwnProperty(name); - }; +"use strict"; - XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); +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); }; - - XMLElement.prototype.setIdAttribute = function(name, isId) { - if (this.attribs.hasOwnProperty(name)) { - return this.attribs[name].isId; - } else { - return isId; - } + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ObjectReader_1 = __nccwpck_require__(768); +var BaseReader_1 = __nccwpck_require__(3396); +/** + * Parses XML nodes from a JSON string. + */ +var JSONReader = /** @class */ (function (_super) { + __extends(JSONReader, _super); + function JSONReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param str - JSON string to parse + */ + JSONReader.prototype._parse = function (node, str) { + return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, JSON.parse(str)); }; + return JSONReader; +}(BaseReader_1.BaseReader)); +exports.JSONReader = JSONReader; +//# sourceMappingURL=JSONReader.js.map - XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +/***/ }), - XMLElement.prototype.getElementsByTagName = function(tagname) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +/***/ 768: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; +"use strict"; - XMLElement.prototype.getElementsByClassName = function(classNames) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); +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); }; - - XMLElement.prototype.isEqualNode = function(node) { - var i, j, ref1; - if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { - return false; - } - if (node.namespaceURI !== this.namespaceURI) { - return false; - } - if (node.prefix !== this.prefix) { - return false; - } - if (node.localName !== this.localName) { - return false; - } - if (node.attribs.length !== this.attribs.length) { - return false; - } - for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) { - if (!this.attribs[i].isEqualNode(node.attribs[i])) { - return false; - } - } - return true; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - return XMLElement; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 4361: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLNamedNodeMap; - - module.exports = XMLNamedNodeMap = (function() { - function XMLNamedNodeMap(nodes) { - this.nodes = nodes; - } - - Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { - get: function() { - return Object.keys(this.nodes).length || 0; - } - }); - - XMLNamedNodeMap.prototype.clone = function() { - return this.nodes = null; - }; - - XMLNamedNodeMap.prototype.getNamedItem = function(name) { - return this.nodes[name]; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var BaseReader_1 = __nccwpck_require__(3396); +var dom_1 = __nccwpck_require__(770); +/** + * Parses XML nodes from objects and arrays. + * ES6 maps and sets are also supoorted. + */ +var ObjectReader = /** @class */ (function (_super) { + __extends(ObjectReader, _super); + function ObjectReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param obj - object to parse + */ + ObjectReader.prototype._parse = function (node, obj) { + var _this = this; + var options = this._builderOptions; + // sanitizes input characters + var invalidCharReplacement = options.invalidCharReplacement; + var s = function (str) { + return dom_1.sanitizeInput(str, invalidCharReplacement); + }; + var lastChild = null; + if (util_1.isFunction(obj)) { + // evaluate if function + lastChild = this.parse(node, obj.apply(this)); + } + else if (util_1.isArray(obj) || util_1.isSet(obj)) { + util_1.forEachArray(obj, function (item) { return lastChild = _this.parse(node, item); }, this); + } + else /* if (isMap(obj) || isObject(obj)) */ { + // expand if object + util_1.forEachObject(obj, function (key, val) { + if (util_1.isFunction(val)) { + // evaluate if function + val = val.apply(_this); + } + if (!options.ignoreConverters && key.indexOf(options.convert.att) === 0) { + // assign attributes + if (key === options.convert.att) { + if (util_1.isArray(val) || util_1.isSet(val)) { + throw new Error("Invalid attribute: " + val.toString() + ". " + node._debugInfo()); + } + else /* if (isMap(val) || isObject(val)) */ { + util_1.forEachObject(val, function (attrKey, attrVal) { + lastChild = _this.attribute(node, undefined, s(attrKey), s(attrVal)) || lastChild; + }); + } + } + else { + lastChild = _this.attribute(node, undefined, s(key.substr(options.convert.att.length)), s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.text) === 0) { + // text node + if (util_1.isMap(val) || util_1.isObject(val)) { + // if the key is #text expand child nodes under this node to support mixed content + lastChild = _this.parse(node, val); + } + else { + lastChild = _this.text(node, s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.cdata) === 0) { + // cdata node + if (util_1.isArray(val) || util_1.isSet(val)) { + util_1.forEachArray(val, function (item) { return lastChild = _this.cdata(node, s(item)) || lastChild; }, _this); + } + else { + lastChild = _this.cdata(node, s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.comment) === 0) { + // comment node + if (util_1.isArray(val) || util_1.isSet(val)) { + util_1.forEachArray(val, function (item) { return lastChild = _this.comment(node, s(item)) || lastChild; }, _this); + } + else { + lastChild = _this.comment(node, s(val)) || lastChild; + } + } + else if (!options.ignoreConverters && key.indexOf(options.convert.ins) === 0) { + // processing instruction + if (util_1.isString(val)) { + var insIndex = val.indexOf(' '); + var insTarget = (insIndex === -1 ? val : val.substr(0, insIndex)); + var insValue = (insIndex === -1 ? '' : val.substr(insIndex + 1)); + lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; + } + else if (util_1.isArray(val) || util_1.isSet(val)) { + util_1.forEachArray(val, function (item) { + var insIndex = item.indexOf(' '); + var insTarget = (insIndex === -1 ? item : item.substr(0, insIndex)); + var insValue = (insIndex === -1 ? '' : item.substr(insIndex + 1)); + lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; + }, _this); + } + else /* if (isMap(target) || isObject(target)) */ { + util_1.forEachObject(val, function (insTarget, insValue) { return lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; }, _this); + } + } + else if ((util_1.isArray(val) || util_1.isSet(val)) && util_1.isEmpty(val)) { + // skip empty arrays + } + else if ((util_1.isMap(val) || util_1.isObject(val)) && util_1.isEmpty(val)) { + // empty objects produce one node + lastChild = _this.element(node, undefined, s(key)) || lastChild; + } + else if (!options.keepNullNodes && (val == null)) { + // skip null and undefined nodes + } + else if (util_1.isArray(val) || util_1.isSet(val)) { + // expand list by creating child nodes + util_1.forEachArray(val, function (item) { + var childNode = {}; + childNode[key] = item; + lastChild = _this.parse(node, childNode); + }, _this); + } + else if (util_1.isMap(val) || util_1.isObject(val)) { + // create a parent node + var parent = _this.element(node, undefined, key); + if (parent) { + lastChild = parent; + // expand child nodes under parent + _this.parse(parent, val); + } + } + else if (val != null && val !== '') { + // leaf element node with a single text node + var parent = _this.element(node, undefined, key); + if (parent) { + lastChild = parent; + _this.text(parent, s(val)); + } + } + else { + // leaf element node + lastChild = _this.element(node, undefined, s(key)) || lastChild; + } + }, this); + } + return lastChild || node; }; + return ObjectReader; +}(BaseReader_1.BaseReader)); +exports.ObjectReader = ObjectReader; +//# sourceMappingURL=ObjectReader.js.map - XMLNamedNodeMap.prototype.setNamedItem = function(node) { - var oldNode; - oldNode = this.nodes[node.nodeName]; - this.nodes[node.nodeName] = node; - return oldNode || null; - }; +/***/ }), - XMLNamedNodeMap.prototype.removeNamedItem = function(name) { - var oldNode; - oldNode = this.nodes[name]; - delete this.nodes[name]; - return oldNode || null; - }; +/***/ 5044: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLNamedNodeMap.prototype.item = function(index) { - return this.nodes[Object.keys(this.nodes)[index]] || null; - }; +"use strict"; - XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented."); +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); }; - - XMLNamedNodeMap.prototype.setNamedItemNS = function(node) { - throw new Error("This DOM method is not implemented."); + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - - XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) { - throw new Error("This DOM method is not implemented."); +})(); +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 XMLStringLexer_1 = __nccwpck_require__(7061); +var interfaces_1 = __nccwpck_require__(7707); +var infra_1 = __nccwpck_require__(4251); +var algorithm_1 = __nccwpck_require__(61); +var dom_1 = __nccwpck_require__(770); +var BaseReader_1 = __nccwpck_require__(3396); +/** + * Parses XML nodes from an XML document string. + */ +var XMLReader = /** @class */ (function (_super) { + __extends(XMLReader, _super); + function XMLReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param str - XML document string to parse + */ + XMLReader.prototype._parse = function (node, str) { + var e_1, _a, e_2, _b; + var lexer = new XMLStringLexer_1.XMLStringLexer(str, { skipWhitespaceOnlyText: true }); + // sanitizes input characters + var invalidCharReplacement = this._builderOptions.invalidCharReplacement; + var s = function (str) { + return dom_1.sanitizeInput(str, invalidCharReplacement); + }; + var context = node; + var token = lexer.nextToken(); + while (token.type !== interfaces_1.TokenType.EOF) { + switch (token.type) { + case interfaces_1.TokenType.Declaration: + var declaration = token; + var version = s(declaration.version); + if (version !== "1.0") { + throw new Error("Invalid xml version: " + version); + } + var builderOptions = { + version: version + }; + if (declaration.encoding) { + builderOptions.encoding = s(declaration.encoding); + } + if (declaration.standalone) { + builderOptions.standalone = (s(declaration.standalone) === "yes"); + } + context.set(builderOptions); + break; + case interfaces_1.TokenType.DocType: + var doctype = token; + context = this.docType(context, s(doctype.name), s(doctype.pubId), s(doctype.sysId)) || context; + break; + case interfaces_1.TokenType.CDATA: + var cdata = token; + context = this.cdata(context, s(cdata.data)) || context; + break; + case interfaces_1.TokenType.Comment: + var comment = token; + context = this.comment(context, s(comment.data)) || context; + break; + case interfaces_1.TokenType.PI: + var pi = token; + context = this.instruction(context, s(pi.target), s(pi.data)) || context; + break; + case interfaces_1.TokenType.Text: + var text = token; + context = this.text(context, s(text.data)) || context; + break; + case interfaces_1.TokenType.Element: + var element = token; + var elementName = s(element.name); + // inherit namespace from parent + var _c = __read(algorithm_1.namespace_extractQName(elementName), 1), prefix = _c[0]; + var namespace = context.node.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]; + attName = s(attName); + attValue = s(attValue); + 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 ? + this.element(context, namespace, elementName) : + this.element(context, undefined, elementName)); + if (elementNode === undefined) + break; + try { + // assign attributes + 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]; + attName = s(attName); + attValue = s(attValue); + 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.node.lookupNamespaceURI(attPrefix); + if (attNamespace !== null && elementNode.node.isDefaultNamespace(attNamespace)) { + attNamespace = null; + } + else if (attNamespace === null && attPrefix !== null) { + attNamespace = nsDeclarations[attPrefix] || null; + } + } + if (attNamespace !== null) + this.attribute(elementNode, attNamespace, attName, attValue); + else + this.attribute(elementNode, undefined, 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: + /* istanbul ignore else */ + if (context.node.parentNode) { + context = context.up(); + } + break; + } + token = lexer.nextToken(); + } + return context; + }; + return XMLReader; +}(BaseReader_1.BaseReader)); +exports.XMLReader = XMLReader; +//# sourceMappingURL=XMLReader.js.map - return XMLNamedNodeMap; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 7608: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1, - hasProp = {}.hasOwnProperty; - - ref1 = __nccwpck_require__(8229), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue; - - XMLElement = null; - - XMLCData = null; - - XMLComment = null; - - XMLDeclaration = null; - - XMLDocType = null; - - XMLRaw = null; - - XMLText = null; - - XMLProcessingInstruction = null; +/***/ }), - XMLDummy = null; +/***/ 2475: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - NodeType = null; +"use strict"; - XMLNodeList = null; +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 ObjectReader_1 = __nccwpck_require__(768); +var BaseReader_1 = __nccwpck_require__(3396); +var js_yaml_1 = __nccwpck_require__(1917); +/** + * Parses XML nodes from a YAML string. + */ +var YAMLReader = /** @class */ (function (_super) { + __extends(YAMLReader, _super); + function YAMLReader() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * Parses the given document representation. + * + * @param node - node receive parsed XML nodes + * @param str - YAML string to parse + */ + YAMLReader.prototype._parse = function (node, str) { + var result = js_yaml_1.safeLoad(str); + /* istanbul ignore next */ + if (result === undefined) { + throw new Error("Unable to parse YAML document."); + } + return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, result); + }; + return YAMLReader; +}(BaseReader_1.BaseReader)); +exports.YAMLReader = YAMLReader; +//# sourceMappingURL=YAMLReader.js.map - XMLNamedNodeMap = null; +/***/ }), - DocumentPosition = null; +/***/ 560: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - module.exports = XMLNode = (function() { - function XMLNode(parent1) { - this.parent = parent1; - if (this.parent) { - this.options = this.parent.options; - this.stringify = this.parent.stringify; - } - this.value = null; - this.children = []; - this.baseURI = null; - if (!XMLElement) { - XMLElement = __nccwpck_require__(9437); - XMLCData = __nccwpck_require__(333); - XMLComment = __nccwpck_require__(4407); - XMLDeclaration = __nccwpck_require__(6364); - XMLDocType = __nccwpck_require__(1801); - XMLRaw = __nccwpck_require__(6329); - XMLText = __nccwpck_require__(1318); - XMLProcessingInstruction = __nccwpck_require__(6939); - XMLDummy = __nccwpck_require__(3590); - NodeType = __nccwpck_require__(9267); - XMLNodeList = __nccwpck_require__(6768); - XMLNamedNodeMap = __nccwpck_require__(4361); - DocumentPosition = __nccwpck_require__(2839); - } - } +"use strict"; - Object.defineProperty(XMLNode.prototype, 'nodeName', { - get: function() { - return this.name; - } - }); - - Object.defineProperty(XMLNode.prototype, 'nodeType', { - get: function() { - return this.type; - } - }); - - Object.defineProperty(XMLNode.prototype, 'nodeValue', { - get: function() { - return this.value; - } - }); - - Object.defineProperty(XMLNode.prototype, 'parentNode', { - get: function() { - return this.parent; - } - }); - - Object.defineProperty(XMLNode.prototype, 'childNodes', { - get: function() { - if (!this.childNodeList || !this.childNodeList.nodes) { - this.childNodeList = new XMLNodeList(this.children); - } - return this.childNodeList; - } - }); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var XMLReader_1 = __nccwpck_require__(5044); +exports.XMLReader = XMLReader_1.XMLReader; +var ObjectReader_1 = __nccwpck_require__(768); +exports.ObjectReader = ObjectReader_1.ObjectReader; +var JSONReader_1 = __nccwpck_require__(3518); +exports.JSONReader = JSONReader_1.JSONReader; +var YAMLReader_1 = __nccwpck_require__(2475); +exports.YAMLReader = YAMLReader_1.YAMLReader; +//# sourceMappingURL=index.js.map - Object.defineProperty(XMLNode.prototype, 'firstChild', { - get: function() { - return this.children[0] || null; - } - }); +/***/ }), - Object.defineProperty(XMLNode.prototype, 'lastChild', { - get: function() { - return this.children[this.children.length - 1] || null; - } - }); +/***/ 708: +/***/ ((__unused_webpack_module, exports) => { - Object.defineProperty(XMLNode.prototype, 'previousSibling', { - get: function() { - var i; - i = this.parent.children.indexOf(this); - return this.parent.children[i - 1] || null; - } - }); +"use strict"; - Object.defineProperty(XMLNode.prototype, 'nextSibling', { - get: function() { - var i; - i = this.parent.children.indexOf(this); - return this.parent.children[i + 1] || null; - } - }); +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 - Object.defineProperty(XMLNode.prototype, 'ownerDocument', { - get: function() { - return this.document() || null; - } - }); +/***/ }), - Object.defineProperty(XMLNode.prototype, 'textContent', { - get: function() { - var child, j, len, ref2, str; - if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) { - str = ''; - ref2 = this.children; - for (j = 0, len = ref2.length; j < len; j++) { - child = ref2[j]; - if (child.textContent) { - str += child.textContent; - } - } - return str; - } else { - return null; - } - }, - set: function(value) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); +/***/ 7644: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLNode.prototype.setParent = function(parent) { - var child, j, len, ref2, results; - this.parent = parent; - if (parent) { - this.options = parent.options; - this.stringify = parent.stringify; - } - ref2 = this.children; - results = []; - for (j = 0, len = ref2.length; j < len; j++) { - child = ref2[j]; - results.push(child.setParent(this)); - } - return results; - }; +"use strict"; - XMLNode.prototype.element = function(name, attributes, text) { - var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val; - lastChild = null; - if (attributes === null && (text == null)) { - ref2 = [{}, null], attributes = ref2[0], text = ref2[1]; - } - if (attributes == null) { - attributes = {}; - } - attributes = getValue(attributes); - if (!isObject(attributes)) { - ref3 = [attributes, text], text = ref3[0], attributes = ref3[1]; - } - if (name != null) { - name = getValue(name); - } - if (Array.isArray(name)) { - for (j = 0, len = name.length; j < len; j++) { - item = name[j]; - lastChild = this.element(item); - } - } else if (isFunction(name)) { - lastChild = this.element(name.apply()); - } else if (isObject(name)) { - for (key in name) { - if (!hasProp.call(name, key)) continue; - val = name[key]; - if (isFunction(val)) { - val = val.apply(); - } - if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) { - lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val); - } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) { - lastChild = this.dummy(); - } else if (isObject(val) && isEmpty(val)) { - lastChild = this.element(key); - } else if (!this.options.keepNullNodes && (val == null)) { - lastChild = this.dummy(); - } else if (!this.options.separateArrayItems && Array.isArray(val)) { - for (k = 0, len1 = val.length; k < len1; k++) { - item = val[k]; - childNode = {}; - childNode[key] = item; - lastChild = this.element(childNode); - } - } else if (isObject(val)) { - if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) { - lastChild = this.element(val); - } else { - lastChild = this.element(key); - lastChild.element(val); - } - } else { - lastChild = this.element(key, val); - } - } - } else if (!this.options.keepNullNodes && text === null) { - lastChild = this.dummy(); - } else { - if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) { - lastChild = this.text(text); - } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) { - lastChild = this.cdata(text); - } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) { - lastChild = this.comment(text); - } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) { - lastChild = this.raw(text); - } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) { - lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text); - } else { - lastChild = this.node(name, attributes, text); +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 }; } - } - if (lastChild == null) { - throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo()); - } - return lastChild; }; - - XMLNode.prototype.insertBefore = function(name, attributes, text) { - var child, i, newChild, refChild, removed; - if (name != null ? name.type : void 0) { - newChild = name; - refChild = attributes; - newChild.setParent(this); - if (refChild) { - i = children.indexOf(refChild); - removed = children.splice(i); - children.push(newChild); - Array.prototype.push.apply(children, removed); - } else { - children.push(newChild); - } - return newChild; - } else { - if (this.isRoot) { - throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); + 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); } - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i); - child = this.parent.element(name, attributes, text); - Array.prototype.push.apply(this.parent.children, removed); - return child; - } - }; - - XMLNode.prototype.insertAfter = function(name, attributes, text) { - var child, i, removed; - if (this.isRoot) { - throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); - } - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i + 1); - child = this.parent.element(name, attributes, text); - Array.prototype.push.apply(this.parent.children, removed); - return child; - }; - - XMLNode.prototype.remove = function() { - var i, ref2; - if (this.isRoot) { - throw new Error("Cannot remove the root element. " + this.debugInfo()); - } - i = this.parent.children.indexOf(this); - [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2; - return this.parent; - }; - - XMLNode.prototype.node = function(name, attributes, text) { - var child, ref2; - if (name != null) { - name = getValue(name); - } - attributes || (attributes = {}); - attributes = getValue(attributes); - if (!isObject(attributes)) { - ref2 = [attributes, text], text = ref2[0], attributes = ref2[1]; - } - child = new XMLElement(this, name, attributes); - if (text != null) { - child.text(text); - } - this.children.push(child); - return child; - }; - - XMLNode.prototype.text = function(value) { - var child; - if (isObject(value)) { - this.element(value); - } - child = new XMLText(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.cdata = function(value) { - var child; - child = new XMLCData(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.comment = function(value) { - var child; - child = new XMLComment(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.commentBefore = function(value) { - var child, i, removed; - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i); - child = this.parent.comment(value); - Array.prototype.push.apply(this.parent.children, removed); - return this; - }; - - XMLNode.prototype.commentAfter = function(value) { - var child, i, removed; - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i + 1); - child = this.parent.comment(value); - Array.prototype.push.apply(this.parent.children, removed); - return this; - }; - - XMLNode.prototype.raw = function(value) { - var child; - child = new XMLRaw(this, value); - this.children.push(child); - return this; - }; - - XMLNode.prototype.dummy = function() { - var child; - child = new XMLDummy(this); - return child; - }; - - XMLNode.prototype.instruction = function(target, value) { - var insTarget, insValue, instruction, j, len; - if (target != null) { - target = getValue(target); - } - if (value != null) { - value = getValue(value); - } - if (Array.isArray(target)) { - for (j = 0, len = target.length; j < len; j++) { - insTarget = target[j]; - this.instruction(insTarget); - } - } else if (isObject(target)) { - for (insTarget in target) { - if (!hasProp.call(target, insTarget)) continue; - insValue = target[insTarget]; - this.instruction(insTarget, insValue); + 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 interfaces_1 = __nccwpck_require__(7305); +var LocalNameSet_1 = __nccwpck_require__(9049); +var NamespacePrefixMap_1 = __nccwpck_require__(283); +var infra_1 = __nccwpck_require__(4251); +var algorithm_1 = __nccwpck_require__(61); +/** + * Pre-serializes XML nodes. + */ +var BaseWriter = /** @class */ (function () { + /** + * Initializes a new instance of `BaseWriter`. + * + * @param builderOptions - XML builder options + */ + function BaseWriter(builderOptions) { + /** + * Gets the current depth of the XML tree. + */ + this.level = 0; + this._builderOptions = builderOptions; + } + /** + * 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]); + } } - } else { - if (isFunction(value)) { - value = value.apply(); + 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; } } - instruction = new XMLProcessingInstruction(this, target, value); - this.children.push(instruction); - } - return this; - }; - - XMLNode.prototype.instructionBefore = function(target, value) { - var child, i, removed; - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i); - child = this.parent.instruction(target, value); - Array.prototype.push.apply(this.parent.children, removed); - return this; - }; - - XMLNode.prototype.instructionAfter = function(target, value) { - var child, i, removed; - i = this.parent.children.indexOf(this); - removed = this.parent.children.splice(i + 1); - child = this.parent.instruction(target, value); - Array.prototype.push.apply(this.parent.children, removed); - return this; }; - - XMLNode.prototype.declaration = function(version, encoding, standalone) { - var doc, xmldec; - doc = this.document(); - xmldec = new XMLDeclaration(doc, version, encoding, standalone); - if (doc.children.length === 0) { - doc.children.unshift(xmldec); - } else if (doc.children[0].type === NodeType.Declaration) { - doc.children[0] = xmldec; - } else { - doc.children.unshift(xmldec); - } - return doc.root() || doc; - }; - - XMLNode.prototype.dtd = function(pubID, sysID) { - var child, doc, doctype, i, j, k, len, len1, ref2, ref3; - doc = this.document(); - doctype = new XMLDocType(doc, pubID, sysID); - ref2 = doc.children; - for (i = j = 0, len = ref2.length; j < len; i = ++j) { - child = ref2[i]; - if (child.type === NodeType.DocType) { - doc.children[i] = doctype; - return doctype; + /** + * 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); } - } - ref3 = doc.children; - for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) { - child = ref3[i]; - if (child.isRoot) { - doc.children.splice(i, 0, doctype); - return doctype; + else { + this._serializeNode(node, requireWellFormed, noDoubleEncoding); } - } - doc.children.push(doctype); - return doctype; - }; - - XMLNode.prototype.up = function() { - if (this.isRoot) { - throw new Error("The root node has no parent. Use doc() if you need to get the document object."); - } - return this.parent; }; - - XMLNode.prototype.root = function() { - var node; - node = this; - while (node) { - if (node.type === NodeType.Document) { - return node.rootObject; - } else if (node.isRoot) { - return node; - } else { - node = node.parent; + /** + * 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); } - } }; - - XMLNode.prototype.document = function() { - var node; - node = this; - while (node) { - if (node.type === NodeType.Document) { - return node; - } else { - node = node.parent; + /** + * 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); } - } - }; - - XMLNode.prototype.end = function(options) { - return this.document().end(options); - }; - - XMLNode.prototype.prev = function() { - var i; - i = this.parent.children.indexOf(this); - if (i < 1) { - throw new Error("Already at the first node. " + this.debugInfo()); - } - return this.parent.children[i - 1]; - }; - - XMLNode.prototype.next = function() { - var i; - i = this.parent.children.indexOf(this); - if (i === -1 || i === this.parent.children.length - 1) { - throw new Error("Already at the last node. " + this.debugInfo()); - } - return this.parent.children[i + 1]; - }; - - XMLNode.prototype.importDocument = function(doc) { - var clonedRoot; - clonedRoot = doc.root().clone(); - clonedRoot.parent = this; - clonedRoot.isRoot = false; - this.children.push(clonedRoot); - return this; - }; - - XMLNode.prototype.debugInfo = function(name) { - var ref2, ref3; - name = name || this.name; - if ((name == null) && !((ref2 = this.parent) != null ? ref2.name : void 0)) { - return ""; - } else if (name == null) { - return "parent: <" + this.parent.name + ">"; - } else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) { - return "node: <" + name + ">"; - } else { - return "node: <" + name + ">, parent: <" + this.parent.name + ">"; - } - }; - - XMLNode.prototype.ele = function(name, attributes, text) { - return this.element(name, attributes, text); - }; - - XMLNode.prototype.nod = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLNode.prototype.txt = function(value) { - return this.text(value); - }; - - XMLNode.prototype.dat = function(value) { - return this.cdata(value); }; - - XMLNode.prototype.com = function(value) { - return this.comment(value); - }; - - XMLNode.prototype.ins = function(target, value) { - return this.instruction(target, value); - }; - - XMLNode.prototype.doc = function() { - return this.document(); - }; - - XMLNode.prototype.dec = function(version, encoding, standalone) { - return this.declaration(version, encoding, standalone); - }; - - XMLNode.prototype.e = function(name, attributes, text) { - return this.element(name, attributes, text); - }; - - XMLNode.prototype.n = function(name, attributes, text) { - return this.node(name, attributes, text); - }; - - XMLNode.prototype.t = function(value) { - return this.text(value); - }; - - XMLNode.prototype.d = function(value) { - return this.cdata(value); - }; - - XMLNode.prototype.c = function(value) { - return this.comment(value); - }; - - XMLNode.prototype.r = function(value) { - return this.raw(value); - }; - - XMLNode.prototype.i = function(target, value) { - return this.instruction(target, value); - }; - - XMLNode.prototype.u = function() { - return this.up(); - }; - - XMLNode.prototype.importXMLBuilder = function(doc) { - return this.importDocument(doc); - }; - - XMLNode.prototype.replaceChild = function(newChild, oldChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.removeChild = function(oldChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.appendChild = function(newChild) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.hasChildNodes = function() { - return this.children.length !== 0; - }; - - XMLNode.prototype.cloneNode = function(deep) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.normalize = function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.isSupported = function(feature, version) { - return true; - }; - - XMLNode.prototype.hasAttributes = function() { - return this.attribs.length !== 0; - }; - - XMLNode.prototype.compareDocumentPosition = function(other) { - var ref, res; - ref = this; - if (ref === other) { - return 0; - } else if (this.document() !== other.document()) { - res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific; - if (Math.random() < 0.5) { - res |= DocumentPosition.Preceding; - } else { - res |= DocumentPosition.Following; - } - return res; - } else if (ref.isAncestor(other)) { - return DocumentPosition.Contains | DocumentPosition.Preceding; - } else if (ref.isDescendant(other)) { - return DocumentPosition.Contains | DocumentPosition.Following; - } else if (ref.isPreceding(other)) { - return DocumentPosition.Preceding; - } else { - return DocumentPosition.Following; - } - }; - - XMLNode.prototype.isSameNode = function(other) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.lookupPrefix = function(namespaceURI) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.isDefaultNamespace = function(namespaceURI) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.lookupNamespaceURI = function(prefix) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.isEqualNode = function(node) { - var i, j, ref2; - if (node.nodeType !== this.nodeType) { - return false; - } - if (node.children.length !== this.children.length) { - return false; - } - for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) { - if (!this.children[i].isEqualNode(node.children[i])) { - return false; - } - } - return true; - }; - - XMLNode.prototype.getFeature = function(feature, version) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.setUserData = function(key, data, handler) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.getUserData = function(key) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - }; - - XMLNode.prototype.contains = function(other) { - if (!other) { - return false; - } - return other === this || this.isDescendant(other); - }; - - XMLNode.prototype.isDescendant = function(node) { - var child, isDescendantChild, j, len, ref2; - ref2 = this.children; - for (j = 0, len = ref2.length; j < len; j++) { - child = ref2[j]; - if (node === child) { - return true; + /** + * 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 + */ + 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)."); } - isDescendantChild = child.isDescendant(node); - if (isDescendantChild) { - return true; + /** + * 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) { + /** + * 11.1. If local default namespace is not null, then set ignore + * namespace definition attribute to true. + */ + if (localDefaultNamespace !== null) { + ignoreNamespaceDefinitionAttribute = 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. + */ + 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); } - } - return false; - }; - - XMLNode.prototype.isAncestor = function(node) { - return node.isDescendant(this); - }; - - XMLNode.prototype.isPreceding = function(node) { - var nodePos, thisPos; - nodePos = this.treePosition(node); - thisPos = this.treePosition(this); - if (nodePos === -1 || thisPos === -1) { - return false; - } else { - return nodePos < thisPos; - } - }; - - XMLNode.prototype.isFollowing = function(node) { - var nodePos, thisPos; - nodePos = this.treePosition(node); - thisPos = this.treePosition(this); - if (nodePos === -1 || thisPos === -1) { - return false; - } else { - return nodePos > thisPos; - } - }; - - XMLNode.prototype.treePosition = function(node) { - var found, pos; - pos = 0; - found = false; - this.foreachTreeNode(this.document(), function(childNode) { - pos++; - if (!found && childNode === node) { - return found = true; - } - }); - if (found) { - return pos; - } else { - return -1; - } - }; - - XMLNode.prototype.foreachTreeNode = function(node, func) { - var child, j, len, ref2, res; - node || (node = this.document()); - ref2 = node.children; - for (j = 0, len = ref2.length; j < len; j++) { - child = ref2[j]; - if (res = func(child)) { - return res; - } else { - res = this.foreachTreeNode(child, func); - if (res) { - return res; - } + 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)."); + } + /** + * 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; + /** + * 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); + } } - } - }; - - return XMLNode; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 6768: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLNodeList; - - module.exports = XMLNodeList = (function() { - function XMLNodeList(nodes) { - this.nodes = nodes; - } - - Object.defineProperty(XMLNodeList.prototype, 'length', { - get: function() { - return this.nodes.length || 0; - } - }); - - XMLNodeList.prototype.clone = function() { - return this.nodes = null; + /** + * 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_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.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); }; - - XMLNodeList.prototype.item = function(index) { - return this.nodes[index] || null; + /** + * 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; + } + 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--; + } + } + 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; } + } + /** + * 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); }; - - return XMLNodeList; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 6939: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLCharacterData, XMLProcessingInstruction, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - NodeType = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); - - module.exports = XMLProcessingInstruction = (function(superClass) { - extend(XMLProcessingInstruction, superClass); - - function XMLProcessingInstruction(parent, target, value) { - XMLProcessingInstruction.__super__.constructor.call(this, parent); - if (target == null) { - throw new Error("Missing instruction target. " + this.debugInfo()); - } - this.type = NodeType.ProcessingInstruction; - this.target = this.stringify.insTarget(target); - this.name = this.target; - if (value) { - this.value = this.stringify.insValue(value); - } - } - - XMLProcessingInstruction.prototype.clone = function() { - return Object.create(this); - }; - - XMLProcessingInstruction.prototype.toString = function(options) { - return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(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; + /** + * 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)."); + } + 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; } + } }; - - XMLProcessingInstruction.prototype.isEqualNode = function(node) { - if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { - return false; - } - if (node.target !== this.target) { - return false; - } - return true; + /** + * 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)."); + } + 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; } + } }; - - return XMLProcessingInstruction; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 6329: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLNode, XMLRaw, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - NodeType = __nccwpck_require__(9267); - - XMLNode = __nccwpck_require__(7608); - - module.exports = XMLRaw = (function(superClass) { - extend(XMLRaw, superClass); - - function XMLRaw(parent, text) { - XMLRaw.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing raw text. " + this.debugInfo()); - } - this.type = NodeType.Raw; - this.value = this.stringify.raw(text); - } - - XMLRaw.prototype.clone = function() { - return Object.create(this); + /** + * 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) { + /** + * 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)."); + } + /** + * Otherwise, return the concatenation of "". + */ + this.comment(node.data); }; - - XMLRaw.prototype.toString = function(options) { - return this.options.writer.raw(this, this.options.writer.filterOptions(options)); + /** + * 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 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 (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); }; - - return XMLRaw; - - })(XMLNode); - -}).call(this); - - -/***/ }), - -/***/ 8601: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, WriterState, XMLStreamWriter, XMLWriterBase, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - NodeType = __nccwpck_require__(9267); - - XMLWriterBase = __nccwpck_require__(6752); - - WriterState = __nccwpck_require__(9766); - - module.exports = XMLStreamWriter = (function(superClass) { - extend(XMLStreamWriter, superClass); - - function XMLStreamWriter(stream, options) { - this.stream = stream; - XMLStreamWriter.__super__.constructor.call(this, options); - } - - XMLStreamWriter.prototype.endline = function(node, options, level) { - if (node.isLastRootNode && options.state === WriterState.CloseTag) { - return ''; - } else { - return XMLStreamWriter.__super__.endline.call(this, node, options, level); - } - }; - - XMLStreamWriter.prototype.document = function(doc, options) { - var child, i, j, k, len, len1, ref, ref1, results; - ref = doc.children; - for (i = j = 0, len = ref.length; j < len; i = ++j) { - child = ref[i]; - child.isLastRootNode = i === doc.children.length - 1; - } - options = this.filterOptions(options); - ref1 = doc.children; - results = []; - for (k = 0, len1 = ref1.length; k < len1; k++) { - child = ref1[k]; - results.push(this.writeChildNode(child, options, 0)); - } - return results; - }; - - XMLStreamWriter.prototype.attribute = function(att, options, level) { - return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level)); - }; - - XMLStreamWriter.prototype.cdata = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.comment = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.declaration = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level)); + /** + * 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; } + } }; - - XMLStreamWriter.prototype.docType = function(node, options, level) { - var child, j, len, ref; - level || (level = 0); - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - this.stream.write(this.indent(node, options, level)); - this.stream.write(' 0) { - this.stream.write(' ['); - this.stream.write(this.endline(node, options, level)); - options.state = WriterState.InsideTag; - ref = node.children; - for (j = 0, len = ref.length; j < len; j++) { - child = ref[j]; - this.writeChildNode(child, options, level + 1); + /** + * 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; } } - options.state = WriterState.CloseTag; - this.stream.write(']'); - } - options.state = WriterState.CloseTag; - this.stream.write(options.spaceBeforeSlash + '>'); - this.stream.write(this.endline(node, options, level)); - options.state = WriterState.None; - return this.closeNode(node, options, level); }; - - XMLStreamWriter.prototype.element = function(node, options, level) { - var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1; - level || (level = 0); - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - this.stream.write(this.indent(node, options, level) + '<' + node.name); - ref = node.attribs; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - att = ref[name]; - this.attribute(att, options, level); - } - childNodeCount = node.children.length; - firstChildNode = childNodeCount === 0 ? null : node.children[0]; - if (childNodeCount === 0 || node.children.every(function(e) { - return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === ''; - })) { - if (options.allowEmpty) { - this.stream.write('>'); - options.state = WriterState.CloseTag; - this.stream.write(''); - } else { - options.state = WriterState.CloseTag; - this.stream.write(options.spaceBeforeSlash + '/>'); + /** + * 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 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 (requireWellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { + throw new Error("DocType public identifier does not match PubidChar construct (well-formed required)."); } - } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) { - this.stream.write('>'); - options.state = WriterState.InsideTag; - options.suppressPrettyCount++; - prettySuppressed = true; - this.writeChildNode(firstChildNode, options, level + 1); - options.suppressPrettyCount--; - prettySuppressed = false; - options.state = WriterState.CloseTag; - this.stream.write(''); - } else { - this.stream.write('>' + this.endline(node, options, level)); - options.state = WriterState.InsideTag; - ref1 = node.children; - for (j = 0, len = ref1.length; j < len; j++) { - child = ref1[j]; - this.writeChildNode(child, options, level + 1); + /** + * 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 (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)."); } - options.state = WriterState.CloseTag; - this.stream.write(this.indent(node, options, level) + ''); - } - this.stream.write(this.endline(node, options, level)); - options.state = WriterState.None; - return this.closeNode(node, options, level); + /** + * 3. Let markup be an empty string. + * 4. Append the string "" (U+003E GREATER-THAN SIGN) to markup. + * 11. Return the value of markup. + */ + this.docType(node.name, node.publicId, node.systemId); }; - - XMLStreamWriter.prototype.processingInstruction = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.raw = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.text = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.dtdAttList = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.dtdElement = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.dtdEntity = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level)); - }; - - XMLStreamWriter.prototype.dtdNotation = function(node, options, level) { - return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level)); - }; - - return XMLStreamWriter; - - })(XMLWriterBase); - -}).call(this); - - -/***/ }), - -/***/ 5913: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLStringWriter, XMLWriterBase, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - XMLWriterBase = __nccwpck_require__(6752); - - module.exports = XMLStringWriter = (function(superClass) { - extend(XMLStringWriter, superClass); - - function XMLStringWriter(options) { - XMLStringWriter.__super__.constructor.call(this, options); - } - - XMLStringWriter.prototype.document = function(doc, options) { - var child, i, len, r, ref; - options = this.filterOptions(options); - r = ''; - ref = doc.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - r += this.writeChildNode(child, options, 0); - } - if (options.pretty && r.slice(-options.newline.length) === options.newline) { - r = r.slice(0, -options.newline.length); - } - return r; - }; - - return XMLStringWriter; - - })(XMLWriterBase); - -}).call(this); - - -/***/ }), - -/***/ 8594: -/***/ (function(module) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var XMLStringifier, - bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, - hasProp = {}.hasOwnProperty; - - module.exports = XMLStringifier = (function() { - function XMLStringifier(options) { - this.assertLegalName = bind(this.assertLegalName, this); - this.assertLegalChar = bind(this.assertLegalChar, this); - var key, ref, value; - options || (options = {}); - this.options = options; - if (!this.options.version) { - this.options.version = '1.0'; - } - ref = options.stringify || {}; - for (key in ref) { - if (!hasProp.call(ref, key)) continue; - value = ref[key]; - this[key] = value; - } - } - - XMLStringifier.prototype.name = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalName('' + val || ''); - }; - - XMLStringifier.prototype.text = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar(this.textEscape('' + val || '')); - }; - - XMLStringifier.prototype.cdata = function(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - val = val.replace(']]>', ']]]]>'); - return this.assertLegalChar(val); - }; - - XMLStringifier.prototype.comment = function(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - if (val.match(/--/)) { - throw new Error("Comment text cannot contain double-hypen: " + val); - } - return this.assertLegalChar(val); - }; - - XMLStringifier.prototype.raw = function(val) { - if (this.options.noValidation) { - return val; - } - return '' + val || ''; - }; - - XMLStringifier.prototype.attValue = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar(this.attEscape(val = '' + val || '')); - }; - - XMLStringifier.prototype.insTarget = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.insValue = function(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - if (val.match(/\?>/)) { - throw new Error("Invalid processing instruction value: " + val); - } - return this.assertLegalChar(val); - }; - - XMLStringifier.prototype.xmlVersion = function(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - if (!val.match(/1\.[0-9]+/)) { - throw new Error("Invalid version number: " + val); - } - return val; - }; - - XMLStringifier.prototype.xmlEncoding = function(val) { - if (this.options.noValidation) { - return val; - } - val = '' + val || ''; - if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) { - throw new Error("Invalid encoding: " + val); - } - return this.assertLegalChar(val); + /** + * 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 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 (requireWellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { + throw new Error("Processing instruction target contains invalid characters (well-formed required)."); + } + /** + * 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 (requireWellFormed && (!algorithm_1.xml_isLegalChar(node.data) || + node.data.indexOf("?>") !== -1)) { + throw new Error("Processing instruction data contains invalid characters (well-formed required)."); + } + /** + * 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. + */ + this.instruction(node.target, node.data); }; - - XMLStringifier.prototype.xmlStandalone = function(val) { - if (this.options.noValidation) { - return val; - } - if (val) { - return "yes"; - } else { - return "no"; - } + /** + * 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)."); + } + this.cdata(node.data); }; - - XMLStringifier.prototype.dtdPubID = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdSysID = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdElementValue = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdAttType = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdAttDefault = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.dtdEntityValue = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); + /** + * 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 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 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; } + } + /** + * 4. Return the value of result. + */ + return result; }; - - XMLStringifier.prototype.dtdNData = function(val) { - if (this.options.noValidation) { - return val; - } - return this.assertLegalChar('' + val || ''); - }; - - XMLStringifier.prototype.convertAttKey = '@'; - - XMLStringifier.prototype.convertPIKey = '?'; - - XMLStringifier.prototype.convertTextKey = '#text'; - - XMLStringifier.prototype.convertCDataKey = '#cdata'; - - XMLStringifier.prototype.convertCommentKey = '#comment'; - - XMLStringifier.prototype.convertRawKey = '#raw'; - - XMLStringifier.prototype.assertLegalChar = function(str) { - var regex, res; - if (this.options.noValidation) { - return str; - } - regex = ''; - if (this.options.version === '1.0') { - regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; - if (res = str.match(regex)) { - throw new Error("Invalid character in string: " + str + " at index " + res.index); + /** + * 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 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 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 if (this.options.version === '1.1') { - regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; - if (res = str.match(regex)) { - throw new Error("Invalid character in string: " + str + " at index " + res.index); + 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 str; + /** + * 4. Return the value of result. + */ + return result; }; - - XMLStringifier.prototype.assertLegalName = function(str) { - var regex; - if (this.options.noValidation) { - return str; - } - this.assertLegalChar(str); - regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_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])*$/; - if (!str.match(regex)) { - throw new Error("Invalid character in name"); - } - return str; + /** + * 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; + /** + * 1. Let default namespace attr value be null. + */ + var defaultNamespaceAttrValue = null; + try { + /** + * 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 || ''; + } + } + } + } + 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; }; - - XMLStringifier.prototype.textEscape = function(str) { - var ampregex; - if (this.options.noValidation) { - return str; - } - ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; - return str.replace(ampregex, '&').replace(//g, '>').replace(/\r/g, ' '); + /** + * 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; }; - - XMLStringifier.prototype.attEscape = function(str) { - var ampregex; - if (this.options.noValidation) { - return str; - } - ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; - return str.replace(ampregex, '&').replace(/" 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; + } + return result; + } }; - - return XMLStringifier; - - })(); - -}).call(this); - + 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 /***/ }), -/***/ 1318: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, XMLCharacterData, XMLText, - extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, - hasProp = {}.hasOwnProperty; - - NodeType = __nccwpck_require__(9267); - - XMLCharacterData = __nccwpck_require__(7709); +/***/ 7525: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - module.exports = XMLText = (function(superClass) { - extend(XMLText, superClass); +"use strict"; - function XMLText(parent, text) { - XMLText.__super__.constructor.call(this, parent); - if (text == null) { - throw new Error("Missing element text. " + this.debugInfo()); - } - this.name = "#text"; - this.type = NodeType.Text; - this.value = this.stringify.text(text); +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 = __nccwpck_require__(708); +/** + * Serializes XML nodes. + */ +var JSONCBWriter = /** @class */ (function (_super) { + __extends(JSONCBWriter, _super); + /** + * Initializes a new instance of `JSONCBWriter`. + * + * @param builderOptions - XML builder options + */ + function JSONCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._hasChildren = []; + _this._additionalLevel = 0; + return _this; } - - Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', { - get: function() { - throw new Error("This DOM method is not implemented." + this.debugInfo()); - } - }); - - Object.defineProperty(XMLText.prototype, 'wholeText', { - get: function() { - var next, prev, str; - str = ''; - prev = this.previousSibling; - while (prev) { - str = prev.data + str; - prev = prev.previousSibling; - } - str += this.data; - next = this.nextSibling; - while (next) { - str = str + next.data; - next = next.nextSibling; - } - return str; - } - }); - - XMLText.prototype.clone = function() { - return Object.create(this); + /** @inheritdoc */ + JSONCBWriter.prototype.frontMatter = function () { + return ""; }; - - XMLText.prototype.toString = function(options) { - return this.options.writer.text(this, this.options.writer.filterOptions(options)); + /** @inheritdoc */ + JSONCBWriter.prototype.declaration = function (version, encoding, standalone) { + return ""; }; - - XMLText.prototype.splitText = function(offset) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + JSONCBWriter.prototype.docType = function (name, publicId, systemId) { + return ""; }; - - XMLText.prototype.replaceWholeText = function(content) { - throw new Error("This DOM method is not implemented." + this.debugInfo()); + /** @inheritdoc */ + JSONCBWriter.prototype.comment = function (data) { + // { "!": "hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.comment) + this._sep() + + this._val(data) + this._sep() + "}"; }; - - return XMLText; - - })(XMLCharacterData); - -}).call(this); - - -/***/ }), - -/***/ 6752: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, WriterState, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLProcessingInstruction, XMLRaw, XMLText, XMLWriterBase, assign, - hasProp = {}.hasOwnProperty; - - assign = (__nccwpck_require__(8229).assign); - - NodeType = __nccwpck_require__(9267); - - XMLDeclaration = __nccwpck_require__(6364); - - XMLDocType = __nccwpck_require__(1801); - - XMLCData = __nccwpck_require__(333); - - XMLComment = __nccwpck_require__(4407); - - XMLElement = __nccwpck_require__(9437); - - XMLRaw = __nccwpck_require__(6329); - - XMLText = __nccwpck_require__(1318); - - XMLProcessingInstruction = __nccwpck_require__(6939); - - XMLDummy = __nccwpck_require__(3590); - - XMLDTDAttList = __nccwpck_require__(1015); - - XMLDTDElement = __nccwpck_require__(2421); - - XMLDTDEntity = __nccwpck_require__(53); - - XMLDTDNotation = __nccwpck_require__(2837); - - WriterState = __nccwpck_require__(9766); - - module.exports = XMLWriterBase = (function() { - function XMLWriterBase(options) { - var key, ref, value; - options || (options = {}); - this.options = options; - ref = options.writer || {}; - for (key in ref) { - if (!hasProp.call(ref, key)) continue; - value = ref[key]; - this["_" + key] = this[key]; - this[key] = value; - } - } - - XMLWriterBase.prototype.filterOptions = function(options) { - var filteredOptions, ref, ref1, ref2, ref3, ref4, ref5, ref6; - options || (options = {}); - options = assign({}, this.options, options); - filteredOptions = { - writer: this - }; - filteredOptions.pretty = options.pretty || false; - filteredOptions.allowEmpty = options.allowEmpty || false; - filteredOptions.indent = (ref = options.indent) != null ? ref : ' '; - filteredOptions.newline = (ref1 = options.newline) != null ? ref1 : '\n'; - filteredOptions.offset = (ref2 = options.offset) != null ? ref2 : 0; - filteredOptions.dontPrettyTextNodes = (ref3 = (ref4 = options.dontPrettyTextNodes) != null ? ref4 : options.dontprettytextnodes) != null ? ref3 : 0; - filteredOptions.spaceBeforeSlash = (ref5 = (ref6 = options.spaceBeforeSlash) != null ? ref6 : options.spacebeforeslash) != null ? ref5 : ''; - if (filteredOptions.spaceBeforeSlash === true) { - filteredOptions.spaceBeforeSlash = ' '; - } - filteredOptions.suppressPrettyCount = 0; - filteredOptions.user = {}; - filteredOptions.state = WriterState.None; - return filteredOptions; + /** @inheritdoc */ + JSONCBWriter.prototype.text = function (data) { + // { "#": "hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.text) + this._sep() + + this._val(data) + this._sep() + "}"; }; - - XMLWriterBase.prototype.indent = function(node, options, level) { - var indentLevel; - if (!options.pretty || options.suppressPrettyCount) { - return ''; - } else if (options.pretty) { - indentLevel = (level || 0) + options.offset + 1; - if (indentLevel > 0) { - return new Array(indentLevel).join(options.indent); - } - } - return ''; + /** @inheritdoc */ + JSONCBWriter.prototype.instruction = function (target, data) { + // { "?": "target hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.ins) + this._sep() + + this._val(data ? target + " " + data : target) + this._sep() + "}"; }; - - XMLWriterBase.prototype.endline = function(node, options, level) { - if (!options.pretty || options.suppressPrettyCount) { - return ''; - } else { - return options.newline; - } + /** @inheritdoc */ + JSONCBWriter.prototype.cdata = function (data) { + // { "$": "hello" } + return this._comma() + this._beginLine() + "{" + this._sep() + + this._key(this._builderOptions.convert.cdata) + this._sep() + + this._val(data) + this._sep() + "}"; }; - - XMLWriterBase.prototype.attribute = function(att, options, level) { - var r; - this.openAttribute(att, options, level); - r = ' ' + att.name + '="' + att.value + '"'; - this.closeAttribute(att, options, level); - return r; + /** @inheritdoc */ + JSONCBWriter.prototype.attribute = function (name, value) { + // { "@name": "val" } + return this._comma() + this._beginLine(1) + "{" + this._sep() + + this._key(this._builderOptions.convert.att + name) + this._sep() + + this._val(value) + this._sep() + "}"; }; - - XMLWriterBase.prototype.cdata = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** @inheritdoc */ + JSONCBWriter.prototype.openTagBegin = function (name) { + // { "node": { "#": [ + var str = this._comma() + this._beginLine() + "{" + this._sep() + this._key(name) + this._sep() + "{"; + this._additionalLevel++; + this.hasData = true; + str += this._beginLine() + this._key(this._builderOptions.convert.text) + this._sep() + "["; + this._hasChildren.push(false); + return str; }; - - XMLWriterBase.prototype.comment = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** @inheritdoc */ + JSONCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (selfClosing) { + var str = this._sep() + "]"; + this._additionalLevel--; + str += this._beginLine() + "}" + this._sep() + "}"; + return str; + } + else { + return ""; + } }; - - XMLWriterBase.prototype.declaration = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + ''; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** @inheritdoc */ + JSONCBWriter.prototype.closeTag = function (name) { + // ] } } + var str = this._beginLine() + "]"; + this._additionalLevel--; + str += this._beginLine() + "}" + this._sep() + "}"; + return str; }; - - XMLWriterBase.prototype.docType = function(node, options, level) { - var child, i, len, r, ref; - level || (level = 0); - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level); - r += ' 0) { - r += ' ['; - r += this.endline(node, options, level); - options.state = WriterState.InsideTag; - ref = node.children; - for (i = 0, len = ref.length; i < len; i++) { - child = ref[i]; - r += this.writeChildNode(child, options, level + 1); + /** @inheritdoc */ + JSONCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + JSONCBWriter.prototype.endElement = function (name) { this._hasChildren.pop(); }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + JSONCBWriter.prototype._beginLine = function (additionalOffset) { + if (additionalOffset === void 0) { additionalOffset = 0; } + if (this._writerOptions.prettyPrint) { + return (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level + additionalOffset); + } + else { + return ""; } - options.state = WriterState.CloseTag; - r += ']'; - } - options.state = WriterState.CloseTag; - r += options.spaceBeforeSlash + '>'; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; }; - - XMLWriterBase.prototype.element = function(node, options, level) { - var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2; - level || (level = 0); - prettySuppressed = false; - r = ''; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r += this.indent(node, options, level) + '<' + node.name; - ref = node.attribs; - for (name in ref) { - if (!hasProp.call(ref, name)) continue; - att = ref[name]; - r += this.attribute(att, options, level); - } - childNodeCount = node.children.length; - firstChildNode = childNodeCount === 0 ? null : node.children[0]; - if (childNodeCount === 0 || node.children.every(function(e) { - return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === ''; - })) { - if (options.allowEmpty) { - r += '>'; - options.state = WriterState.CloseTag; - r += '' + this.endline(node, options, level); - } else { - options.state = WriterState.CloseTag; - r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level); + /** + * Produces an indentation string. + * + * @param level - depth of the tree + */ + JSONCBWriter.prototype._indent = function (level) { + if (level + this._additionalLevel <= 0) { + return ""; } - } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) { - r += '>'; - options.state = WriterState.InsideTag; - options.suppressPrettyCount++; - prettySuppressed = true; - r += this.writeChildNode(firstChildNode, options, level + 1); - options.suppressPrettyCount--; - prettySuppressed = false; - options.state = WriterState.CloseTag; - r += '' + this.endline(node, options, level); - } else { - if (options.dontPrettyTextNodes) { - ref1 = node.children; - for (i = 0, len = ref1.length; i < len; i++) { - child = ref1[i]; - if ((child.type === NodeType.Text || child.type === NodeType.Raw) && (child.value != null)) { - options.suppressPrettyCount++; - prettySuppressed = true; - break; - } - } - } - r += '>' + this.endline(node, options, level); - options.state = WriterState.InsideTag; - ref2 = node.children; - for (j = 0, len1 = ref2.length; j < len1; j++) { - child = ref2[j]; - r += this.writeChildNode(child, options, level + 1); + else { + return this._writerOptions.indent.repeat(level + this._additionalLevel); } - options.state = WriterState.CloseTag; - r += this.indent(node, options, level) + ''; - if (prettySuppressed) { - options.suppressPrettyCount--; + }; + /** + * Produces a comma before a child node if it has previous siblings. + */ + JSONCBWriter.prototype._comma = function () { + var str = (this._hasChildren[this._hasChildren.length - 1] ? "," : ""); + if (this._hasChildren.length > 0) { + this._hasChildren[this._hasChildren.length - 1] = true; } - r += this.endline(node, options, level); - options.state = WriterState.None; - } - this.closeNode(node, options, level); - return r; + return str; }; - - XMLWriterBase.prototype.writeChildNode = function(node, options, level) { - switch (node.type) { - case NodeType.CData: - return this.cdata(node, options, level); - case NodeType.Comment: - return this.comment(node, options, level); - case NodeType.Element: - return this.element(node, options, level); - case NodeType.Raw: - return this.raw(node, options, level); - case NodeType.Text: - return this.text(node, options, level); - case NodeType.ProcessingInstruction: - return this.processingInstruction(node, options, level); - case NodeType.Dummy: - return ''; - case NodeType.Declaration: - return this.declaration(node, options, level); - case NodeType.DocType: - return this.docType(node, options, level); - case NodeType.AttributeDeclaration: - return this.dtdAttList(node, options, level); - case NodeType.ElementDeclaration: - return this.dtdElement(node, options, level); - case NodeType.EntityDeclaration: - return this.dtdEntity(node, options, level); - case NodeType.NotationDeclaration: - return this.dtdNotation(node, options, level); - default: - throw new Error("Unknown XML node type: " + node.constructor.name); - } + /** + * Produces a separator string. + */ + JSONCBWriter.prototype._sep = function () { + return (this._writerOptions.prettyPrint ? " " : ""); }; - - XMLWriterBase.prototype.processingInstruction = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + ''; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** + * Produces a JSON key string delimited with double quotes. + */ + JSONCBWriter.prototype._key = function (key) { + return "\"" + key + "\":"; }; - - XMLWriterBase.prototype.raw = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level); - options.state = WriterState.InsideTag; - r += node.value; - options.state = WriterState.CloseTag; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; + /** + * Produces a JSON value string delimited with double quotes. + */ + JSONCBWriter.prototype._val = function (val) { + return JSON.stringify(val); }; + return JSONCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.JSONCBWriter = JSONCBWriter; +//# sourceMappingURL=JSONCBWriter.js.map - XMLWriterBase.prototype.text = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level); - options.state = WriterState.InsideTag; - r += node.value; - options.state = WriterState.CloseTag; - r += this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - }; +/***/ }), - XMLWriterBase.prototype.dtdAttList = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - }; +/***/ 7510: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - XMLWriterBase.prototype.dtdElement = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - }; +"use strict"; - XMLWriterBase.prototype.dtdEntity = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; +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); }; - - XMLWriterBase.prototype.dtdNotation = function(node, options, level) { - var r; - this.openNode(node, options, level); - options.state = WriterState.OpenTag; - r = this.indent(node, options, level) + '' + this.endline(node, options, level); - options.state = WriterState.None; - this.closeNode(node, options, level); - return r; - }; - - XMLWriterBase.prototype.openNode = function(node, options, level) {}; - - XMLWriterBase.prototype.closeNode = function(node, options, level) {}; - - XMLWriterBase.prototype.openAttribute = function(att, options, level) {}; - - XMLWriterBase.prototype.closeAttribute = function(att, options, level) {}; - - return XMLWriterBase; - - })(); - -}).call(this); - - -/***/ }), - -/***/ 2958: -/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { - -// Generated by CoffeeScript 1.12.7 -(function() { - var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref; - - ref = __nccwpck_require__(8229), assign = ref.assign, isFunction = ref.isFunction; - - XMLDOMImplementation = __nccwpck_require__(8310); - - XMLDocument = __nccwpck_require__(3730); - - XMLDocumentCB = __nccwpck_require__(7356); - - XMLStringWriter = __nccwpck_require__(5913); - - XMLStreamWriter = __nccwpck_require__(8601); - - NodeType = __nccwpck_require__(9267); - - WriterState = __nccwpck_require__(9766); - - module.exports.create = function(name, xmldec, doctype, options) { - var doc, root; - if (name == null) { - throw new Error("Root element needs a name."); - } - options = assign({}, xmldec, doctype, options); - doc = new XMLDocument(options); - root = doc.element(name); - if (!options.headless) { - doc.declaration(options); - if ((options.pubID != null) || (options.sysID != null)) { - doc.dtd(options); - } - } - return root; - }; - - module.exports.begin = function(options, onData, onEnd) { - var ref1; - if (isFunction(options)) { - ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1]; - options = {}; - } - if (onData) { - return new XMLDocumentCB(options, onData, onEnd); - } else { - return new XMLDocument(options); - } - }; - - module.exports.stringWriter = function(options) { - return new XMLStringWriter(options); - }; - - module.exports.streamWriter = function(stream, options) { - return new XMLStreamWriter(stream, options); - }; - - module.exports.implementation = new XMLDOMImplementation(); - - module.exports.nodeType = NodeType; - - module.exports.writerState = WriterState; - -}).call(this); - - -/***/ }), - -/***/ 5696: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(6417); -var util_1 = __nccwpck_require__(6195); -var util_2 = __nccwpck_require__(5282); -var _1 = __nccwpck_require__(4260); -var dom_1 = __nccwpck_require__(770); -/** @inheritdoc */ -function builder(p1, p2) { - var options = formatBuilderOptions(isXMLBuilderCreateOptions(p1) ? p1 : interfaces_1.DefaultBuilderOptions); - var nodes = util_2.Guard.isNode(p1) || util_1.isArray(p1) ? p1 : p2; - if (nodes === undefined) { - throw new Error("Invalid arguments."); - } - if (util_1.isArray(nodes)) { - var builders = []; - for (var i = 0; i < nodes.length; i++) { - var builder_1 = new _1.XMLBuilderImpl(nodes[i]); - builder_1.set(options); - builders.push(builder_1); - } - return builders; - } - else { - var builder_2 = new _1.XMLBuilderImpl(nodes); - builder_2.set(options); - return builder_2; - } -} -exports.builder = builder; -/** @inheritdoc */ -function create(p1, p2) { - var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? - p1 : interfaces_1.DefaultBuilderOptions); - var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; - var doc = dom_1.createDocument(); - setOptions(doc, options); - var builder = new _1.XMLBuilderImpl(doc); - if (contents !== undefined) { - // parse contents - builder.ele(contents); - } - return builder; -} -exports.create = create; -/** @inheritdoc */ -function fragment(p1, p2) { - var options = formatBuilderOptions(p1 === undefined || isXMLBuilderCreateOptions(p1) ? - p1 : interfaces_1.DefaultBuilderOptions); - var contents = isXMLBuilderCreateOptions(p1) ? p2 : p1; - var doc = dom_1.createDocument(); - setOptions(doc, options, true); - var builder = new _1.XMLBuilderImpl(doc.createDocumentFragment()); - if (contents !== undefined) { - // parse contents - builder.ele(contents); - } - return builder; -} -exports.fragment = fragment; -/** @inheritdoc */ -function convert(p1, p2, p3) { - var builderOptions; - var contents; - var convertOptions; - if (isXMLBuilderCreateOptions(p1) && p2 !== undefined) { - builderOptions = p1; - contents = p2; - convertOptions = p3; - } - else { - builderOptions = interfaces_1.DefaultBuilderOptions; - contents = p1; - convertOptions = p2 || undefined; - } - return create(builderOptions, contents).end(convertOptions); -} -exports.convert = convert; -function isXMLBuilderCreateOptions(obj) { - if (!util_1.isPlainObject(obj)) - return false; - for (var key in obj) { - /* istanbul ignore else */ - if (obj.hasOwnProperty(key)) { - if (!interfaces_1.XMLBuilderOptionKeys.has(key)) - return false; - } - } - return true; -} -function formatBuilderOptions(createOptions) { - if (createOptions === void 0) { createOptions = {}; } - var options = util_1.applyDefaults(createOptions, interfaces_1.DefaultBuilderOptions); - if (options.convert.att.length === 0 || - options.convert.ins.length === 0 || - options.convert.text.length === 0 || - options.convert.cdata.length === 0 || - options.convert.comment.length === 0) { - throw new Error("JS object converter strings cannot be zero length."); - } - return options; -} -function setOptions(doc, options, isFragment) { - var docWithSettings = doc; - docWithSettings._xmlBuilderOptions = options; - docWithSettings._isFragment = isFragment; -} -//# sourceMappingURL=BuilderFunctions.js.map - -/***/ }), - -/***/ 268: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -var _1 = __nccwpck_require__(4260); -/** - * 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 - -/***/ }), - -/***/ 1438: -/***/ (function(__unused_webpack_module, exports, __nccwpck_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 __()); + 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) { @@ -96908,5876 +96900,5884 @@ 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; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); -var interfaces_1 = __nccwpck_require__(6417); +var ObjectWriter_1 = __nccwpck_require__(243); var util_1 = __nccwpck_require__(6195); -var BuilderFunctions_1 = __nccwpck_require__(5696); -var algorithm_1 = __nccwpck_require__(61); -var infra_1 = __nccwpck_require__(4251); -var NamespacePrefixMap_1 = __nccwpck_require__(283); -var LocalNameSet_1 = __nccwpck_require__(9049); -var util_2 = __nccwpck_require__(5282); -var XMLCBWriter_1 = __nccwpck_require__(7572); -var JSONCBWriter_1 = __nccwpck_require__(7525); -var YAMLCBWriter_1 = __nccwpck_require__(2444); -var events_1 = __nccwpck_require__(2361); +var BaseWriter_1 = __nccwpck_require__(7644); /** - * Represents a readable XML document stream. + * Serializes XML nodes into a JSON string. */ -var XMLBuilderCBImpl = /** @class */ (function (_super) { - __extends(XMLBuilderCBImpl, _super); - /** - * Initializes a new instance of `XMLStream`. - * - * @param options - stream writer options - * @param fragment - whether to create fragment stream or a document stream +var JSONWriter = /** @class */ (function (_super) { + __extends(JSONWriter, _super); + /** + * Initializes a new instance of `JSONWriter`. * - * @returns XML stream + * @param builderOptions - XML builder options + * @param writerOptions - serialization options */ - function XMLBuilderCBImpl(options, fragment) { - if (fragment === void 0) { fragment = false; } - var _this = _super.call(this) || this; - _this._hasDeclaration = false; - _this._docTypeName = ""; - _this._hasDocumentElement = false; - _this._currentElementSerialized = false; - _this._openTags = []; - _this._ended = false; - _this._fragment = fragment; + function JSONWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; // provide default options - _this._options = util_1.applyDefaults(options || {}, interfaces_1.DefaultXMLBuilderCBOptions); - _this._builderOptions = { - defaultNamespace: _this._options.defaultNamespace, - namespaceAlias: _this._options.namespaceAlias - }; - if (_this._options.format === "json") { - _this._writer = new JSONCBWriter_1.JSONCBWriter(_this._options); - } - else if (_this._options.format === "yaml") { - _this._writer = new YAMLCBWriter_1.YAMLCBWriter(_this._options); - } - else { - _this._writer = new XMLCBWriter_1.XMLCBWriter(_this._options); - } - // automatically create listeners for callbacks passed via options - if (_this._options.data !== undefined) { - _this.on("data", _this._options.data); - } - if (_this._options.end !== undefined) { - _this.on("end", _this._options.end); - } - if (_this._options.error !== undefined) { - _this.on("error", _this._options.error); - } - _this._prefixMap = new NamespacePrefixMap_1.NamespacePrefixMap(); - _this._prefixMap.set("xml", infra_1.namespace.XML); - _this._prefixIndex = { value: 1 }; - _this._push(_this._writer.frontMatter()); + _this._writerOptions = util_1.applyDefaults(writerOptions, { + wellFormed: false, + noDoubleEncoding: false, + prettyPrint: false, + indent: ' ', + newline: '\n', + offset: 0, + group: false, + verbose: false + }); return _this; } - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.ele = function (p1, p2, p3) { + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + * @param writerOptions - serialization options + */ + JSONWriter.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); + // recursively convert object into JSON string + return this._beginLine(this._writerOptions, 0) + this._convertObject(val, 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 + */ + JSONWriter.prototype._convertObject = function (obj, options, level) { var e_1, _a; - // parse if JS object or XML or JSON string - if (util_1.isObject(p1) || (util_1.isString(p1) && (/^\s* 0) { + return new Array(indentLevel).join(options.indent); + } } - this._currentElementSerialized = false; - if (!this._fragment) { - this._hasDocumentElement = true; + return ''; + }; + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + * + * @param options - serialization options + * @param level - current depth of the XML tree + */ + JSONWriter.prototype._endLine = function (options, level) { + if (!options.prettyPrint) { + return ''; + } + else { + return options.newline; } - return this; }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.att = function (p1, p2, p3) { - if (this._currentElement === undefined) { - this.emit("error", new Error("Cannot insert an attribute node as child of a document node.")); - return this; + /** + * Produces a JSON key string delimited with double quotes. + */ + JSONWriter.prototype._key = function (key) { + return "\"" + key + "\":"; + }; + /** + * Produces a JSON value string delimited with double quotes. + */ + JSONWriter.prototype._val = function (val) { + return JSON.stringify(val); + }; + /** + * Determines if an object is a leaf node. + * + * @param obj + */ + JSONWriter.prototype._isLeafNode = function (obj) { + return this._descendantCount(obj) <= 1; + }; + /** + * Counts the number of descendants of the given object. + * + * @param obj + * @param count + */ + JSONWriter.prototype._descendantCount = function (obj, count) { + var _this = this; + if (count === void 0) { count = 0; } + if (util_1.isArray(obj)) { + util_1.forEachArray(obj, function (val) { return count += _this._descendantCount(val, count); }, this); } - try { - this._currentElement.att(p1, p2, p3); + else if (util_1.isObject(obj)) { + util_1.forEachObject(obj, function (key, val) { return count += _this._descendantCount(val, count); }, this); } - catch (err) { - this.emit("error", err); - return this; + else { + count++; } - return this; + return count; }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.com = function (content) { - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).com(content).first().node; - } - catch (err) { - /* istanbul ignore next */ - this.emit("error", err); - /* istanbul ignore next */ - return this; - } - if (this._options.wellFormed && (!algorithm_1.xml_isLegalChar(node.data) || - node.data.indexOf("--") !== -1 || node.data.endsWith("-"))) { - this.emit("error", new Error("Comment data contains invalid characters (well-formed required).")); - return this; - } - this._push(this._writer.comment(node.data)); - return this; + return JSONWriter; +}(BaseWriter_1.BaseWriter)); +exports.JSONWriter = JSONWriter; +//# sourceMappingURL=JSONWriter.js.map + +/***/ }), + +/***/ 1397: +/***/ (function(__unused_webpack_module, exports, __nccwpck_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); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.txt = function (content) { - if (!this._fragment && this._currentElement === undefined) { - this.emit("error", new Error("Cannot insert a text node as child of a document node.")); - return this; - } - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).txt(content).first().node; - } - catch (err) { - /* istanbul ignore next */ - this.emit("error", err); - /* istanbul ignore next */ - return this; - } - if (this._options.wellFormed && !algorithm_1.xml_isLegalChar(node.data)) { - this.emit("error", new Error("Text data contains invalid characters (well-formed required).")); - return this; - } - var markup = ""; - if (this._options.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._push(this._writer.text(markup)); - return this; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.ins = function (target, content) { - if (content === void 0) { content = ''; } - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).ins(target, content).first().node; - } - catch (err) { - /* istanbul ignore next */ - this.emit("error", err); - /* istanbul ignore next */ - return this; +})(); +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var ObjectWriter_1 = __nccwpck_require__(243); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into ES6 maps and arrays. + */ +var MapWriter = /** @class */ (function (_super) { + __extends(MapWriter, _super); + /** + * Initializes a new instance of `MapWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function MapWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + format: "map", + wellFormed: false, + noDoubleEncoding: false, + group: false, + verbose: false + }); + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + */ + MapWriter.prototype.serialize = function (node) { + // convert to object + var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { + format: "object", + wellFormed: false, + noDoubleEncoding: false, + verbose: false + }); + var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); + var val = objectWriter.serialize(node); + // recursively convert object into Map + return this._convertObject(val); + }; + /** + * Recursively converts a JS object into an ES5 map. + * + * @param obj - a JS object + */ + MapWriter.prototype._convertObject = function (obj) { + if (util_1.isArray(obj)) { + for (var i = 0; i < obj.length; i++) { + obj[i] = this._convertObject(obj[i]); + } + return obj; } - if (this._options.wellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { - this.emit("error", new Error("Processing instruction target contains invalid characters (well-formed required).")); - return this; + else if (util_1.isObject(obj)) { + var map = new Map(); + for (var key in obj) { + map.set(key, this._convertObject(obj[key])); + } + return map; } - if (this._options.wellFormed && !algorithm_1.xml_isLegalChar(node.data)) { - this.emit("error", Error("Processing instruction data contains invalid characters (well-formed required).")); - return this; + else { + return obj; } - this._push(this._writer.instruction(node.target, node.data)); - return this; }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.dat = function (content) { - this._serializeOpenTag(true); - var node; - try { - node = BuilderFunctions_1.fragment(this._builderOptions).dat(content).first().node; - } - catch (err) { - this.emit("error", err); - return this; - } - this._push(this._writer.cdata(node.data)); - return this; + return MapWriter; +}(BaseWriter_1.BaseWriter)); +exports.MapWriter = MapWriter; +//# sourceMappingURL=MapWriter.js.map + +/***/ }), + +/***/ 243: +/***/ (function(__unused_webpack_module, exports, __nccwpck_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); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.dec = function (options) { - if (options === void 0) { options = { version: "1.0" }; } - if (this._fragment) { - this.emit("error", Error("Cannot insert an XML declaration into a document fragment.")); - return this; - } - if (this._hasDeclaration) { - this.emit("error", Error("XML declaration is already inserted.")); - return this; - } - this._push(this._writer.declaration(options.version || "1.0", options.encoding, options.standalone)); - this._hasDeclaration = true; - return this; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.dtd = function (options) { - if (this._fragment) { - this.emit("error", Error("Cannot insert a DocType declaration into a document fragment.")); - return this; - } - if (this._docTypeName !== "") { - this.emit("error", new Error("DocType declaration is already inserted.")); - return this; - } - if (this._hasDocumentElement) { - this.emit("error", new Error("Cannot insert DocType declaration after document element.")); - return this; - } - var node; - try { - node = BuilderFunctions_1.create().dtd(options).first().node; - } - catch (err) { - this.emit("error", err); - return this; - } - if (this._options.wellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { - this.emit("error", new Error("DocType public identifier does not match PubidChar construct (well-formed required).")); - return this; - } - if (this._options.wellFormed && - (!algorithm_1.xml_isLegalChar(node.systemId) || - (node.systemId.indexOf('"') !== -1 && node.systemId.indexOf("'") !== -1))) { - this.emit("error", new Error("DocType system identifier contains invalid characters (well-formed required).")); - return this; +})(); +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 }; } - this._docTypeName = options.name; - this._push(this._writer.docType(options.name, node.publicId, node.systemId)); - return this; - }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.up = function () { - this._serializeOpenTag(false); - this._serializeCloseTag(); - return this; - }; - /** @inheritdoc */ - XMLBuilderCBImpl.prototype.end = function () { - this._serializeOpenTag(false); - while (this._openTags.length > 0) { - this._serializeCloseTag(); - } - this._push(null); - return this; }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var util_1 = __nccwpck_require__(6195); +var interfaces_1 = __nccwpck_require__(7305); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into objects and arrays. + */ +var ObjectWriter = /** @class */ (function (_super) { + __extends(ObjectWriter, _super); /** - * Serializes the opening tag of an element node. + * Initializes a new instance of `ObjectWriter`. * - * @param hasChildren - whether the element node has child nodes + * @param builderOptions - XML builder options + * @param writerOptions - serialization options */ - XMLBuilderCBImpl.prototype._serializeOpenTag = function (hasChildren) { - if (this._currentElementSerialized) - return; - if (this._currentElement === undefined) - return; - var node = this._currentElement.node; - if (this._options.wellFormed && (node.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(node.localName))) { - this.emit("error", new Error("Node local name contains invalid characters (well-formed required).")); - return; - } - var qualifiedName = ""; - var ignoreNamespaceDefinitionAttribute = false; - var map = this._prefixMap.copy(); - var localPrefixesMap = {}; - var localDefaultNamespace = this._recordNamespaceInformation(node, map, localPrefixesMap); - var inheritedNS = this._openTags.length === 0 ? null : this._openTags[this._openTags.length - 1][1]; - var ns = node.namespaceURI; - if (ns === null) - ns = inheritedNS; - if (inheritedNS === ns) { - if (localDefaultNamespace !== null) { - ignoreNamespaceDefinitionAttribute = true; - } - if (ns === infra_1.namespace.XML) { - qualifiedName = "xml:" + node.localName; - } - else { - qualifiedName = node.localName; - } - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - } - else { - var prefix = node.prefix; - var candidatePrefix = null; - if (prefix !== null || ns !== localDefaultNamespace) { - candidatePrefix = map.get(prefix, ns); - } - if (prefix === "xmlns") { - if (this._options.wellFormed) { - this.emit("error", new Error("An element cannot have the 'xmlns' prefix (well-formed required).")); - return; - } - candidatePrefix = prefix; - } - if (candidatePrefix !== null) { - qualifiedName = candidatePrefix + ':' + node.localName; - if (localDefaultNamespace !== null && localDefaultNamespace !== infra_1.namespace.XML) { - inheritedNS = localDefaultNamespace || null; - } - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - } - else if (prefix !== null) { - if (prefix in localPrefixesMap) { - prefix = this._generatePrefix(ns, map, this._prefixIndex); - } - map.set(prefix, ns); - qualifiedName += prefix + ':' + node.localName; - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - this._push(this._writer.attribute("xmlns:" + prefix, this._serializeAttributeValue(ns, this._options.wellFormed))); - if (localDefaultNamespace !== null) { - inheritedNS = localDefaultNamespace || null; - } - } - else if (localDefaultNamespace === null || - (localDefaultNamespace !== null && localDefaultNamespace !== ns)) { - ignoreNamespaceDefinitionAttribute = true; - qualifiedName += node.localName; - inheritedNS = ns; - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - this._push(this._writer.attribute("xmlns", this._serializeAttributeValue(ns, this._options.wellFormed))); - } - else { - qualifiedName += node.localName; - inheritedNS = ns; - this._writer.beginElement(qualifiedName); - this._push(this._writer.openTagBegin(qualifiedName)); - } - } - this._serializeAttributes(node, map, this._prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, this._options.wellFormed); - var isHTML = (ns === infra_1.namespace.HTML); - if (isHTML && !hasChildren && - XMLBuilderCBImpl._VoidElementNames.has(node.localName)) { - this._push(this._writer.openTagEnd(qualifiedName, true, true)); - this._writer.endElement(qualifiedName); - } - else if (!isHTML && !hasChildren) { - this._push(this._writer.openTagEnd(qualifiedName, true, false)); - this._writer.endElement(qualifiedName); - } - else { - this._push(this._writer.openTagEnd(qualifiedName, false, false)); - } - this._currentElementSerialized = true; - /** - * Save qualified name, original inherited ns, original prefix map, and - * hasChildren flag. - */ - this._openTags.push([qualifiedName, inheritedNS, this._prefixMap, hasChildren]); + 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]; /** - * New values of inherited namespace and prefix map will be used while - * serializing child nodes. They will be returned to their original values - * when this node is closed using the _openTags array item we saved above. + * 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 (this._isPrefixMapModified(this._prefixMap, map)) { - this._prefixMap = map; - } + this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); /** - * Calls following this will either serialize child nodes or close this tag. + * 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" ] + * } + * ] + * } + * } */ - this._writer.level++; + return this._process(this._currentList, this._writerOptions); }; - /** - * Serializes the closing tag of an element node. - */ - XMLBuilderCBImpl.prototype._serializeCloseTag = function () { - this._writer.level--; - var lastEle = this._openTags.pop(); - /* istanbul ignore next */ - if (lastEle === undefined) { - this.emit("error", new Error("Last element is undefined.")); - return; + 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 _a = __read(lastEle, 4), qualifiedName = _a[0], ns = _a[1], map = _a[2], hasChildren = _a[3]; - /** - * Restore original values of inherited namespace and prefix map. - */ - this._prefixMap = map; - if (!hasChildren) - return; - this._push(this._writer.closeTag(qualifiedName)); - this._writer.endElement(qualifiedName); - }; - /** - * Pushes data to internal buffer. - * - * @param data - data - */ - XMLBuilderCBImpl.prototype._push = function (data) { - if (data === null) { - this._ended = true; - this.emit("end"); - } - else if (this._ended) { - this.emit("error", new Error("Cannot push to ended stream.")); - } - else if (data.length !== 0) { - this._writer.hasData = true; - this.emit("data", data, this._writer.level); + 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]["#"]; } - }; - /** - * Reads and serializes an XML tree. - * - * @param node - root node - */ - XMLBuilderCBImpl.prototype._fromNode = function (node) { - var e_2, _a, e_3, _b; - if (util_2.Guard.isElementNode(node)) { - var name = node.prefix ? node.prefix + ":" + node.localName : node.localName; - if (node.namespaceURI !== null) { - this.ele(node.namespaceURI, name); - } - else { - this.ele(name); - } - try { - for (var _c = __values(node.attributes), _d = _c.next(); !_d.done; _d = _c.next()) { - var attr = _d.value; - var name_1 = attr.prefix ? attr.prefix + ":" + attr.localName : attr.localName; - if (attr.namespaceURI !== null) { - this.att(attr.namespaceURI, name_1, attr.value); + 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 { - this.att(name_1, attr.value); + obj[defAttrKey] = item["@"]; } } } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_d && !_d.done && (_a = _c.return)) _a.call(_c); + // 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; } - finally { if (e_2) throw e_2.error; } } + 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 _e = __values(node.childNodes), _f = _e.next(); !_f.done; _f = _e.next()) { - var child = _f.value; - this._fromNode(child); + 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_3_1) { e_3 = { error: e_3_1 }; } + catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_f && !_f.done && (_b = _e.return)) _b.call(_e); + if (item_1_1 && !item_1_1.done && (_a = item_1.return)) _a.call(item_1); } - finally { if (e_3) throw e_3.error; } + finally { if (e_1) throw e_1.error; } } - this.up(); } - else if (util_2.Guard.isExclusiveTextNode(node) && node.data) { - this.txt(node.data); + else { + var key = count > 1 ? defKey + (id++).toString() : defKey; + obj[key] = item; } - else if (util_2.Guard.isCommentNode(node)) { - this.com(node.data); + 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 (util_2.Guard.isCDATASectionNode(node)) { - this.dat(node.data); + 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)); + } } - else if (util_2.Guard.isProcessingInstructionNode(node)) { - this.ins(node.target, node.data); + this._currentIndex++; + if (this._listRegister.length > this._currentIndex) { + this._listRegister[this._currentIndex] = childItems; + } + else { + this._listRegister.push(childItems); } + this._currentList = childItems; }; - /** - * 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 - */ - XMLBuilderCBImpl.prototype._serializeAttributes = function (node, map, prefixIndex, localPrefixesMap, ignoreNamespaceDefinitionAttribute, requireWellFormed) { - var e_4, _a; - var localNameSet = requireWellFormed ? new LocalNameSet_1.LocalNameSet() : undefined; - try { - 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) { - this._push(this._writer.attribute(attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); - continue; - } - if (requireWellFormed && localNameSet && localNameSet.has(attr.namespaceURI, attr.localName)) { - this.emit("error", new Error("Element contains duplicate attributes (well-formed required).")); - return; - } - if (requireWellFormed && localNameSet) - localNameSet.set(attr.namespaceURI, attr.localName); - var attributeNamespace = attr.namespaceURI; - var candidatePrefix = null; - if (attributeNamespace !== null) { - candidatePrefix = map.get(attr.prefix, attributeNamespace); - if (attributeNamespace === infra_1.namespace.XMLNS) { - 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; - if (requireWellFormed && attr.value === infra_1.namespace.XMLNS) { - this.emit("error", new Error("XMLNS namespace is reserved (well-formed required).")); - return; - } - if (requireWellFormed && attr.value === '') { - this.emit("error", new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).")); - return; - } - if (attr.prefix === 'xmlns') - candidatePrefix = 'xmlns'; - /** - * _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 { - candidatePrefix = this._generatePrefix(attributeNamespace, map, prefixIndex); - } - this._push(this._writer.attribute("xmlns:" + candidatePrefix, this._serializeAttributeValue(attributeNamespace, this._options.wellFormed))); - } + /** @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); } - if (requireWellFormed && (attr.localName.indexOf(":") !== -1 || - !algorithm_1.xml_isName(attr.localName) || - (attr.localName === "xmlns" && attributeNamespace === null))) { - this.emit("error", new Error("Attribute local name contains invalid characters (well-formed required).")); - return; + else { + lastItem["!"] = [lastItem["!"], data]; } - this._push(this._writer.attribute((candidatePrefix !== null ? candidatePrefix + ":" : "") + attr.localName, this._serializeAttributeValue(attr.value, this._options.wellFormed))); } - } - 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({ "!": data }); } - finally { if (e_4) throw e_4.error; } } }; - /** - * Produces an XML serialization of an attribute value. - * - * @param value - attribute value - * @param requireWellFormed - whether to check conformance - */ - XMLBuilderCBImpl.prototype._serializeAttributeValue = function (value, requireWellFormed) { - if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { - this.emit("error", new Error("Invalid characters in attribute value.")); - return ""; - } - if (value === null) - return ""; - if (this._options.noDoubleEncoding) { - return value.replace(/(?!&(lt|gt|amp|apos|quot);)&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"'); + /** @inheritdoc */ + ObjectWriter.prototype.text = function (data) { + if (this._currentList.length === 0) { + this._currentList.push({ "#": data }); } 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; + 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 }); } - 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 - */ - XMLBuilderCBImpl.prototype._recordNamespaceInformation = function (node, map, localPrefixesMap) { - var e_5, _a; - var defaultNamespaceAttrValue = null; - try { - for (var _b = __values(node.attributes), _c = _b.next(); !_c.done; _c = _b.next()) { - var attr = _c.value; - var attributeNamespace = attr.namespaceURI; - var attributePrefix = attr.prefix; - if (attributeNamespace === infra_1.namespace.XMLNS) { - if (attributePrefix === null) { - defaultNamespaceAttrValue = attr.value; - continue; - } - else { - var prefixDefinition = attr.localName; - var namespaceDefinition = attr.value; - if (namespaceDefinition === infra_1.namespace.XML) { - continue; - } - if (namespaceDefinition === '') { - namespaceDefinition = null; - } - if (map.has(prefixDefinition, namespaceDefinition)) { - continue; - } - map.set(prefixDefinition, namespaceDefinition); - localPrefixesMap[prefixDefinition] = namespaceDefinition || ''; - } + /** @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 }); } } - catch (e_5_1) { e_5 = { error: e_5_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + }; + /** @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 }); } - finally { if (e_5) throw e_5.error; } } - return defaultNamespaceAttrValue; + }; + 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; }; /** - * 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 + * Returns an object key for an attribute or namespace declaration. */ - XMLBuilderCBImpl.prototype._generatePrefix = function (newNamespace, prefixMap, prefixIndex) { - var generatedPrefix = "ns" + prefixIndex.value; - prefixIndex.value++; - prefixMap.set(generatedPrefix, newNamespace); - return generatedPrefix; + ObjectWriter.prototype._getAttrKey = function () { + return this._builderOptions.convert.att; }; /** - * Determines if the namespace prefix map was modified from its original. + * Returns an object key for the given node type. * - * @param originalMap - original namespace prefix map - * @param newMap - new namespace prefix map + * @param nodeType - node type to get a key for */ - XMLBuilderCBImpl.prototype._isPrefixMapModified = function (originalMap, newMap) { - var items1 = originalMap._items; - var items2 = newMap._items; - var nullItems1 = originalMap._nullItems; - var nullItems2 = newMap._nullItems; - for (var key in items2) { - var arr1 = items1[key]; - if (arr1 === undefined) - return true; - var arr2 = items2[key]; - if (arr1.length !== arr2.length) - return true; - for (var i = 0; i < arr1.length; i++) { - if (arr1[i] !== arr2[i]) - return true; - } - } - if (nullItems1.length !== nullItems2.length) - return true; - for (var i = 0; i < nullItems1.length; i++) { - if (nullItems1[i] !== nullItems2[i]) - return true; + 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 false; }; - XMLBuilderCBImpl._VoidElementNames = new Set(['area', 'base', 'basefont', - 'bgsound', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'keygen', - 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr']); - return XMLBuilderCBImpl; -}(events_1.EventEmitter)); -exports.XMLBuilderCBImpl = XMLBuilderCBImpl; -//# sourceMappingURL=XMLBuilderCBImpl.js.map + return ObjectWriter; +}(BaseWriter_1.BaseWriter)); +exports.ObjectWriter = ObjectWriter; +//# sourceMappingURL=ObjectWriter.js.map /***/ }), -/***/ 8248: +/***/ 7572: /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; - } +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); }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; + 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 interfaces_1 = __nccwpck_require__(6417); -var util_1 = __nccwpck_require__(6195); -var writers_1 = __nccwpck_require__(7476); -var interfaces_2 = __nccwpck_require__(7305); -var util_2 = __nccwpck_require__(5282); -var algorithm_1 = __nccwpck_require__(61); -var dom_1 = __nccwpck_require__(770); -var infra_1 = __nccwpck_require__(4251); -var readers_1 = __nccwpck_require__(560); +var BaseCBWriter_1 = __nccwpck_require__(708); /** - * Represents a wrapper that extends XML nodes to implement easy to use and - * chainable document builder methods. + * Serializes XML nodes. */ -var XMLBuilderImpl = /** @class */ (function () { +var XMLCBWriter = /** @class */ (function (_super) { + __extends(XMLCBWriter, _super); /** - * Initializes a new instance of `XMLBuilderNodeImpl`. + * Initializes a new instance of `XMLCBWriter`. * - * @param domNode - the DOM node to wrap + * @param builderOptions - XML builder options */ - function XMLBuilderImpl(domNode) { - this._domNode = domNode; + function XMLCBWriter(builderOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._lineLength = 0; + return _this; } - Object.defineProperty(XMLBuilderImpl.prototype, "node", { - /** @inheritdoc */ - get: function () { return this._domNode; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(XMLBuilderImpl.prototype, "options", { - /** @inheritdoc */ - get: function () { return this._options; }, - enumerable: true, - configurable: true - }); /** @inheritdoc */ - XMLBuilderImpl.prototype.set = function (options) { - this._options = util_1.applyDefaults(util_1.applyDefaults(this._options, options, true), // apply user settings - interfaces_1.DefaultBuilderOptions); // provide defaults - return this; + XMLCBWriter.prototype.frontMatter = function () { + return ""; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.ele = function (p1, p2, p3) { - var _a, _b, _c; - var namespace; - var name; - var attributes; - if (util_1.isObject(p1)) { - // ele(obj: ExpandObject) - return new readers_1.ObjectReader(this._options).parse(this, p1); - } - else if (p1 !== null && /^\s*"; + return markup; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.docType = function (name, publicId, systemId) { + var markup = this._beginLine(); + if (publicId && systemId) { + markup += ""; } - if ((p1 === null || util_1.isString(p1)) && util_1.isString(p2)) { - // ele(namespace: string, name: string, attributes?: AttributesObject) - _a = __read([p1, p2, p3], 3), namespace = _a[0], name = _a[1], attributes = _a[2]; + else if (publicId) { + markup += ""; } - else if (p1 !== null) { - // ele(name: string, attributes?: AttributesObject) - _b = __read([undefined, p1, util_1.isObject(p2) ? p2 : undefined], 3), namespace = _b[0], name = _b[1], attributes = _b[2]; + else if (systemId) { + markup += ""; } else { - throw new Error("Element name cannot be null. " + this._debugInfo()); + markup += ""; } - if (attributes) { - attributes = util_1.getValue(attributes); + return markup; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.comment = function (data) { + return this._beginLine() + ""; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.text = function (data) { + return this._beginLine() + data; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.instruction = function (target, data) { + if (data) { + return this._beginLine() + ""; } - _c = __read(this._extractNamespace(dom_1.sanitizeInput(namespace, this._options.invalidCharReplacement), dom_1.sanitizeInput(name, this._options.invalidCharReplacement), true), 2), namespace = _c[0], name = _c[1]; - // inherit namespace from parent - if (namespace === undefined) { - var _d = __read(algorithm_1.namespace_extractQName(name), 1), prefix = _d[0]; - namespace = this.node.lookupNamespaceURI(prefix); + else { + return this._beginLine() + ""; } - // create a child element node - var childNode = (namespace !== undefined && namespace !== null ? - this._doc.createElementNS(namespace, name) : - this._doc.createElement(name)); - this.node.appendChild(childNode); - var builder = new XMLBuilderImpl(childNode); - // update doctype node if the new node is the document element node - var oldDocType = this._doc.doctype; - if (childNode === this._doc.documentElement && oldDocType !== null) { - var docType = this._doc.implementation.createDocumentType(this._doc.documentElement.tagName, oldDocType.publicId, oldDocType.systemId); - this._doc.replaceChild(docType, oldDocType); + }; + /** @inheritdoc */ + XMLCBWriter.prototype.cdata = function (data) { + return this._beginLine() + ""; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.openTagBegin = function (name) { + this._lineLength += 1 + name.length; + return this._beginLine() + "<" + name; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (voidElement) { + return " />"; } - // create attributes - if (attributes && !util_1.isEmpty(attributes)) { - builder.att(attributes); + else if (selfClosing) { + if (this._writerOptions.allowEmptyTags) { + return ">"; + } + else if (this._writerOptions.spaceBeforeSlash) { + return " />"; + } + else { + return "/>"; + } + } + else { + return ">"; } - return builder; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.remove = function () { - var parent = this.up(); - parent.node.removeChild(this.node); - return parent; + XMLCBWriter.prototype.closeTag = function (name) { + return this._beginLine() + ""; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.att = function (p1, p2, p3) { - var _a, _b, _c; - var _this = this; - if (util_1.isMap(p1) || util_1.isObject(p1)) { - // att(obj: AttributesObject) - // expand if object - util_1.forEachObject(p1, function (attName, attValue) { return _this.att(attName, attValue); }, this); - return this; - } - // get primitive values - if (p1 !== undefined && p1 !== null) - p1 = util_1.getValue(p1 + ""); - if (p2 !== undefined && p2 !== null) - p2 = util_1.getValue(p2 + ""); - if (p3 !== undefined && p3 !== null) - p3 = util_1.getValue(p3 + ""); - var namespace; - var name; - var value; - if ((p1 === null || util_1.isString(p1)) && util_1.isString(p2) && (p3 === null || util_1.isString(p3))) { - // att(namespace: string, name: string, value: string) - _a = __read([p1, p2, p3], 3), namespace = _a[0], name = _a[1], value = _a[2]; - } - else if (util_1.isString(p1) && (p2 == null || util_1.isString(p2))) { - // ele(name: string, value: string) - _b = __read([undefined, p1, p2], 3), namespace = _b[0], name = _b[1], value = _b[2]; + XMLCBWriter.prototype.attribute = function (name, value) { + var str = name + "=\"" + value + "\""; + if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && + this._lineLength + 1 + str.length > this._writerOptions.width) { + str = this._beginLine() + this._indent(1) + str; + this._lineLength = str.length; + return str; } else { - throw new Error("Attribute name and value not specified. " + this._debugInfo()); - } - if (this._options.keepNullAttributes && (value == null)) { - // keep null attributes - value = ""; - } - else if (value == null) { - // skip null|undefined attributes - return this; - } - if (!util_2.Guard.isElementNode(this.node)) { - throw new Error("An attribute can only be assigned to an element node."); - } - var ele = this.node; - _c = __read(this._extractNamespace(namespace, name, false), 2), namespace = _c[0], name = _c[1]; - name = dom_1.sanitizeInput(name, this._options.invalidCharReplacement); - namespace = dom_1.sanitizeInput(namespace, this._options.invalidCharReplacement); - value = dom_1.sanitizeInput(value, this._options.invalidCharReplacement); - var _d = __read(algorithm_1.namespace_extractQName(name), 2), prefix = _d[0], localName = _d[1]; - var _e = __read(algorithm_1.namespace_extractQName(ele.prefix ? ele.prefix + ':' + ele.localName : ele.localName), 1), elePrefix = _e[0]; - // check if this is a namespace declaration attribute - // assign a new element namespace if it wasn't previously assigned - var eleNamespace = null; - if (prefix === "xmlns") { - namespace = infra_1.namespace.XMLNS; - if (ele.namespaceURI === null && elePrefix === localName) { - eleNamespace = value; - } + this._lineLength += 1 + str.length; + return " " + str; } - else if (prefix === null && localName === "xmlns" && elePrefix === null) { - namespace = infra_1.namespace.XMLNS; - eleNamespace = value; + }; + /** @inheritdoc */ + XMLCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + XMLCBWriter.prototype.endElement = function (name) { }; + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + XMLCBWriter.prototype._beginLine = function () { + if (this._writerOptions.prettyPrint) { + var str = (this.hasData ? this._writerOptions.newline : "") + + this._indent(this._writerOptions.offset + this.level); + this._lineLength = str.length; + return str; } - // re-create the element node if its namespace changed - // we can't simply change the namespaceURI since its read-only - if (eleNamespace !== null) { - this._updateNamespace(eleNamespace); - ele = this.node; + else { + return ""; } - if (namespace !== undefined) { - ele.setAttributeNS(namespace, name, value); + }; + /** + * Produces an indentation string. + * + * @param level - depth of the tree + */ + XMLCBWriter.prototype._indent = function (level) { + if (level <= 0) { + return ""; } else { - ele.setAttribute(name, value); + return this._writerOptions.indent.repeat(level); } - return this; }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.removeAtt = function (p1, p2) { - var _this = this; - if (!util_2.Guard.isElementNode(this.node)) { - throw new Error("An attribute can only be removed from an element node."); + return XMLCBWriter; +}(BaseCBWriter_1.BaseCBWriter)); +exports.XMLCBWriter = XMLCBWriter; +//# sourceMappingURL=XMLCBWriter.js.map + +/***/ }), + +/***/ 9606: +/***/ (function(__unused_webpack_module, exports, __nccwpck_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 util_1 = __nccwpck_require__(6195); +var interfaces_1 = __nccwpck_require__(7305); +var BaseWriter_1 = __nccwpck_require__(7644); +var util_2 = __nccwpck_require__(5282); +/** + * Serializes XML nodes into strings. + */ +var XMLWriter = /** @class */ (function (_super) { + __extends(XMLWriter, _super); + /** + * Initializes a new instance of `XMLWriter`. + * + * @param builderOptions - XML builder options + * @param writerOptions - serialization options + */ + function XMLWriter(builderOptions, writerOptions) { + var _this = _super.call(this, builderOptions) || this; + _this._indentation = {}; + _this._lengthToLastNewline = 0; + // provide default options + _this._writerOptions = util_1.applyDefaults(writerOptions, { + wellFormed: false, + noDoubleEncoding: false, + headless: false, + prettyPrint: false, + indent: " ", + newline: "\n", + offset: 0, + width: 0, + allowEmptyTags: false, + indentTextOnlyNodes: false, + spaceBeforeSlash: false + }); + return _this; + } + /** + * Produces an XML serialization of the given node. + * + * @param node - node to serialize + */ + XMLWriter.prototype.serialize = function (node) { + this._refs = { suppressPretty: false, emptyNode: false, markup: "" }; + // Serialize XML declaration + if (node.nodeType === interfaces_1.NodeType.Document && !this._writerOptions.headless) { + this.declaration(this._builderOptions.version, this._builderOptions.encoding, this._builderOptions.standalone); } - // get primitive values - p1 = util_1.getValue(p1); - if (p2 !== undefined) { - p2 = util_1.getValue(p2); + // recursively serialize node + this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); + // remove trailing newline + if (this._writerOptions.prettyPrint && + this._refs.markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { + this._refs.markup = this._refs.markup.slice(0, -this._writerOptions.newline.length); } - var namespace; - var name; - if (p1 !== null && p2 === undefined) { - name = p1; + return this._refs.markup; + }; + /** @inheritdoc */ + XMLWriter.prototype.declaration = function (version, encoding, standalone) { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); + }; + /** @inheritdoc */ + XMLWriter.prototype.docType = function (name, publicId, systemId) { + this._beginLine(); + if (publicId && systemId) { + this._refs.markup += ""; } - if (util_1.isArray(name) || util_1.isSet(name)) { - // removeAtt(names: string[]) - // removeAtt(namespace: string, names: string[]) - util_1.forEachArray(name, function (attName) { - return namespace === undefined ? _this.removeAtt(attName) : _this.removeAtt(namespace, attName); - }, this); + else if (publicId) { + this._refs.markup += ""; } - else if (namespace !== undefined) { - // removeAtt(namespace: string, name: string) - name = dom_1.sanitizeInput(name, this._options.invalidCharReplacement); - namespace = dom_1.sanitizeInput(namespace, this._options.invalidCharReplacement); - this.node.removeAttributeNS(namespace, name); + else if (systemId) { + this._refs.markup += ""; } else { - // removeAtt(name: string) - name = dom_1.sanitizeInput(name, this._options.invalidCharReplacement); - this.node.removeAttribute(name); + this._refs.markup += ""; } - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.txt = function (content) { - var child = this._doc.createTextNode(dom_1.sanitizeInput(content, this._options.invalidCharReplacement)); - this.node.appendChild(child); - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.com = function (content) { - var child = this._doc.createComment(dom_1.sanitizeInput(content, this._options.invalidCharReplacement)); - this.node.appendChild(child); - return this; + this._endLine(); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.dat = function (content) { - var child = this._doc.createCDATASection(dom_1.sanitizeInput(content, this._options.invalidCharReplacement)); - this.node.appendChild(child); - return this; + XMLWriter.prototype.openTagBegin = function (name) { + this._beginLine(); + this._refs.markup += "<" + name; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.ins = function (target, content) { - var _this = this; - if (content === void 0) { content = ''; } - if (util_1.isArray(target) || util_1.isSet(target)) { - util_1.forEachArray(target, function (item) { - item += ""; - var insIndex = item.indexOf(' '); - var insTarget = (insIndex === -1 ? item : item.substr(0, insIndex)); - var insValue = (insIndex === -1 ? '' : item.substr(insIndex + 1)); - _this.ins(insTarget, insValue); - }, this); - } - else if (util_1.isMap(target) || util_1.isObject(target)) { - util_1.forEachObject(target, function (insTarget, insValue) { return _this.ins(insTarget, insValue); }, this); - } - else { - var child = this._doc.createProcessingInstruction(dom_1.sanitizeInput(target, this._options.invalidCharReplacement), dom_1.sanitizeInput(content, this._options.invalidCharReplacement)); - this.node.appendChild(child); - } - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.dec = function (options) { - this._options.version = options.version || "1.0"; - this._options.encoding = options.encoding; - this._options.standalone = options.standalone; - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.dtd = function (options) { - var name = dom_1.sanitizeInput((options && options.name) || (this._doc.documentElement ? this._doc.documentElement.tagName : "ROOT"), this._options.invalidCharReplacement); - var pubID = dom_1.sanitizeInput((options && options.pubID) || "", this._options.invalidCharReplacement); - var sysID = dom_1.sanitizeInput((options && options.sysID) || "", this._options.invalidCharReplacement); - // name must match document element - if (this._doc.documentElement !== null && name !== this._doc.documentElement.tagName) { - throw new Error("DocType name does not match document element name."); + XMLWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + // do not indent text only elements or elements with empty text nodes + this._refs.suppressPretty = false; + this._refs.emptyNode = false; + if (this._writerOptions.prettyPrint && !selfClosing && !voidElement) { + var textOnlyNode = true; + var emptyNode = true; + var childNode = this.currentNode.firstChild; + var cdataCount = 0; + var textCount = 0; + while (childNode) { + if (util_2.Guard.isExclusiveTextNode(childNode)) { + textCount++; + } + else if (util_2.Guard.isCDATASectionNode(childNode)) { + cdataCount++; + } + else { + textOnlyNode = false; + emptyNode = false; + break; + } + if (childNode.data !== '') { + emptyNode = false; + } + childNode = childNode.nextSibling; + } + this._refs.suppressPretty = !this._writerOptions.indentTextOnlyNodes && textOnlyNode && ((cdataCount <= 1 && textCount === 0) || cdataCount === 0); + this._refs.emptyNode = emptyNode; } - // create doctype node - var docType = this._doc.implementation.createDocumentType(name, pubID, sysID); - if (this._doc.doctype !== null) { - // replace existing doctype - this._doc.replaceChild(docType, this._doc.doctype); + if ((voidElement || selfClosing || this._refs.emptyNode) && this._writerOptions.allowEmptyTags) { + this._refs.markup += ">"; } else { - // insert before document element node or append to end - this._doc.insertBefore(docType, this._doc.documentElement); + this._refs.markup += voidElement ? " />" : + (selfClosing || this._refs.emptyNode) ? (this._writerOptions.spaceBeforeSlash ? " />" : "/>") : ">"; } - return this; + this._endLine(); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.import = function (node) { - var e_1, _a; - var hostNode = this._domNode; - var hostDoc = this._doc; - var importedNode = node.node; - if (util_2.Guard.isDocumentNode(importedNode)) { - // import document node - var elementNode = importedNode.documentElement; - if (elementNode === null) { - throw new Error("Imported document has no document element node. " + this._debugInfo()); - } - var clone = hostDoc.importNode(elementNode, true); - hostNode.appendChild(clone); - var _b = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _b[0]; - var namespace = hostNode.lookupNamespaceURI(prefix); - new XMLBuilderImpl(clone)._updateNamespace(namespace); - } - else if (util_2.Guard.isDocumentFragmentNode(importedNode)) { - try { - // import child nodes - for (var _c = __values(importedNode.childNodes), _d = _c.next(); !_d.done; _d = _c.next()) { - var childNode = _d.value; - var clone = hostDoc.importNode(childNode, true); - hostNode.appendChild(clone); - if (util_2.Guard.isElementNode(clone)) { - var _e = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _e[0]; - var namespace = hostNode.lookupNamespaceURI(prefix); - new XMLBuilderImpl(clone)._updateNamespace(namespace); - } - } - } - 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 { - // import node - var clone = hostDoc.importNode(importedNode, true); - hostNode.appendChild(clone); - if (util_2.Guard.isElementNode(clone)) { - var _f = __read(algorithm_1.namespace_extractQName(clone.prefix ? clone.prefix + ':' + clone.localName : clone.localName), 1), prefix = _f[0]; - var namespace = hostNode.lookupNamespaceURI(prefix); - new XMLBuilderImpl(clone)._updateNamespace(namespace); - } + XMLWriter.prototype.closeTag = function (name) { + if (!this._refs.emptyNode) { + this._beginLine(); + this._refs.markup += ""; } - return this; + this._refs.suppressPretty = false; + this._refs.emptyNode = false; + this._endLine(); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.doc = function () { - if (this._doc._isFragment) { - var node = this.node; - while (node && node.nodeType !== interfaces_2.NodeType.DocumentFragment) { - node = node.parentNode; - } - /* istanbul ignore next */ - if (node === null) { - throw new Error("Node has no parent node while searching for document fragment ancestor. " + this._debugInfo()); - } - return new XMLBuilderImpl(node); + XMLWriter.prototype.attribute = function (name, value) { + var str = name + "=\"" + value + "\""; + if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && + this._refs.markup.length - this._lengthToLastNewline + 1 + str.length > this._writerOptions.width) { + this._endLine(); + this._beginLine(); + this._refs.markup += this._indent(1) + str; } else { - return new XMLBuilderImpl(this._doc); + this._refs.markup += " " + str; } }; /** @inheritdoc */ - XMLBuilderImpl.prototype.root = function () { - var ele = this._doc.documentElement; - if (!ele) { - throw new Error("Document root element is null. " + this._debugInfo()); + XMLWriter.prototype.text = function (data) { + if (data !== '') { + this._beginLine(); + this._refs.markup += data; + this._endLine(); } - return new XMLBuilderImpl(ele); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.up = function () { - var parent = this._domNode.parentNode; - if (!parent) { - throw new Error("Parent node is null. " + this._debugInfo()); + XMLWriter.prototype.cdata = function (data) { + if (data !== '') { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); } - return new XMLBuilderImpl(parent); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.prev = function () { - var node = this._domNode.previousSibling; - if (!node) { - throw new Error("Previous sibling node is null. " + this._debugInfo()); - } - return new XMLBuilderImpl(node); + XMLWriter.prototype.comment = function (data) { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.next = function () { - var node = this._domNode.nextSibling; - if (!node) { - throw new Error("Next sibling node is null. " + this._debugInfo()); - } - return new XMLBuilderImpl(node); + XMLWriter.prototype.instruction = function (target, data) { + this._beginLine(); + this._refs.markup += ""; + this._endLine(); }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.first = function () { - var node = this._domNode.firstChild; - if (!node) { - throw new Error("First child node is null. " + this._debugInfo()); + /** + * Produces characters to be prepended to a line of string in pretty-print + * mode. + */ + XMLWriter.prototype._beginLine = function () { + if (this._writerOptions.prettyPrint && !this._refs.suppressPretty) { + this._refs.markup += this._indent(this._writerOptions.offset + this.level); } - return new XMLBuilderImpl(node); }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.last = function () { - var node = this._domNode.lastChild; - if (!node) { - throw new Error("Last child node is null. " + this._debugInfo()); + /** + * Produces characters to be appended to a line of string in pretty-print + * mode. + */ + XMLWriter.prototype._endLine = function () { + if (this._writerOptions.prettyPrint && !this._refs.suppressPretty) { + this._refs.markup += this._writerOptions.newline; + this._lengthToLastNewline = this._refs.markup.length; } - return new XMLBuilderImpl(node); }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.each = function (callback, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = this._getFirstDescendantNode(this._domNode, self, recursive); - while (result[0]) { - var nextResult = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); - callback.call(thisArg, new XMLBuilderImpl(result[0]), result[1], result[2]); - result = nextResult; + /** + * Produces an indentation string. + * + * @param level - depth of the tree + */ + XMLWriter.prototype._indent = function (level) { + if (level <= 0) { + return ""; + } + else if (this._indentation[level] !== undefined) { + return this._indentation[level]; + } + else { + var str = this._writerOptions.indent.repeat(level); + this._indentation[level] = str; + return str; } - return this; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.map = function (callback, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = []; - this.each(function (node, index, level) { - return result.push(callback.call(thisArg, node, index, level)); - }, self, recursive); - return result; - }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.reduce = function (callback, initialValue, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var value = initialValue; - this.each(function (node, index, level) { - return value = callback.call(thisArg, value, node, index, level); - }, self, recursive); - return value; }; - /** @inheritdoc */ - XMLBuilderImpl.prototype.find = function (predicate, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = this._getFirstDescendantNode(this._domNode, self, recursive); - while (result[0]) { - var builder = new XMLBuilderImpl(result[0]); - if (predicate.call(thisArg, builder, result[1], result[2])) { - return builder; - } - result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); + return XMLWriter; +}(BaseWriter_1.BaseWriter)); +exports.XMLWriter = XMLWriter; +//# sourceMappingURL=XMLWriter.js.map + +/***/ }), + +/***/ 2444: +/***/ (function(__unused_webpack_module, exports, __nccwpck_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 = __nccwpck_require__(708); +/** + * 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."); } - return undefined; + 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 */ - XMLBuilderImpl.prototype.filter = function (predicate, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = []; - this.each(function (node, index, level) { - if (predicate.call(thisArg, node, index, level)) { - result.push(node); - } - }, self, recursive); - return result; + YAMLCBWriter.prototype.declaration = function (version, encoding, standalone) { + return ""; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.every = function (predicate, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = this._getFirstDescendantNode(this._domNode, self, recursive); - while (result[0]) { - var builder = new XMLBuilderImpl(result[0]); - if (!predicate.call(thisArg, builder, result[1], result[2])) { - return false; - } - result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); - } - return true; + YAMLCBWriter.prototype.docType = function (name, publicId, systemId) { + return ""; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.some = function (predicate, self, recursive, thisArg) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = this._getFirstDescendantNode(this._domNode, self, recursive); - while (result[0]) { - var builder = new XMLBuilderImpl(result[0]); - if (predicate.call(thisArg, builder, result[1], result[2])) { - return true; - } - result = this._getNextDescendantNode(this._domNode, result[0], recursive, result[1], result[2]); - } - return false; + YAMLCBWriter.prototype.comment = function (data) { + // "!": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.comment) + " " + + this._val(data); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.toArray = function (self, recursive) { - if (self === void 0) { self = false; } - if (recursive === void 0) { recursive = false; } - var result = []; - this.each(function (node) { return result.push(node); }, self, recursive); - return result; + YAMLCBWriter.prototype.text = function (data) { + // "#": "hello" + return this._beginLine() + + this._key(this._builderOptions.convert.text) + " " + + this._val(data); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.toString = function (writerOptions) { - writerOptions = writerOptions || {}; - if (writerOptions.format === undefined) { - writerOptions.format = "xml"; - } - return this._serialize(writerOptions); + YAMLCBWriter.prototype.instruction = function (target, data) { + // "?": "target hello" + return this._beginLine() + + this._key(this._builderOptions.convert.ins) + " " + + this._val(data ? target + " " + data : target); }; /** @inheritdoc */ - XMLBuilderImpl.prototype.toObject = function (writerOptions) { - writerOptions = writerOptions || {}; - if (writerOptions.format === undefined) { - writerOptions.format = "object"; + 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; } - return this._serialize(writerOptions); + this.hasData = true; + this._additionalLevel++; + str += this._beginLine(true) + this._key(this._builderOptions.convert.text); + return str; }; /** @inheritdoc */ - XMLBuilderImpl.prototype.end = function (writerOptions) { - writerOptions = writerOptions || {}; - if (writerOptions.format === undefined) { - writerOptions.format = "xml"; + YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { + if (selfClosing) { + return " " + this._val(""); } - return this.doc()._serialize(writerOptions); + return ""; + }; + /** @inheritdoc */ + YAMLCBWriter.prototype.closeTag = function (name) { + this._additionalLevel--; + return ""; }; + /** @inheritdoc */ + YAMLCBWriter.prototype.beginElement = function (name) { }; + /** @inheritdoc */ + YAMLCBWriter.prototype.endElement = function (name) { }; /** - * Gets the next descendant of the given node of the tree rooted at `root` - * in depth-first pre-order. Returns a three-tuple with - * [descendant, descendant_index, descendant_level]. - * - * @param root - root node of the tree - * @param self - whether to visit the current node along with child nodes - * @param recursive - whether to visit all descendant nodes in tree-order or - * only the immediate child nodes + * Produces characters to be prepended to a line of string in pretty-print + * mode. */ - XMLBuilderImpl.prototype._getFirstDescendantNode = function (root, self, recursive) { - if (self) - return [this._domNode, 0, 0]; - else if (recursive) - return this._getNextDescendantNode(root, root, recursive, 0, 0); - else - return [this._domNode.firstChild, 0, 1]; + 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); }; /** - * Gets the next descendant of the given node of the tree rooted at `root` - * in depth-first pre-order. Returns a three-tuple with - * [descendant, descendant_index, descendant_level]. + * Produces an indentation string. * - * @param root - root node of the tree - * @param node - current node - * @param recursive - whether to visit all descendant nodes in tree-order or - * only the immediate child nodes - * @param index - child node index - * @param level - current depth of the XML tree + * @param level - depth of the tree + * @param suppressArray - whether the suppress array marker */ - XMLBuilderImpl.prototype._getNextDescendantNode = function (root, node, recursive, index, level) { - if (recursive) { - // traverse child nodes - if (node.firstChild) - return [node.firstChild, 0, level + 1]; - if (node === root) - return [null, -1, -1]; - // traverse siblings - if (node.nextSibling) - return [node.nextSibling, index + 1, level]; - // traverse parent's next sibling - var parent = node.parentNode; - while (parent && parent !== root) { - if (parent.nextSibling) - return [parent.nextSibling, algorithm_1.tree_index(parent.nextSibling), level - 1]; - parent = parent.parentNode; - level--; - } + YAMLCBWriter.prototype._indent = function (level, suppressArray) { + if (level + this._additionalLevel <= 0) { + return ""; } else { - if (root === node) - return [node.firstChild, 0, level + 1]; - else - return [node.nextSibling, index + 1, level]; + 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; } - return [null, -1, -1]; }; /** - * Converts the node into its string or object representation. - * - * @param options - serialization options + * Produces a YAML key string delimited with double quotes. */ - XMLBuilderImpl.prototype._serialize = function (writerOptions) { - if (writerOptions.format === "xml") { - var writer = new writers_1.XMLWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else if (writerOptions.format === "map") { - var writer = new writers_1.MapWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else if (writerOptions.format === "object") { - var writer = new writers_1.ObjectWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else if (writerOptions.format === "json") { - var writer = new writers_1.JSONWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else if (writerOptions.format === "yaml") { - var writer = new writers_1.YAMLWriter(this._options, writerOptions); - return writer.serialize(this.node); - } - else { - throw new Error("Invalid writer format: " + writerOptions.format + ". " + this._debugInfo()); + 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 + +/***/ }), + +/***/ 6517: +/***/ (function(__unused_webpack_module, exports, __nccwpck_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."); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +var ObjectWriter_1 = __nccwpck_require__(243); +var util_1 = __nccwpck_require__(6195); +var BaseWriter_1 = __nccwpck_require__(7644); +/** + * Serializes XML nodes into a YAML string. + */ +var YAMLWriter = /** @class */ (function (_super) { + __extends(YAMLWriter, _super); /** - * Extracts a namespace and name from the given string. + * Initializes a new instance of `YAMLWriter`. * - * @param namespace - namespace - * @param name - a string containing both a name and namespace separated by an - * `'@'` character - * @param ele - `true` if this is an element namespace; otherwise `false` + * @param builderOptions - XML builder options + * @param writerOptions - serialization options */ - XMLBuilderImpl.prototype._extractNamespace = function (namespace, name, ele) { - // extract from name - var atIndex = name.indexOf("@"); - if (atIndex > 0) { - if (namespace === undefined) - namespace = name.slice(atIndex + 1); - name = name.slice(0, atIndex); + 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 (namespace === undefined) { - // look-up default namespace - namespace = (ele ? this._options.defaultNamespace.ele : this._options.defaultNamespace.att); + if (_this._writerOptions.offset < 0) { + throw new Error("YAML offset should be zero or a positive number."); } - else if (namespace !== null && namespace[0] === "@") { - // look-up namespace aliases - var alias = namespace.slice(1); - namespace = this._options.namespaceAlias[alias]; - if (namespace === undefined) { - throw new Error("Namespace alias `" + alias + "` is not defined. " + this._debugInfo()); - } + 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 [namespace, name]; + return markup; }; /** - * Updates the element's namespace. + * Produces an XML serialization of the given object. * - * @param ns - new namespace + * @param obj - object to serialize + * @param options - serialization options + * @param level - depth of the XML tree + * @param indentLeaf - indents leaf nodes */ - XMLBuilderImpl.prototype._updateNamespace = function (ns) { - var e_2, _a, e_3, _b; - var ele = this._domNode; - if (util_2.Guard.isElementNode(ele) && ns !== null && ele.namespaceURI !== ns) { - var _c = __read(algorithm_1.namespace_extractQName(ele.prefix ? ele.prefix + ':' + ele.localName : ele.localName), 2), elePrefix = _c[0], eleLocalName = _c[1]; - // re-create the element node if its namespace changed - // we can't simply change the namespaceURI since its read-only - var newEle = algorithm_1.create_element(this._doc, eleLocalName, ns, elePrefix); + 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 _d = __values(ele.attributes), _e = _d.next(); !_e.done; _e = _d.next()) { - var attr = _e.value; - var attrQName = attr.prefix ? attr.prefix + ':' + attr.localName : attr.localName; - var _f = __read(algorithm_1.namespace_extractQName(attrQName), 1), attrPrefix = _f[0]; - var newAttrNS = attr.namespaceURI; - if (newAttrNS === null && attrPrefix !== null) { - newAttrNS = ele.lookupNamespaceURI(attrPrefix); + 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); } - if (newAttrNS === null) { - newEle.setAttribute(attrQName, attr.value); + else if (util_1.isEmpty(val)) { + markup += '""' + this._endLine(options); } else { - newEle.setAttributeNS(newAttrNS, attrQName, attr.value); + markup += this._convertObject(val, options, level, true); } } } - catch (e_2_1) { e_2 = { error: e_2_1 }; } + catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { - if (_e && !_e.done && (_a = _d.return)) _a.call(_d); + if (obj_1_1 && !obj_1_1.done && (_a = obj_1.return)) _a.call(obj_1); } - finally { if (e_2) throw e_2.error; } - } - // replace the new node in parent node - var parent = ele.parentNode; - /* istanbul ignore next */ - if (parent === null) { - throw new Error("Parent node is null." + this._debugInfo()); + finally { if (e_1) throw e_1.error; } } - parent.replaceChild(newEle, ele); - this._domNode = newEle; - try { - // check child nodes - for (var _g = __values(ele.childNodes), _h = _g.next(); !_h.done; _h = _g.next()) { - var childNode = _h.value; - var newChildNode = childNode.cloneNode(true); - newEle.appendChild(newChildNode); - if (util_2.Guard.isElementNode(newChildNode)) { - var _j = __read(algorithm_1.namespace_extractQName(newChildNode.prefix ? newChildNode.prefix + ':' + newChildNode.localName : newChildNode.localName), 1), newChildNodePrefix = _j[0]; - var newChildNodeNS = newEle.lookupNamespaceURI(newChildNodePrefix); - new XMLBuilderImpl(newChildNode)._updateNamespace(newChildNodeNS); - } + } + else /* if (isObject(obj)) */ { + util_1.forEachObject(obj, function (key, val) { + if (suppressIndent) { + markup += _this._key(key); + suppressIndent = false; } - } - catch (e_3_1) { e_3 = { error: e_3_1 }; } - finally { - try { - if (_h && !_h.done && (_b = _g.return)) _b.call(_g); + else { + markup += _this._beginLine(options, level) + _this._key(key); } - finally { if (e_3) throw e_3.error; } - } + 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; }; - Object.defineProperty(XMLBuilderImpl.prototype, "_doc", { - /** - * Returns the document owning this node. - */ - get: function () { - var node = this.node; - if (util_2.Guard.isDocumentNode(node)) { - return node; - } - else { - var docNode = node.ownerDocument; - /* istanbul ignore next */ - if (!docNode) - throw new Error("Owner document is null. " + this._debugInfo()); - return docNode; - } - }, - enumerable: true, - configurable: true - }); /** - * Returns debug information for this node. + * Produces characters to be prepended to a line of string in pretty-print + * mode. * - * @param name - node name + * @param options - serialization options + * @param level - current depth of the XML tree + * @param isArray - whether this line is an array item */ - XMLBuilderImpl.prototype._debugInfo = function (name) { - var node = this.node; - var parentNode = node.parentNode; - name = name || node.nodeName; - var parentName = parentNode ? parentNode.nodeName : ''; - if (!parentName) { - return "node: <" + name + ">"; + 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 "node: <" + name + ">, parent: <" + parentName + ">"; + return chars; } }; - Object.defineProperty(XMLBuilderImpl.prototype, "_options", { - /** - * Gets or sets builder options. - */ - get: function () { - var doc = this._doc; - /* istanbul ignore next */ - if (doc._xmlBuilderOptions === undefined) { - throw new Error("Builder options is not set."); - } - return doc._xmlBuilderOptions; - }, - set: function (value) { - var doc = this._doc; - doc._xmlBuilderOptions = value; - }, - enumerable: true, - configurable: true - }); - return XMLBuilderImpl; -}()); -exports.XMLBuilderImpl = XMLBuilderImpl; -//# sourceMappingURL=XMLBuilderImpl.js.map + /** + * 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 /***/ }), -/***/ 770: +/***/ 7476: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -var dom_1 = __nccwpck_require__(4646); -var dom_2 = __nccwpck_require__(633); -var util_1 = __nccwpck_require__(6195); -dom_2.dom.setFeatures(false); -/** - * Creates an XML document without any child nodes. - */ -function createDocument() { - var impl = new dom_1.DOMImplementation(); - var doc = impl.createDocument(null, 'root', null); - /* istanbul ignore else */ - if (doc.documentElement) { - doc.removeChild(doc.documentElement); - } - return doc; -} -exports.createDocument = createDocument; -/** - * Sanitizes input strings with user supplied replacement characters. - * - * @param str - input string - * @param replacement - replacement character or function - */ -function sanitizeInput(str, replacement) { - if (str == null) { - return str; - } - else if (replacement === undefined) { - return str + ""; - } - else { - var result = ""; - str = str + ""; - for (var i = 0; i < str.length; i++) { - var n = str.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)) { - // valid character - not surrogate pair - result += str.charAt(i); - } - else if (n >= 0xD800 && n <= 0xDBFF && i < str.length - 1) { - var n2 = str.charCodeAt(i + 1); - if (n2 >= 0xDC00 && n2 <= 0xDFFF) { - // valid surrogate pair - n = (n - 0xD800) * 0x400 + n2 - 0xDC00 + 0x10000; - result += String.fromCodePoint(n); - i++; - } - else { - // invalid lone surrogate - result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); - } - } - else { - // invalid character - result += util_1.isString(replacement) ? replacement : replacement(str.charAt(i), i, str); - } - } - return result; - } -} -exports.sanitizeInput = sanitizeInput; -//# sourceMappingURL=dom.js.map +var MapWriter_1 = __nccwpck_require__(1397); +exports.MapWriter = MapWriter_1.MapWriter; +var XMLWriter_1 = __nccwpck_require__(9606); +exports.XMLWriter = XMLWriter_1.XMLWriter; +var ObjectWriter_1 = __nccwpck_require__(243); +exports.ObjectWriter = ObjectWriter_1.ObjectWriter; +var JSONWriter_1 = __nccwpck_require__(7510); +exports.JSONWriter = JSONWriter_1.JSONWriter; +var YAMLWriter_1 = __nccwpck_require__(6517); +exports.YAMLWriter = YAMLWriter_1.YAMLWriter; +//# sourceMappingURL=index.js.map /***/ }), -/***/ 4260: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 2839: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + module.exports = { + Disconnected: 1, + Preceding: 2, + Following: 4, + Contains: 8, + ContainedBy: 16, + ImplementationSpecific: 32 + }; + +}).call(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var XMLBuilderImpl_1 = __nccwpck_require__(8248); -exports.XMLBuilderImpl = XMLBuilderImpl_1.XMLBuilderImpl; -var XMLBuilderCBImpl_1 = __nccwpck_require__(1438); -exports.XMLBuilderCBImpl = XMLBuilderCBImpl_1.XMLBuilderCBImpl; -var BuilderFunctions_1 = __nccwpck_require__(5696); -exports.builder = BuilderFunctions_1.builder; -exports.create = BuilderFunctions_1.create; -exports.fragment = BuilderFunctions_1.fragment; -exports.convert = BuilderFunctions_1.convert; -var BuilderFunctionsCB_1 = __nccwpck_require__(268); -exports.createCB = BuilderFunctionsCB_1.createCB; -exports.fragmentCB = BuilderFunctionsCB_1.fragmentCB; -//# sourceMappingURL=index.js.map /***/ }), -/***/ 151: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 9267: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + module.exports = { + Element: 1, + Attribute: 2, + Text: 3, + CData: 4, + EntityReference: 5, + EntityDeclaration: 6, + ProcessingInstruction: 7, + Comment: 8, + Document: 9, + DocType: 10, + DocumentFragment: 11, + NotationDeclaration: 12, + Declaration: 201, + Raw: 202, + AttributeDeclaration: 203, + ElementDeclaration: 204, + Dummy: 205 + }; + +}).call(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var builder_1 = __nccwpck_require__(4260); -exports.builder = builder_1.builder; -exports.create = builder_1.create; -exports.fragment = builder_1.fragment; -exports.convert = builder_1.convert; -exports.createCB = builder_1.createCB; -exports.fragmentCB = builder_1.fragmentCB; -//# sourceMappingURL=index.js.map /***/ }), -/***/ 6417: -/***/ ((__unused_webpack_module, exports) => { +/***/ 8229: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject, + slice = [].slice, + hasProp = {}.hasOwnProperty; -Object.defineProperty(exports, "__esModule", ({ value: true })); -/** - * Defines default values for builder options. - */ -exports.DefaultBuilderOptions = { - version: "1.0", - encoding: undefined, - standalone: undefined, - keepNullNodes: false, - keepNullAttributes: false, - ignoreConverters: false, - convert: { - att: "@", - ins: "?", - text: "#", - cdata: "$", - comment: "!" - }, - defaultNamespace: { - ele: undefined, - att: undefined - }, - namespaceAlias: { - html: "http://www.w3.org/1999/xhtml", - xml: "http://www.w3.org/XML/1998/namespace", - xmlns: "http://www.w3.org/2000/xmlns/", - mathml: "http://www.w3.org/1998/Math/MathML", - svg: "http://www.w3.org/2000/svg", - xlink: "http://www.w3.org/1999/xlink" - }, - invalidCharReplacement: undefined, - parser: undefined -}; -/** - * Contains keys of `XMLBuilderOptions`. - */ -exports.XMLBuilderOptionKeys = new Set(Object.keys(exports.DefaultBuilderOptions)); -/** - * Defines default values for builder options. - */ -exports.DefaultXMLBuilderCBOptions = { - format: "xml", - wellFormed: false, - prettyPrint: false, - indent: " ", - newline: "\n", - offset: 0, - width: 0, - allowEmptyTags: false, - spaceBeforeSlash: false, - keepNullNodes: false, - keepNullAttributes: false, - ignoreConverters: false, - convert: { - att: "@", - ins: "?", - text: "#", - cdata: "$", - comment: "!" - }, - defaultNamespace: { - ele: undefined, - att: undefined - }, - namespaceAlias: { - html: "http://www.w3.org/1999/xhtml", - xml: "http://www.w3.org/XML/1998/namespace", - xmlns: "http://www.w3.org/2000/xmlns/", - mathml: "http://www.w3.org/1998/Math/MathML", - svg: "http://www.w3.org/2000/svg", - xlink: "http://www.w3.org/1999/xlink" + assign = function() { + var i, key, len, source, sources, target; + target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : []; + if (isFunction(Object.assign)) { + Object.assign.apply(null, arguments); + } else { + for (i = 0, len = sources.length; i < len; i++) { + source = sources[i]; + if (source != null) { + for (key in source) { + if (!hasProp.call(source, key)) continue; + target[key] = source[key]; + } + } + } } -}; -//# sourceMappingURL=interfaces.js.map - -/***/ }), + return target; + }; -/***/ 3396: -/***/ ((__unused_webpack_module, exports) => { + isFunction = function(val) { + return !!val && Object.prototype.toString.call(val) === '[object Function]'; + }; -"use strict"; + isObject = function(val) { + var ref; + return !!val && ((ref = typeof val) === 'function' || ref === 'object'); + }; -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); - } + isArray = function(val) { + if (isFunction(Array.isArray)) { + return Array.isArray(val); + } else { + return Object.prototype.toString.call(val) === '[object Array]'; } - 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 - -/***/ }), + }; -/***/ 3518: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + isEmpty = function(val) { + var key; + if (isArray(val)) { + return !val.length; + } else { + for (key in val) { + if (!hasProp.call(val, key)) continue; + return false; + } + return true; + } + }; -"use strict"; + isPlainObject = function(val) { + var ctor, proto; + return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object)); + }; -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 ObjectReader_1 = __nccwpck_require__(768); -var BaseReader_1 = __nccwpck_require__(3396); -/** - * Parses XML nodes from a JSON string. - */ -var JSONReader = /** @class */ (function (_super) { - __extends(JSONReader, _super); - function JSONReader() { - return _super !== null && _super.apply(this, arguments) || this; + getValue = function(obj) { + if (isFunction(obj.valueOf)) { + return obj.valueOf(); + } else { + return obj; } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param str - JSON string to parse - */ - JSONReader.prototype._parse = function (node, str) { - return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, JSON.parse(str)); - }; - return JSONReader; -}(BaseReader_1.BaseReader)); -exports.JSONReader = JSONReader; -//# sourceMappingURL=JSONReader.js.map + }; -/***/ }), + module.exports.assign = assign; -/***/ 768: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + module.exports.isFunction = isFunction; -"use strict"; + module.exports.isObject = isObject; + + module.exports.isArray = isArray; + + module.exports.isEmpty = isEmpty; + + module.exports.isPlainObject = isPlainObject; + + module.exports.getValue = getValue; + +}).call(this); -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 util_1 = __nccwpck_require__(6195); -var BaseReader_1 = __nccwpck_require__(3396); -var dom_1 = __nccwpck_require__(770); -/** - * Parses XML nodes from objects and arrays. - * ES6 maps and sets are also supoorted. - */ -var ObjectReader = /** @class */ (function (_super) { - __extends(ObjectReader, _super); - function ObjectReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param obj - object to parse - */ - ObjectReader.prototype._parse = function (node, obj) { - var _this = this; - var options = this._builderOptions; - // sanitizes input characters - var invalidCharReplacement = options.invalidCharReplacement; - var s = function (str) { - return dom_1.sanitizeInput(str, invalidCharReplacement); - }; - var lastChild = null; - if (util_1.isFunction(obj)) { - // evaluate if function - lastChild = this.parse(node, obj.apply(this)); - } - else if (util_1.isArray(obj) || util_1.isSet(obj)) { - util_1.forEachArray(obj, function (item) { return lastChild = _this.parse(node, item); }, this); - } - else /* if (isMap(obj) || isObject(obj)) */ { - // expand if object - util_1.forEachObject(obj, function (key, val) { - if (util_1.isFunction(val)) { - // evaluate if function - val = val.apply(_this); - } - if (!options.ignoreConverters && key.indexOf(options.convert.att) === 0) { - // assign attributes - if (key === options.convert.att) { - if (util_1.isArray(val) || util_1.isSet(val)) { - throw new Error("Invalid attribute: " + val.toString() + ". " + node._debugInfo()); - } - else /* if (isMap(val) || isObject(val)) */ { - util_1.forEachObject(val, function (attrKey, attrVal) { - lastChild = _this.attribute(node, undefined, s(attrKey), s(attrVal)) || lastChild; - }); - } - } - else { - lastChild = _this.attribute(node, undefined, s(key.substr(options.convert.att.length)), s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.text) === 0) { - // text node - if (util_1.isMap(val) || util_1.isObject(val)) { - // if the key is #text expand child nodes under this node to support mixed content - lastChild = _this.parse(node, val); - } - else { - lastChild = _this.text(node, s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.cdata) === 0) { - // cdata node - if (util_1.isArray(val) || util_1.isSet(val)) { - util_1.forEachArray(val, function (item) { return lastChild = _this.cdata(node, s(item)) || lastChild; }, _this); - } - else { - lastChild = _this.cdata(node, s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.comment) === 0) { - // comment node - if (util_1.isArray(val) || util_1.isSet(val)) { - util_1.forEachArray(val, function (item) { return lastChild = _this.comment(node, s(item)) || lastChild; }, _this); - } - else { - lastChild = _this.comment(node, s(val)) || lastChild; - } - } - else if (!options.ignoreConverters && key.indexOf(options.convert.ins) === 0) { - // processing instruction - if (util_1.isString(val)) { - var insIndex = val.indexOf(' '); - var insTarget = (insIndex === -1 ? val : val.substr(0, insIndex)); - var insValue = (insIndex === -1 ? '' : val.substr(insIndex + 1)); - lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; - } - else if (util_1.isArray(val) || util_1.isSet(val)) { - util_1.forEachArray(val, function (item) { - var insIndex = item.indexOf(' '); - var insTarget = (insIndex === -1 ? item : item.substr(0, insIndex)); - var insValue = (insIndex === -1 ? '' : item.substr(insIndex + 1)); - lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; - }, _this); - } - else /* if (isMap(target) || isObject(target)) */ { - util_1.forEachObject(val, function (insTarget, insValue) { return lastChild = _this.instruction(node, s(insTarget), s(insValue)) || lastChild; }, _this); - } - } - else if ((util_1.isArray(val) || util_1.isSet(val)) && util_1.isEmpty(val)) { - // skip empty arrays - } - else if ((util_1.isMap(val) || util_1.isObject(val)) && util_1.isEmpty(val)) { - // empty objects produce one node - lastChild = _this.element(node, undefined, s(key)) || lastChild; - } - else if (!options.keepNullNodes && (val == null)) { - // skip null and undefined nodes - } - else if (util_1.isArray(val) || util_1.isSet(val)) { - // expand list by creating child nodes - util_1.forEachArray(val, function (item) { - var childNode = {}; - childNode[key] = item; - lastChild = _this.parse(node, childNode); - }, _this); - } - else if (util_1.isMap(val) || util_1.isObject(val)) { - // create a parent node - var parent = _this.element(node, undefined, key); - if (parent) { - lastChild = parent; - // expand child nodes under parent - _this.parse(parent, val); - } - } - else if (val != null && val !== '') { - // leaf element node with a single text node - var parent = _this.element(node, undefined, key); - if (parent) { - lastChild = parent; - _this.text(parent, s(val)); - } - } - else { - // leaf element node - lastChild = _this.element(node, undefined, s(key)) || lastChild; - } - }, this); - } - return lastChild || node; - }; - return ObjectReader; -}(BaseReader_1.BaseReader)); -exports.ObjectReader = ObjectReader; -//# sourceMappingURL=ObjectReader.js.map /***/ }), -/***/ 5044: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 9766: +/***/ (function(module) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + module.exports = { + None: 0, + OpenTag: 1, + InsideTag: 2, + CloseTag: 3 + }; -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 __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; } +}).call(this); + + +/***/ }), + +/***/ 8376: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLAttribute, XMLNode; + + NodeType = __nccwpck_require__(9267); + + XMLNode = __nccwpck_require__(7608); + + module.exports = XMLAttribute = (function() { + function XMLAttribute(parent, name, value) { + this.parent = parent; + if (this.parent) { + this.options = this.parent.options; + this.stringify = this.parent.stringify; + } + if (name == null) { + throw new Error("Missing attribute name. " + this.debugInfo(name)); + } + this.name = this.stringify.name(name); + this.value = this.stringify.attValue(value); + this.type = NodeType.Attribute; + this.isId = false; + this.schemaTypeInfo = null; } - 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 XMLStringLexer_1 = __nccwpck_require__(7061); -var interfaces_1 = __nccwpck_require__(7707); -var infra_1 = __nccwpck_require__(4251); -var algorithm_1 = __nccwpck_require__(61); -var dom_1 = __nccwpck_require__(770); -var BaseReader_1 = __nccwpck_require__(3396); -/** - * Parses XML nodes from an XML document string. - */ -var XMLReader = /** @class */ (function (_super) { - __extends(XMLReader, _super); - function XMLReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param str - XML document string to parse - */ - XMLReader.prototype._parse = function (node, str) { - var e_1, _a, e_2, _b; - var lexer = new XMLStringLexer_1.XMLStringLexer(str, { skipWhitespaceOnlyText: true }); - // sanitizes input characters - var invalidCharReplacement = this._builderOptions.invalidCharReplacement; - var s = function (str) { - return dom_1.sanitizeInput(str, invalidCharReplacement); - }; - var context = node; - var token = lexer.nextToken(); - while (token.type !== interfaces_1.TokenType.EOF) { - switch (token.type) { - case interfaces_1.TokenType.Declaration: - var declaration = token; - var version = s(declaration.version); - if (version !== "1.0") { - throw new Error("Invalid xml version: " + version); - } - var builderOptions = { - version: version - }; - if (declaration.encoding) { - builderOptions.encoding = s(declaration.encoding); - } - if (declaration.standalone) { - builderOptions.standalone = (s(declaration.standalone) === "yes"); - } - context.set(builderOptions); - break; - case interfaces_1.TokenType.DocType: - var doctype = token; - context = this.docType(context, s(doctype.name), s(doctype.pubId), s(doctype.sysId)) || context; - break; - case interfaces_1.TokenType.CDATA: - var cdata = token; - context = this.cdata(context, s(cdata.data)) || context; - break; - case interfaces_1.TokenType.Comment: - var comment = token; - context = this.comment(context, s(comment.data)) || context; - break; - case interfaces_1.TokenType.PI: - var pi = token; - context = this.instruction(context, s(pi.target), s(pi.data)) || context; - break; - case interfaces_1.TokenType.Text: - var text = token; - context = this.text(context, s(text.data)) || context; - break; - case interfaces_1.TokenType.Element: - var element = token; - var elementName = s(element.name); - // inherit namespace from parent - var _c = __read(algorithm_1.namespace_extractQName(elementName), 1), prefix = _c[0]; - var namespace = context.node.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]; - attName = s(attName); - attValue = s(attValue); - 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 ? - this.element(context, namespace, elementName) : - this.element(context, undefined, elementName)); - if (elementNode === undefined) - break; - try { - // assign attributes - 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]; - attName = s(attName); - attValue = s(attValue); - 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.node.lookupNamespaceURI(attPrefix); - if (attNamespace !== null && elementNode.node.isDefaultNamespace(attNamespace)) { - attNamespace = null; - } - else if (attNamespace === null && attPrefix !== null) { - attNamespace = nsDeclarations[attPrefix] || null; - } - } - if (attNamespace !== null) - this.attribute(elementNode, attNamespace, attName, attValue); - else - this.attribute(elementNode, undefined, 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: - /* istanbul ignore else */ - if (context.node.parentNode) { - context = context.up(); - } - break; - } - token = lexer.nextToken(); - } - return context; - }; - return XMLReader; -}(BaseReader_1.BaseReader)); -exports.XMLReader = XMLReader; -//# sourceMappingURL=XMLReader.js.map - -/***/ }), -/***/ 2475: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + Object.defineProperty(XMLAttribute.prototype, 'nodeType', { + get: function() { + return this.type; + } + }); -"use strict"; + Object.defineProperty(XMLAttribute.prototype, 'ownerElement', { + get: function() { + return this.parent; + } + }); -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 ObjectReader_1 = __nccwpck_require__(768); -var BaseReader_1 = __nccwpck_require__(3396); -var js_yaml_1 = __nccwpck_require__(1917); -/** - * Parses XML nodes from a YAML string. - */ -var YAMLReader = /** @class */ (function (_super) { - __extends(YAMLReader, _super); - function YAMLReader() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * Parses the given document representation. - * - * @param node - node receive parsed XML nodes - * @param str - YAML string to parse - */ - YAMLReader.prototype._parse = function (node, str) { - var result = js_yaml_1.safeLoad(str); - /* istanbul ignore next */ - if (result === undefined) { - throw new Error("Unable to parse YAML document."); - } - return new ObjectReader_1.ObjectReader(this._builderOptions).parse(node, result); - }; - return YAMLReader; -}(BaseReader_1.BaseReader)); -exports.YAMLReader = YAMLReader; -//# sourceMappingURL=YAMLReader.js.map + Object.defineProperty(XMLAttribute.prototype, 'textContent', { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ''; + } + }); -/***/ }), + Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', { + get: function() { + return ''; + } + }); -/***/ 560: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + Object.defineProperty(XMLAttribute.prototype, 'prefix', { + get: function() { + return ''; + } + }); -"use strict"; + Object.defineProperty(XMLAttribute.prototype, 'localName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLAttribute.prototype, 'specified', { + get: function() { + return true; + } + }); + + XMLAttribute.prototype.clone = function() { + return Object.create(this); + }; + + XMLAttribute.prototype.toString = function(options) { + return this.options.writer.attribute(this, this.options.writer.filterOptions(options)); + }; + + XMLAttribute.prototype.debugInfo = function(name) { + name = name || this.name; + if (name == null) { + return "parent: <" + this.parent.name + ">"; + } else { + return "attribute: {" + name + "}, parent: <" + this.parent.name + ">"; + } + }; + + XMLAttribute.prototype.isEqualNode = function(node) { + if (node.namespaceURI !== this.namespaceURI) { + return false; + } + if (node.prefix !== this.prefix) { + return false; + } + if (node.localName !== this.localName) { + return false; + } + if (node.value !== this.value) { + return false; + } + return true; + }; + + return XMLAttribute; + + })(); + +}).call(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var XMLReader_1 = __nccwpck_require__(5044); -exports.XMLReader = XMLReader_1.XMLReader; -var ObjectReader_1 = __nccwpck_require__(768); -exports.ObjectReader = ObjectReader_1.ObjectReader; -var JSONReader_1 = __nccwpck_require__(3518); -exports.JSONReader = JSONReader_1.JSONReader; -var YAMLReader_1 = __nccwpck_require__(2475); -exports.YAMLReader = YAMLReader_1.YAMLReader; -//# sourceMappingURL=index.js.map /***/ }), -/***/ 708: -/***/ ((__unused_webpack_module, exports) => { +/***/ 333: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLCData, XMLCharacterData, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; -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; + NodeType = __nccwpck_require__(9267); + + XMLCharacterData = __nccwpck_require__(7709); + + module.exports = XMLCData = (function(superClass) { + extend(XMLCData, superClass); + + function XMLCData(parent, text) { + XMLCData.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing CDATA text. " + this.debugInfo()); + } + this.name = "#cdata-section"; + this.type = NodeType.CData; + this.value = this.stringify.cdata(text); } - return BaseCBWriter; -}()); -exports.BaseCBWriter = BaseCBWriter; -//# sourceMappingURL=BaseCBWriter.js.map + + XMLCData.prototype.clone = function() { + return Object.create(this); + }; + + XMLCData.prototype.toString = function(options) { + return this.options.writer.cdata(this, this.options.writer.filterOptions(options)); + }; + + return XMLCData; + + })(XMLCharacterData); + +}).call(this); + /***/ }), -/***/ 7644: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 7709: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLCharacterData, XMLNode, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; -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); + XMLNode = __nccwpck_require__(7608); + + module.exports = XMLCharacterData = (function(superClass) { + extend(XMLCharacterData, superClass); + + function XMLCharacterData(parent) { + XMLCharacterData.__super__.constructor.call(this, parent); + this.value = ''; } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } + + Object.defineProperty(XMLCharacterData.prototype, 'data', { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ''; + } + }); + + Object.defineProperty(XMLCharacterData.prototype, 'length', { + get: function() { + return this.value.length; + } + }); + + Object.defineProperty(XMLCharacterData.prototype, 'textContent', { + get: function() { + return this.value; + }, + set: function(value) { + return this.value = value || ''; + } + }); + + XMLCharacterData.prototype.clone = function() { + return Object.create(this); + }; + + XMLCharacterData.prototype.substringData = function(offset, count) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.appendData = function(arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.insertData = function(offset, arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.deleteData = function(offset, count) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.replaceData = function(offset, count, arg) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLCharacterData.prototype.isEqualNode = function(node) { + if (!XMLCharacterData.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.data !== this.data) { + return false; + } + return true; + }; + + return XMLCharacterData; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 4407: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLCharacterData, XMLComment, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + NodeType = __nccwpck_require__(9267); + + XMLCharacterData = __nccwpck_require__(7709); + + module.exports = XMLComment = (function(superClass) { + extend(XMLComment, superClass); + + function XMLComment(parent, text) { + XMLComment.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing comment text. " + this.debugInfo()); + } + this.name = "#comment"; + this.type = NodeType.Comment; + this.value = this.stringify.comment(text); } - 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 = __nccwpck_require__(7305); -var LocalNameSet_1 = __nccwpck_require__(9049); -var NamespacePrefixMap_1 = __nccwpck_require__(283); -var infra_1 = __nccwpck_require__(4251); -var algorithm_1 = __nccwpck_require__(61); -/** - * Pre-serializes XML nodes. - */ -var BaseWriter = /** @class */ (function () { - /** - * Initializes a new instance of `BaseWriter`. - * - * @param builderOptions - XML builder options - */ - function BaseWriter(builderOptions) { - /** - * Gets the current depth of the XML tree. - */ - this.level = 0; - this._builderOptions = builderOptions; + + XMLComment.prototype.clone = function() { + return Object.create(this); + }; + + XMLComment.prototype.toString = function(options) { + return this.options.writer.comment(this, this.options.writer.filterOptions(options)); + }; + + return XMLComment; + + })(XMLCharacterData); + +}).call(this); + + +/***/ }), + +/***/ 7465: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMConfiguration, XMLDOMErrorHandler, XMLDOMStringList; + + XMLDOMErrorHandler = __nccwpck_require__(6744); + + XMLDOMStringList = __nccwpck_require__(7028); + + module.exports = XMLDOMConfiguration = (function() { + function XMLDOMConfiguration() { + var clonedSelf; + this.defaultParams = { + "canonical-form": false, + "cdata-sections": false, + "comments": false, + "datatype-normalization": false, + "element-content-whitespace": true, + "entities": true, + "error-handler": new XMLDOMErrorHandler(), + "infoset": true, + "validate-if-schema": false, + "namespaces": true, + "namespace-declarations": true, + "normalize-characters": false, + "schema-location": '', + "schema-type": '', + "split-cdata-sections": true, + "validate": false, + "well-formed": true + }; + this.params = clonedSelf = Object.create(this.defaultParams); } - /** - * 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; } - } + + Object.defineProperty(XMLDOMConfiguration.prototype, 'parameterNames', { + get: function() { + return new XMLDOMStringList(Object.keys(this.defaultParams)); + } + }); + + XMLDOMConfiguration.prototype.getParameter = function(name) { + if (this.params.hasOwnProperty(name)) { + return this.params[name]; + } else { + return null; + } }; - /** - * 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); - } + + XMLDOMConfiguration.prototype.canSetParameter = function(name, value) { + return true; }; - /** - * 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); - } + + XMLDOMConfiguration.prototype.setParameter = function(name, value) { + if (value != null) { + return this.params[name] = value; + } else { + return delete this.params[name]; + } }; - /** - * 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); - } + + return XMLDOMConfiguration; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 6744: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMErrorHandler; + + module.exports = XMLDOMErrorHandler = (function() { + function XMLDOMErrorHandler() {} + + XMLDOMErrorHandler.prototype.handleError = function(error) { + throw new Error(error); }; - /** - * 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 - */ - 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) { - /** - * 11.1. If local default namespace is not null, then set ignore - * namespace definition attribute to true. - */ - if (localDefaultNamespace !== null) { - ignoreNamespaceDefinitionAttribute = 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. - */ - 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 { - /** - * 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)."); - } - /** - * 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; - /** - * 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); - } - } - /** - * 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_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); - } - finally { if (e_2) throw e_2.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); + + return XMLDOMErrorHandler; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 8310: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMImplementation; + + module.exports = XMLDOMImplementation = (function() { + function XMLDOMImplementation() {} + + XMLDOMImplementation.prototype.hasFeature = function(feature, version) { + return true; }; - /** - * 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; - } - 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--; - } - } - 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; } - } - /** - * 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); + + XMLDOMImplementation.prototype.createDocumentType = function(qualifiedName, publicId, systemId) { + throw new Error("This DOM method is not implemented."); }; - /** - * 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)."); - } - 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; } - } + + XMLDOMImplementation.prototype.createDocument = function(namespaceURI, qualifiedName, doctype) { + throw new Error("This DOM method is not implemented."); }; - /** - * 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)."); - } - 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; } - } + + XMLDOMImplementation.prototype.createHTMLDocument = function(title) { + throw new Error("This DOM method is not implemented."); }; - /** - * 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) { - /** - * 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)."); - } - /** - * Otherwise, return the concatenation of "". - */ - this.comment(node.data); + + XMLDOMImplementation.prototype.getFeature = function(feature, version) { + throw new Error("This DOM method is not implemented."); }; - /** - * 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 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 (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); + + return XMLDOMImplementation; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 7028: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLDOMStringList; + + module.exports = XMLDOMStringList = (function() { + function XMLDOMStringList(arr) { + this.arr = arr || []; + } + + Object.defineProperty(XMLDOMStringList.prototype, 'length', { + get: function() { + return this.arr.length; + } + }); + + XMLDOMStringList.prototype.item = function(index) { + return this.arr[index] || 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; - 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); - } + + XMLDOMStringList.prototype.contains = function(str) { + return this.arr.indexOf(str) !== -1; + }; + + return XMLDOMStringList; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 1015: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLDTDAttList, XMLNode, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDTDAttList = (function(superClass) { + extend(XMLDTDAttList, superClass); + + function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) { + XMLDTDAttList.__super__.constructor.call(this, parent); + if (elementName == null) { + throw new Error("Missing DTD element name. " + this.debugInfo()); + } + if (attributeName == null) { + throw new Error("Missing DTD attribute name. " + this.debugInfo(elementName)); + } + if (!attributeType) { + throw new Error("Missing DTD attribute type. " + this.debugInfo(elementName)); + } + if (!defaultValueType) { + throw new Error("Missing DTD attribute default. " + this.debugInfo(elementName)); + } + if (defaultValueType.indexOf('#') !== 0) { + defaultValueType = '#' + defaultValueType; + } + if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) { + throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. " + this.debugInfo(elementName)); + } + if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) { + throw new Error("Default value only applies to #FIXED or #DEFAULT. " + this.debugInfo(elementName)); + } + this.elementName = this.stringify.name(elementName); + this.type = NodeType.AttributeDeclaration; + this.attributeName = this.stringify.name(attributeName); + this.attributeType = this.stringify.dtdAttType(attributeType); + if (defaultValue) { + this.defaultValue = this.stringify.dtdAttDefault(defaultValue); + } + this.defaultValueType = defaultValueType; + } + + XMLDTDAttList.prototype.toString = function(options) { + return this.options.writer.dtdAttList(this, this.options.writer.filterOptions(options)); + }; + + return XMLDTDAttList; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 2421: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLDTDElement, XMLNode, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDTDElement = (function(superClass) { + extend(XMLDTDElement, superClass); + + function XMLDTDElement(parent, name, value) { + XMLDTDElement.__super__.constructor.call(this, parent); + if (name == null) { + throw new Error("Missing DTD element name. " + this.debugInfo()); + } + if (!value) { + value = '(#PCDATA)'; + } + if (Array.isArray(value)) { + value = '(' + value.join(',') + ')'; + } + this.name = this.stringify.name(name); + this.type = NodeType.ElementDeclaration; + this.value = this.stringify.dtdElementValue(value); + } + + XMLDTDElement.prototype.toString = function(options) { + return this.options.writer.dtdElement(this, this.options.writer.filterOptions(options)); + }; + + return XMLDTDElement; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 53: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLDTDEntity, XMLNode, isObject, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + isObject = (__nccwpck_require__(8229).isObject); + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDTDEntity = (function(superClass) { + extend(XMLDTDEntity, superClass); + + function XMLDTDEntity(parent, pe, name, value) { + XMLDTDEntity.__super__.constructor.call(this, parent); + if (name == null) { + throw new Error("Missing DTD entity name. " + this.debugInfo(name)); + } + if (value == null) { + throw new Error("Missing DTD entity value. " + this.debugInfo(name)); + } + this.pe = !!pe; + this.name = this.stringify.name(name); + this.type = NodeType.EntityDeclaration; + if (!isObject(value)) { + this.value = this.stringify.dtdEntityValue(value); + this.internal = true; + } else { + if (!value.pubID && !value.sysID) { + throw new Error("Public and/or system identifiers are required for an external entity. " + this.debugInfo(name)); } - 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; } + if (value.pubID && !value.sysID) { + throw new Error("System identifier is required for a public external entity. " + this.debugInfo(name)); } - }; - /** - * 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); - } + this.internal = false; + if (value.pubID != null) { + this.pubID = this.stringify.dtdPubID(value.pubID); } - 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; } - } - }; - /** - * 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 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 (requireWellFormed && !algorithm_1.xml_isPubidChar(node.publicId)) { - throw new Error("DocType public identifier does not match PubidChar construct (well-formed required)."); - } - /** - * 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 (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 (value.sysID != null) { + this.sysID = this.stringify.dtdSysID(value.sysID); } - /** - * 3. Let markup be an empty string. - * 4. Append the string "" (U+003E GREATER-THAN SIGN) to markup. - * 11. Return the value of markup. - */ - this.docType(node.name, node.publicId, node.systemId); - }; - /** - * 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 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 (requireWellFormed && (node.target.indexOf(":") !== -1 || (/^xml$/i).test(node.target))) { - throw new Error("Processing instruction target contains invalid characters (well-formed required)."); + if (value.nData != null) { + this.nData = this.stringify.dtdNData(value.nData); } - /** - * 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 (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.pe && this.nData) { + throw new Error("Notation declaration is not allowed in a parameter entity. " + this.debugInfo(name)); } - /** - * 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. - */ - this.instruction(node.target, node.data); + } + } + + Object.defineProperty(XMLDTDEntity.prototype, 'publicId', { + get: function() { + return this.pubID; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'systemId', { + get: function() { + return this.sysID; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'notationName', { + get: function() { + return this.nData || null; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'inputEncoding', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'xmlEncoding', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDTDEntity.prototype, 'xmlVersion', { + get: function() { + return null; + } + }); + + XMLDTDEntity.prototype.toString = function(options) { + return this.options.writer.dtdEntity(this, this.options.writer.filterOptions(options)); }; - /** - * 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)."); - } - this.cdata(node.data); + + return XMLDTDEntity; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 2837: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLDTDNotation, XMLNode, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDTDNotation = (function(superClass) { + extend(XMLDTDNotation, superClass); + + function XMLDTDNotation(parent, name, value) { + XMLDTDNotation.__super__.constructor.call(this, parent); + if (name == null) { + throw new Error("Missing DTD notation name. " + this.debugInfo(name)); + } + if (!value.pubID && !value.sysID) { + throw new Error("Public or system identifiers are required for an external entity. " + this.debugInfo(name)); + } + this.name = this.stringify.name(name); + this.type = NodeType.NotationDeclaration; + if (value.pubID != null) { + this.pubID = this.stringify.dtdPubID(value.pubID); + } + if (value.sysID != null) { + this.sysID = this.stringify.dtdSysID(value.sysID); + } + } + + Object.defineProperty(XMLDTDNotation.prototype, 'publicId', { + get: function() { + return this.pubID; + } + }); + + Object.defineProperty(XMLDTDNotation.prototype, 'systemId', { + get: function() { + return this.sysID; + } + }); + + XMLDTDNotation.prototype.toString = function(options) { + return this.options.writer.dtdNotation(this, this.options.writer.filterOptions(options)); }; - /** - * 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 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 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)]); - } + + return XMLDTDNotation; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 6364: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLDeclaration, XMLNode, isObject, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + isObject = (__nccwpck_require__(8229).isObject); + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDeclaration = (function(superClass) { + extend(XMLDeclaration, superClass); + + function XMLDeclaration(parent, version, encoding, standalone) { + var ref; + XMLDeclaration.__super__.constructor.call(this, parent); + if (isObject(version)) { + ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone; + } + if (!version) { + version = '1.0'; + } + this.type = NodeType.Declaration; + this.version = this.stringify.xmlVersion(version); + if (encoding != null) { + this.encoding = this.stringify.xmlEncoding(encoding); + } + if (standalone != null) { + this.standalone = this.stringify.xmlStandalone(standalone); + } + } + + XMLDeclaration.prototype.toString = function(options) { + return this.options.writer.declaration(this, this.options.writer.filterOptions(options)); + }; + + return XMLDeclaration; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 1801: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNamedNodeMap, XMLNode, isObject, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + isObject = (__nccwpck_require__(8229).isObject); + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + XMLDTDAttList = __nccwpck_require__(1015); + + XMLDTDEntity = __nccwpck_require__(53); + + XMLDTDElement = __nccwpck_require__(2421); + + XMLDTDNotation = __nccwpck_require__(2837); + + XMLNamedNodeMap = __nccwpck_require__(4361); + + module.exports = XMLDocType = (function(superClass) { + extend(XMLDocType, superClass); + + function XMLDocType(parent, pubID, sysID) { + var child, i, len, ref, ref1, ref2; + XMLDocType.__super__.constructor.call(this, parent); + this.type = NodeType.DocType; + if (parent.children) { + ref = parent.children; + for (i = 0, len = ref.length; i < len; i++) { + child = ref[i]; + if (child.type === NodeType.Element) { + this.name = child.name; + break; + } + } + } + this.documentObject = parent; + if (isObject(pubID)) { + ref1 = pubID, pubID = ref1.pubID, sysID = ref1.sysID; + } + if (sysID == null) { + ref2 = [pubID, sysID], sysID = ref2[0], pubID = ref2[1]; + } + if (pubID != null) { + this.pubID = this.stringify.dtdPubID(pubID); + } + if (sysID != null) { + this.sysID = this.stringify.dtdSysID(sysID); + } + } + + Object.defineProperty(XMLDocType.prototype, 'entities', { + get: function() { + var child, i, len, nodes, ref; + nodes = {}; + ref = this.children; + for (i = 0, len = ref.length; i < len; i++) { + child = ref[i]; + if ((child.type === NodeType.EntityDeclaration) && !child.pe) { + nodes[child.name] = child; + } + } + return new XMLNamedNodeMap(nodes); + } + }); + + Object.defineProperty(XMLDocType.prototype, 'notations', { + get: function() { + var child, i, len, nodes, ref; + nodes = {}; + ref = this.children; + for (i = 0, len = ref.length; i < len; i++) { + child = ref[i]; + if (child.type === NodeType.NotationDeclaration) { + nodes[child.name] = child; + } + } + return new XMLNamedNodeMap(nodes); + } + }); + + Object.defineProperty(XMLDocType.prototype, 'publicId', { + get: function() { + return this.pubID; + } + }); + + Object.defineProperty(XMLDocType.prototype, 'systemId', { + get: function() { + return this.sysID; + } + }); + + Object.defineProperty(XMLDocType.prototype, 'internalSubset', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + XMLDocType.prototype.element = function(name, value) { + var child; + child = new XMLDTDElement(this, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { + var child; + child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.entity = function(name, value) { + var child; + child = new XMLDTDEntity(this, false, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.pEntity = function(name, value) { + var child; + child = new XMLDTDEntity(this, true, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.notation = function(name, value) { + var child; + child = new XMLDTDNotation(this, name, value); + this.children.push(child); + return this; + }; + + XMLDocType.prototype.toString = function(options) { + return this.options.writer.docType(this, this.options.writer.filterOptions(options)); + }; + + XMLDocType.prototype.ele = function(name, value) { + return this.element(name, value); + }; + + XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { + return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue); + }; + + XMLDocType.prototype.ent = function(name, value) { + return this.entity(name, value); + }; + + XMLDocType.prototype.pent = function(name, value) { + return this.pEntity(name, value); + }; + + XMLDocType.prototype.not = function(name, value) { + return this.notation(name, value); + }; + + XMLDocType.prototype.up = function() { + return this.root() || this.documentObject; + }; + + XMLDocType.prototype.isEqualNode = function(node) { + if (!XMLDocType.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.name !== this.name) { + return false; + } + if (node.publicId !== this.publicId) { + return false; + } + if (node.systemId !== this.systemId) { + return false; + } + return true; + }; + + return XMLDocType; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 3730: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLDOMConfiguration, XMLDOMImplementation, XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + isPlainObject = (__nccwpck_require__(8229).isPlainObject); + + XMLDOMImplementation = __nccwpck_require__(8310); + + XMLDOMConfiguration = __nccwpck_require__(7465); + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + XMLStringifier = __nccwpck_require__(8594); + + XMLStringWriter = __nccwpck_require__(5913); + + module.exports = XMLDocument = (function(superClass) { + extend(XMLDocument, superClass); + + function XMLDocument(options) { + XMLDocument.__super__.constructor.call(this, null); + this.name = "#document"; + this.type = NodeType.Document; + this.documentURI = null; + this.domConfig = new XMLDOMConfiguration(); + options || (options = {}); + if (!options.writer) { + options.writer = new XMLStringWriter(); + } + this.options = options; + this.stringify = new XMLStringifier(options); + } + + Object.defineProperty(XMLDocument.prototype, 'implementation', { + value: new XMLDOMImplementation() + }); + + Object.defineProperty(XMLDocument.prototype, 'doctype', { + get: function() { + var child, i, len, ref; + ref = this.children; + for (i = 0, len = ref.length; i < len; i++) { + child = ref[i]; + if (child.type === NodeType.DocType) { + return child; + } + } + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'documentElement', { + get: function() { + return this.rootObject || null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'inputEncoding', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'strictErrorChecking', { + get: function() { + return false; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'xmlEncoding', { + get: function() { + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { + return this.children[0].encoding; + } else { + return null; + } + } + }); + + Object.defineProperty(XMLDocument.prototype, 'xmlStandalone', { + get: function() { + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { + return this.children[0].standalone === 'yes'; + } else { + return false; + } + } + }); + + Object.defineProperty(XMLDocument.prototype, 'xmlVersion', { + get: function() { + if (this.children.length !== 0 && this.children[0].type === NodeType.Declaration) { + return this.children[0].version; + } else { + return "1.0"; + } + } + }); + + Object.defineProperty(XMLDocument.prototype, 'URL', { + get: function() { + return this.documentURI; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'origin', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'compatMode', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'characterSet', { + get: function() { + return null; + } + }); + + Object.defineProperty(XMLDocument.prototype, 'contentType', { + get: function() { + return null; + } + }); + + XMLDocument.prototype.end = function(writer) { + var writerOptions; + writerOptions = {}; + if (!writer) { + writer = this.options.writer; + } else if (isPlainObject(writer)) { + writerOptions = writer; + writer = this.options.writer; + } + return writer.document(this, writer.filterOptions(writerOptions)); + }; + + XMLDocument.prototype.toString = function(options) { + return this.options.writer.document(this, this.options.writer.filterOptions(options)); + }; + + XMLDocument.prototype.createElement = function(tagName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createDocumentFragment = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createTextNode = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createComment = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createCDATASection = function(data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createProcessingInstruction = function(target, data) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createAttribute = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createEntityReference = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.getElementsByTagName = function(tagname) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.importNode = function(importedNode, deep) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createElementNS = function(namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createAttributeNS = function(namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.getElementById = function(elementId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.adoptNode = function(source) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.normalizeDocument = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.renameNode = function(node, namespaceURI, qualifiedName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.getElementsByClassName = function(classNames) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createEvent = function(eventInterface) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createRange = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createNodeIterator = function(root, whatToShow, filter) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLDocument.prototype.createTreeWalker = function(root, whatToShow, filter) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + return XMLDocument; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 7356: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, WriterState, XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocument, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, getValue, isFunction, isObject, isPlainObject, ref, + hasProp = {}.hasOwnProperty; + + ref = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject, getValue = ref.getValue; + + NodeType = __nccwpck_require__(9267); + + XMLDocument = __nccwpck_require__(3730); + + XMLElement = __nccwpck_require__(9437); + + XMLCData = __nccwpck_require__(333); + + XMLComment = __nccwpck_require__(4407); + + XMLRaw = __nccwpck_require__(6329); + + XMLText = __nccwpck_require__(1318); + + XMLProcessingInstruction = __nccwpck_require__(6939); + + XMLDeclaration = __nccwpck_require__(6364); + + XMLDocType = __nccwpck_require__(1801); + + XMLDTDAttList = __nccwpck_require__(1015); + + XMLDTDEntity = __nccwpck_require__(53); + + XMLDTDElement = __nccwpck_require__(2421); + + XMLDTDNotation = __nccwpck_require__(2837); + + XMLAttribute = __nccwpck_require__(8376); + + XMLStringifier = __nccwpck_require__(8594); + + XMLStringWriter = __nccwpck_require__(5913); + + WriterState = __nccwpck_require__(9766); + + module.exports = XMLDocumentCB = (function() { + function XMLDocumentCB(options, onData, onEnd) { + var writerOptions; + this.name = "?xml"; + this.type = NodeType.Document; + options || (options = {}); + writerOptions = {}; + if (!options.writer) { + options.writer = new XMLStringWriter(); + } else if (isPlainObject(options.writer)) { + writerOptions = options.writer; + options.writer = new XMLStringWriter(); + } + this.options = options; + this.writer = options.writer; + this.writerOptions = this.writer.filterOptions(writerOptions); + this.stringify = new XMLStringifier(options); + this.onDataCallback = onData || function() {}; + this.onEndCallback = onEnd || function() {}; + this.currentNode = null; + this.currentLevel = -1; + this.openTags = {}; + this.documentStarted = false; + this.documentCompleted = false; + this.root = null; + } + + XMLDocumentCB.prototype.createChildNode = function(node) { + var att, attName, attributes, child, i, len, ref1, ref2; + switch (node.type) { + case NodeType.CData: + this.cdata(node.value); + break; + case NodeType.Comment: + this.comment(node.value); + break; + case NodeType.Element: + attributes = {}; + ref1 = node.attribs; + for (attName in ref1) { + if (!hasProp.call(ref1, attName)) continue; + att = ref1[attName]; + attributes[attName] = att.value; + } + this.node(node.name, attributes); + break; + case NodeType.Dummy: + this.dummy(); + break; + case NodeType.Raw: + this.raw(node.value); + break; + case NodeType.Text: + this.text(node.value); + break; + case NodeType.ProcessingInstruction: + this.instruction(node.target, node.value); + break; + default: + throw new Error("This XML node type is not supported in a JS object: " + node.constructor.name); + } + ref2 = node.children; + for (i = 0, len = ref2.length; i < len; i++) { + child = ref2[i]; + this.createChildNode(child); + if (child.type === NodeType.Element) { + this.up(); } - catch (e_8_1) { e_8 = { error: e_8_1 }; } - finally { - try { - if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + return this; + }; + + XMLDocumentCB.prototype.dummy = function() { + return this; + }; + + XMLDocumentCB.prototype.node = function(name, attributes, text) { + var ref1; + if (name == null) { + throw new Error("Missing node name."); + } + if (this.root && this.currentLevel === -1) { + throw new Error("Document can only have one root node. " + this.debugInfo(name)); + } + this.openCurrent(); + name = getValue(name); + if (attributes == null) { + attributes = {}; + } + attributes = getValue(attributes); + if (!isObject(attributes)) { + ref1 = [attributes, text], text = ref1[0], attributes = ref1[1]; + } + this.currentNode = new XMLElement(this, name, attributes); + this.currentNode.children = false; + this.currentLevel++; + this.openTags[this.currentLevel] = this.currentNode; + if (text != null) { + this.text(text); + } + return this; + }; + + XMLDocumentCB.prototype.element = function(name, attributes, text) { + var child, i, len, oldValidationFlag, ref1, root; + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + this.dtdElement.apply(this, arguments); + } else { + if (Array.isArray(name) || isObject(name) || isFunction(name)) { + oldValidationFlag = this.options.noValidation; + this.options.noValidation = true; + root = new XMLDocument(this.options).element('TEMP_ROOT'); + root.element(name); + this.options.noValidation = oldValidationFlag; + ref1 = root.children; + for (i = 0, len = ref1.length; i < len; i++) { + child = ref1[i]; + this.createChildNode(child); + if (child.type === NodeType.Element) { + this.up(); } - finally { if (e_8) throw e_8.error; } + } + } else { + this.node(name, attributes, text); } - /** - * 4. Return the value of result. - */ - return result; + } + return this; }; - /** - * 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 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 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)]); - } + + XMLDocumentCB.prototype.attribute = function(name, value) { + var attName, attValue; + if (!this.currentNode || this.currentNode.children) { + throw new Error("att() can only be used immediately after an ele() call in callback mode. " + this.debugInfo(name)); + } + if (name != null) { + name = getValue(name); + } + if (isObject(name)) { + for (attName in name) { + if (!hasProp.call(name, attName)) continue; + attValue = name[attName]; + this.attribute(attName, attValue); + } + } else { + if (isFunction(value)) { + value = value.apply(); + } + if (this.options.keepNullAttributes && (value == null)) { + this.currentNode.attribs[name] = new XMLAttribute(this, name, ""); + } else if (value != null) { + this.currentNode.attribs[name] = new XMLAttribute(this, name, value); + } + } + return this; + }; + + XMLDocumentCB.prototype.text = function(value) { + var node; + this.openCurrent(); + node = new XMLText(this, value); + this.onData(this.writer.text(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.cdata = function(value) { + var node; + this.openCurrent(); + node = new XMLCData(this, value); + this.onData(this.writer.cdata(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.comment = function(value) { + var node; + this.openCurrent(); + node = new XMLComment(this, value); + this.onData(this.writer.comment(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.raw = function(value) { + var node; + this.openCurrent(); + node = new XMLRaw(this, value); + this.onData(this.writer.raw(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.instruction = function(target, value) { + var i, insTarget, insValue, len, node; + this.openCurrent(); + if (target != null) { + target = getValue(target); + } + if (value != null) { + value = getValue(value); + } + if (Array.isArray(target)) { + for (i = 0, len = target.length; i < len; i++) { + insTarget = target[i]; + this.instruction(insTarget); } - 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; } + } else if (isObject(target)) { + for (insTarget in target) { + if (!hasProp.call(target, insTarget)) continue; + insValue = target[insTarget]; + this.instruction(insTarget, insValue); } - /** - * 4. Return the value of result. - */ - 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; - /** - * 1. Let default namespace attr value be null. - */ - var defaultNamespaceAttrValue = null; - try { - /** - * 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 || ''; - } - } - } + } else { + if (isFunction(value)) { + value = value.apply(); } - 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; } + node = new XMLProcessingInstruction(this, target, value); + this.onData(this.writer.processingInstruction(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + } + return this; + }; + + XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) { + var node; + this.openCurrent(); + if (this.documentStarted) { + throw new Error("declaration() must be the first node."); + } + node = new XMLDeclaration(this, version, encoding, standalone); + this.onData(this.writer.declaration(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) { + this.openCurrent(); + if (root == null) { + throw new Error("Missing root node name."); + } + if (this.root) { + throw new Error("dtd() must come before the root node."); + } + this.currentNode = new XMLDocType(this, pubID, sysID); + this.currentNode.rootNodeName = root; + this.currentNode.children = false; + this.currentLevel++; + this.openTags[this.currentLevel] = this.currentNode; + return this; + }; + + XMLDocumentCB.prototype.dtdElement = function(name, value) { + var node; + this.openCurrent(); + node = new XMLDTDElement(this, name, value); + this.onData(this.writer.dtdElement(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) { + var node; + this.openCurrent(); + node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue); + this.onData(this.writer.dtdAttList(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.entity = function(name, value) { + var node; + this.openCurrent(); + node = new XMLDTDEntity(this, false, name, value); + this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.pEntity = function(name, value) { + var node; + this.openCurrent(); + node = new XMLDTDEntity(this, true, name, value); + this.onData(this.writer.dtdEntity(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.notation = function(name, value) { + var node; + this.openCurrent(); + node = new XMLDTDNotation(this, name, value); + this.onData(this.writer.dtdNotation(node, this.writerOptions, this.currentLevel + 1), this.currentLevel + 1); + return this; + }; + + XMLDocumentCB.prototype.up = function() { + if (this.currentLevel < 0) { + throw new Error("The document node has no parent."); + } + if (this.currentNode) { + if (this.currentNode.children) { + this.closeNode(this.currentNode); + } else { + this.openNode(this.currentNode); } - /** - * 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; + this.currentNode = null; + } else { + this.closeNode(this.openTags[this.currentLevel]); + } + delete this.openTags[this.currentLevel]; + this.currentLevel--; + return this; }; - /** - * 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; + + XMLDocumentCB.prototype.end = function() { + while (this.currentLevel >= 0) { + this.up(); + } + return this.onEnd(); }; - /** - * 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) { - /** - * 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. - */ - if (requireWellFormed && value !== null && !algorithm_1.xml_isLegalChar(value)) { - throw new Error("Invalid characters in attribute value."); + + XMLDocumentCB.prototype.openCurrent = function() { + if (this.currentNode) { + this.currentNode.children = true; + return this.openNode(this.currentNode); + } + }; + + XMLDocumentCB.prototype.openNode = function(node) { + var att, chunk, name, ref1; + if (!node.isOpen) { + if (!this.root && this.currentLevel === 0 && node.type === NodeType.Element) { + this.root = node; } - /** - * 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, '"'); + chunk = ''; + if (node.type === NodeType.Element) { + this.writerOptions.state = WriterState.OpenTag; + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '<' + node.name; + ref1 = node.attribs; + for (name in ref1) { + if (!hasProp.call(ref1, name)) continue; + att = ref1[name]; + chunk += this.writer.attribute(att, this.writerOptions, this.currentLevel); + } + chunk += (node.children ? '>' : '/>') + this.writer.endline(node, this.writerOptions, this.currentLevel); + this.writerOptions.state = WriterState.InsideTag; + } else { + this.writerOptions.state = WriterState.OpenTag; + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ''; + } + chunk += this.writer.endline(node, this.writerOptions, this.currentLevel); } - 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; + this.onData(chunk, this.currentLevel); + return node.isOpen = true; + } + }; + + XMLDocumentCB.prototype.closeNode = function(node) { + var chunk; + if (!node.isClosed) { + chunk = ''; + this.writerOptions.state = WriterState.CloseTag; + if (node.type === NodeType.Element) { + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + '' + this.writer.endline(node, this.writerOptions, this.currentLevel); + } else { + chunk = this.writer.indent(node, this.writerOptions, this.currentLevel) + ']>' + this.writer.endline(node, this.writerOptions, this.currentLevel); } + this.writerOptions.state = WriterState.None; + this.onData(chunk, this.currentLevel); + return node.isClosed = true; + } + }; + + XMLDocumentCB.prototype.onData = function(chunk, level) { + this.documentStarted = true; + return this.onDataCallback(chunk, level + 1); + }; + + XMLDocumentCB.prototype.onEnd = function() { + this.documentCompleted = true; + return this.onEndCallback(); + }; + + XMLDocumentCB.prototype.debugInfo = function(name) { + if (name == null) { + return ""; + } else { + return "node: <" + name + ">"; + } + }; + + XMLDocumentCB.prototype.ele = function() { + return this.element.apply(this, arguments); + }; + + XMLDocumentCB.prototype.nod = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + + XMLDocumentCB.prototype.txt = function(value) { + return this.text(value); + }; + + XMLDocumentCB.prototype.dat = function(value) { + return this.cdata(value); + }; + + XMLDocumentCB.prototype.com = function(value) { + return this.comment(value); + }; + + XMLDocumentCB.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; + + XMLDocumentCB.prototype.dec = function(version, encoding, standalone) { + return this.declaration(version, encoding, standalone); + }; + + XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) { + return this.doctype(root, pubID, sysID); + }; + + XMLDocumentCB.prototype.e = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + + XMLDocumentCB.prototype.n = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + + XMLDocumentCB.prototype.t = function(value) { + return this.text(value); + }; + + XMLDocumentCB.prototype.d = function(value) { + return this.cdata(value); + }; + + XMLDocumentCB.prototype.c = function(value) { + return this.comment(value); + }; + + XMLDocumentCB.prototype.r = function(value) { + return this.raw(value); + }; + + XMLDocumentCB.prototype.i = function(target, value) { + return this.instruction(target, value); + }; + + XMLDocumentCB.prototype.att = function() { + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + return this.attList.apply(this, arguments); + } else { + return this.attribute.apply(this, arguments); + } + }; + + XMLDocumentCB.prototype.a = function() { + if (this.currentNode && this.currentNode.type === NodeType.DocType) { + return this.attList.apply(this, arguments); + } else { + return this.attribute.apply(this, arguments); + } + }; + + XMLDocumentCB.prototype.ent = function(name, value) { + return this.entity(name, value); + }; + + XMLDocumentCB.prototype.pent = function(name, value) { + return this.pEntity(name, value); + }; + + XMLDocumentCB.prototype.not = function(name, value) { + return this.notation(name, value); + }; + + return XMLDocumentCB; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 3590: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLDummy, XMLNode, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + module.exports = XMLDummy = (function(superClass) { + extend(XMLDummy, superClass); + + function XMLDummy(parent) { + XMLDummy.__super__.constructor.call(this, parent); + this.type = NodeType.Dummy; + } + + XMLDummy.prototype.clone = function() { + return Object.create(this); }; - 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 + + XMLDummy.prototype.toString = function(options) { + return ''; + }; + + return XMLDummy; + + })(XMLNode); + +}).call(this); + /***/ }), -/***/ 7525: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 9437: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLAttribute, XMLElement, XMLNamedNodeMap, XMLNode, getValue, isFunction, isObject, ref, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; -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); + ref = __nccwpck_require__(8229), isObject = ref.isObject, isFunction = ref.isFunction, getValue = ref.getValue; + + XMLNode = __nccwpck_require__(7608); + + NodeType = __nccwpck_require__(9267); + + XMLAttribute = __nccwpck_require__(8376); + + XMLNamedNodeMap = __nccwpck_require__(4361); + + module.exports = XMLElement = (function(superClass) { + extend(XMLElement, superClass); + + function XMLElement(parent, name, attributes) { + var child, j, len, ref1; + XMLElement.__super__.constructor.call(this, parent); + if (name == null) { + throw new Error("Missing element name. " + this.debugInfo()); + } + this.name = this.stringify.name(name); + this.type = NodeType.Element; + this.attribs = {}; + this.schemaTypeInfo = null; + if (attributes != null) { + this.attribute(attributes); + } + if (parent.type === NodeType.Document) { + this.isRoot = true; + this.documentObject = parent; + parent.rootObject = this; + if (parent.children) { + ref1 = parent.children; + for (j = 0, len = ref1.length; j < len; j++) { + child = ref1[j]; + if (child.type === NodeType.DocType) { + child.name = this.name; + break; + } + } + } + } + } + + Object.defineProperty(XMLElement.prototype, 'tagName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLElement.prototype, 'namespaceURI', { + get: function() { + return ''; + } + }); + + Object.defineProperty(XMLElement.prototype, 'prefix', { + get: function() { + return ''; + } + }); + + Object.defineProperty(XMLElement.prototype, 'localName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLElement.prototype, 'id', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + Object.defineProperty(XMLElement.prototype, 'className', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + Object.defineProperty(XMLElement.prototype, 'classList', { + get: function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + Object.defineProperty(XMLElement.prototype, 'attributes', { + get: function() { + if (!this.attributeMap || !this.attributeMap.nodes) { + this.attributeMap = new XMLNamedNodeMap(this.attribs); + } + return this.attributeMap; + } + }); + + XMLElement.prototype.clone = function() { + var att, attName, clonedSelf, ref1; + clonedSelf = Object.create(this); + if (clonedSelf.isRoot) { + clonedSelf.documentObject = null; + } + clonedSelf.attribs = {}; + ref1 = this.attribs; + for (attName in ref1) { + if (!hasProp.call(ref1, attName)) continue; + att = ref1[attName]; + clonedSelf.attribs[attName] = att.clone(); + } + clonedSelf.children = []; + this.children.forEach(function(child) { + var clonedChild; + clonedChild = child.clone(); + clonedChild.parent = clonedSelf; + return clonedSelf.children.push(clonedChild); + }); + return clonedSelf; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLElement.prototype.attribute = function(name, value) { + var attName, attValue; + if (name != null) { + name = getValue(name); + } + if (isObject(name)) { + for (attName in name) { + if (!hasProp.call(name, attName)) continue; + attValue = name[attName]; + this.attribute(attName, attValue); + } + } else { + if (isFunction(value)) { + value = value.apply(); + } + if (this.options.keepNullAttributes && (value == null)) { + this.attribs[name] = new XMLAttribute(this, name, ""); + } else if (value != null) { + this.attribs[name] = new XMLAttribute(this, name, value); + } + } + return this; }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var BaseCBWriter_1 = __nccwpck_require__(708); -/** - * Serializes XML nodes. - */ -var JSONCBWriter = /** @class */ (function (_super) { - __extends(JSONCBWriter, _super); - /** - * Initializes a new instance of `JSONCBWriter`. - * - * @param builderOptions - XML builder options - */ - function JSONCBWriter(builderOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._hasChildren = []; - _this._additionalLevel = 0; - return _this; - } - /** @inheritdoc */ - JSONCBWriter.prototype.frontMatter = function () { - return ""; + + XMLElement.prototype.removeAttribute = function(name) { + var attName, j, len; + if (name == null) { + throw new Error("Missing attribute name. " + this.debugInfo()); + } + name = getValue(name); + if (Array.isArray(name)) { + for (j = 0, len = name.length; j < len; j++) { + attName = name[j]; + delete this.attribs[attName]; + } + } else { + delete this.attribs[name]; + } + return this; }; - /** @inheritdoc */ - JSONCBWriter.prototype.declaration = function (version, encoding, standalone) { - return ""; + + XMLElement.prototype.toString = function(options) { + return this.options.writer.element(this, this.options.writer.filterOptions(options)); }; - /** @inheritdoc */ - JSONCBWriter.prototype.docType = function (name, publicId, systemId) { - return ""; + + XMLElement.prototype.att = function(name, value) { + return this.attribute(name, value); }; - /** @inheritdoc */ - JSONCBWriter.prototype.comment = function (data) { - // { "!": "hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.comment) + this._sep() + - this._val(data) + this._sep() + "}"; + + XMLElement.prototype.a = function(name, value) { + return this.attribute(name, value); }; - /** @inheritdoc */ - JSONCBWriter.prototype.text = function (data) { - // { "#": "hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.text) + this._sep() + - this._val(data) + this._sep() + "}"; + + XMLElement.prototype.getAttribute = function(name) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name].value; + } else { + return null; + } + }; + + XMLElement.prototype.setAttribute = function(name, value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - JSONCBWriter.prototype.instruction = function (target, data) { - // { "?": "target hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.ins) + this._sep() + - this._val(data ? target + " " + data : target) + this._sep() + "}"; + + XMLElement.prototype.getAttributeNode = function(name) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name]; + } else { + return null; + } }; - /** @inheritdoc */ - JSONCBWriter.prototype.cdata = function (data) { - // { "$": "hello" } - return this._comma() + this._beginLine() + "{" + this._sep() + - this._key(this._builderOptions.convert.cdata) + this._sep() + - this._val(data) + this._sep() + "}"; + + XMLElement.prototype.setAttributeNode = function(newAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - JSONCBWriter.prototype.attribute = function (name, value) { - // { "@name": "val" } - return this._comma() + this._beginLine(1) + "{" + this._sep() + - this._key(this._builderOptions.convert.att + name) + this._sep() + - this._val(value) + this._sep() + "}"; + + XMLElement.prototype.removeAttributeNode = function(oldAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - JSONCBWriter.prototype.openTagBegin = function (name) { - // { "node": { "#": [ - var str = this._comma() + this._beginLine() + "{" + this._sep() + this._key(name) + this._sep() + "{"; - this._additionalLevel++; - this.hasData = true; - str += this._beginLine() + this._key(this._builderOptions.convert.text) + this._sep() + "["; - this._hasChildren.push(false); - return str; + + XMLElement.prototype.getElementsByTagName = function(name) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - JSONCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (selfClosing) { - var str = this._sep() + "]"; - this._additionalLevel--; - str += this._beginLine() + "}" + this._sep() + "}"; - return str; - } - else { - return ""; - } + + XMLElement.prototype.getAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - JSONCBWriter.prototype.closeTag = function (name) { - // ] } } - var str = this._beginLine() + "]"; - this._additionalLevel--; - str += this._beginLine() + "}" + this._sep() + "}"; - return str; + + XMLElement.prototype.setAttributeNS = function(namespaceURI, qualifiedName, value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** @inheritdoc */ - JSONCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - JSONCBWriter.prototype.endElement = function (name) { this._hasChildren.pop(); }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - JSONCBWriter.prototype._beginLine = function (additionalOffset) { - if (additionalOffset === void 0) { additionalOffset = 0; } - if (this._writerOptions.prettyPrint) { - return (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level + additionalOffset); - } - else { - return ""; - } + + XMLElement.prototype.removeAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - */ - JSONCBWriter.prototype._indent = function (level) { - if (level + this._additionalLevel <= 0) { - return ""; - } - else { - return this._writerOptions.indent.repeat(level + this._additionalLevel); - } + + XMLElement.prototype.getAttributeNodeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces a comma before a child node if it has previous siblings. - */ - JSONCBWriter.prototype._comma = function () { - var str = (this._hasChildren[this._hasChildren.length - 1] ? "," : ""); - if (this._hasChildren.length > 0) { - this._hasChildren[this._hasChildren.length - 1] = true; - } - return str; + + XMLElement.prototype.setAttributeNodeNS = function(newAttr) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces a separator string. - */ - JSONCBWriter.prototype._sep = function () { - return (this._writerOptions.prettyPrint ? " " : ""); + + XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - /** - * Produces a JSON key string delimited with double quotes. - */ - JSONCBWriter.prototype._key = function (key) { - return "\"" + key + "\":"; + + XMLElement.prototype.hasAttribute = function(name) { + return this.attribs.hasOwnProperty(name); }; - /** - * Produces a JSON value string delimited with double quotes. - */ - JSONCBWriter.prototype._val = function (val) { - return JSON.stringify(val); + + XMLElement.prototype.hasAttributeNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - return JSONCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.JSONCBWriter = JSONCBWriter; -//# sourceMappingURL=JSONCBWriter.js.map -/***/ }), + XMLElement.prototype.setIdAttribute = function(name, isId) { + if (this.attribs.hasOwnProperty(name)) { + return this.attribs[name].isId; + } else { + return isId; + } + }; -/***/ 7510: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLElement.prototype.setIdAttributeNS = function(namespaceURI, localName, isId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -"use strict"; + XMLElement.prototype.setIdAttributeNode = function(idAttr, isId) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; -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); + XMLElement.prototype.getElementsByTagName = function(tagname) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLElement.prototype.getElementsByTagNameNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); }; -})(); -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 }; + + XMLElement.prototype.getElementsByClassName = function(classNames) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLElement.prototype.isEqualNode = function(node) { + var i, j, ref1; + if (!XMLElement.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.namespaceURI !== this.namespaceURI) { + return false; + } + if (node.prefix !== this.prefix) { + return false; + } + if (node.localName !== this.localName) { + return false; + } + if (node.attribs.length !== this.attribs.length) { + return false; + } + for (i = j = 0, ref1 = this.attribs.length - 1; 0 <= ref1 ? j <= ref1 : j >= ref1; i = 0 <= ref1 ? ++j : --j) { + if (!this.attribs[i].isEqualNode(node.attribs[i])) { + return false; } + } + return true; }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectWriter_1 = __nccwpck_require__(243); -var util_1 = __nccwpck_require__(6195); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into a JSON string. - */ -var JSONWriter = /** @class */ (function (_super) { - __extends(JSONWriter, _super); - /** - * Initializes a new instance of `JSONWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function JSONWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - wellFormed: false, - noDoubleEncoding: false, - prettyPrint: false, - indent: ' ', - newline: '\n', - offset: 0, - group: false, - verbose: false - }); - return _this; + + return XMLElement; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 4361: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLNamedNodeMap; + + module.exports = XMLNamedNodeMap = (function() { + function XMLNamedNodeMap(nodes) { + this.nodes = nodes; } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - * @param writerOptions - serialization options - */ - JSONWriter.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); - // recursively convert object into JSON string - return this._beginLine(this._writerOptions, 0) + this._convertObject(val, this._writerOptions); + + Object.defineProperty(XMLNamedNodeMap.prototype, 'length', { + get: function() { + return Object.keys(this.nodes).length || 0; + } + }); + + XMLNamedNodeMap.prototype.clone = function() { + return this.nodes = null; }; - /** - * Produces an XML serialization of the given object. - * - * @param obj - object to serialize - * @param options - serialization options - * @param level - depth of the XML tree - */ - JSONWriter.prototype._convertObject = function (obj, options, level) { - var e_1, _a; - var _this = this; - if (level === void 0) { level = 0; } - var markup = ''; - var isLeaf = this._isLeafNode(obj); - if (util_1.isArray(obj)) { - markup += '['; - var len = obj.length; - var i = 0; - 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._endLine(options, level + 1) + - this._beginLine(options, level + 1) + - this._convertObject(val, options, level + 1); - if (i < len - 1) { - markup += ','; - } - i++; - } - } - 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; } - } - markup += this._endLine(options, level) + this._beginLine(options, level); - markup += ']'; - } - else if (util_1.isObject(obj)) { - markup += '{'; - var len_1 = util_1.objectLength(obj); - var i_1 = 0; - util_1.forEachObject(obj, function (key, val) { - if (isLeaf && options.prettyPrint) { - markup += ' '; - } - else { - markup += _this._endLine(options, level + 1) + _this._beginLine(options, level + 1); - } - markup += _this._key(key); - if (options.prettyPrint) { - markup += ' '; - } - markup += _this._convertObject(val, options, level + 1); - if (i_1 < len_1 - 1) { - markup += ','; - } - i_1++; - }, this); - if (isLeaf && options.prettyPrint) { - markup += ' '; - } - else { - markup += this._endLine(options, level) + this._beginLine(options, level); - } - markup += '}'; - } - else { - markup += this._val(obj); - } - return markup; + + XMLNamedNodeMap.prototype.getNamedItem = function(name) { + return this.nodes[name]; }; - /** - * 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 - */ - JSONWriter.prototype._beginLine = function (options, level) { - if (!options.prettyPrint) { - return ''; - } - else { - var indentLevel = options.offset + level + 1; - if (indentLevel > 0) { - return new Array(indentLevel).join(options.indent); - } - } - return ''; + + XMLNamedNodeMap.prototype.setNamedItem = function(node) { + var oldNode; + oldNode = this.nodes[node.nodeName]; + this.nodes[node.nodeName] = node; + return oldNode || null; }; - /** - * Produces characters to be appended to a line of string in pretty-print - * mode. - * - * @param options - serialization options - * @param level - current depth of the XML tree - */ - JSONWriter.prototype._endLine = function (options, level) { - if (!options.prettyPrint) { - return ''; - } - else { - return options.newline; - } + + XMLNamedNodeMap.prototype.removeNamedItem = function(name) { + var oldNode; + oldNode = this.nodes[name]; + delete this.nodes[name]; + return oldNode || null; }; - /** - * Produces a JSON key string delimited with double quotes. - */ - JSONWriter.prototype._key = function (key) { - return "\"" + key + "\":"; + + XMLNamedNodeMap.prototype.item = function(index) { + return this.nodes[Object.keys(this.nodes)[index]] || null; }; - /** - * Produces a JSON value string delimited with double quotes. - */ - JSONWriter.prototype._val = function (val) { - return JSON.stringify(val); + + XMLNamedNodeMap.prototype.getNamedItemNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented."); }; - /** - * Determines if an object is a leaf node. - * - * @param obj - */ - JSONWriter.prototype._isLeafNode = function (obj) { - return this._descendantCount(obj) <= 1; + + XMLNamedNodeMap.prototype.setNamedItemNS = function(node) { + throw new Error("This DOM method is not implemented."); }; - /** - * Counts the number of descendants of the given object. - * - * @param obj - * @param count - */ - JSONWriter.prototype._descendantCount = function (obj, count) { - var _this = this; - if (count === void 0) { count = 0; } - if (util_1.isArray(obj)) { - util_1.forEachArray(obj, function (val) { return count += _this._descendantCount(val, count); }, this); - } - else if (util_1.isObject(obj)) { - util_1.forEachObject(obj, function (key, val) { return count += _this._descendantCount(val, count); }, this); - } - else { - count++; + + XMLNamedNodeMap.prototype.removeNamedItemNS = function(namespaceURI, localName) { + throw new Error("This DOM method is not implemented."); + }; + + return XMLNamedNodeMap; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 7608: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var DocumentPosition, NodeType, XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLDummy, XMLElement, XMLNamedNodeMap, XMLNode, XMLNodeList, XMLProcessingInstruction, XMLRaw, XMLText, getValue, isEmpty, isFunction, isObject, ref1, + hasProp = {}.hasOwnProperty; + + ref1 = __nccwpck_require__(8229), isObject = ref1.isObject, isFunction = ref1.isFunction, isEmpty = ref1.isEmpty, getValue = ref1.getValue; + + XMLElement = null; + + XMLCData = null; + + XMLComment = null; + + XMLDeclaration = null; + + XMLDocType = null; + + XMLRaw = null; + + XMLText = null; + + XMLProcessingInstruction = null; + + XMLDummy = null; + + NodeType = null; + + XMLNodeList = null; + + XMLNamedNodeMap = null; + + DocumentPosition = null; + + module.exports = XMLNode = (function() { + function XMLNode(parent1) { + this.parent = parent1; + if (this.parent) { + this.options = this.parent.options; + this.stringify = this.parent.stringify; + } + this.value = null; + this.children = []; + this.baseURI = null; + if (!XMLElement) { + XMLElement = __nccwpck_require__(9437); + XMLCData = __nccwpck_require__(333); + XMLComment = __nccwpck_require__(4407); + XMLDeclaration = __nccwpck_require__(6364); + XMLDocType = __nccwpck_require__(1801); + XMLRaw = __nccwpck_require__(6329); + XMLText = __nccwpck_require__(1318); + XMLProcessingInstruction = __nccwpck_require__(6939); + XMLDummy = __nccwpck_require__(3590); + NodeType = __nccwpck_require__(9267); + XMLNodeList = __nccwpck_require__(6768); + XMLNamedNodeMap = __nccwpck_require__(4361); + DocumentPosition = __nccwpck_require__(2839); + } + } + + Object.defineProperty(XMLNode.prototype, 'nodeName', { + get: function() { + return this.name; + } + }); + + Object.defineProperty(XMLNode.prototype, 'nodeType', { + get: function() { + return this.type; + } + }); + + Object.defineProperty(XMLNode.prototype, 'nodeValue', { + get: function() { + return this.value; + } + }); + + Object.defineProperty(XMLNode.prototype, 'parentNode', { + get: function() { + return this.parent; + } + }); + + Object.defineProperty(XMLNode.prototype, 'childNodes', { + get: function() { + if (!this.childNodeList || !this.childNodeList.nodes) { + this.childNodeList = new XMLNodeList(this.children); } - return count; - }; - return JSONWriter; -}(BaseWriter_1.BaseWriter)); -exports.JSONWriter = JSONWriter; -//# sourceMappingURL=JSONWriter.js.map + return this.childNodeList; + } + }); -/***/ }), + Object.defineProperty(XMLNode.prototype, 'firstChild', { + get: function() { + return this.children[0] || null; + } + }); -/***/ 1397: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + Object.defineProperty(XMLNode.prototype, 'lastChild', { + get: function() { + return this.children[this.children.length - 1] || null; + } + }); -"use strict"; + Object.defineProperty(XMLNode.prototype, 'previousSibling', { + get: function() { + var i; + i = this.parent.children.indexOf(this); + return this.parent.children[i - 1] || null; + } + }); -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 util_1 = __nccwpck_require__(6195); -var ObjectWriter_1 = __nccwpck_require__(243); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into ES6 maps and arrays. - */ -var MapWriter = /** @class */ (function (_super) { - __extends(MapWriter, _super); - /** - * Initializes a new instance of `MapWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function MapWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - format: "map", - wellFormed: false, - noDoubleEncoding: false, - group: false, - verbose: false - }); - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - */ - MapWriter.prototype.serialize = function (node) { - // convert to object - var objectWriterOptions = util_1.applyDefaults(this._writerOptions, { - format: "object", - wellFormed: false, - noDoubleEncoding: false, - verbose: false - }); - var objectWriter = new ObjectWriter_1.ObjectWriter(this._builderOptions, objectWriterOptions); - var val = objectWriter.serialize(node); - // recursively convert object into Map - return this._convertObject(val); + Object.defineProperty(XMLNode.prototype, 'nextSibling', { + get: function() { + var i; + i = this.parent.children.indexOf(this); + return this.parent.children[i + 1] || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'ownerDocument', { + get: function() { + return this.document() || null; + } + }); + + Object.defineProperty(XMLNode.prototype, 'textContent', { + get: function() { + var child, j, len, ref2, str; + if (this.nodeType === NodeType.Element || this.nodeType === NodeType.DocumentFragment) { + str = ''; + ref2 = this.children; + for (j = 0, len = ref2.length; j < len; j++) { + child = ref2[j]; + if (child.textContent) { + str += child.textContent; + } + } + return str; + } else { + return null; + } + }, + set: function(value) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + } + }); + + XMLNode.prototype.setParent = function(parent) { + var child, j, len, ref2, results; + this.parent = parent; + if (parent) { + this.options = parent.options; + this.stringify = parent.stringify; + } + ref2 = this.children; + results = []; + for (j = 0, len = ref2.length; j < len; j++) { + child = ref2[j]; + results.push(child.setParent(this)); + } + return results; }; - /** - * Recursively converts a JS object into an ES5 map. - * - * @param obj - a JS object - */ - MapWriter.prototype._convertObject = function (obj) { - if (util_1.isArray(obj)) { - for (var i = 0; i < obj.length; i++) { - obj[i] = this._convertObject(obj[i]); + + XMLNode.prototype.element = function(name, attributes, text) { + var childNode, item, j, k, key, lastChild, len, len1, ref2, ref3, val; + lastChild = null; + if (attributes === null && (text == null)) { + ref2 = [{}, null], attributes = ref2[0], text = ref2[1]; + } + if (attributes == null) { + attributes = {}; + } + attributes = getValue(attributes); + if (!isObject(attributes)) { + ref3 = [attributes, text], text = ref3[0], attributes = ref3[1]; + } + if (name != null) { + name = getValue(name); + } + if (Array.isArray(name)) { + for (j = 0, len = name.length; j < len; j++) { + item = name[j]; + lastChild = this.element(item); + } + } else if (isFunction(name)) { + lastChild = this.element(name.apply()); + } else if (isObject(name)) { + for (key in name) { + if (!hasProp.call(name, key)) continue; + val = name[key]; + if (isFunction(val)) { + val = val.apply(); + } + if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) { + lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val); + } else if (!this.options.separateArrayItems && Array.isArray(val) && isEmpty(val)) { + lastChild = this.dummy(); + } else if (isObject(val) && isEmpty(val)) { + lastChild = this.element(key); + } else if (!this.options.keepNullNodes && (val == null)) { + lastChild = this.dummy(); + } else if (!this.options.separateArrayItems && Array.isArray(val)) { + for (k = 0, len1 = val.length; k < len1; k++) { + item = val[k]; + childNode = {}; + childNode[key] = item; + lastChild = this.element(childNode); } - return obj; + } else if (isObject(val)) { + if (!this.options.ignoreDecorators && this.stringify.convertTextKey && key.indexOf(this.stringify.convertTextKey) === 0) { + lastChild = this.element(val); + } else { + lastChild = this.element(key); + lastChild.element(val); + } + } else { + lastChild = this.element(key, val); + } + } + } else if (!this.options.keepNullNodes && text === null) { + lastChild = this.dummy(); + } else { + if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) { + lastChild = this.text(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) { + lastChild = this.cdata(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) { + lastChild = this.comment(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) { + lastChild = this.raw(text); + } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) { + lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text); + } else { + lastChild = this.node(name, attributes, text); } - else if (util_1.isObject(obj)) { - var map = new Map(); - for (var key in obj) { - map.set(key, this._convertObject(obj[key])); - } - return map; + } + if (lastChild == null) { + throw new Error("Could not create any elements with: " + name + ". " + this.debugInfo()); + } + return lastChild; + }; + + XMLNode.prototype.insertBefore = function(name, attributes, text) { + var child, i, newChild, refChild, removed; + if (name != null ? name.type : void 0) { + newChild = name; + refChild = attributes; + newChild.setParent(this); + if (refChild) { + i = children.indexOf(refChild); + removed = children.splice(i); + children.push(newChild); + Array.prototype.push.apply(children, removed); + } else { + children.push(newChild); } - else { - return obj; + return newChild; + } else { + if (this.isRoot) { + throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); } + i = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i); + child = this.parent.element(name, attributes, text); + Array.prototype.push.apply(this.parent.children, removed); + return child; + } }; - return MapWriter; -}(BaseWriter_1.BaseWriter)); -exports.MapWriter = MapWriter; -//# sourceMappingURL=MapWriter.js.map -/***/ }), + XMLNode.prototype.insertAfter = function(name, attributes, text) { + var child, i, removed; + if (this.isRoot) { + throw new Error("Cannot insert elements at root level. " + this.debugInfo(name)); + } + i = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i + 1); + child = this.parent.element(name, attributes, text); + Array.prototype.push.apply(this.parent.children, removed); + return child; + }; -/***/ 243: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLNode.prototype.remove = function() { + var i, ref2; + if (this.isRoot) { + throw new Error("Cannot remove the root element. " + this.debugInfo()); + } + i = this.parent.children.indexOf(this); + [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref2 = [])), ref2; + return this.parent; + }; -"use strict"; + XMLNode.prototype.node = function(name, attributes, text) { + var child, ref2; + if (name != null) { + name = getValue(name); + } + attributes || (attributes = {}); + attributes = getValue(attributes); + if (!isObject(attributes)) { + ref2 = [attributes, text], text = ref2[0], attributes = ref2[1]; + } + child = new XMLElement(this, name, attributes); + if (text != null) { + child.text(text); + } + this.children.push(child); + return child; + }; -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); + XMLNode.prototype.text = function(value) { + var child; + if (isObject(value)) { + this.element(value); + } + child = new XMLText(this, value); + this.children.push(child); + return this; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLNode.prototype.cdata = function(value) { + var child; + child = new XMLCData(this, value); + this.children.push(child); + return this; }; -})(); -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 }; - } + + XMLNode.prototype.comment = function(value) { + var child; + child = new XMLComment(this, value); + this.children.push(child); + return this; }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var interfaces_1 = __nccwpck_require__(7305); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * Serializes XML nodes into objects and arrays. - */ -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); + + XMLNode.prototype.commentBefore = function(value) { + var child, i, removed; + i = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i); + child = this.parent.comment(value); + Array.prototype.push.apply(this.parent.children, removed); + return this; + }; + + XMLNode.prototype.commentAfter = function(value) { + var child, i, removed; + i = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i + 1); + child = this.parent.comment(value); + Array.prototype.push.apply(this.parent.children, removed); + return this; + }; + + XMLNode.prototype.raw = function(value) { + var child; + child = new XMLRaw(this, value); + this.children.push(child); + return this; + }; + + XMLNode.prototype.dummy = function() { + var child; + child = new XMLDummy(this); + return child; + }; + + XMLNode.prototype.instruction = function(target, value) { + var insTarget, insValue, instruction, j, len; + if (target != null) { + target = getValue(target); + } + if (value != null) { + value = getValue(value); + } + if (Array.isArray(target)) { + for (j = 0, len = target.length; j < len; j++) { + insTarget = target[j]; + this.instruction(insTarget); + } + } else if (isObject(target)) { + for (insTarget in target) { + if (!hasProp.call(target, insTarget)) continue; + insValue = target[insTarget]; + this.instruction(insTarget, insValue); + } + } else { + if (isFunction(value)) { + value = value.apply(); + } + instruction = new XMLProcessingInstruction(this, target, value); + this.children.push(instruction); + } + return this; }; - 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; - } + + XMLNode.prototype.instructionBefore = function(target, value) { + var child, i, removed; + i = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i); + child = this.parent.instruction(target, value); + Array.prototype.push.apply(this.parent.children, removed); + return this; + }; + + XMLNode.prototype.instructionAfter = function(target, value) { + var child, i, removed; + i = this.parent.children.indexOf(this); + removed = this.parent.children.splice(i + 1); + child = this.parent.instruction(target, value); + Array.prototype.push.apply(this.parent.children, removed); + return this; + }; + + XMLNode.prototype.declaration = function(version, encoding, standalone) { + var doc, xmldec; + doc = this.document(); + xmldec = new XMLDeclaration(doc, version, encoding, standalone); + if (doc.children.length === 0) { + doc.children.unshift(xmldec); + } else if (doc.children[0].type === NodeType.Declaration) { + doc.children[0] = xmldec; + } else { + doc.children.unshift(xmldec); + } + return doc.root() || doc; + }; + + XMLNode.prototype.dtd = function(pubID, sysID) { + var child, doc, doctype, i, j, k, len, len1, ref2, ref3; + doc = this.document(); + doctype = new XMLDocType(doc, pubID, sysID); + ref2 = doc.children; + for (i = j = 0, len = ref2.length; j < len; i = ++j) { + child = ref2[i]; + if (child.type === NodeType.DocType) { + doc.children[i] = doctype; + return doctype; } - 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]["#"]; + } + ref3 = doc.children; + for (i = k = 0, len1 = ref3.length; k < len1; i = ++k) { + child = ref3[i]; + if (child.isRoot) { + doc.children.splice(i, 0, doctype); + return doctype; } - 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; + } + doc.children.push(doctype); + return doctype; + }; + + XMLNode.prototype.up = function() { + if (this.isRoot) { + throw new Error("The root node has no parent. Use doc() if you need to get the document object."); + } + return this.parent; + }; + + XMLNode.prototype.root = function() { + var node; + node = this; + while (node) { + if (node.type === NodeType.Document) { + return node.rootObject; + } else if (node.isRoot) { + return node; + } else { + node = node.parent; } - 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; + } + }; + + XMLNode.prototype.document = function() { + var node; + node = this; + while (node) { + if (node.type === NodeType.Document) { + return node; + } else { + node = node.parent; } + } }; - 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; } - } + + XMLNode.prototype.end = function(options) { + return this.document().end(options); + }; + + XMLNode.prototype.prev = function() { + var i; + i = this.parent.children.indexOf(this); + if (i < 1) { + throw new Error("Already at the first node. " + this.debugInfo()); + } + return this.parent.children[i - 1]; + }; + + XMLNode.prototype.next = function() { + var i; + i = this.parent.children.indexOf(this); + if (i === -1 || i === this.parent.children.length - 1) { + throw new Error("Already at the last node. " + this.debugInfo()); + } + return this.parent.children[i + 1]; + }; + + XMLNode.prototype.importDocument = function(doc) { + var clonedRoot; + clonedRoot = doc.root().clone(); + clonedRoot.parent = this; + clonedRoot.isRoot = false; + this.children.push(clonedRoot); + return this; + }; + + XMLNode.prototype.debugInfo = function(name) { + var ref2, ref3; + name = name || this.name; + if ((name == null) && !((ref2 = this.parent) != null ? ref2.name : void 0)) { + return ""; + } else if (name == null) { + return "parent: <" + this.parent.name + ">"; + } else if (!((ref3 = this.parent) != null ? ref3.name : void 0)) { + return "node: <" + name + ">"; + } else { + return "node: <" + name + ">, parent: <" + this.parent.name + ">"; + } + }; + + XMLNode.prototype.ele = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + + XMLNode.prototype.nod = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + + XMLNode.prototype.txt = function(value) { + return this.text(value); + }; + + XMLNode.prototype.dat = function(value) { + return this.cdata(value); + }; + + XMLNode.prototype.com = function(value) { + return this.comment(value); + }; + + XMLNode.prototype.ins = function(target, value) { + return this.instruction(target, value); + }; + + XMLNode.prototype.doc = function() { + return this.document(); + }; + + XMLNode.prototype.dec = function(version, encoding, standalone) { + return this.declaration(version, encoding, standalone); + }; + + XMLNode.prototype.e = function(name, attributes, text) { + return this.element(name, attributes, text); + }; + + XMLNode.prototype.n = function(name, attributes, text) { + return this.node(name, attributes, text); + }; + + XMLNode.prototype.t = function(value) { + return this.text(value); + }; + + XMLNode.prototype.d = function(value) { + return this.cdata(value); + }; + + XMLNode.prototype.c = function(value) { + return this.comment(value); + }; + + XMLNode.prototype.r = function(value) { + return this.raw(value); + }; + + XMLNode.prototype.i = function(target, value) { + return this.instruction(target, value); + }; + + XMLNode.prototype.u = function() { + return this.up(); + }; + + XMLNode.prototype.importXMLBuilder = function(doc) { + return this.importDocument(doc); + }; + + XMLNode.prototype.replaceChild = function(newChild, oldChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.removeChild = function(oldChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.appendChild = function(newChild) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.hasChildNodes = function() { + return this.children.length !== 0; + }; + + XMLNode.prototype.cloneNode = function(deep) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.normalize = function() { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.isSupported = function(feature, version) { + return true; + }; + + XMLNode.prototype.hasAttributes = function() { + return this.attribs.length !== 0; + }; + + XMLNode.prototype.compareDocumentPosition = function(other) { + var ref, res; + ref = this; + if (ref === other) { + return 0; + } else if (this.document() !== other.document()) { + res = DocumentPosition.Disconnected | DocumentPosition.ImplementationSpecific; + if (Math.random() < 0.5) { + res |= DocumentPosition.Preceding; + } else { + res |= DocumentPosition.Following; } - else { - var key = count > 1 ? defKey + (id++).toString() : defKey; - obj[key] = item; + return res; + } else if (ref.isAncestor(other)) { + return DocumentPosition.Contains | DocumentPosition.Preceding; + } else if (ref.isDescendant(other)) { + return DocumentPosition.Contains | DocumentPosition.Following; + } else if (ref.isPreceding(other)) { + return DocumentPosition.Preceding; + } else { + return DocumentPosition.Following; + } + }; + + XMLNode.prototype.isSameNode = function(other) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.lookupPrefix = function(namespaceURI) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.isDefaultNamespace = function(namespaceURI) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.lookupNamespaceURI = function(prefix) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.isEqualNode = function(node) { + var i, j, ref2; + if (node.nodeType !== this.nodeType) { + return false; + } + if (node.children.length !== this.children.length) { + return false; + } + for (i = j = 0, ref2 = this.children.length - 1; 0 <= ref2 ? j <= ref2 : j >= ref2; i = 0 <= ref2 ? ++j : --j) { + if (!this.children[i].isEqualNode(node.children[i])) { + return false; } - return id; + } + return true; }; - /** @inheritdoc */ - ObjectWriter.prototype.beginElement = function (name) { - var _a, _b; - var childItems = []; - if (this._currentList.length === 0) { - this._currentList.push((_a = {}, _a[name] = childItems, _a)); + + XMLNode.prototype.getFeature = function(feature, version) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.setUserData = function(key, data, handler) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.getUserData = function(key) { + throw new Error("This DOM method is not implemented." + this.debugInfo()); + }; + + XMLNode.prototype.contains = function(other) { + if (!other) { + return false; + } + return other === this || this.isDescendant(other); + }; + + XMLNode.prototype.isDescendant = function(node) { + var child, isDescendantChild, j, len, ref2; + ref2 = this.children; + for (j = 0, len = ref2.length; j < len; j++) { + child = ref2[j]; + if (node === child) { + return true; } - 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)); - } + isDescendantChild = child.isDescendant(node); + if (isDescendantChild) { + return true; } - this._currentIndex++; - if (this._listRegister.length > this._currentIndex) { - this._listRegister[this._currentIndex] = childItems; + } + return false; + }; + + XMLNode.prototype.isAncestor = function(node) { + return node.isDescendant(this); + }; + + XMLNode.prototype.isPreceding = function(node) { + var nodePos, thisPos; + nodePos = this.treePosition(node); + thisPos = this.treePosition(this); + if (nodePos === -1 || thisPos === -1) { + return false; + } else { + return nodePos < thisPos; + } + }; + + XMLNode.prototype.isFollowing = function(node) { + var nodePos, thisPos; + nodePos = this.treePosition(node); + thisPos = this.treePosition(this); + if (nodePos === -1 || thisPos === -1) { + return false; + } else { + return nodePos > thisPos; + } + }; + + XMLNode.prototype.treePosition = function(node) { + var found, pos; + pos = 0; + found = false; + this.foreachTreeNode(this.document(), function(childNode) { + pos++; + if (!found && childNode === node) { + return found = true; } - else { - this._listRegister.push(childItems); + }); + if (found) { + return pos; + } else { + return -1; + } + }; + + XMLNode.prototype.foreachTreeNode = function(node, func) { + var child, j, len, ref2, res; + node || (node = this.document()); + ref2 = node.children; + for (j = 0, len = ref2.length; j < len; j++) { + child = ref2[j]; + if (res = func(child)) { + return res; + } else { + res = this.foreachTreeNode(child, func); + if (res) { + return res; + } } - this._currentList = childItems; + } + }; + + return XMLNode; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 6768: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLNodeList; + + module.exports = XMLNodeList = (function() { + function XMLNodeList(nodes) { + this.nodes = nodes; + } + + Object.defineProperty(XMLNodeList.prototype, 'length', { + get: function() { + return this.nodes.length || 0; + } + }); + + XMLNodeList.prototype.clone = function() { + return this.nodes = null; + }; + + XMLNodeList.prototype.item = function(index) { + return this.nodes[index] || null; + }; + + return XMLNodeList; + + })(); + +}).call(this); + + +/***/ }), + +/***/ 6939: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLCharacterData, XMLProcessingInstruction, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + NodeType = __nccwpck_require__(9267); + + XMLCharacterData = __nccwpck_require__(7709); + + module.exports = XMLProcessingInstruction = (function(superClass) { + extend(XMLProcessingInstruction, superClass); + + function XMLProcessingInstruction(parent, target, value) { + XMLProcessingInstruction.__super__.constructor.call(this, parent); + if (target == null) { + throw new Error("Missing instruction target. " + this.debugInfo()); + } + this.type = NodeType.ProcessingInstruction; + this.target = this.stringify.insTarget(target); + this.name = this.target; + if (value) { + this.value = this.stringify.insValue(value); + } + } + + XMLProcessingInstruction.prototype.clone = function() { + return Object.create(this); + }; + + XMLProcessingInstruction.prototype.toString = function(options) { + return this.options.writer.processingInstruction(this, this.options.writer.filterOptions(options)); + }; + + XMLProcessingInstruction.prototype.isEqualNode = function(node) { + if (!XMLProcessingInstruction.__super__.isEqualNode.apply(this, arguments).isEqualNode(node)) { + return false; + } + if (node.target !== this.target) { + return false; + } + return true; + }; + + return XMLProcessingInstruction; + + })(XMLCharacterData); + +}).call(this); + + +/***/ }), + +/***/ 6329: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, XMLNode, XMLRaw, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + NodeType = __nccwpck_require__(9267); + + XMLNode = __nccwpck_require__(7608); + + module.exports = XMLRaw = (function(superClass) { + extend(XMLRaw, superClass); + + function XMLRaw(parent, text) { + XMLRaw.__super__.constructor.call(this, parent); + if (text == null) { + throw new Error("Missing raw text. " + this.debugInfo()); + } + this.type = NodeType.Raw; + this.value = this.stringify.raw(text); + } + + XMLRaw.prototype.clone = function() { + return Object.create(this); + }; + + XMLRaw.prototype.toString = function(options) { + return this.options.writer.raw(this, this.options.writer.filterOptions(options)); + }; + + return XMLRaw; + + })(XMLNode); + +}).call(this); + + +/***/ }), + +/***/ 8601: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, WriterState, XMLStreamWriter, XMLWriterBase, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; + + NodeType = __nccwpck_require__(9267); + + XMLWriterBase = __nccwpck_require__(6752); + + WriterState = __nccwpck_require__(9766); + + module.exports = XMLStreamWriter = (function(superClass) { + extend(XMLStreamWriter, superClass); + + function XMLStreamWriter(stream, options) { + this.stream = stream; + XMLStreamWriter.__super__.constructor.call(this, options); + } + + XMLStreamWriter.prototype.endline = function(node, options, level) { + if (node.isLastRootNode && options.state === WriterState.CloseTag) { + return ''; + } else { + return XMLStreamWriter.__super__.endline.call(this, node, options, level); + } }; - /** @inheritdoc */ - ObjectWriter.prototype.endElement = function () { - this._currentList = this._listRegister[--this._currentIndex]; + + XMLStreamWriter.prototype.document = function(doc, options) { + var child, i, j, k, len, len1, ref, ref1, results; + ref = doc.children; + for (i = j = 0, len = ref.length; j < len; i = ++j) { + child = ref[i]; + child.isLastRootNode = i === doc.children.length - 1; + } + options = this.filterOptions(options); + ref1 = doc.children; + results = []; + for (k = 0, len1 = ref1.length; k < len1; k++) { + child = ref1[k]; + results.push(this.writeChildNode(child, options, 0)); + } + return results; }; - /** @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) }); - } - } + + XMLStreamWriter.prototype.attribute = function(att, options, level) { + return this.stream.write(XMLStreamWriter.__super__.attribute.call(this, att, options, level)); }; - /** @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 }); - } - } + + XMLStreamWriter.prototype.cdata = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.cdata.call(this, node, options, level)); }; - /** @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 }); - } - } + + XMLStreamWriter.prototype.comment = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.comment.call(this, node, options, level)); }; - /** @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 }); - } + + XMLStreamWriter.prototype.declaration = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.declaration.call(this, node, options, level)); + }; + + XMLStreamWriter.prototype.docType = function(node, options, level) { + var child, j, len, ref; + level || (level = 0); + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + this.stream.write(this.indent(node, options, level)); + this.stream.write(' 0) { + this.stream.write(' ['); + this.stream.write(this.endline(node, options, level)); + options.state = WriterState.InsideTag; + ref = node.children; + for (j = 0, len = ref.length; j < len; j++) { + child = ref[j]; + this.writeChildNode(child, options, level + 1); } + options.state = WriterState.CloseTag; + this.stream.write(']'); + } + options.state = WriterState.CloseTag; + this.stream.write(options.spaceBeforeSlash + '>'); + this.stream.write(this.endline(node, options, level)); + options.state = WriterState.None; + return this.closeNode(node, options, level); }; - /** @inheritdoc */ - ObjectWriter.prototype.cdata = function (data) { - if (this._currentList.length === 0) { - this._currentList.push({ "$": data }); + + XMLStreamWriter.prototype.element = function(node, options, level) { + var att, child, childNodeCount, firstChildNode, j, len, name, prettySuppressed, ref, ref1; + level || (level = 0); + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + this.stream.write(this.indent(node, options, level) + '<' + node.name); + ref = node.attribs; + for (name in ref) { + if (!hasProp.call(ref, name)) continue; + att = ref[name]; + this.attribute(att, options, level); + } + childNodeCount = node.children.length; + firstChildNode = childNodeCount === 0 ? null : node.children[0]; + if (childNodeCount === 0 || node.children.every(function(e) { + return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === ''; + })) { + if (options.allowEmpty) { + this.stream.write('>'); + options.state = WriterState.CloseTag; + this.stream.write(''); + } else { + options.state = WriterState.CloseTag; + this.stream.write(options.spaceBeforeSlash + '/>'); } - 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 }); - } + } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) { + this.stream.write('>'); + options.state = WriterState.InsideTag; + options.suppressPrettyCount++; + prettySuppressed = true; + this.writeChildNode(firstChildNode, options, level + 1); + options.suppressPrettyCount--; + prettySuppressed = false; + options.state = WriterState.CloseTag; + this.stream.write(''); + } else { + this.stream.write('>' + this.endline(node, options, level)); + options.state = WriterState.InsideTag; + ref1 = node.children; + for (j = 0, len = ref1.length; j < len; j++) { + child = ref1[j]; + this.writeChildNode(child, options, level + 1); } + options.state = WriterState.CloseTag; + this.stream.write(this.indent(node, options, level) + ''); + } + this.stream.write(this.endline(node, options, level)); + options.state = WriterState.None; + return this.closeNode(node, options, level); }; - ObjectWriter.prototype._isAttrNode = function (x) { - return "@" in x; - }; - ObjectWriter.prototype._isTextNode = function (x) { - return "#" in x; + + XMLStreamWriter.prototype.processingInstruction = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.processingInstruction.call(this, node, options, level)); }; - ObjectWriter.prototype._isCommentNode = function (x) { - return "!" in x; + + XMLStreamWriter.prototype.raw = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.raw.call(this, node, options, level)); }; - ObjectWriter.prototype._isInstructionNode = function (x) { - return "?" in x; + + XMLStreamWriter.prototype.text = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.text.call(this, node, options, level)); }; - ObjectWriter.prototype._isCDATANode = function (x) { - return "$" in x; + + XMLStreamWriter.prototype.dtdAttList = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdAttList.call(this, node, options, level)); }; - ObjectWriter.prototype._isElementNode = function (x, name) { - return name in x; + + XMLStreamWriter.prototype.dtdElement = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdElement.call(this, node, options, level)); }; - /** - * Returns an object key for an attribute or namespace declaration. - */ - ObjectWriter.prototype._getAttrKey = function () { - return this._builderOptions.convert.att; + + XMLStreamWriter.prototype.dtdEntity = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdEntity.call(this, node, options, level)); }; - /** - * 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."); - } + + XMLStreamWriter.prototype.dtdNotation = function(node, options, level) { + return this.stream.write(XMLStreamWriter.__super__.dtdNotation.call(this, node, options, level)); }; - return ObjectWriter; -}(BaseWriter_1.BaseWriter)); -exports.ObjectWriter = ObjectWriter; -//# sourceMappingURL=ObjectWriter.js.map + + return XMLStreamWriter; + + })(XMLWriterBase); + +}).call(this); + /***/ }), -/***/ 7572: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { +/***/ 5913: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLStringWriter, XMLWriterBase, + extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + hasProp = {}.hasOwnProperty; -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 = __nccwpck_require__(708); -/** - * Serializes XML nodes. - */ -var XMLCBWriter = /** @class */ (function (_super) { - __extends(XMLCBWriter, _super); - /** - * Initializes a new instance of `XMLCBWriter`. - * - * @param builderOptions - XML builder options - */ - function XMLCBWriter(builderOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._lineLength = 0; - return _this; + XMLWriterBase = __nccwpck_require__(6752); + + module.exports = XMLStringWriter = (function(superClass) { + extend(XMLStringWriter, superClass); + + function XMLStringWriter(options) { + XMLStringWriter.__super__.constructor.call(this, options); } - /** @inheritdoc */ - XMLCBWriter.prototype.frontMatter = function () { - return ""; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.declaration = function (version, encoding, standalone) { - var markup = this._beginLine() + ""; - return markup; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.docType = function (name, publicId, systemId) { - var markup = this._beginLine(); - if (publicId && systemId) { - markup += ""; - } - else if (publicId) { - markup += ""; - } - else if (systemId) { - markup += ""; - } - else { - markup += ""; - } - return markup; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.comment = function (data) { - return this._beginLine() + ""; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.text = function (data) { - return this._beginLine() + data; - }; - /** @inheritdoc */ - XMLCBWriter.prototype.instruction = function (target, data) { - if (data) { - return this._beginLine() + ""; - } - else { - return this._beginLine() + ""; - } + + XMLStringWriter.prototype.document = function(doc, options) { + var child, i, len, r, ref; + options = this.filterOptions(options); + r = ''; + ref = doc.children; + for (i = 0, len = ref.length; i < len; i++) { + child = ref[i]; + r += this.writeChildNode(child, options, 0); + } + if (options.pretty && r.slice(-options.newline.length) === options.newline) { + r = r.slice(0, -options.newline.length); + } + return r; }; - /** @inheritdoc */ - XMLCBWriter.prototype.cdata = function (data) { - return this._beginLine() + ""; + + return XMLStringWriter; + + })(XMLWriterBase); + +}).call(this); + + +/***/ }), + +/***/ 8594: +/***/ (function(module) { + +// Generated by CoffeeScript 1.12.7 +(function() { + var XMLStringifier, + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + hasProp = {}.hasOwnProperty; + + module.exports = XMLStringifier = (function() { + function XMLStringifier(options) { + this.assertLegalName = bind(this.assertLegalName, this); + this.assertLegalChar = bind(this.assertLegalChar, this); + var key, ref, value; + options || (options = {}); + this.options = options; + if (!this.options.version) { + this.options.version = '1.0'; + } + ref = options.stringify || {}; + for (key in ref) { + if (!hasProp.call(ref, key)) continue; + value = ref[key]; + this[key] = value; + } + } + + XMLStringifier.prototype.name = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalName('' + val || ''); }; - /** @inheritdoc */ - XMLCBWriter.prototype.openTagBegin = function (name) { - this._lineLength += 1 + name.length; - return this._beginLine() + "<" + name; + + XMLStringifier.prototype.text = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar(this.textEscape('' + val || '')); }; - /** @inheritdoc */ - XMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (voidElement) { - return " />"; - } - else if (selfClosing) { - if (this._writerOptions.allowEmptyTags) { - return ">"; - } - else if (this._writerOptions.spaceBeforeSlash) { - return " />"; - } - else { - return "/>"; - } - } - else { - return ">"; - } + + XMLStringifier.prototype.cdata = function(val) { + if (this.options.noValidation) { + return val; + } + val = '' + val || ''; + val = val.replace(']]>', ']]]]>'); + return this.assertLegalChar(val); }; - /** @inheritdoc */ - XMLCBWriter.prototype.closeTag = function (name) { - return this._beginLine() + ""; + + XMLStringifier.prototype.comment = function(val) { + if (this.options.noValidation) { + return val; + } + val = '' + val || ''; + if (val.match(/--/)) { + throw new Error("Comment text cannot contain double-hypen: " + val); + } + return this.assertLegalChar(val); }; - /** @inheritdoc */ - XMLCBWriter.prototype.attribute = function (name, value) { - var str = name + "=\"" + value + "\""; - if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && - this._lineLength + 1 + str.length > this._writerOptions.width) { - str = this._beginLine() + this._indent(1) + str; - this._lineLength = str.length; - return str; - } - else { - this._lineLength += 1 + str.length; - return " " + str; - } + + XMLStringifier.prototype.raw = function(val) { + if (this.options.noValidation) { + return val; + } + return '' + val || ''; }; - /** @inheritdoc */ - XMLCBWriter.prototype.beginElement = function (name) { }; - /** @inheritdoc */ - XMLCBWriter.prototype.endElement = function (name) { }; - /** - * Produces characters to be prepended to a line of string in pretty-print - * mode. - */ - XMLCBWriter.prototype._beginLine = function () { - if (this._writerOptions.prettyPrint) { - var str = (this.hasData ? this._writerOptions.newline : "") + - this._indent(this._writerOptions.offset + this.level); - this._lineLength = str.length; - return str; - } - else { - return ""; - } + + XMLStringifier.prototype.attValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar(this.attEscape(val = '' + val || '')); }; - /** - * Produces an indentation string. - * - * @param level - depth of the tree - */ - XMLCBWriter.prototype._indent = function (level) { - if (level <= 0) { - return ""; - } - else { - return this._writerOptions.indent.repeat(level); - } + + XMLStringifier.prototype.insTarget = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - return XMLCBWriter; -}(BaseCBWriter_1.BaseCBWriter)); -exports.XMLCBWriter = XMLCBWriter; -//# sourceMappingURL=XMLCBWriter.js.map -/***/ }), + XMLStringifier.prototype.insValue = function(val) { + if (this.options.noValidation) { + return val; + } + val = '' + val || ''; + if (val.match(/\?>/)) { + throw new Error("Invalid processing instruction value: " + val); + } + return this.assertLegalChar(val); + }; -/***/ 9606: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + XMLStringifier.prototype.xmlVersion = function(val) { + if (this.options.noValidation) { + return val; + } + val = '' + val || ''; + if (!val.match(/1\.[0-9]+/)) { + throw new Error("Invalid version number: " + val); + } + return val; + }; -"use strict"; + XMLStringifier.prototype.xmlEncoding = function(val) { + if (this.options.noValidation) { + return val; + } + val = '' + val || ''; + if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) { + throw new Error("Invalid encoding: " + val); + } + return this.assertLegalChar(val); + }; -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); + XMLStringifier.prototype.xmlStandalone = function(val) { + if (this.options.noValidation) { + return val; + } + if (val) { + return "yes"; + } else { + return "no"; + } }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLStringifier.prototype.dtdPubID = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; -})(); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var util_1 = __nccwpck_require__(6195); -var interfaces_1 = __nccwpck_require__(7305); -var BaseWriter_1 = __nccwpck_require__(7644); -var util_2 = __nccwpck_require__(5282); -/** - * Serializes XML nodes into strings. - */ -var XMLWriter = /** @class */ (function (_super) { - __extends(XMLWriter, _super); - /** - * Initializes a new instance of `XMLWriter`. - * - * @param builderOptions - XML builder options - * @param writerOptions - serialization options - */ - function XMLWriter(builderOptions, writerOptions) { - var _this = _super.call(this, builderOptions) || this; - _this._indentation = {}; - _this._lengthToLastNewline = 0; - // provide default options - _this._writerOptions = util_1.applyDefaults(writerOptions, { - wellFormed: false, - noDoubleEncoding: false, - headless: false, - prettyPrint: false, - indent: " ", - newline: "\n", - offset: 0, - width: 0, - allowEmptyTags: false, - indentTextOnlyNodes: false, - spaceBeforeSlash: false - }); - return _this; - } - /** - * Produces an XML serialization of the given node. - * - * @param node - node to serialize - */ - XMLWriter.prototype.serialize = function (node) { - this._refs = { suppressPretty: false, emptyNode: false, markup: "" }; - // Serialize XML declaration - if (node.nodeType === interfaces_1.NodeType.Document && !this._writerOptions.headless) { - this.declaration(this._builderOptions.version, this._builderOptions.encoding, this._builderOptions.standalone); - } - // recursively serialize node - this.serializeNode(node, this._writerOptions.wellFormed, this._writerOptions.noDoubleEncoding); - // remove trailing newline - if (this._writerOptions.prettyPrint && - this._refs.markup.slice(-this._writerOptions.newline.length) === this._writerOptions.newline) { - this._refs.markup = this._refs.markup.slice(0, -this._writerOptions.newline.length); - } - return this._refs.markup; + + XMLStringifier.prototype.dtdSysID = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.declaration = function (version, encoding, standalone) { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); + + XMLStringifier.prototype.dtdElementValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.docType = function (name, publicId, systemId) { - this._beginLine(); - if (publicId && systemId) { - this._refs.markup += ""; - } - else if (publicId) { - this._refs.markup += ""; - } - else if (systemId) { - this._refs.markup += ""; - } - else { - this._refs.markup += ""; - } - this._endLine(); + + XMLStringifier.prototype.dtdAttType = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.openTagBegin = function (name) { - this._beginLine(); - this._refs.markup += "<" + name; + + XMLStringifier.prototype.dtdAttDefault = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - // do not indent text only elements or elements with empty text nodes - this._refs.suppressPretty = false; - this._refs.emptyNode = false; - if (this._writerOptions.prettyPrint && !selfClosing && !voidElement) { - var textOnlyNode = true; - var emptyNode = true; - var childNode = this.currentNode.firstChild; - var cdataCount = 0; - var textCount = 0; - while (childNode) { - if (util_2.Guard.isExclusiveTextNode(childNode)) { - textCount++; - } - else if (util_2.Guard.isCDATASectionNode(childNode)) { - cdataCount++; - } - else { - textOnlyNode = false; - emptyNode = false; - break; - } - if (childNode.data !== '') { - emptyNode = false; - } - childNode = childNode.nextSibling; - } - this._refs.suppressPretty = !this._writerOptions.indentTextOnlyNodes && textOnlyNode && ((cdataCount <= 1 && textCount === 0) || cdataCount === 0); - this._refs.emptyNode = emptyNode; - } - if ((voidElement || selfClosing || this._refs.emptyNode) && this._writerOptions.allowEmptyTags) { - this._refs.markup += ">"; - } - else { - this._refs.markup += voidElement ? " />" : - (selfClosing || this._refs.emptyNode) ? (this._writerOptions.spaceBeforeSlash ? " />" : "/>") : ">"; - } - this._endLine(); + + XMLStringifier.prototype.dtdEntityValue = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.closeTag = function (name) { - if (!this._refs.emptyNode) { - this._beginLine(); - this._refs.markup += ""; - } - this._refs.suppressPretty = false; - this._refs.emptyNode = false; - this._endLine(); + + XMLStringifier.prototype.dtdNData = function(val) { + if (this.options.noValidation) { + return val; + } + return this.assertLegalChar('' + val || ''); }; - /** @inheritdoc */ - XMLWriter.prototype.attribute = function (name, value) { - var str = name + "=\"" + value + "\""; - if (this._writerOptions.prettyPrint && this._writerOptions.width > 0 && - this._refs.markup.length - this._lengthToLastNewline + 1 + str.length > this._writerOptions.width) { - this._endLine(); - this._beginLine(); - this._refs.markup += this._indent(1) + str; - } - else { - this._refs.markup += " " + str; + + XMLStringifier.prototype.convertAttKey = '@'; + + XMLStringifier.prototype.convertPIKey = '?'; + + XMLStringifier.prototype.convertTextKey = '#text'; + + XMLStringifier.prototype.convertCDataKey = '#cdata'; + + XMLStringifier.prototype.convertCommentKey = '#comment'; + + XMLStringifier.prototype.convertRawKey = '#raw'; + + XMLStringifier.prototype.assertLegalChar = function(str) { + var regex, res; + if (this.options.noValidation) { + return str; + } + regex = ''; + if (this.options.version === '1.0') { + regex = /[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; + if (res = str.match(regex)) { + throw new Error("Invalid character in string: " + str + " at index " + res.index); } - }; - /** @inheritdoc */ - XMLWriter.prototype.text = function (data) { - if (data !== '') { - this._beginLine(); - this._refs.markup += data; - this._endLine(); + } else if (this.options.version === '1.1') { + regex = /[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; + if (res = str.match(regex)) { + throw new Error("Invalid character in string: " + str + " at index " + res.index); } + } + return str; }; - /** @inheritdoc */ - XMLWriter.prototype.cdata = function (data) { - if (data !== '') { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); - } + + XMLStringifier.prototype.assertLegalName = function(str) { + var regex; + if (this.options.noValidation) { + return str; + } + this.assertLegalChar(str); + regex = /^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_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])*$/; + if (!str.match(regex)) { + throw new Error("Invalid character in name"); + } + return str; }; - /** @inheritdoc */ - XMLWriter.prototype.comment = function (data) { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); + + XMLStringifier.prototype.textEscape = function(str) { + var ampregex; + if (this.options.noValidation) { + return str; + } + ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; + return str.replace(ampregex, '&').replace(//g, '>').replace(/\r/g, ' '); }; - /** @inheritdoc */ - XMLWriter.prototype.instruction = function (target, data) { - this._beginLine(); - this._refs.markup += ""; - this._endLine(); + + XMLStringifier.prototype.attEscape = function(str) { + var ampregex; + if (this.options.noValidation) { + return str; + } + ampregex = this.options.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g; + return str.replace(ampregex, '&').replace(/ 0) { + return new Array(indentLevel).join(options.indent); } - 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); + } + return ''; }; - /** @inheritdoc */ - YAMLCBWriter.prototype.text = function (data) { - // "#": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.text) + " " + - this._val(data); + + XMLWriterBase.prototype.endline = function(node, options, level) { + if (!options.pretty || options.suppressPrettyCount) { + return ''; + } else { + return options.newline; + } }; - /** @inheritdoc */ - YAMLCBWriter.prototype.instruction = function (target, data) { - // "?": "target hello" - return this._beginLine() + - this._key(this._builderOptions.convert.ins) + " " + - this._val(data ? target + " " + data : target); + + XMLWriterBase.prototype.attribute = function(att, options, level) { + var r; + this.openAttribute(att, options, level); + r = ' ' + att.name + '="' + att.value + '"'; + this.closeAttribute(att, options, level); + return r; }; - /** @inheritdoc */ - YAMLCBWriter.prototype.cdata = function (data) { - // "$": "hello" - return this._beginLine() + - this._key(this._builderOptions.convert.cdata) + " " + - this._val(data); + + XMLWriterBase.prototype.cdata = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** @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; + + XMLWriterBase.prototype.comment = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** @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; + + XMLWriterBase.prototype.declaration = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + ''; + r += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** @inheritdoc */ - YAMLCBWriter.prototype.openTagEnd = function (name, selfClosing, voidElement) { - if (selfClosing) { - return " " + this._val(""); + + XMLWriterBase.prototype.docType = function(node, options, level) { + var child, i, len, r, ref; + level || (level = 0); + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level); + r += ' 0) { + r += ' ['; + r += this.endline(node, options, level); + options.state = WriterState.InsideTag; + ref = node.children; + for (i = 0, len = ref.length; i < len; i++) { + child = ref[i]; + r += this.writeChildNode(child, options, level + 1); } - 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 ""; + options.state = WriterState.CloseTag; + r += ']'; + } + options.state = WriterState.CloseTag; + r += options.spaceBeforeSlash + '>'; + r += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; + }; + + XMLWriterBase.prototype.element = function(node, options, level) { + var att, child, childNodeCount, firstChildNode, i, j, len, len1, name, prettySuppressed, r, ref, ref1, ref2; + level || (level = 0); + prettySuppressed = false; + r = ''; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r += this.indent(node, options, level) + '<' + node.name; + ref = node.attribs; + for (name in ref) { + if (!hasProp.call(ref, name)) continue; + att = ref[name]; + r += this.attribute(att, options, level); + } + childNodeCount = node.children.length; + firstChildNode = childNodeCount === 0 ? null : node.children[0]; + if (childNodeCount === 0 || node.children.every(function(e) { + return (e.type === NodeType.Text || e.type === NodeType.Raw) && e.value === ''; + })) { + if (options.allowEmpty) { + r += '>'; + options.state = WriterState.CloseTag; + r += '' + this.endline(node, options, level); + } else { + options.state = WriterState.CloseTag; + r += options.spaceBeforeSlash + '/>' + this.endline(node, options, level); } - 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); + } else if (options.pretty && childNodeCount === 1 && (firstChildNode.type === NodeType.Text || firstChildNode.type === NodeType.Raw) && (firstChildNode.value != null)) { + r += '>'; + options.state = WriterState.InsideTag; + options.suppressPrettyCount++; + prettySuppressed = true; + r += this.writeChildNode(firstChildNode, options, level + 1); + options.suppressPrettyCount--; + prettySuppressed = false; + options.state = WriterState.CloseTag; + r += '' + this.endline(node, options, level); + } else { + if (options.dontPrettyTextNodes) { + ref1 = node.children; + for (i = 0, len = ref1.length; i < len; i++) { + child = ref1[i]; + if ((child.type === NodeType.Text || child.type === NodeType.Raw) && (child.value != null)) { + options.suppressPrettyCount++; + prettySuppressed = true; + break; } - return chars; + } } + r += '>' + this.endline(node, options, level); + options.state = WriterState.InsideTag; + ref2 = node.children; + for (j = 0, len1 = ref2.length; j < len1; j++) { + child = ref2[j]; + r += this.writeChildNode(child, options, level + 1); + } + options.state = WriterState.CloseTag; + r += this.indent(node, options, level) + ''; + if (prettySuppressed) { + options.suppressPrettyCount--; + } + r += this.endline(node, options, level); + options.state = WriterState.None; + } + this.closeNode(node, options, level); + return r; }; - /** - * 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 -/***/ }), - -/***/ 6517: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; + XMLWriterBase.prototype.writeChildNode = function(node, options, level) { + switch (node.type) { + case NodeType.CData: + return this.cdata(node, options, level); + case NodeType.Comment: + return this.comment(node, options, level); + case NodeType.Element: + return this.element(node, options, level); + case NodeType.Raw: + return this.raw(node, options, level); + case NodeType.Text: + return this.text(node, options, level); + case NodeType.ProcessingInstruction: + return this.processingInstruction(node, options, level); + case NodeType.Dummy: + return ''; + case NodeType.Declaration: + return this.declaration(node, options, level); + case NodeType.DocType: + return this.docType(node, options, level); + case NodeType.AttributeDeclaration: + return this.dtdAttList(node, options, level); + case NodeType.ElementDeclaration: + return this.dtdElement(node, options, level); + case NodeType.EntityDeclaration: + return this.dtdEntity(node, options, level); + case NodeType.NotationDeclaration: + return this.dtdNotation(node, options, level); + default: + throw new Error("Unknown XML node type: " + node.constructor.name); + } + }; -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); + XMLWriterBase.prototype.processingInstruction = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + ''; + r += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + + XMLWriterBase.prototype.raw = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level); + options.state = WriterState.InsideTag; + r += node.value; + options.state = WriterState.CloseTag; + r += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; -})(); -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 }; - } + + XMLWriterBase.prototype.text = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level); + options.state = WriterState.InsideTag; + r += node.value; + options.state = WriterState.CloseTag; + r += this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -var ObjectWriter_1 = __nccwpck_require__(243); -var util_1 = __nccwpck_require__(6195); -var BaseWriter_1 = __nccwpck_require__(7644); -/** - * 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; + + XMLWriterBase.prototype.dtdAttList = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** - * 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; + + XMLWriterBase.prototype.dtdElement = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** - * 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); + + XMLWriterBase.prototype.dtdEntity = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - /** - * 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); + + XMLWriterBase.prototype.dtdNotation = function(node, options, level) { + var r; + this.openNode(node, options, level); + options.state = WriterState.OpenTag; + r = this.indent(node, options, level) + '' + this.endline(node, options, level); + options.state = WriterState.None; + this.closeNode(node, options, level); + return r; }; - return YAMLWriter; -}(BaseWriter_1.BaseWriter)); -exports.YAMLWriter = YAMLWriter; -//# sourceMappingURL=YAMLWriter.js.map + + XMLWriterBase.prototype.openNode = function(node, options, level) {}; + + XMLWriterBase.prototype.closeNode = function(node, options, level) {}; + + XMLWriterBase.prototype.openAttribute = function(att, options, level) {}; + + XMLWriterBase.prototype.closeAttribute = function(att, options, level) {}; + + return XMLWriterBase; + + })(); + +}).call(this); + /***/ }), -/***/ 7476: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { +/***/ 2958: +/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) { -"use strict"; +// Generated by CoffeeScript 1.12.7 +(function() { + var NodeType, WriterState, XMLDOMImplementation, XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref; + + ref = __nccwpck_require__(8229), assign = ref.assign, isFunction = ref.isFunction; + + XMLDOMImplementation = __nccwpck_require__(8310); + + XMLDocument = __nccwpck_require__(3730); + + XMLDocumentCB = __nccwpck_require__(7356); + + XMLStringWriter = __nccwpck_require__(5913); + + XMLStreamWriter = __nccwpck_require__(8601); + + NodeType = __nccwpck_require__(9267); + + WriterState = __nccwpck_require__(9766); + + module.exports.create = function(name, xmldec, doctype, options) { + var doc, root; + if (name == null) { + throw new Error("Root element needs a name."); + } + options = assign({}, xmldec, doctype, options); + doc = new XMLDocument(options); + root = doc.element(name); + if (!options.headless) { + doc.declaration(options); + if ((options.pubID != null) || (options.sysID != null)) { + doc.dtd(options); + } + } + return root; + }; + + module.exports.begin = function(options, onData, onEnd) { + var ref1; + if (isFunction(options)) { + ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1]; + options = {}; + } + if (onData) { + return new XMLDocumentCB(options, onData, onEnd); + } else { + return new XMLDocument(options); + } + }; + + module.exports.stringWriter = function(options) { + return new XMLStringWriter(options); + }; + + module.exports.streamWriter = function(stream, options) { + return new XMLStreamWriter(stream, options); + }; + + module.exports.implementation = new XMLDOMImplementation(); + + module.exports.nodeType = NodeType; + + module.exports.writerState = WriterState; + +}).call(this); -Object.defineProperty(exports, "__esModule", ({ value: true })); -var MapWriter_1 = __nccwpck_require__(1397); -exports.MapWriter = MapWriter_1.MapWriter; -var XMLWriter_1 = __nccwpck_require__(9606); -exports.XMLWriter = XMLWriter_1.XMLWriter; -var ObjectWriter_1 = __nccwpck_require__(243); -exports.ObjectWriter = ObjectWriter_1.ObjectWriter; -var JSONWriter_1 = __nccwpck_require__(7510); -exports.JSONWriter = JSONWriter_1.JSONWriter; -var YAMLWriter_1 = __nccwpck_require__(6517); -exports.YAMLWriter = YAMLWriter_1.YAMLWriter; -//# sourceMappingURL=index.js.map /***/ }), @@ -103235,718 +103235,718 @@ try { /***/ (function(__unused_webpack_module, exports, __nccwpck_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()); + }); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.generate = exports.createAuthenticationSettings = exports.configureAuthentication = void 0; +const path = __importStar(__nccwpck_require__(1017)); +const core = __importStar(__nccwpck_require__(2186)); +const io = __importStar(__nccwpck_require__(7436)); +const fs = __importStar(__nccwpck_require__(7147)); +const os = __importStar(__nccwpck_require__(2037)); +const xmlbuilder2_1 = __nccwpck_require__(151); +const constants = __importStar(__nccwpck_require__(9042)); +const gpg = __importStar(__nccwpck_require__(3759)); +const util_1 = __nccwpck_require__(2629); +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(), constants.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 ${constants.MVN_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}}` + } + ] + } + } + }; + 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, constants.MVN_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' + }); + }); +} -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 = void 0; -const path = __importStar(__nccwpck_require__(1017)); -const core = __importStar(__nccwpck_require__(2186)); -const io = __importStar(__nccwpck_require__(7436)); -const fs = __importStar(__nccwpck_require__(7147)); -const os = __importStar(__nccwpck_require__(2037)); -const xmlbuilder2_1 = __nccwpck_require__(151); -const constants = __importStar(__nccwpck_require__(9042)); -const gpg = __importStar(__nccwpck_require__(3759)); -const util_1 = __nccwpck_require__(2629); -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(), constants.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 ${constants.MVN_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}}` - } - ] - } - } - }; - 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, constants.MVN_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' - }); - }); -} - - -/***/ }), - -/***/ 4810: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { - -"use strict"; - -/** - * @fileoverview this file provides methods handling dependency cache - */ -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.save = exports.restore = void 0; -const path_1 = __nccwpck_require__(1017); -const os_1 = __importDefault(__nccwpck_require__(2037)); -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const glob = __importStar(__nccwpck_require__(8090)); -const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'; -const CACHE_MATCHED_KEY = 'cache-matched-key'; -const CACHE_KEY_PREFIX = 'setup-java'; -const supportedPackageManager = [ - { - id: 'maven', - path: [path_1.join(os_1.default.homedir(), '.m2', 'repository')], - // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven - pattern: ['**/pom.xml'] - }, - { - id: 'gradle', - path: [path_1.join(os_1.default.homedir(), '.gradle', 'caches'), path_1.join(os_1.default.homedir(), '.gradle', 'wrapper')], - // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle - pattern: [ - '**/*.gradle*', - '**/gradle-wrapper.properties', - 'buildSrc/**/Versions.kt', - 'buildSrc/**/Dependencies.kt', - 'gradle/*.versions.toml' - ] - }, - { - id: 'sbt', - path: [ - path_1.join(os_1.default.homedir(), '.ivy2', 'cache'), - path_1.join(os_1.default.homedir(), '.sbt'), - getCoursierCachePath(), - // Some files should not be cached to avoid resolution problems. - // In particular the resolution of snapshots (ideological gap between maven/ivy). - '!' + path_1.join(os_1.default.homedir(), '.sbt', '*.lock'), - '!' + path_1.join(os_1.default.homedir(), '**', 'ivydata-*.properties') - ], - pattern: ['**/*.sbt', '**/project/build.properties', '**/project/**.{scala,sbt}'] - } -]; -function getCoursierCachePath() { - if (os_1.default.type() === 'Linux') - return path_1.join(os_1.default.homedir(), '.cache', 'coursier'); - if (os_1.default.type() === 'Darwin') - return path_1.join(os_1.default.homedir(), 'Library', 'Caches', 'Coursier'); - return path_1.join(os_1.default.homedir(), 'AppData', 'Local', 'Coursier', 'Cache'); -} -function findPackageManager(id) { - const packageManager = supportedPackageManager.find(packageManager => packageManager.id === id); - if (packageManager === undefined) { - throw new Error(`unknown package manager specified: ${id}`); - } - return packageManager; -} -/** - * A function that generates a cache key to use. - * Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". - * If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-). - * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key} - */ -function computeCacheKey(packageManager) { - return __awaiter(this, void 0, void 0, function* () { - const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); - return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; - }); -} -/** - * Restore the dependency cache - * @param id ID of the package manager, should be "maven" or "gradle" - */ -function restore(id) { - return __awaiter(this, void 0, void 0, function* () { - const packageManager = findPackageManager(id); - const primaryKey = yield computeCacheKey(packageManager); - core.debug(`primary key is ${primaryKey}`); - core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey); - if (primaryKey.endsWith('-')) { - throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); - } - // No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269) - const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey); - if (matchedKey) { - core.saveState(CACHE_MATCHED_KEY, matchedKey); - core.setOutput('cache-hit', matchedKey === primaryKey); - core.info(`Cache restored from key: ${matchedKey}`); - } - else { - core.setOutput('cache-hit', false); - core.info(`${packageManager.id} cache is not found`); - } - }); -} -exports.restore = restore; -/** - * Save the dependency cache - * @param id ID of the package manager, should be "maven" or "gradle" - */ -function save(id) { - return __awaiter(this, void 0, void 0, function* () { - const packageManager = findPackageManager(id); - const matchedKey = core.getState(CACHE_MATCHED_KEY); - // Inputs are re-evaluated before the post action, so we want the original key used for restore - const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); - if (!primaryKey) { - core.warning('Error retrieving key from state.'); - return; - } - else if (matchedKey === primaryKey) { - // no change in target directories - core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); - return; - } - try { - yield cache.saveCache(packageManager.path, primaryKey); - core.info(`Cache saved with the key: ${primaryKey}`); - } - catch (error) { - if (error.name === cache.ReserveCacheError.name) { - core.info(error.message); - } - else { - if (isProbablyGradleDaemonProblem(packageManager, error)) { - core.warning('Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.'); - } - throw error; - } - } - }); -} -exports.save = save; -/** - * @param packageManager the specified package manager by user - * @param error the error thrown by the saveCache - * @returns true if the given error seems related to the {@link https://github.com/actions/cache/issues/454|running Gradle Daemon issue}. - * @see {@link https://github.com/actions/cache/issues/454#issuecomment-840493935|why --no-daemon is necessary} - */ -function isProbablyGradleDaemonProblem(packageManager, error) { - if (packageManager.id !== 'gradle' || process.env['RUNNER_OS'] !== 'Windows') { - return false; - } - const message = error.message || ''; - return message.startsWith('Tar failed with error: '); -} - - -/***/ }), - -/***/ 9042: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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.INPUT_CACHE = 'cache'; -exports.INPUT_JOB_STATUS = 'job-status'; -exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; -exports.M2_DIR = '.m2'; -exports.MVN_SETTINGS_FILE = 'settings.xml'; -exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; -exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; -exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; - - -/***/ }), - -/***/ 8766: -/***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.AdoptDistribution = exports.AdoptImplementation = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const tc = __importStar(__nccwpck_require__(7784)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const semver_1 = __importDefault(__nccwpck_require__(1383)); -const base_installer_1 = __nccwpck_require__(9741); -const util_1 = __nccwpck_require__(2629); -var AdoptImplementation; -(function (AdoptImplementation) { - AdoptImplementation["Hotspot"] = "Hotspot"; - AdoptImplementation["OpenJ9"] = "OpenJ9"; -})(AdoptImplementation = exports.AdoptImplementation || (exports.AdoptImplementation = {})); -class AdoptDistribution extends base_installer_1.JavaBase { - constructor(installerOptions, jvmImpl) { - super(`Adopt-${jvmImpl}`, installerOptions); - this.jvmImpl = jvmImpl; - } - findPackageForDownload(version) { - return __awaiter(this, void 0, void 0, function* () { - const availableVersionsRaw = yield this.getAvailableVersions(); - const availableVersionsWithBinaries = availableVersionsRaw - .filter(item => item.binaries.length > 0) - .map(item => { - return { - version: item.version_data.semver, - url: item.binaries[0].package.link - }; - }); - const satisfiedVersions = availableVersionsWithBinaries - .filter(item => util_1.isVersionSatisfies(version, item.version)) - .sort((a, b) => { - return -semver_1.default.compareBuild(a.version, b.version); - }); - const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; - if (!resolvedFullVersion) { - const availableOptions = availableVersionsWithBinaries.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 javaPath; - 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 version = this.getToolcacheVersionName(javaRelease.version); - javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture); - return { version: javaRelease.version, path: javaPath }; - }); - } - get toolcacheFolderName() { - if (this.jvmImpl === AdoptImplementation.Hotspot) { - // exclude Hotspot postfix from distribution name because Hosted runners have pre-cached Adopt OpenJDK under "Java_Adopt_jdk" - // for more information see: https://github.com/actions/setup-java/pull/155#discussion_r610451063 - return `Java_Adopt_${this.packageType}`; - } - return super.toolcacheFolderName; - } - getAvailableVersions() { - return __awaiter(this, void 0, void 0, function* () { - const platform = this.getPlatformOption(); - const arch = this.distributionArchitecture(); - const imageType = this.packageType; - const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions - const releaseType = this.stable ? 'ga' : 'ea'; - if (core.isDebug()) { - console.time('adopt-retrieve-available-versions'); - } - const baseRequestArguments = [ - `project=jdk`, - 'vendor=adoptopenjdk', - `heap_size=normal`, - 'sort_method=DEFAULT', - 'sort_order=DESC', - `os=${platform}`, - `architecture=${arch}`, - `image_type=${imageType}`, - `release_type=${releaseType}`, - `jvm_impl=${this.jvmImpl.toLowerCase()}` - ].join('&'); - // need to iterate through all pages to retrieve the list of all versions - // Adopt API doesn't provide way to retrieve the count of pages to iterate so infinity loop - let page_index = 0; - const availableVersions = []; - while (true) { - const requestArguments = `${baseRequestArguments}&page_size=20&page=${page_index}`; - const availableVersionsUrl = `https://api.adoptopenjdk.net/v3/assets/version/${versionRange}?${requestArguments}`; - if (core.isDebug() && page_index === 0) { - // url is identical except page_index so print it once for debug - core.debug(`Gathering available versions from '${availableVersionsUrl}'`); - } - const paginationPage = (yield this.http.getJson(availableVersionsUrl)).result; - if (paginationPage === null || paginationPage.length === 0) { - // break infinity loop because we have reached end of pagination - break; - } - availableVersions.push(...paginationPage); - page_index++; - } - if (core.isDebug()) { - core.startGroup('Print information about available versions'); - console.timeEnd('adopt-retrieve-available-versions'); - console.log(`Available versions: [${availableVersions.length}]`); - console.log(availableVersions.map(item => item.version_data.semver).join(', ')); - core.endGroup(); - } - return availableVersions; - }); - } - getPlatformOption() { - // Adopt has own platform names so need to map them - switch (process.platform) { - case 'darwin': - return 'mac'; - case 'win32': - return 'windows'; - default: - return process.platform; - } - } -} -exports.AdoptDistribution = AdoptDistribution; +/***/ }), + +/***/ 4810: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { + +"use strict"; + +/** + * @fileoverview this file provides methods handling dependency cache + */ +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.save = exports.restore = void 0; +const path_1 = __nccwpck_require__(1017); +const os_1 = __importDefault(__nccwpck_require__(2037)); +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const glob = __importStar(__nccwpck_require__(8090)); +const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'; +const CACHE_MATCHED_KEY = 'cache-matched-key'; +const CACHE_KEY_PREFIX = 'setup-java'; +const supportedPackageManager = [ + { + id: 'maven', + path: [path_1.join(os_1.default.homedir(), '.m2', 'repository')], + // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven + pattern: ['**/pom.xml'] + }, + { + id: 'gradle', + path: [path_1.join(os_1.default.homedir(), '.gradle', 'caches'), path_1.join(os_1.default.homedir(), '.gradle', 'wrapper')], + // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle + pattern: [ + '**/*.gradle*', + '**/gradle-wrapper.properties', + 'buildSrc/**/Versions.kt', + 'buildSrc/**/Dependencies.kt', + 'gradle/*.versions.toml' + ] + }, + { + id: 'sbt', + path: [ + path_1.join(os_1.default.homedir(), '.ivy2', 'cache'), + path_1.join(os_1.default.homedir(), '.sbt'), + getCoursierCachePath(), + // Some files should not be cached to avoid resolution problems. + // In particular the resolution of snapshots (ideological gap between maven/ivy). + '!' + path_1.join(os_1.default.homedir(), '.sbt', '*.lock'), + '!' + path_1.join(os_1.default.homedir(), '**', 'ivydata-*.properties') + ], + pattern: ['**/*.sbt', '**/project/build.properties', '**/project/**.{scala,sbt}'] + } +]; +function getCoursierCachePath() { + if (os_1.default.type() === 'Linux') + return path_1.join(os_1.default.homedir(), '.cache', 'coursier'); + if (os_1.default.type() === 'Darwin') + return path_1.join(os_1.default.homedir(), 'Library', 'Caches', 'Coursier'); + return path_1.join(os_1.default.homedir(), 'AppData', 'Local', 'Coursier', 'Cache'); +} +function findPackageManager(id) { + const packageManager = supportedPackageManager.find(packageManager => packageManager.id === id); + if (packageManager === undefined) { + throw new Error(`unknown package manager specified: ${id}`); + } + return packageManager; +} +/** + * A function that generates a cache key to use. + * Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". + * If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-). + * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key} + */ +function computeCacheKey(packageManager) { + return __awaiter(this, void 0, void 0, function* () { + const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); + return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; + }); +} +/** + * Restore the dependency cache + * @param id ID of the package manager, should be "maven" or "gradle" + */ +function restore(id) { + return __awaiter(this, void 0, void 0, function* () { + const packageManager = findPackageManager(id); + const primaryKey = yield computeCacheKey(packageManager); + core.debug(`primary key is ${primaryKey}`); + core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey); + if (primaryKey.endsWith('-')) { + throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); + } + // No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269) + const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey); + if (matchedKey) { + core.saveState(CACHE_MATCHED_KEY, matchedKey); + core.setOutput('cache-hit', matchedKey === primaryKey); + core.info(`Cache restored from key: ${matchedKey}`); + } + else { + core.setOutput('cache-hit', false); + core.info(`${packageManager.id} cache is not found`); + } + }); +} +exports.restore = restore; +/** + * Save the dependency cache + * @param id ID of the package manager, should be "maven" or "gradle" + */ +function save(id) { + return __awaiter(this, void 0, void 0, function* () { + const packageManager = findPackageManager(id); + const matchedKey = core.getState(CACHE_MATCHED_KEY); + // Inputs are re-evaluated before the post action, so we want the original key used for restore + const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); + if (!primaryKey) { + core.warning('Error retrieving key from state.'); + return; + } + else if (matchedKey === primaryKey) { + // no change in target directories + core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); + return; + } + try { + yield cache.saveCache(packageManager.path, primaryKey); + core.info(`Cache saved with the key: ${primaryKey}`); + } + catch (error) { + if (error.name === cache.ReserveCacheError.name) { + core.info(error.message); + } + else { + if (isProbablyGradleDaemonProblem(packageManager, error)) { + core.warning('Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.'); + } + throw error; + } + } + }); +} +exports.save = save; +/** + * @param packageManager the specified package manager by user + * @param error the error thrown by the saveCache + * @returns true if the given error seems related to the {@link https://github.com/actions/cache/issues/454|running Gradle Daemon issue}. + * @see {@link https://github.com/actions/cache/issues/454#issuecomment-840493935|why --no-daemon is necessary} + */ +function isProbablyGradleDaemonProblem(packageManager, error) { + if (packageManager.id !== 'gradle' || process.env['RUNNER_OS'] !== 'Windows') { + return false; + } + const message = error.message || ''; + return message.startsWith('Tar failed with error: '); +} /***/ }), -/***/ 9741: +/***/ 9042: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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.INPUT_CACHE = 'cache'; +exports.INPUT_JOB_STATUS = 'job-status'; +exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; +exports.M2_DIR = '.m2'; +exports.MVN_SETTINGS_FILE = 'settings.xml'; +exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; +exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; +exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; + + +/***/ }), + +/***/ 8766: /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.AdoptDistribution = exports.AdoptImplementation = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const semver_1 = __importDefault(__nccwpck_require__(1383)); +const base_installer_1 = __nccwpck_require__(9741); +const util_1 = __nccwpck_require__(2629); +var AdoptImplementation; +(function (AdoptImplementation) { + AdoptImplementation["Hotspot"] = "Hotspot"; + AdoptImplementation["OpenJ9"] = "OpenJ9"; +})(AdoptImplementation = exports.AdoptImplementation || (exports.AdoptImplementation = {})); +class AdoptDistribution extends base_installer_1.JavaBase { + constructor(installerOptions, jvmImpl) { + super(`Adopt-${jvmImpl}`, installerOptions); + this.jvmImpl = jvmImpl; + } + findPackageForDownload(version) { + return __awaiter(this, void 0, void 0, function* () { + const availableVersionsRaw = yield this.getAvailableVersions(); + const availableVersionsWithBinaries = availableVersionsRaw + .filter(item => item.binaries.length > 0) + .map(item => { + return { + version: item.version_data.semver, + url: item.binaries[0].package.link + }; + }); + const satisfiedVersions = availableVersionsWithBinaries + .filter(item => util_1.isVersionSatisfies(version, item.version)) + .sort((a, b) => { + return -semver_1.default.compareBuild(a.version, b.version); + }); + const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; + if (!resolvedFullVersion) { + const availableOptions = availableVersionsWithBinaries.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 javaPath; + 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 version = this.getToolcacheVersionName(javaRelease.version); + javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture); + return { version: javaRelease.version, path: javaPath }; + }); + } + get toolcacheFolderName() { + if (this.jvmImpl === AdoptImplementation.Hotspot) { + // exclude Hotspot postfix from distribution name because Hosted runners have pre-cached Adopt OpenJDK under "Java_Adopt_jdk" + // for more information see: https://github.com/actions/setup-java/pull/155#discussion_r610451063 + return `Java_Adopt_${this.packageType}`; + } + return super.toolcacheFolderName; + } + getAvailableVersions() { + return __awaiter(this, void 0, void 0, function* () { + const platform = this.getPlatformOption(); + const arch = this.distributionArchitecture(); + const imageType = this.packageType; + const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions + const releaseType = this.stable ? 'ga' : 'ea'; + if (core.isDebug()) { + console.time('adopt-retrieve-available-versions'); + } + const baseRequestArguments = [ + `project=jdk`, + 'vendor=adoptopenjdk', + `heap_size=normal`, + 'sort_method=DEFAULT', + 'sort_order=DESC', + `os=${platform}`, + `architecture=${arch}`, + `image_type=${imageType}`, + `release_type=${releaseType}`, + `jvm_impl=${this.jvmImpl.toLowerCase()}` + ].join('&'); + // need to iterate through all pages to retrieve the list of all versions + // Adopt API doesn't provide way to retrieve the count of pages to iterate so infinity loop + let page_index = 0; + const availableVersions = []; + while (true) { + const requestArguments = `${baseRequestArguments}&page_size=20&page=${page_index}`; + const availableVersionsUrl = `https://api.adoptopenjdk.net/v3/assets/version/${versionRange}?${requestArguments}`; + if (core.isDebug() && page_index === 0) { + // url is identical except page_index so print it once for debug + core.debug(`Gathering available versions from '${availableVersionsUrl}'`); + } + const paginationPage = (yield this.http.getJson(availableVersionsUrl)).result; + if (paginationPage === null || paginationPage.length === 0) { + // break infinity loop because we have reached end of pagination + break; + } + availableVersions.push(...paginationPage); + page_index++; + } + if (core.isDebug()) { + core.startGroup('Print information about available versions'); + console.timeEnd('adopt-retrieve-available-versions'); + console.log(`Available versions: [${availableVersions.length}]`); + console.log(availableVersions.map(item => item.version_data.semver).join(', ')); + core.endGroup(); + } + return availableVersions; + }); + } + getPlatformOption() { + // Adopt has own platform names so need to map them + switch (process.platform) { + case 'darwin': + return 'mac'; + case 'win32': + return 'windows'; + default: + return process.platform; + } + } +} +exports.AdoptDistribution = AdoptDistribution; -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.JavaBase = void 0; -const tc = __importStar(__nccwpck_require__(7784)); -const core = __importStar(__nccwpck_require__(2186)); -const fs = __importStar(__nccwpck_require__(7147)); -const semver_1 = __importDefault(__nccwpck_require__(1383)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const httpm = __importStar(__nccwpck_require__(9925)); -const util_1 = __nccwpck_require__(2629); -const constants_1 = __nccwpck_require__(9042); -const os_1 = __importDefault(__nccwpck_require__(2037)); -class JavaBase { - constructor(distribution, installerOptions) { - this.distribution = distribution; - this.http = new httpm.HttpClient('actions/setup-java', undefined, { - allowRetries: true, - maxRetries: 3 - }); - ({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version)); - this.architecture = installerOptions.architecture || os_1.default.arch(); - this.packageType = installerOptions.packageType; - this.checkLatest = installerOptions.checkLatest; - } - setupJava() { - 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 the latest version from remote'); - const javaRelease = yield this.findPackageForDownload(this.version); - core.info(`Resolved latest version as ${javaRelease.version}`); - if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) { - core.info(`Resolved Java ${foundJava.version} from tool-cache`); - } - else { - core.info('Trying to download...'); - foundJava = yield this.downloadTool(javaRelease); - core.info(`Java ${foundJava.version} was downloaded`); - } - } - // JDK folder may contain postfix "Contents/Home" on macOS - const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX); - if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) { - foundJava.path = macOSPostfixPath; - } - core.info(`Setting Java ${foundJava.version} as the default`); - this.setJavaDefault(foundJava.version, foundJava.path); - return foundJava; - }); - } - get toolcacheFolderName() { - return `Java_${this.distribution}_${this.packageType}`; - } - getToolcacheVersionName(version) { - if (!this.stable) { - if (version.includes('+')) { - return version.replace('+', '-ea.'); - } - else { - return `${version}-ea`; - } - } - // Kotlin and some Java dependencies don't work properly when Java path contains "+" sign - // so replace "/hostedtoolcache/Java/11.0.3+4/x64" to "/hostedtoolcache/Java/11.0.3-4/x64" when saves to cache - // related issue: https://github.com/actions/virtual-environments/issues/3014 - return version.replace('+', '-'); - } - findInToolcache() { - // we can't use tc.find directly because firstly, we need to filter versions by stability flag - // if *-ea is provided, take only ea versions from toolcache, otherwise - only stable versions - const availableVersions = tc - .findAllVersions(this.toolcacheFolderName, this.architecture) - .map(item => { - return { - version: item - .replace('-ea.', '+') - .replace(/-ea$/, '') - // Kotlin and some Java dependencies don't work properly when Java path contains "+" sign - // so replace "/hostedtoolcache/Java/11.0.3-4/x64" to "/hostedtoolcache/Java/11.0.3+4/x64" when retrieves to cache - // related issue: https://github.com/actions/virtual-environments/issues/3014 - .replace('-', '+'), - path: util_1.getToolcachePath(this.toolcacheFolderName, item, this.architecture) || '', - stable: !item.includes('-ea') - }; - }) - .filter(item => item.stable === this.stable); - const satisfiedVersions = availableVersions - .filter(item => util_1.isVersionSatisfies(this.version, item.version)) - .filter(item => item.path) - .sort((a, b) => { - return -semver_1.default.compareBuild(a.version, b.version); - }); - if (!satisfiedVersions || satisfiedVersions.length === 0) { - return null; - } - return { - version: satisfiedVersions[0].version, - path: satisfiedVersions[0].path - }; - } - normalizeVersion(version) { - let stable = true; - if (version.endsWith('-ea')) { - version = version.replace(/-ea$/, ''); - stable = false; - } - else if (version.includes('-ea.')) { - // transform '11.0.3-ea.2' -> '11.0.3+2' - version = version.replace('-ea.', '+'); - stable = false; - } - if (!semver_1.default.validRange(version)) { - throw new Error(`The string '${version}' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information`); - } - return { - version, - stable - }; - } - setJavaDefault(version, toolPath) { - const majorVersion = version.split('.')[0]; - core.exportVariable('JAVA_HOME', toolPath); - core.addPath(path_1.default.join(toolPath, 'bin')); - core.setOutput('distribution', this.distribution); - core.setOutput('path', toolPath); - core.setOutput('version', version); - core.exportVariable(`JAVA_HOME_${majorVersion}_${this.architecture.toUpperCase()}`, toolPath); - } - distributionArchitecture() { - // default mappings of config architectures to distribution architectures - // override if a distribution uses any different names; see liberica for an example - // node's os.arch() - which this defaults to - can return any of: - // 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', and 'x64' - // so we need to map these to java distribution architectures - // 'amd64' is included here too b/c it's a common alias for 'x64' people might use explicitly - switch (this.architecture) { - case 'amd64': - return 'x64'; - case 'ia32': - return 'x86'; - case 'arm64': - return 'aarch64'; - default: - return this.architecture; - } - } -} -exports.JavaBase = JavaBase; + +/***/ }), + +/***/ 9741: +/***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.JavaBase = void 0; +const tc = __importStar(__nccwpck_require__(7784)); +const core = __importStar(__nccwpck_require__(2186)); +const fs = __importStar(__nccwpck_require__(7147)); +const semver_1 = __importDefault(__nccwpck_require__(1383)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const httpm = __importStar(__nccwpck_require__(9925)); +const util_1 = __nccwpck_require__(2629); +const constants_1 = __nccwpck_require__(9042); +const os_1 = __importDefault(__nccwpck_require__(2037)); +class JavaBase { + constructor(distribution, installerOptions) { + this.distribution = distribution; + this.http = new httpm.HttpClient('actions/setup-java', undefined, { + allowRetries: true, + maxRetries: 3 + }); + ({ version: this.version, stable: this.stable } = this.normalizeVersion(installerOptions.version)); + this.architecture = installerOptions.architecture || os_1.default.arch(); + this.packageType = installerOptions.packageType; + this.checkLatest = installerOptions.checkLatest; + } + setupJava() { + 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 the latest version from remote'); + const javaRelease = yield this.findPackageForDownload(this.version); + core.info(`Resolved latest version as ${javaRelease.version}`); + if ((foundJava === null || foundJava === void 0 ? void 0 : foundJava.version) === javaRelease.version) { + core.info(`Resolved Java ${foundJava.version} from tool-cache`); + } + else { + core.info('Trying to download...'); + foundJava = yield this.downloadTool(javaRelease); + core.info(`Java ${foundJava.version} was downloaded`); + } + } + // JDK folder may contain postfix "Contents/Home" on macOS + const macOSPostfixPath = path_1.default.join(foundJava.path, constants_1.MACOS_JAVA_CONTENT_POSTFIX); + if (process.platform === 'darwin' && fs.existsSync(macOSPostfixPath)) { + foundJava.path = macOSPostfixPath; + } + core.info(`Setting Java ${foundJava.version} as the default`); + this.setJavaDefault(foundJava.version, foundJava.path); + return foundJava; + }); + } + get toolcacheFolderName() { + return `Java_${this.distribution}_${this.packageType}`; + } + getToolcacheVersionName(version) { + if (!this.stable) { + if (version.includes('+')) { + return version.replace('+', '-ea.'); + } + else { + return `${version}-ea`; + } + } + // Kotlin and some Java dependencies don't work properly when Java path contains "+" sign + // so replace "/hostedtoolcache/Java/11.0.3+4/x64" to "/hostedtoolcache/Java/11.0.3-4/x64" when saves to cache + // related issue: https://github.com/actions/virtual-environments/issues/3014 + return version.replace('+', '-'); + } + findInToolcache() { + // we can't use tc.find directly because firstly, we need to filter versions by stability flag + // if *-ea is provided, take only ea versions from toolcache, otherwise - only stable versions + const availableVersions = tc + .findAllVersions(this.toolcacheFolderName, this.architecture) + .map(item => { + return { + version: item + .replace('-ea.', '+') + .replace(/-ea$/, '') + // Kotlin and some Java dependencies don't work properly when Java path contains "+" sign + // so replace "/hostedtoolcache/Java/11.0.3-4/x64" to "/hostedtoolcache/Java/11.0.3+4/x64" when retrieves to cache + // related issue: https://github.com/actions/virtual-environments/issues/3014 + .replace('-', '+'), + path: util_1.getToolcachePath(this.toolcacheFolderName, item, this.architecture) || '', + stable: !item.includes('-ea') + }; + }) + .filter(item => item.stable === this.stable); + const satisfiedVersions = availableVersions + .filter(item => util_1.isVersionSatisfies(this.version, item.version)) + .filter(item => item.path) + .sort((a, b) => { + return -semver_1.default.compareBuild(a.version, b.version); + }); + if (!satisfiedVersions || satisfiedVersions.length === 0) { + return null; + } + return { + version: satisfiedVersions[0].version, + path: satisfiedVersions[0].path + }; + } + normalizeVersion(version) { + let stable = true; + if (version.endsWith('-ea')) { + version = version.replace(/-ea$/, ''); + stable = false; + } + else if (version.includes('-ea.')) { + // transform '11.0.3-ea.2' -> '11.0.3+2' + version = version.replace('-ea.', '+'); + stable = false; + } + if (!semver_1.default.validRange(version)) { + throw new Error(`The string '${version}' is not valid SemVer notation for a Java version. Please check README file for code snippets and more detailed information`); + } + return { + version, + stable + }; + } + setJavaDefault(version, toolPath) { + const majorVersion = version.split('.')[0]; + core.exportVariable('JAVA_HOME', toolPath); + core.addPath(path_1.default.join(toolPath, 'bin')); + core.setOutput('distribution', this.distribution); + core.setOutput('path', toolPath); + core.setOutput('version', version); + core.exportVariable(`JAVA_HOME_${majorVersion}_${this.architecture.toUpperCase()}`, toolPath); + } + distributionArchitecture() { + // default mappings of config architectures to distribution architectures + // override if a distribution uses any different names; see liberica for an example + // node's os.arch() - which this defaults to - can return any of: + // 'arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', and 'x64' + // so we need to map these to java distribution architectures + // 'amd64' is included here too b/c it's a common alias for 'x64' people might use explicitly + switch (this.architecture) { + case 'amd64': + return 'x64'; + case 'ia32': + return 'x86'; + case 'arm64': + return 'aarch64'; + default: + return this.architecture; + } + } +} +exports.JavaBase = JavaBase; /***/ }), @@ -103955,166 +103955,166 @@ exports.JavaBase = JavaBase; /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.CorrettoDistribution = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const tc = __importStar(__nccwpck_require__(7784)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const util_1 = __nccwpck_require__(2629); -const base_installer_1 = __nccwpck_require__(9741); -class CorrettoDistribution extends base_installer_1.JavaBase { - constructor(installerOptions) { - super('Corretto', installerOptions); - } - downloadTool(javaRelease) { - return __awaiter(this, void 0, void 0, function* () { - core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); - core.info(`Extracting Java archive...`); - const extractedJavaPath = yield util_1.extractJdkFile(javaArchivePath, util_1.getDownloadArchiveExtension()); - const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; - const archivePath = path_1.default.join(extractedJavaPath, archiveName); - const version = this.getToolcacheVersionName(javaRelease.version); - const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture); - return { version: javaRelease.version, path: javaPath }; - }); - } - findPackageForDownload(version) { - return __awaiter(this, void 0, void 0, function* () { - if (!this.stable) { - throw new Error('Early access versions are not supported'); - } - if (version.includes('.')) { - throw new Error('Only major versions are supported'); - } - const availableVersions = yield this.getAvailableVersions(); - const matchingVersions = availableVersions - .filter(item => item.version == version) - .map(item => { - return { - version: item.correttoVersion, - url: item.downloadLink - }; - }); - const resolvedVersion = matchingVersions.length > 0 ? matchingVersions[0] : null; - if (!resolvedVersion) { - 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 resolvedVersion; - }); - } - getAvailableVersions() { - var _a, _b; - return __awaiter(this, void 0, void 0, function* () { - const platform = this.getPlatformOption(); - const arch = this.distributionArchitecture(); - const imageType = this.packageType; - if (core.isDebug()) { - console.time('corretto-retrieve-available-versions'); - } - const availableVersionsUrl = 'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json'; - const fetchCurrentVersions = yield this.http.getJson(availableVersionsUrl); - const fetchedCurrentVersions = fetchCurrentVersions.result; - if (!fetchedCurrentVersions) { - throw Error(`Could not fetch latest corretto versions from ${availableVersionsUrl}`); - } - const eligibleVersions = (_b = (_a = fetchedCurrentVersions === null || fetchedCurrentVersions === void 0 ? void 0 : fetchedCurrentVersions[platform]) === null || _a === void 0 ? void 0 : _a[arch]) === null || _b === void 0 ? void 0 : _b[imageType]; - const availableVersions = this.getAvailableVersionsForPlatform(eligibleVersions); - if (core.isDebug()) { - this.printAvailableVersions(availableVersions); - } - return availableVersions; - }); - } - getAvailableVersionsForPlatform(eligibleVersions) { - const availableVersions = []; - for (const version in eligibleVersions) { - const availableVersion = eligibleVersions[version]; - for (const fileType in availableVersion) { - const skipNonExtractableBinaries = fileType != util_1.getDownloadArchiveExtension(); - if (skipNonExtractableBinaries) { - continue; - } - const availableVersionDetails = availableVersion[fileType]; - const correttoVersion = this.getCorrettoVersion(availableVersionDetails.resource); - availableVersions.push({ - checksum: availableVersionDetails.checksum, - checksum_sha256: availableVersionDetails.checksum_sha256, - fileType, - resource: availableVersionDetails.resource, - downloadLink: `https://corretto.aws${availableVersionDetails.resource}`, - version: version, - correttoVersion - }); - } - } - return availableVersions; - } - printAvailableVersions(availableVersions) { - core.startGroup('Print information about available versions'); - console.timeEnd('corretto-retrieve-available-versions'); - console.log(`Available versions: [${availableVersions.length}]`); - console.log(availableVersions.map(item => `${item.version}: ${item.correttoVersion}`).join(', ')); - core.endGroup(); - } - getPlatformOption() { - // Corretto has its own platform names so we need to map them - switch (process.platform) { - case 'darwin': - return 'macos'; - case 'win32': - return 'windows'; - default: - return process.platform; - } - } - getCorrettoVersion(resource) { - const regex = /(\d+.+)\//; - const match = regex.exec(resource); - if (match === null) { - throw Error(`Could not parse corretto version from ${resource}`); - } - return match[1]; - } -} -exports.CorrettoDistribution = CorrettoDistribution; + +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.CorrettoDistribution = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const util_1 = __nccwpck_require__(2629); +const base_installer_1 = __nccwpck_require__(9741); +class CorrettoDistribution extends base_installer_1.JavaBase { + constructor(installerOptions) { + super('Corretto', installerOptions); + } + downloadTool(javaRelease) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); + const javaArchivePath = yield tc.downloadTool(javaRelease.url); + core.info(`Extracting Java archive...`); + const extractedJavaPath = yield util_1.extractJdkFile(javaArchivePath, util_1.getDownloadArchiveExtension()); + const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; + const archivePath = path_1.default.join(extractedJavaPath, archiveName); + const version = this.getToolcacheVersionName(javaRelease.version); + const javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture); + return { version: javaRelease.version, path: javaPath }; + }); + } + findPackageForDownload(version) { + return __awaiter(this, void 0, void 0, function* () { + if (!this.stable) { + throw new Error('Early access versions are not supported'); + } + if (version.includes('.')) { + throw new Error('Only major versions are supported'); + } + const availableVersions = yield this.getAvailableVersions(); + const matchingVersions = availableVersions + .filter(item => item.version == version) + .map(item => { + return { + version: item.correttoVersion, + url: item.downloadLink + }; + }); + const resolvedVersion = matchingVersions.length > 0 ? matchingVersions[0] : null; + if (!resolvedVersion) { + 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 resolvedVersion; + }); + } + getAvailableVersions() { + var _a, _b; + return __awaiter(this, void 0, void 0, function* () { + const platform = this.getPlatformOption(); + const arch = this.distributionArchitecture(); + const imageType = this.packageType; + if (core.isDebug()) { + console.time('corretto-retrieve-available-versions'); + } + const availableVersionsUrl = 'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json'; + const fetchCurrentVersions = yield this.http.getJson(availableVersionsUrl); + const fetchedCurrentVersions = fetchCurrentVersions.result; + if (!fetchedCurrentVersions) { + throw Error(`Could not fetch latest corretto versions from ${availableVersionsUrl}`); + } + const eligibleVersions = (_b = (_a = fetchedCurrentVersions === null || fetchedCurrentVersions === void 0 ? void 0 : fetchedCurrentVersions[platform]) === null || _a === void 0 ? void 0 : _a[arch]) === null || _b === void 0 ? void 0 : _b[imageType]; + const availableVersions = this.getAvailableVersionsForPlatform(eligibleVersions); + if (core.isDebug()) { + this.printAvailableVersions(availableVersions); + } + return availableVersions; + }); + } + getAvailableVersionsForPlatform(eligibleVersions) { + const availableVersions = []; + for (const version in eligibleVersions) { + const availableVersion = eligibleVersions[version]; + for (const fileType in availableVersion) { + const skipNonExtractableBinaries = fileType != util_1.getDownloadArchiveExtension(); + if (skipNonExtractableBinaries) { + continue; + } + const availableVersionDetails = availableVersion[fileType]; + const correttoVersion = this.getCorrettoVersion(availableVersionDetails.resource); + availableVersions.push({ + checksum: availableVersionDetails.checksum, + checksum_sha256: availableVersionDetails.checksum_sha256, + fileType, + resource: availableVersionDetails.resource, + downloadLink: `https://corretto.aws${availableVersionDetails.resource}`, + version: version, + correttoVersion + }); + } + } + return availableVersions; + } + printAvailableVersions(availableVersions) { + core.startGroup('Print information about available versions'); + console.timeEnd('corretto-retrieve-available-versions'); + console.log(`Available versions: [${availableVersions.length}]`); + console.log(availableVersions.map(item => `${item.version}: ${item.correttoVersion}`).join(', ')); + core.endGroup(); + } + getPlatformOption() { + // Corretto has its own platform names so we need to map them + switch (process.platform) { + case 'darwin': + return 'macos'; + case 'win32': + return 'windows'; + default: + return process.platform; + } + } + getCorrettoVersion(resource) { + const regex = /(\d+.+)\//; + const match = regex.exec(resource); + if (match === null) { + throw Error(`Could not parse corretto version from ${resource}`); + } + return match[1]; + } +} +exports.CorrettoDistribution = CorrettoDistribution; /***/ }), @@ -104123,52 +104123,52 @@ exports.CorrettoDistribution = CorrettoDistribution; /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.getJavaDistribution = void 0; -const installer_1 = __nccwpck_require__(9917); -const installer_2 = __nccwpck_require__(2005); -const installer_3 = __nccwpck_require__(8766); -const installer_4 = __nccwpck_require__(8579); -const installer_5 = __nccwpck_require__(883); -const installer_6 = __nccwpck_require__(3613); -const installer_7 = __nccwpck_require__(4750); -var JavaDistribution; -(function (JavaDistribution) { - JavaDistribution["Adopt"] = "adopt"; - JavaDistribution["AdoptHotspot"] = "adopt-hotspot"; - JavaDistribution["AdoptOpenJ9"] = "adopt-openj9"; - JavaDistribution["Temurin"] = "temurin"; - JavaDistribution["Zulu"] = "zulu"; - JavaDistribution["Liberica"] = "liberica"; - JavaDistribution["JdkFile"] = "jdkfile"; - JavaDistribution["Microsoft"] = "microsoft"; - JavaDistribution["Corretto"] = "corretto"; -})(JavaDistribution || (JavaDistribution = {})); -function getJavaDistribution(distributionName, installerOptions, jdkFile) { - switch (distributionName) { - case JavaDistribution.JdkFile: - return new installer_1.LocalDistribution(installerOptions, jdkFile); - case JavaDistribution.Adopt: - case JavaDistribution.AdoptHotspot: - return new installer_3.AdoptDistribution(installerOptions, installer_3.AdoptImplementation.Hotspot); - case JavaDistribution.AdoptOpenJ9: - return new installer_3.AdoptDistribution(installerOptions, installer_3.AdoptImplementation.OpenJ9); - case JavaDistribution.Temurin: - return new installer_4.TemurinDistribution(installerOptions, installer_4.TemurinImplementation.Hotspot); - case JavaDistribution.Zulu: - return new installer_2.ZuluDistribution(installerOptions); - case JavaDistribution.Liberica: - return new installer_5.LibericaDistributions(installerOptions); - case JavaDistribution.Microsoft: - return new installer_6.MicrosoftDistributions(installerOptions); - case JavaDistribution.Corretto: - return new installer_7.CorrettoDistribution(installerOptions); - default: - return null; - } -} -exports.getJavaDistribution = getJavaDistribution; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.getJavaDistribution = void 0; +const installer_1 = __nccwpck_require__(9917); +const installer_2 = __nccwpck_require__(2005); +const installer_3 = __nccwpck_require__(8766); +const installer_4 = __nccwpck_require__(8579); +const installer_5 = __nccwpck_require__(883); +const installer_6 = __nccwpck_require__(3613); +const installer_7 = __nccwpck_require__(4750); +var JavaDistribution; +(function (JavaDistribution) { + JavaDistribution["Adopt"] = "adopt"; + JavaDistribution["AdoptHotspot"] = "adopt-hotspot"; + JavaDistribution["AdoptOpenJ9"] = "adopt-openj9"; + JavaDistribution["Temurin"] = "temurin"; + JavaDistribution["Zulu"] = "zulu"; + JavaDistribution["Liberica"] = "liberica"; + JavaDistribution["JdkFile"] = "jdkfile"; + JavaDistribution["Microsoft"] = "microsoft"; + JavaDistribution["Corretto"] = "corretto"; +})(JavaDistribution || (JavaDistribution = {})); +function getJavaDistribution(distributionName, installerOptions, jdkFile) { + switch (distributionName) { + case JavaDistribution.JdkFile: + return new installer_1.LocalDistribution(installerOptions, jdkFile); + case JavaDistribution.Adopt: + case JavaDistribution.AdoptHotspot: + return new installer_3.AdoptDistribution(installerOptions, installer_3.AdoptImplementation.Hotspot); + case JavaDistribution.AdoptOpenJ9: + return new installer_3.AdoptDistribution(installerOptions, installer_3.AdoptImplementation.OpenJ9); + case JavaDistribution.Temurin: + return new installer_4.TemurinDistribution(installerOptions, installer_4.TemurinImplementation.Hotspot); + case JavaDistribution.Zulu: + return new installer_2.ZuluDistribution(installerOptions); + case JavaDistribution.Liberica: + return new installer_5.LibericaDistributions(installerOptions); + case JavaDistribution.Microsoft: + return new installer_6.MicrosoftDistributions(installerOptions); + case JavaDistribution.Corretto: + return new installer_7.CorrettoDistribution(installerOptions); + default: + return null; + } +} +exports.getJavaDistribution = getJavaDistribution; /***/ }), @@ -104177,170 +104177,170 @@ exports.getJavaDistribution = getJavaDistribution; /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.LibericaDistributions = void 0; -const base_installer_1 = __nccwpck_require__(9741); -const semver_1 = __importDefault(__nccwpck_require__(1383)); -const util_1 = __nccwpck_require__(2629); -const core = __importStar(__nccwpck_require__(2186)); -const tc = __importStar(__nccwpck_require__(7784)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const supportedPlatform = `'linux', 'linux-musl', 'macos', 'solaris', 'windows'`; -const supportedArchitectures = `'x86', 'x64', 'armv7', 'aarch64', 'ppc64le'`; -class LibericaDistributions extends base_installer_1.JavaBase { - constructor(installerOptions) { - super('Liberica', installerOptions); - } - downloadTool(javaRelease) { - return __awaiter(this, void 0, void 0, function* () { - core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); - core.info(`Extracting Java archive...`); - const extension = util_1.getDownloadArchiveExtension(); - const 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 }; - }); - } - findPackageForDownload(range) { - return __awaiter(this, void 0, void 0, function* () { - const availableVersionsRaw = yield this.getAvailableVersions(); - const availableVersions = availableVersionsRaw.map(item => ({ - url: item.downloadUrl, - version: this.convertVersionToSemver(item) - })); - const satisfiedVersion = availableVersions - .filter(item => util_1.isVersionSatisfies(range, item.version)) - .sort((a, b) => -semver_1.default.compareBuild(a.version, b.version))[0]; - if (!satisfiedVersion) { - const availableOptions = availableVersions.map(item => item.version).join(', '); - const availableOptionsMessage = availableOptions - ? `\nAvailable versions: ${availableOptions}` - : ''; - throw new Error(`Could not find satisfied version for semver ${range}. ${availableOptionsMessage}`); - } - return satisfiedVersion; - }); - } - getAvailableVersions() { - var _a; - return __awaiter(this, void 0, void 0, function* () { - if (core.isDebug()) { - console.time('liberica-retrieve-available-versions'); - } - const url = this.prepareAvailableVersionsUrl(); - if (core.isDebug()) { - core.debug(`Gathering available versions from '${url}'`); - } - const availableVersions = (_a = (yield this.http.getJson(url)).result) !== null && _a !== void 0 ? _a : []; - if (core.isDebug()) { - core.startGroup('Print information about available versions'); - console.timeEnd('liberica-retrieve-available-versions'); - console.log(`Available versions: [${availableVersions.length}]`); - console.log(availableVersions.map(item => item.version)); - core.endGroup(); - } - return availableVersions; - }); - } - prepareAvailableVersionsUrl() { - const urlOptions = Object.assign(Object.assign({ os: this.getPlatformOption(), 'bundle-type': this.getBundleType() }, this.getArchitectureOptions()), { 'build-type': this.stable ? 'all' : 'ea', 'installation-type': 'archive', fields: 'downloadUrl,version,featureVersion,interimVersion,updateVersion,buildVersion' }); - const searchParams = new URLSearchParams(urlOptions).toString(); - return `https://api.bell-sw.com/v1/liberica/releases?${searchParams}`; - } - getBundleType() { - const [bundleType, feature] = this.packageType.split('+'); - if (feature === null || feature === void 0 ? void 0 : feature.includes('fx')) { - return bundleType + '-full'; - } - return bundleType; - } - getArchitectureOptions() { - const arch = this.distributionArchitecture(); - switch (arch) { - case 'x86': - return { bitness: '32', arch: 'x86' }; - case 'x64': - return { bitness: '64', arch: 'x86' }; - case 'armv7': - return { bitness: '32', arch: 'arm' }; - case 'aarch64': - return { bitness: '64', arch: 'arm' }; - case 'ppc64le': - return { bitness: '64', arch: 'ppc' }; - default: - throw new Error(`Architecture '${this.architecture}' is not supported. Supported architectures: ${supportedArchitectures}`); - } - } - getPlatformOption(platform = process.platform) { - switch (platform) { - case 'darwin': - return 'macos'; - case 'win32': - case 'cygwin': - return 'windows'; - case 'linux': - return 'linux'; - case 'sunos': - return 'solaris'; - default: - throw new Error(`Platform '${platform}' is not supported. Supported platforms: ${supportedPlatform}`); - } - } - convertVersionToSemver(version) { - let { buildVersion, featureVersion, interimVersion, updateVersion } = version; - const mainVersion = [featureVersion, interimVersion, updateVersion].join('.'); - if (buildVersion != 0) { - return `${mainVersion}+${buildVersion}`; - } - return mainVersion; - } - distributionArchitecture() { - let arch = super.distributionArchitecture(); - switch (arch) { - case 'arm': - return 'armv7'; - default: - return arch; - } - } -} -exports.LibericaDistributions = LibericaDistributions; + +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.LibericaDistributions = void 0; +const base_installer_1 = __nccwpck_require__(9741); +const semver_1 = __importDefault(__nccwpck_require__(1383)); +const util_1 = __nccwpck_require__(2629); +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const supportedPlatform = `'linux', 'linux-musl', 'macos', 'solaris', 'windows'`; +const supportedArchitectures = `'x86', 'x64', 'armv7', 'aarch64', 'ppc64le'`; +class LibericaDistributions extends base_installer_1.JavaBase { + constructor(installerOptions) { + super('Liberica', installerOptions); + } + downloadTool(javaRelease) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); + const javaArchivePath = yield tc.downloadTool(javaRelease.url); + core.info(`Extracting Java archive...`); + const extension = util_1.getDownloadArchiveExtension(); + const 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 }; + }); + } + findPackageForDownload(range) { + return __awaiter(this, void 0, void 0, function* () { + const availableVersionsRaw = yield this.getAvailableVersions(); + const availableVersions = availableVersionsRaw.map(item => ({ + url: item.downloadUrl, + version: this.convertVersionToSemver(item) + })); + const satisfiedVersion = availableVersions + .filter(item => util_1.isVersionSatisfies(range, item.version)) + .sort((a, b) => -semver_1.default.compareBuild(a.version, b.version))[0]; + if (!satisfiedVersion) { + const availableOptions = availableVersions.map(item => item.version).join(', '); + const availableOptionsMessage = availableOptions + ? `\nAvailable versions: ${availableOptions}` + : ''; + throw new Error(`Could not find satisfied version for semver ${range}. ${availableOptionsMessage}`); + } + return satisfiedVersion; + }); + } + getAvailableVersions() { + var _a; + return __awaiter(this, void 0, void 0, function* () { + if (core.isDebug()) { + console.time('liberica-retrieve-available-versions'); + } + const url = this.prepareAvailableVersionsUrl(); + if (core.isDebug()) { + core.debug(`Gathering available versions from '${url}'`); + } + const availableVersions = (_a = (yield this.http.getJson(url)).result) !== null && _a !== void 0 ? _a : []; + if (core.isDebug()) { + core.startGroup('Print information about available versions'); + console.timeEnd('liberica-retrieve-available-versions'); + console.log(`Available versions: [${availableVersions.length}]`); + console.log(availableVersions.map(item => item.version)); + core.endGroup(); + } + return availableVersions; + }); + } + prepareAvailableVersionsUrl() { + const urlOptions = Object.assign(Object.assign({ os: this.getPlatformOption(), 'bundle-type': this.getBundleType() }, this.getArchitectureOptions()), { 'build-type': this.stable ? 'all' : 'ea', 'installation-type': 'archive', fields: 'downloadUrl,version,featureVersion,interimVersion,updateVersion,buildVersion' }); + const searchParams = new URLSearchParams(urlOptions).toString(); + return `https://api.bell-sw.com/v1/liberica/releases?${searchParams}`; + } + getBundleType() { + const [bundleType, feature] = this.packageType.split('+'); + if (feature === null || feature === void 0 ? void 0 : feature.includes('fx')) { + return bundleType + '-full'; + } + return bundleType; + } + getArchitectureOptions() { + const arch = this.distributionArchitecture(); + switch (arch) { + case 'x86': + return { bitness: '32', arch: 'x86' }; + case 'x64': + return { bitness: '64', arch: 'x86' }; + case 'armv7': + return { bitness: '32', arch: 'arm' }; + case 'aarch64': + return { bitness: '64', arch: 'arm' }; + case 'ppc64le': + return { bitness: '64', arch: 'ppc' }; + default: + throw new Error(`Architecture '${this.architecture}' is not supported. Supported architectures: ${supportedArchitectures}`); + } + } + getPlatformOption(platform = process.platform) { + switch (platform) { + case 'darwin': + return 'macos'; + case 'win32': + case 'cygwin': + return 'windows'; + case 'linux': + return 'linux'; + case 'sunos': + return 'solaris'; + default: + throw new Error(`Platform '${platform}' is not supported. Supported platforms: ${supportedPlatform}`); + } + } + convertVersionToSemver(version) { + let { buildVersion, featureVersion, interimVersion, updateVersion } = version; + const mainVersion = [featureVersion, interimVersion, updateVersion].join('.'); + if (buildVersion != 0) { + return `${mainVersion}+${buildVersion}`; + } + return mainVersion; + } + distributionArchitecture() { + let arch = super.distributionArchitecture(); + switch (arch) { + case 'arm': + return 'armv7'; + default: + return arch; + } + } +} +exports.LibericaDistributions = LibericaDistributions; /***/ }), @@ -104349,397 +104349,397 @@ exports.LibericaDistributions = LibericaDistributions; /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.LocalDistribution = void 0; -const tc = __importStar(__nccwpck_require__(7784)); -const core = __importStar(__nccwpck_require__(2186)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const base_installer_1 = __nccwpck_require__(9741); -const util_1 = __nccwpck_require__(2629); -const constants_1 = __nccwpck_require__(9042); -class LocalDistribution extends base_installer_1.JavaBase { - constructor(installerOptions, jdkFile) { - super('jdkfile', installerOptions); - this.jdkFile = jdkFile; - } - setupJava() { - return __awaiter(this, void 0, void 0, function* () { - let foundJava = this.findInToolcache(); - if (foundJava) { - core.info(`Resolved Java ${foundJava.version} from tool-cache`); - } - else { - core.info(`Java ${this.version} was not found in tool-cache. Trying to unpack JDK file...`); - if (!this.jdkFile) { - throw new Error("'jdkFile' is not specified"); - } - const jdkFilePath = path_1.default.resolve(this.jdkFile); - const stats = fs_1.default.statSync(jdkFilePath); - if (!stats.isFile()) { - throw new Error(`JDK file was not found in path '${jdkFilePath}'`); - } - core.info(`Extracting Java from '${jdkFilePath}'`); - const extractedJavaPath = yield util_1.extractJdkFile(jdkFilePath); - const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; - const archivePath = path_1.default.join(extractedJavaPath, archiveName); - const javaVersion = this.version; - let javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaVersion), this.architecture); - // for different Java distributions, postfix can exist or not so need to check both cases - if (process.platform === 'darwin' && - fs_1.default.existsSync(path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX))) { - javaPath = path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX); - } - foundJava = { - version: javaVersion, - path: javaPath - }; - } - core.info(`Setting Java ${foundJava.version} as default`); - this.setJavaDefault(foundJava.version, foundJava.path); - return foundJava; - }); - } - findPackageForDownload(version) { - return __awaiter(this, void 0, void 0, function* () { - throw new Error('This method should not be implemented in local file provider'); - }); - } - downloadTool(javaRelease) { - return __awaiter(this, void 0, void 0, function* () { - throw new Error('This method should not be implemented in local file provider'); - }); - } -} -exports.LocalDistribution = LocalDistribution; - - -/***/ }), - -/***/ 3613: -/***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.MicrosoftDistributions = void 0; -const base_installer_1 = __nccwpck_require__(9741); -const util_1 = __nccwpck_require__(2629); -const core = __importStar(__nccwpck_require__(2186)); -const tc = __importStar(__nccwpck_require__(7784)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -class MicrosoftDistributions extends base_installer_1.JavaBase { - constructor(installerOptions) { - super('Microsoft', installerOptions); - } - downloadTool(javaRelease) { - return __awaiter(this, void 0, void 0, function* () { - core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); - const javaArchivePath = yield tc.downloadTool(javaRelease.url); - core.info(`Extracting Java archive...`); - const extension = util_1.getDownloadArchiveExtension(); - const 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 }; - }); - } - findPackageForDownload(range) { - return __awaiter(this, void 0, void 0, function* () { - const arch = this.distributionArchitecture(); - if (arch !== 'x64' && arch !== 'aarch64') { - throw new Error(`Unsupported architecture: ${this.architecture}`); - } - if (!this.stable) { - throw new Error('Early access versions are not supported'); - } - if (this.packageType !== 'jdk') { - throw new Error('Microsoft Build of OpenJDK provides only the `jdk` package type'); - } - const manifest = yield this.getAvailableVersions(); - if (!manifest) { - throw new Error('Could not load manifest for Microsoft Build of OpenJDK'); - } - const foundRelease = yield tc.findFromManifest(range, true, manifest, arch); - if (!foundRelease) { - throw new Error(`Could not find satisfied version for SemVer ${range}. ${manifest - .map(item => item.version) - .join(', ')}`); - } - return { url: foundRelease.files[0].download_url, version: foundRelease.version }; - }); - } - getAvailableVersions() { - return __awaiter(this, void 0, void 0, function* () { - // TODO get these dynamically! - // We will need Microsoft to add an endpoint where we can query for versions. - const token = core.getInput('token'); - const owner = 'actions'; - const repository = 'setup-java'; - const branch = 'main'; - const filePath = 'src/distributions/microsoft/microsoft-openjdk-versions.json'; - let releases = null; - const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`; - const headers = { - authorization: token, - accept: 'application/vnd.github.VERSION.raw' - }; - let response = null; - try { - response = yield this.http.getJson(fileUrl, headers); - if (!response.result) { - return null; - } - } - catch (err) { - core.debug(`Http request for microsoft-openjdk-versions.json failed with status code: ${response === null || response === void 0 ? void 0 : response.statusCode}`); - return null; - } - if (response.result) { - releases = response.result; - } - return releases; - }); - } -} -exports.MicrosoftDistributions = MicrosoftDistributions; + +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.LocalDistribution = void 0; +const tc = __importStar(__nccwpck_require__(7784)); +const core = __importStar(__nccwpck_require__(2186)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const base_installer_1 = __nccwpck_require__(9741); +const util_1 = __nccwpck_require__(2629); +const constants_1 = __nccwpck_require__(9042); +class LocalDistribution extends base_installer_1.JavaBase { + constructor(installerOptions, jdkFile) { + super('jdkfile', installerOptions); + this.jdkFile = jdkFile; + } + setupJava() { + return __awaiter(this, void 0, void 0, function* () { + let foundJava = this.findInToolcache(); + if (foundJava) { + core.info(`Resolved Java ${foundJava.version} from tool-cache`); + } + else { + core.info(`Java ${this.version} was not found in tool-cache. Trying to unpack JDK file...`); + if (!this.jdkFile) { + throw new Error("'jdkFile' is not specified"); + } + const jdkFilePath = path_1.default.resolve(this.jdkFile); + const stats = fs_1.default.statSync(jdkFilePath); + if (!stats.isFile()) { + throw new Error(`JDK file was not found in path '${jdkFilePath}'`); + } + core.info(`Extracting Java from '${jdkFilePath}'`); + const extractedJavaPath = yield util_1.extractJdkFile(jdkFilePath); + const archiveName = fs_1.default.readdirSync(extractedJavaPath)[0]; + const archivePath = path_1.default.join(extractedJavaPath, archiveName); + const javaVersion = this.version; + let javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaVersion), this.architecture); + // for different Java distributions, postfix can exist or not so need to check both cases + if (process.platform === 'darwin' && + fs_1.default.existsSync(path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX))) { + javaPath = path_1.default.join(javaPath, constants_1.MACOS_JAVA_CONTENT_POSTFIX); + } + foundJava = { + version: javaVersion, + path: javaPath + }; + } + core.info(`Setting Java ${foundJava.version} as default`); + this.setJavaDefault(foundJava.version, foundJava.path); + return foundJava; + }); + } + findPackageForDownload(version) { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('This method should not be implemented in local file provider'); + }); + } + downloadTool(javaRelease) { + return __awaiter(this, void 0, void 0, function* () { + throw new Error('This method should not be implemented in local file provider'); + }); + } +} +exports.LocalDistribution = LocalDistribution; /***/ }), -/***/ 8579: +/***/ 3613: /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.MicrosoftDistributions = void 0; +const base_installer_1 = __nccwpck_require__(9741); +const util_1 = __nccwpck_require__(2629); +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +class MicrosoftDistributions extends base_installer_1.JavaBase { + constructor(installerOptions) { + super('Microsoft', installerOptions); + } + downloadTool(javaRelease) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`); + const javaArchivePath = yield tc.downloadTool(javaRelease.url); + core.info(`Extracting Java archive...`); + const extension = util_1.getDownloadArchiveExtension(); + const 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 }; + }); + } + findPackageForDownload(range) { + return __awaiter(this, void 0, void 0, function* () { + const arch = this.distributionArchitecture(); + if (arch !== 'x64' && arch !== 'aarch64') { + throw new Error(`Unsupported architecture: ${this.architecture}`); + } + if (!this.stable) { + throw new Error('Early access versions are not supported'); + } + if (this.packageType !== 'jdk') { + throw new Error('Microsoft Build of OpenJDK provides only the `jdk` package type'); + } + const manifest = yield this.getAvailableVersions(); + if (!manifest) { + throw new Error('Could not load manifest for Microsoft Build of OpenJDK'); + } + const foundRelease = yield tc.findFromManifest(range, true, manifest, arch); + if (!foundRelease) { + throw new Error(`Could not find satisfied version for SemVer ${range}. ${manifest + .map(item => item.version) + .join(', ')}`); + } + return { url: foundRelease.files[0].download_url, version: foundRelease.version }; + }); + } + getAvailableVersions() { + return __awaiter(this, void 0, void 0, function* () { + // TODO get these dynamically! + // We will need Microsoft to add an endpoint where we can query for versions. + const token = core.getInput('token'); + const owner = 'actions'; + const repository = 'setup-java'; + const branch = 'main'; + const filePath = 'src/distributions/microsoft/microsoft-openjdk-versions.json'; + let releases = null; + const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`; + const headers = { + authorization: token, + accept: 'application/vnd.github.VERSION.raw' + }; + let response = null; + try { + response = yield this.http.getJson(fileUrl, headers); + if (!response.result) { + return null; + } + } + catch (err) { + core.debug(`Http request for microsoft-openjdk-versions.json failed with status code: ${response === null || response === void 0 ? void 0 : response.statusCode}`); + return null; + } + if (response.result) { + releases = response.result; + } + return releases; + }); + } +} +exports.MicrosoftDistributions = MicrosoftDistributions; -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.TemurinDistribution = exports.TemurinImplementation = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const tc = __importStar(__nccwpck_require__(7784)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const semver_1 = __importDefault(__nccwpck_require__(1383)); -const base_installer_1 = __nccwpck_require__(9741); -const util_1 = __nccwpck_require__(2629); -var TemurinImplementation; -(function (TemurinImplementation) { - TemurinImplementation["Hotspot"] = "Hotspot"; -})(TemurinImplementation = exports.TemurinImplementation || (exports.TemurinImplementation = {})); -class TemurinDistribution extends base_installer_1.JavaBase { - constructor(installerOptions, jvmImpl) { - super(`Temurin-${jvmImpl}`, installerOptions); - this.jvmImpl = jvmImpl; - } - findPackageForDownload(version) { - return __awaiter(this, void 0, void 0, function* () { - const availableVersionsRaw = yield this.getAvailableVersions(); - const availableVersionsWithBinaries = availableVersionsRaw - .filter(item => item.binaries.length > 0) - .map(item => { - // normalize 17.0.0-beta+33.0.202107301459 to 17.0.0+33.0.202107301459 for earlier access versions - const formattedVersion = this.stable - ? item.version_data.semver - : item.version_data.semver.replace('-beta+', '+'); - return { - version: formattedVersion, - url: item.binaries[0].package.link - }; - }); - const satisfiedVersions = availableVersionsWithBinaries - .filter(item => util_1.isVersionSatisfies(version, item.version)) - .sort((a, b) => { - return -semver_1.default.compareBuild(a.version, b.version); - }); - const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; - if (!resolvedFullVersion) { - const availableOptions = availableVersionsWithBinaries.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 javaPath; - 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 version = this.getToolcacheVersionName(javaRelease.version); - javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture); - return { version: javaRelease.version, path: javaPath }; - }); - } - get toolcacheFolderName() { - return super.toolcacheFolderName; - } - getAvailableVersions() { - return __awaiter(this, void 0, void 0, function* () { - const platform = this.getPlatformOption(); - const arch = this.distributionArchitecture(); - const imageType = this.packageType; - const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions - const releaseType = this.stable ? 'ga' : 'ea'; - if (core.isDebug()) { - console.time('temurin-retrieve-available-versions'); - } - const baseRequestArguments = [ - `project=jdk`, - 'vendor=adoptium', - `heap_size=normal`, - 'sort_method=DEFAULT', - 'sort_order=DESC', - `os=${platform}`, - `architecture=${arch}`, - `image_type=${imageType}`, - `release_type=${releaseType}`, - `jvm_impl=${this.jvmImpl.toLowerCase()}` - ].join('&'); - // need to iterate through all pages to retrieve the list of all versions - // Adoptium API doesn't provide way to retrieve the count of pages to iterate so infinity loop - let page_index = 0; - const availableVersions = []; - while (true) { - const requestArguments = `${baseRequestArguments}&page_size=20&page=${page_index}`; - const availableVersionsUrl = `https://api.adoptium.net/v3/assets/version/${versionRange}?${requestArguments}`; - if (core.isDebug() && page_index === 0) { - // url is identical except page_index so print it once for debug - core.debug(`Gathering available versions from '${availableVersionsUrl}'`); - } - const paginationPage = (yield this.http.getJson(availableVersionsUrl)).result; - if (paginationPage === null || paginationPage.length === 0) { - // break infinity loop because we have reached end of pagination - break; - } - availableVersions.push(...paginationPage); - page_index++; - } - if (core.isDebug()) { - core.startGroup('Print information about available versions'); - console.timeEnd('temurin-retrieve-available-versions'); - console.log(`Available versions: [${availableVersions.length}]`); - console.log(availableVersions.map(item => item.version_data.semver).join(', ')); - core.endGroup(); - } - return availableVersions; - }); - } - getPlatformOption() { - // Adoptium has own platform names so need to map them - switch (process.platform) { - case 'darwin': - return 'mac'; - case 'win32': - return 'windows'; - default: - return process.platform; - } - } -} -exports.TemurinDistribution = TemurinDistribution; + +/***/ }), + +/***/ 8579: +/***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.TemurinDistribution = exports.TemurinImplementation = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const semver_1 = __importDefault(__nccwpck_require__(1383)); +const base_installer_1 = __nccwpck_require__(9741); +const util_1 = __nccwpck_require__(2629); +var TemurinImplementation; +(function (TemurinImplementation) { + TemurinImplementation["Hotspot"] = "Hotspot"; +})(TemurinImplementation = exports.TemurinImplementation || (exports.TemurinImplementation = {})); +class TemurinDistribution extends base_installer_1.JavaBase { + constructor(installerOptions, jvmImpl) { + super(`Temurin-${jvmImpl}`, installerOptions); + this.jvmImpl = jvmImpl; + } + findPackageForDownload(version) { + return __awaiter(this, void 0, void 0, function* () { + const availableVersionsRaw = yield this.getAvailableVersions(); + const availableVersionsWithBinaries = availableVersionsRaw + .filter(item => item.binaries.length > 0) + .map(item => { + // normalize 17.0.0-beta+33.0.202107301459 to 17.0.0+33.0.202107301459 for earlier access versions + const formattedVersion = this.stable + ? item.version_data.semver + : item.version_data.semver.replace('-beta+', '+'); + return { + version: formattedVersion, + url: item.binaries[0].package.link + }; + }); + const satisfiedVersions = availableVersionsWithBinaries + .filter(item => util_1.isVersionSatisfies(version, item.version)) + .sort((a, b) => { + return -semver_1.default.compareBuild(a.version, b.version); + }); + const resolvedFullVersion = satisfiedVersions.length > 0 ? satisfiedVersions[0] : null; + if (!resolvedFullVersion) { + const availableOptions = availableVersionsWithBinaries.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 javaPath; + 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 version = this.getToolcacheVersionName(javaRelease.version); + javaPath = yield tc.cacheDir(archivePath, this.toolcacheFolderName, version, this.architecture); + return { version: javaRelease.version, path: javaPath }; + }); + } + get toolcacheFolderName() { + return super.toolcacheFolderName; + } + getAvailableVersions() { + return __awaiter(this, void 0, void 0, function* () { + const platform = this.getPlatformOption(); + const arch = this.distributionArchitecture(); + const imageType = this.packageType; + const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions + const releaseType = this.stable ? 'ga' : 'ea'; + if (core.isDebug()) { + console.time('temurin-retrieve-available-versions'); + } + const baseRequestArguments = [ + `project=jdk`, + 'vendor=adoptium', + `heap_size=normal`, + 'sort_method=DEFAULT', + 'sort_order=DESC', + `os=${platform}`, + `architecture=${arch}`, + `image_type=${imageType}`, + `release_type=${releaseType}`, + `jvm_impl=${this.jvmImpl.toLowerCase()}` + ].join('&'); + // need to iterate through all pages to retrieve the list of all versions + // Adoptium API doesn't provide way to retrieve the count of pages to iterate so infinity loop + let page_index = 0; + const availableVersions = []; + while (true) { + const requestArguments = `${baseRequestArguments}&page_size=20&page=${page_index}`; + const availableVersionsUrl = `https://api.adoptium.net/v3/assets/version/${versionRange}?${requestArguments}`; + if (core.isDebug() && page_index === 0) { + // url is identical except page_index so print it once for debug + core.debug(`Gathering available versions from '${availableVersionsUrl}'`); + } + const paginationPage = (yield this.http.getJson(availableVersionsUrl)).result; + if (paginationPage === null || paginationPage.length === 0) { + // break infinity loop because we have reached end of pagination + break; + } + availableVersions.push(...paginationPage); + page_index++; + } + if (core.isDebug()) { + core.startGroup('Print information about available versions'); + console.timeEnd('temurin-retrieve-available-versions'); + console.log(`Available versions: [${availableVersions.length}]`); + console.log(availableVersions.map(item => item.version_data.semver).join(', ')); + core.endGroup(); + } + return availableVersions; + }); + } + getPlatformOption() { + // Adoptium has own platform names so need to map them + switch (process.platform) { + case 'darwin': + return 'mac'; + case 'win32': + return 'windows'; + default: + return process.platform; + } + } +} +exports.TemurinDistribution = TemurinDistribution; /***/ }), @@ -104748,176 +104748,176 @@ exports.TemurinDistribution = TemurinDistribution; /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.ZuluDistribution = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const tc = __importStar(__nccwpck_require__(7784)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const fs_1 = __importDefault(__nccwpck_require__(7147)); -const semver_1 = __importDefault(__nccwpck_require__(1383)); -const base_installer_1 = __nccwpck_require__(9741); -const util_1 = __nccwpck_require__(2629); -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'; - if (core.isDebug()) { - 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() { - const arch = this.distributionArchitecture(); - switch (arch) { - case 'x64': - return { arch: 'x86', hw_bitness: '64', abi: '' }; - case 'x86': - return { arch: 'x86', hw_bitness: '32', abi: '' }; - case 'aarch64': - case 'arm64': - return { arch: 'arm', hw_bitness: '64', abi: '' }; - default: - return { arch: arch, 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; + +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.ZuluDistribution = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const fs_1 = __importDefault(__nccwpck_require__(7147)); +const semver_1 = __importDefault(__nccwpck_require__(1383)); +const base_installer_1 = __nccwpck_require__(9741); +const util_1 = __nccwpck_require__(2629); +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'; + if (core.isDebug()) { + 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() { + const arch = this.distributionArchitecture(); + switch (arch) { + case 'x64': + return { arch: 'x86', hw_bitness: '64', abi: '' }; + case 'x86': + return { arch: 'x86', hw_bitness: '32', abi: '' }; + case 'aarch64': + case 'arm64': + return { arch: 'arm', hw_bitness: '64', abi: '' }; + default: + return { arch: arch, 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; /***/ }), @@ -104926,74 +104926,74 @@ exports.ZuluDistribution = ZuluDistribution; /***/ (function(__unused_webpack_module, exports, __nccwpck_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()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.deleteKey = exports.importKey = exports.PRIVATE_KEY_FILE = void 0; -const fs = __importStar(__nccwpck_require__(7147)); -const path = __importStar(__nccwpck_require__(1017)); -const io = __importStar(__nccwpck_require__(7436)); -const exec = __importStar(__nccwpck_require__(1514)); -const util = __importStar(__nccwpck_require__(2629)); -exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); -const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; -function importKey(privateKey) { - return __awaiter(this, void 0, void 0, function* () { - fs.writeFileSync(exports.PRIVATE_KEY_FILE, privateKey, { - encoding: 'utf-8', - flag: 'w' - }); - let output = ''; - const options = { - silent: true, - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }; - yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); - yield io.rmRF(exports.PRIVATE_KEY_FILE); - const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); - return match && match[0]; - }); -} -exports.importKey = importKey; -function deleteKey(keyFingerprint) { - return __awaiter(this, void 0, void 0, function* () { - yield exec.exec('gpg', ['--batch', '--yes', '--delete-secret-and-public-key', keyFingerprint], { - silent: true - }); - }); -} -exports.deleteKey = deleteKey; + +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.deleteKey = exports.importKey = exports.PRIVATE_KEY_FILE = void 0; +const fs = __importStar(__nccwpck_require__(7147)); +const path = __importStar(__nccwpck_require__(1017)); +const io = __importStar(__nccwpck_require__(7436)); +const exec = __importStar(__nccwpck_require__(1514)); +const util = __importStar(__nccwpck_require__(2629)); +exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); +const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; +function importKey(privateKey) { + return __awaiter(this, void 0, void 0, function* () { + fs.writeFileSync(exports.PRIVATE_KEY_FILE, privateKey, { + encoding: 'utf-8', + flag: 'w' + }); + let output = ''; + const options = { + silent: true, + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }; + yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); + yield io.rmRF(exports.PRIVATE_KEY_FILE); + const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); + return match && match[0]; + }); +} +exports.importKey = importKey; +function deleteKey(keyFingerprint) { + return __awaiter(this, void 0, void 0, function* () { + yield exec.exec('gpg', ['--batch', '--yes', '--delete-secret-and-public-key', keyFingerprint], { + silent: true + }); + }); +} +exports.deleteKey = deleteKey; /***/ }), @@ -105002,93 +105002,94 @@ exports.deleteKey = deleteKey; /***/ (function(__unused_webpack_module, exports, __nccwpck_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()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const core = __importStar(__nccwpck_require__(2186)); -const auth = __importStar(__nccwpck_require__(3497)); -const util_1 = __nccwpck_require__(2629); -const toolchains = __importStar(__nccwpck_require__(9322)); -const constants = __importStar(__nccwpck_require__(9042)); -const cache_1 = __nccwpck_require__(4810); -const path = __importStar(__nccwpck_require__(1017)); -const distribution_factory_1 = __nccwpck_require__(924); -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION, { required: true }); - const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); - const architecture = core.getInput(constants.INPUT_ARCHITECTURE); - const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); - const jdkFile = core.getInput(constants.INPUT_JDK_FILE); - const cache = core.getInput(constants.INPUT_CACHE); - const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false); - let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); - if (versions.length !== toolchainIds.length) { - toolchainIds = []; - } - core.startGroup('Installed distributions'); - for (const [index, version] of versions.entries()) { - const installerOptions = { - architecture, - packageType, - version, - checkLatest - }; - const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile); - if (!distribution) { - throw new Error(`No supported distribution was found for input ${distributionName}`); - } - const result = yield distribution.setupJava(); - yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[index]); - core.info(''); - core.info('Java configuration:'); - core.info(` Distribution: ${distributionName}`); - core.info(` Version: ${result.version}`); - core.info(` Path: ${result.path}`); - core.info(''); - } - core.endGroup(); - const matchersPath = path.join(__dirname, '..', '..', '.github'); - core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); - yield auth.configureAuthentication(); - if (cache && util_1.isCacheFeatureAvailable()) { - yield cache_1.restore(cache); - } - } - catch (error) { - core.setFailed(error.message); - } - }); -} -run(); + +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(__nccwpck_require__(2186)); +const auth = __importStar(__nccwpck_require__(3497)); +const util_1 = __nccwpck_require__(2629); +const toolchains = __importStar(__nccwpck_require__(9322)); +const constants = __importStar(__nccwpck_require__(9042)); +const cache_1 = __nccwpck_require__(4810); +const path = __importStar(__nccwpck_require__(1017)); +const distribution_factory_1 = __nccwpck_require__(924); +function run() { + return __awaiter(this, void 0, void 0, function* () { + try { + const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION); + core.info(versions.join(" ")); + const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); + const architecture = core.getInput(constants.INPUT_ARCHITECTURE); + const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); + const jdkFile = core.getInput(constants.INPUT_JDK_FILE); + const cache = core.getInput(constants.INPUT_CACHE); + const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false); + let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); + if (versions.length !== toolchainIds.length) { + toolchainIds = []; + } + core.startGroup('Installed distributions'); + for (const [index, version] of versions.entries()) { + const installerOptions = { + architecture, + packageType, + version, + checkLatest + }; + const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile); + if (!distribution) { + throw new Error(`No supported distribution was found for input ${distributionName}`); + } + const result = yield distribution.setupJava(); + yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[index]); + core.info(''); + core.info('Java configuration:'); + core.info(` Distribution: ${distributionName}`); + core.info(` Version: ${result.version}`); + core.info(` Path: ${result.path}`); + core.info(''); + } + core.endGroup(); + const matchersPath = path.join(__dirname, '..', '..', '.github'); + core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); + yield auth.configureAuthentication(); + if (cache && util_1.isCacheFeatureAvailable()) { + yield cache_1.restore(cache); + } + } + catch (error) { + core.setFailed(error.message); + } + }); +} +run(); /***/ }), @@ -105097,158 +105098,158 @@ run(); /***/ (function(__unused_webpack_module, exports, __nccwpck_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()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.generateToolchainDefinition = exports.createToolchainsSettings = exports.configureToolchains = void 0; -const fs = __importStar(__nccwpck_require__(7147)); -const os = __importStar(__nccwpck_require__(2037)); -const path = __importStar(__nccwpck_require__(1017)); -const core = __importStar(__nccwpck_require__(2186)); -const io = __importStar(__nccwpck_require__(7436)); -const constants = __importStar(__nccwpck_require__(9042)); -const util_1 = __nccwpck_require__(2629); -const xmlbuilder2_1 = __nccwpck_require__(151); -function configureToolchains(version, distributionName, jdkHome, toolchainId) { - return __awaiter(this, void 0, void 0, function* () { - const vendor = core.getInput(constants.INPUT_MVN_TOOLCHAIN_VENDOR) || distributionName; - const id = toolchainId || `${vendor}_${version}`; - const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) || path.join(os.homedir(), constants.M2_DIR); - const overwriteSettings = util_1.getBooleanInput(constants.INPUT_OVERWRITE_SETTINGS, true); - yield createToolchainsSettings({ - jdkInfo: { - version, - vendor, - id, - jdkHome - }, - settingsDirectory, - overwriteSettings - }); - }); -} -exports.configureToolchains = configureToolchains; -function createToolchainsSettings({ jdkInfo, settingsDirectory, overwriteSettings }) { - return __awaiter(this, void 0, void 0, function* () { - core.info(`Creating ${constants.MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`); - // when an alternate m2 location is specified use only that location (no .m2 directory) - // otherwise use the home/.m2/ path - yield io.mkdirP(settingsDirectory); - const originalToolchains = yield readExistingToolchainsFile(settingsDirectory); - const updatedToolchains = generateToolchainDefinition(originalToolchains, jdkInfo.version, jdkInfo.vendor, jdkInfo.id, jdkInfo.jdkHome); - yield writeToolchainsFileToDisk(settingsDirectory, updatedToolchains, overwriteSettings); - }); -} -exports.createToolchainsSettings = createToolchainsSettings; -// only exported for testing purposes -function generateToolchainDefinition(original, version, vendor, id, jdkHome) { - let xmlObj; - if (original === null || original === void 0 ? void 0 : original.length) { - xmlObj = xmlbuilder2_1.create(original) - .root() - .ele({ - toolchain: { - type: 'jdk', - provides: { - version: `${version}`, - vendor: `${vendor}`, - id: `${id}` - }, - configuration: { - jdkHome: `${jdkHome}` - } - } - }); - } - else - xmlObj = xmlbuilder2_1.create({ - toolchains: { - '@xmlns': 'https://maven.apache.org/TOOLCHAINS/1.1.0', - '@xmlns:xsi': 'https://www.w3.org/2001/XMLSchema-instance', - '@xsi:schemaLocation': 'https://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd', - toolchain: [ - { - type: 'jdk', - provides: { - version: `${version}`, - vendor: `${vendor}`, - id: `${id}` - }, - configuration: { - jdkHome: `${jdkHome}` - } - } - ] - } - }); - return xmlObj.end({ - format: 'xml', - wellFormed: false, - headless: false, - prettyPrint: true, - width: 80 - }); -} -exports.generateToolchainDefinition = generateToolchainDefinition; -function readExistingToolchainsFile(directory) { - return __awaiter(this, void 0, void 0, function* () { - const location = path.join(directory, constants.MVN_TOOLCHAINS_FILE); - if (fs.existsSync(location)) { - return fs.readFileSync(location, { - encoding: 'utf-8', - flag: 'r' - }); - } - return ''; - }); -} -function writeToolchainsFileToDisk(directory, settings, overwriteSettings) { - return __awaiter(this, void 0, void 0, function* () { - const location = path.join(directory, constants.MVN_TOOLCHAINS_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 of ${location} because file already exists and overwriting is not enabled`); - return; - } - return fs.writeFileSync(location, settings, { - encoding: 'utf-8', - flag: 'w' - }); - }); -} + +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.generateToolchainDefinition = exports.createToolchainsSettings = exports.configureToolchains = void 0; +const fs = __importStar(__nccwpck_require__(7147)); +const os = __importStar(__nccwpck_require__(2037)); +const path = __importStar(__nccwpck_require__(1017)); +const core = __importStar(__nccwpck_require__(2186)); +const io = __importStar(__nccwpck_require__(7436)); +const constants = __importStar(__nccwpck_require__(9042)); +const util_1 = __nccwpck_require__(2629); +const xmlbuilder2_1 = __nccwpck_require__(151); +function configureToolchains(version, distributionName, jdkHome, toolchainId) { + return __awaiter(this, void 0, void 0, function* () { + const vendor = core.getInput(constants.INPUT_MVN_TOOLCHAIN_VENDOR) || distributionName; + const id = toolchainId || `${vendor}_${version}`; + const settingsDirectory = core.getInput(constants.INPUT_SETTINGS_PATH) || path.join(os.homedir(), constants.M2_DIR); + const overwriteSettings = util_1.getBooleanInput(constants.INPUT_OVERWRITE_SETTINGS, true); + yield createToolchainsSettings({ + jdkInfo: { + version, + vendor, + id, + jdkHome + }, + settingsDirectory, + overwriteSettings + }); + }); +} +exports.configureToolchains = configureToolchains; +function createToolchainsSettings({ jdkInfo, settingsDirectory, overwriteSettings }) { + return __awaiter(this, void 0, void 0, function* () { + core.info(`Creating ${constants.MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`); + // when an alternate m2 location is specified use only that location (no .m2 directory) + // otherwise use the home/.m2/ path + yield io.mkdirP(settingsDirectory); + const originalToolchains = yield readExistingToolchainsFile(settingsDirectory); + const updatedToolchains = generateToolchainDefinition(originalToolchains, jdkInfo.version, jdkInfo.vendor, jdkInfo.id, jdkInfo.jdkHome); + yield writeToolchainsFileToDisk(settingsDirectory, updatedToolchains, overwriteSettings); + }); +} +exports.createToolchainsSettings = createToolchainsSettings; +// only exported for testing purposes +function generateToolchainDefinition(original, version, vendor, id, jdkHome) { + let xmlObj; + if (original === null || original === void 0 ? void 0 : original.length) { + xmlObj = xmlbuilder2_1.create(original) + .root() + .ele({ + toolchain: { + type: 'jdk', + provides: { + version: `${version}`, + vendor: `${vendor}`, + id: `${id}` + }, + configuration: { + jdkHome: `${jdkHome}` + } + } + }); + } + else + xmlObj = xmlbuilder2_1.create({ + toolchains: { + '@xmlns': 'https://maven.apache.org/TOOLCHAINS/1.1.0', + '@xmlns:xsi': 'https://www.w3.org/2001/XMLSchema-instance', + '@xsi:schemaLocation': 'https://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd', + toolchain: [ + { + type: 'jdk', + provides: { + version: `${version}`, + vendor: `${vendor}`, + id: `${id}` + }, + configuration: { + jdkHome: `${jdkHome}` + } + } + ] + } + }); + return xmlObj.end({ + format: 'xml', + wellFormed: false, + headless: false, + prettyPrint: true, + width: 80 + }); +} +exports.generateToolchainDefinition = generateToolchainDefinition; +function readExistingToolchainsFile(directory) { + return __awaiter(this, void 0, void 0, function* () { + const location = path.join(directory, constants.MVN_TOOLCHAINS_FILE); + if (fs.existsSync(location)) { + return fs.readFileSync(location, { + encoding: 'utf-8', + flag: 'r' + }); + } + return ''; + }); +} +function writeToolchainsFileToDisk(directory, settings, overwriteSettings) { + return __awaiter(this, void 0, void 0, function* () { + const location = path.join(directory, constants.MVN_TOOLCHAINS_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 of ${location} because file already exists and overwriting is not enabled`); + return; + } + return fs.writeFileSync(location, settings, { + encoding: 'utf-8', + flag: 'w' + }); + }); +} /***/ }), @@ -105257,135 +105258,135 @@ function writeToolchainsFileToDisk(directory, settings, overwriteSettings) { /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; -const os_1 = __importDefault(__nccwpck_require__(2037)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const fs = __importStar(__nccwpck_require__(7147)); -const semver = __importStar(__nccwpck_require__(1383)); -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const tc = __importStar(__nccwpck_require__(7784)); -const constants_1 = __nccwpck_require__(9042); -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; -function isJobStatusSuccess() { - const jobStatus = core.getInput(constants_1.INPUT_JOB_STATUS); - return jobStatus === 'success'; -} -exports.isJobStatusSuccess = isJobStatusSuccess; -function isGhes() { - const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; -} -exports.isGhes = isGhes; -function isCacheFeatureAvailable() { - if (!cache.isFeatureAvailable()) { - if (isGhes()) { - throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'); - } - else { - core.warning('The runner was not able to contact the cache service. Caching will be skipped'); - } - return false; - } - return true; -} -exports.isCacheFeatureAvailable = isCacheFeatureAvailable; + +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.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +const os_1 = __importDefault(__nccwpck_require__(2037)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const fs = __importStar(__nccwpck_require__(7147)); +const semver = __importStar(__nccwpck_require__(1383)); +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const constants_1 = __nccwpck_require__(9042); +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; +function isJobStatusSuccess() { + const jobStatus = core.getInput(constants_1.INPUT_JOB_STATUS); + return jobStatus === 'success'; +} +exports.isJobStatusSuccess = isJobStatusSuccess; +function isGhes() { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} +exports.isGhes = isGhes; +function isCacheFeatureAvailable() { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'); + } + else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + return false; + } + return true; +} +exports.isCacheFeatureAvailable = isCacheFeatureAvailable; /***/ }), diff --git a/src/setup-java.ts b/src/setup-java.ts index 282c9b6df..716aefec4 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -11,7 +11,7 @@ import { JavaInstallerOptions } from './distributions/base-models'; async function run() { try { const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION); - core.info(versions) + core.info(versions.join(" ")) const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); From d5d37d43c2924c881f2349d3f6752b17b3a9bebd Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 17 Nov 2022 13:16:34 +0100 Subject: [PATCH 03/49] build --- dist/setup/index.js | 9 ++++++++- src/setup-java.ts | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 6e0d413f1..159b30d14 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105031,7 +105031,11 @@ 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 })); +const fs_1 = __importDefault(__nccwpck_require__(7147)); const core = __importStar(__nccwpck_require__(2186)); const auth = __importStar(__nccwpck_require__(3497)); const util_1 = __nccwpck_require__(2629); @@ -105044,7 +105048,6 @@ function run() { return __awaiter(this, void 0, void 0, function* () { try { const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION); - core.info(versions.join(" ")); const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); @@ -105052,6 +105055,10 @@ function run() { const cache = core.getInput(constants.INPUT_CACHE); const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false); let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); + if (!versions.length) { + const contents = fs_1.default.readFileSync('.java-version').toString(); + core.info(contents); + } if (versions.length !== toolchainIds.length) { toolchainIds = []; } diff --git a/src/setup-java.ts b/src/setup-java.ts index 716aefec4..3c93395b4 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -1,3 +1,4 @@ +import fs from "fs"; import * as core from '@actions/core'; import * as auth from './auth'; import { getBooleanInput, isCacheFeatureAvailable } from './util'; @@ -11,7 +12,6 @@ import { JavaInstallerOptions } from './distributions/base-models'; async function run() { try { const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION); - core.info(versions.join(" ")) const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); @@ -20,6 +20,11 @@ async function run() { const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false); let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); + if (!versions.length) { + const contents = fs.readFileSync('.java-version').toString(); + core.info(contents) + } + if (versions.length !== toolchainIds.length) { toolchainIds = []; } From 680565b9c5f37896ecfc8d3c97f38f561e30003e Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 17 Nov 2022 13:21:58 +0100 Subject: [PATCH 04/49] build --- dist/setup/index.js | 6 ++++-- src/setup-java.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 159b30d14..f2ff9e667 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105056,8 +105056,10 @@ function run() { const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false); let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); if (!versions.length) { - const contents = fs_1.default.readFileSync('.java-version').toString(); - core.info(contents); + core.debug("JAVA_VERSION input is empty, looking for .java-version file"); + const versionFileName = '.java-version'; + const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); + versions.push(contents); } if (versions.length !== toolchainIds.length) { toolchainIds = []; diff --git a/src/setup-java.ts b/src/setup-java.ts index 3c93395b4..ea5bec0ab 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -21,8 +21,10 @@ async function run() { let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); if (!versions.length) { - const contents = fs.readFileSync('.java-version').toString(); - core.info(contents) + core.debug("JAVA_VERSION input is empty, looking for .java-version file") + const versionFileName = '.java-version' + const contents = fs.readFileSync(versionFileName).toString().trim(); + versions.push(contents) } if (versions.length !== toolchainIds.length) { From 8dcd17f2ef018ac2aa2c9b0581eead14e2652dc5 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 16:38:22 +0100 Subject: [PATCH 05/49] parse version --- dist/setup/index.js | 3 +++ src/setup-java.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index f2ff9e667..5b1ec81e4 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105044,6 +105044,7 @@ const constants = __importStar(__nccwpck_require__(9042)); const cache_1 = __nccwpck_require__(4810); const path = __importStar(__nccwpck_require__(1017)); const distribution_factory_1 = __nccwpck_require__(924); +const semver = __importStar(__nccwpck_require__(1383)); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -105059,6 +105060,8 @@ function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file"); const versionFileName = '.java-version'; const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); + const version = semver.valid(contents); + core.info(version ? version : "not found"); versions.push(contents); } if (versions.length !== toolchainIds.length) { diff --git a/src/setup-java.ts b/src/setup-java.ts index ea5bec0ab..87c6beec0 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -8,6 +8,7 @@ import { restore } from './cache'; import * as path from 'path'; import { getJavaDistribution } from './distributions/distribution-factory'; import { JavaInstallerOptions } from './distributions/base-models'; +import * as semver from 'semver'; async function run() { try { @@ -24,6 +25,8 @@ async function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file") const versionFileName = '.java-version' const contents = fs.readFileSync(versionFileName).toString().trim(); + const version = semver.valid(contents); + core.info(version ? version : "not found") versions.push(contents) } From 71a377dea9393f3a28617352ccfcbcc4a031f558 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 16:43:44 +0100 Subject: [PATCH 06/49] prettier log err --- dist/setup/index.js | 2 +- src/distributions/microsoft/installer.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 5b1ec81e4..dbd1eda5f 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -104527,7 +104527,7 @@ class MicrosoftDistributions extends base_installer_1.JavaBase { } const foundRelease = yield tc.findFromManifest(range, true, manifest, arch); if (!foundRelease) { - throw new Error(`Could not find satisfied version for SemVer ${range}. ${manifest + throw new Error(`Could not find satisfied version for SemVer ${range}.\nAvailable versions: ${manifest .map(item => item.version) .join(', ')}`); } diff --git a/src/distributions/microsoft/installer.ts b/src/distributions/microsoft/installer.ts index 6284f961c..043a591dd 100644 --- a/src/distributions/microsoft/installer.ts +++ b/src/distributions/microsoft/installer.ts @@ -60,7 +60,7 @@ export class MicrosoftDistributions extends JavaBase { if (!foundRelease) { throw new Error( - `Could not find satisfied version for SemVer ${range}. ${manifest + `Could not find satisfied version for SemVer ${range}.\nAvailable versions: ${manifest .map(item => item.version) .join(', ')}` ); From af8b898a83ba61ee54e3dcaaa8ad0d69e6249327 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 16:50:35 +0100 Subject: [PATCH 07/49] clean string --- dist/setup/index.js | 3 ++- src/setup-java.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index dbd1eda5f..6ae733cd4 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105060,7 +105060,8 @@ function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file"); const versionFileName = '.java-version'; const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); - const version = semver.valid(contents); + const cleanedStr = semver.clean(' = v 2.1.5foo', { loose: true }); + const version = semver.valid(cleanedStr); core.info(version ? version : "not found"); versions.push(contents); } diff --git a/src/setup-java.ts b/src/setup-java.ts index 87c6beec0..e6d2fb440 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -25,7 +25,8 @@ async function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file") const versionFileName = '.java-version' const contents = fs.readFileSync(versionFileName).toString().trim(); - const version = semver.valid(contents); + const cleanedStr = semver.clean(' = v 2.1.5foo', { loose: true }) + const version = semver.valid(cleanedStr); core.info(version ? version : "not found") versions.push(contents) } From c86f786dcf0061a6a4178ea782b408762536f291 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 16:51:47 +0100 Subject: [PATCH 08/49] clean contents --- dist/setup/index.js | 2 +- src/setup-java.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 6ae733cd4..f29117802 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105060,7 +105060,7 @@ function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file"); const versionFileName = '.java-version'; const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); - const cleanedStr = semver.clean(' = v 2.1.5foo', { loose: true }); + const cleanedStr = semver.clean(contents, { loose: true }); const version = semver.valid(cleanedStr); core.info(version ? version : "not found"); versions.push(contents); diff --git a/src/setup-java.ts b/src/setup-java.ts index e6d2fb440..7b6c3ae4c 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -25,7 +25,7 @@ async function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file") const versionFileName = '.java-version' const contents = fs.readFileSync(versionFileName).toString().trim(); - const cleanedStr = semver.clean(' = v 2.1.5foo', { loose: true }) + const cleanedStr = semver.clean(contents, { loose: true }) const version = semver.valid(cleanedStr); core.info(version ? version : "not found") versions.push(contents) From c77138c27313dafb8f575ee276d2bbcf0b6448cf Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 16:54:19 +0100 Subject: [PATCH 09/49] coerce --- dist/setup/index.js | 4 ++-- src/setup-java.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index f29117802..ce1d1e6d7 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105060,8 +105060,8 @@ function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file"); const versionFileName = '.java-version'; const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); - const cleanedStr = semver.clean(contents, { loose: true }); - const version = semver.valid(cleanedStr); + const coercedStr = semver.coerce(contents, { loose: true }); + const version = semver.valid(coercedStr); core.info(version ? version : "not found"); versions.push(contents); } diff --git a/src/setup-java.ts b/src/setup-java.ts index 7b6c3ae4c..db5310fb8 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -25,8 +25,8 @@ async function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file") const versionFileName = '.java-version' const contents = fs.readFileSync(versionFileName).toString().trim(); - const cleanedStr = semver.clean(contents, { loose: true }) - const version = semver.valid(cleanedStr); + const coercedStr = semver.coerce(contents, { loose: true }) + const version = semver.valid(coercedStr); core.info(version ? version : "not found") versions.push(contents) } From d4cd9e298e2d4e15269d3d216767b21a552331d2 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 17:37:53 +0100 Subject: [PATCH 10/49] parseversion --- dist/setup/index.js | 6 +++--- src/setup-java.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index ce1d1e6d7..4ef211dfb 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105060,9 +105060,9 @@ function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file"); const versionFileName = '.java-version'; const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); - const coercedStr = semver.coerce(contents, { loose: true }); - const version = semver.valid(coercedStr); - core.info(version ? version : "not found"); + const semverRegExp = /(\d+\.\d+\.\d+|\d+\.\d+|\d+$)/; + const version = semverRegExp.test(contents) ? RegExp.$1 : ""; + core.info(semver.valid(version) ? semver.valid(version) : "not found"); versions.push(contents); } if (versions.length !== toolchainIds.length) { diff --git a/src/setup-java.ts b/src/setup-java.ts index db5310fb8..e13136eb4 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -25,9 +25,9 @@ async function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file") const versionFileName = '.java-version' const contents = fs.readFileSync(versionFileName).toString().trim(); - const coercedStr = semver.coerce(contents, { loose: true }) - const version = semver.valid(coercedStr); - core.info(version ? version : "not found") + const semverRegExp = /(\d+\.\d+\.\d+|\d+\.\d+|\d+$)/ + const version = semverRegExp.test(contents) ? RegExp.$1 : ""; + core.info(semver.valid(version) ? semver.valid(version) as string : "not found") versions.push(contents) } From 5a3790365586557e0a6b6f551a9b0da50c6f2862 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 17:48:09 +0100 Subject: [PATCH 11/49] ver parse --- dist/setup/index.js | 4 +++- src/setup-java.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 4ef211dfb..6cf46e7af 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105062,7 +105062,9 @@ function run() { const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); const semverRegExp = /(\d+\.\d+\.\d+|\d+\.\d+|\d+$)/; const version = semverRegExp.test(contents) ? RegExp.$1 : ""; - core.info(semver.valid(version) ? semver.valid(version) : "not found"); + const coercedVer = semver.coerce(version); + const validVer = semver.valid(coercedVer); + core.info(validVer ? validVer : "not found"); versions.push(contents); } if (versions.length !== toolchainIds.length) { diff --git a/src/setup-java.ts b/src/setup-java.ts index e13136eb4..a79e18f0b 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -27,7 +27,9 @@ async function run() { const contents = fs.readFileSync(versionFileName).toString().trim(); const semverRegExp = /(\d+\.\d+\.\d+|\d+\.\d+|\d+$)/ const version = semverRegExp.test(contents) ? RegExp.$1 : ""; - core.info(semver.valid(version) ? semver.valid(version) as string : "not found") + const coercedVer = semver.coerce(version) + const validVer = semver.valid(coercedVer) + core.info(validVer ? validVer as string : "not found") versions.push(contents) } From f8c67ed9c3fa9b25afe936bb065b62831228954d Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 18:06:32 +0100 Subject: [PATCH 12/49] install version from file --- dist/setup/index.js | 62 +++++++++++++++++++++++++++------------------ src/setup-java.ts | 43 ++++++++++++++++++++----------- 2 files changed, 66 insertions(+), 39 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 6cf46e7af..2adc73103 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105056,6 +105056,10 @@ function run() { const cache = core.getInput(constants.INPUT_CACHE); const checkLatest = util_1.getBooleanInput(constants.INPUT_CHECK_LATEST, false); let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); + core.startGroup('Installed distributions'); + if (versions.length !== toolchainIds.length) { + toolchainIds = []; + } if (!versions.length) { core.debug("JAVA_VERSION input is empty, looking for .java-version file"); const versionFileName = '.java-version'; @@ -105064,32 +105068,20 @@ function run() { const version = semverRegExp.test(contents) ? RegExp.$1 : ""; const coercedVer = semver.coerce(version); const validVer = semver.valid(coercedVer); - core.info(validVer ? validVer : "not found"); - versions.push(contents); - } - if (versions.length !== toolchainIds.length) { - toolchainIds = []; + if (validVer === null) { + throw new Error("No version found"); + } + const stringVersion = validVer; + try { + installVersion(stringVersion); + } + catch (error) { + core.info(`${stringVersion} not found`); + throw new Error("some err"); + } } - core.startGroup('Installed distributions'); for (const [index, version] of versions.entries()) { - const installerOptions = { - architecture, - packageType, - version, - checkLatest - }; - const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile); - if (!distribution) { - throw new Error(`No supported distribution was found for input ${distributionName}`); - } - const result = yield distribution.setupJava(); - yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[index]); - core.info(''); - core.info('Java configuration:'); - core.info(` Distribution: ${distributionName}`); - core.info(` Version: ${result.version}`); - core.info(` Path: ${result.path}`); - core.info(''); + yield installVersion(version, index); } core.endGroup(); const matchersPath = path.join(__dirname, '..', '..', '.github'); @@ -105098,6 +105090,28 @@ function run() { if (cache && util_1.isCacheFeatureAvailable()) { yield cache_1.restore(cache); } + function installVersion(version, toolchainId = 0) { + return __awaiter(this, void 0, void 0, function* () { + const installerOptions = { + architecture, + packageType, + version, + checkLatest + }; + const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile); + if (!distribution) { + throw new Error(`No supported distribution was found for input ${distributionName}`); + } + const result = yield distribution.setupJava(); + yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[toolchainId]); + core.info(''); + core.info('Java configuration:'); + core.info(` Distribution: ${distributionName}`); + core.info(` Version: ${result.version}`); + core.info(` Path: ${result.path}`); + core.info(''); + }); + } } catch (error) { core.setFailed(error.message); diff --git a/src/setup-java.ts b/src/setup-java.ts index a79e18f0b..3ec148925 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -21,6 +21,12 @@ async function run() { const checkLatest = getBooleanInput(constants.INPUT_CHECK_LATEST, false); let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); + core.startGroup('Installed distributions'); + + if (versions.length !== toolchainIds.length) { + toolchainIds = []; + } + if (!versions.length) { core.debug("JAVA_VERSION input is empty, looking for .java-version file") const versionFileName = '.java-version' @@ -29,16 +35,31 @@ async function run() { const version = semverRegExp.test(contents) ? RegExp.$1 : ""; const coercedVer = semver.coerce(version) const validVer = semver.valid(coercedVer) - core.info(validVer ? validVer as string : "not found") - versions.push(contents) + if (validVer === null) { + throw new Error("No version found") + } + const stringVersion = validVer as string; + try { + installVersion(stringVersion) + } catch (error) { + core.info(`${stringVersion} not found`) + throw new Error("some err") + } } - if (versions.length !== toolchainIds.length) { - toolchainIds = []; + for (const [index, version] of versions.entries()) { + await installVersion(version, index) } + core.endGroup(); + const matchersPath = path.join(__dirname, '..', '..', '.github'); + core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); - core.startGroup('Installed distributions'); - for (const [index, version] of versions.entries()) { + await auth.configureAuthentication(); + if (cache && isCacheFeatureAvailable()) { + await restore(cache); + } + + async function installVersion(version:string, toolchainId = 0 ) { const installerOptions: JavaInstallerOptions = { architecture, packageType, @@ -56,7 +77,7 @@ async function run() { version, distributionName, result.path, - toolchainIds[index] + toolchainIds[toolchainId] ); core.info(''); @@ -66,14 +87,6 @@ async function run() { core.info(` Path: ${result.path}`); core.info(''); } - core.endGroup(); - const matchersPath = path.join(__dirname, '..', '..', '.github'); - core.info(`##[add-matcher]${path.join(matchersPath, 'java.json')}`); - - await auth.configureAuthentication(); - if (cache && isCacheFeatureAvailable()) { - await restore(cache); - } } catch (error) { core.setFailed(error.message); } From 7bad438e84b5d045c4e6a860e757075e3e738f09 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 18:14:22 +0100 Subject: [PATCH 13/49] await install --- dist/setup/index.js | 2 +- src/setup-java.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 2adc73103..6fd0065c0 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105073,7 +105073,7 @@ function run() { } const stringVersion = validVer; try { - installVersion(stringVersion); + yield installVersion(stringVersion); } catch (error) { core.info(`${stringVersion} not found`); diff --git a/src/setup-java.ts b/src/setup-java.ts index 3ec148925..f829a6fde 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -22,7 +22,7 @@ async function run() { let toolchainIds = core.getMultilineInput(constants.INPUT_MVN_TOOLCHAIN_ID); core.startGroup('Installed distributions'); - + if (versions.length !== toolchainIds.length) { toolchainIds = []; } @@ -40,7 +40,7 @@ async function run() { } const stringVersion = validVer as string; try { - installVersion(stringVersion) + await installVersion(stringVersion) } catch (error) { core.info(`${stringVersion} not found`) throw new Error("some err") From 5162a5672996150cbf981f310efe52c25f77ba32 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 18:23:19 +0100 Subject: [PATCH 14/49] retry logic --- dist/setup/index.js | 15 +++++++++++++-- src/setup-java.ts | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 6fd0065c0..af5bcc0b9 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105076,8 +105076,16 @@ function run() { yield installVersion(stringVersion); } catch (error) { - core.info(`${stringVersion} not found`); - throw new Error("some err"); + core.debug(`${error.toString()}`); + try { + const majorMinorVersion = getHigherVersion(stringVersion); + yield installVersion(majorMinorVersion); + } + catch (error) { + core.debug(`${error.toString()}`); + const majorVersion = getHigherVersion(stringVersion); + yield installVersion(majorVersion); + } } } for (const [index, version] of versions.entries()) { @@ -105112,6 +105120,9 @@ function run() { core.info(''); }); } + function getHigherVersion(version) { + return version.substring(0, version.lastIndexOf(".")); + } } catch (error) { core.setFailed(error.message); diff --git a/src/setup-java.ts b/src/setup-java.ts index f829a6fde..9fd9a0484 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -42,8 +42,15 @@ async function run() { try { await installVersion(stringVersion) } catch (error) { - core.info(`${stringVersion} not found`) - throw new Error("some err") + core.debug(`${error.toString()}`) + try { + const majorMinorVersion = getHigherVersion(stringVersion) + await installVersion(majorMinorVersion) + } catch (error) { + core.debug(`${error.toString()}`) + const majorVersion = getHigherVersion(stringVersion) + await installVersion(majorVersion) + } } } @@ -87,6 +94,10 @@ async function run() { core.info(` Path: ${result.path}`); core.info(''); } + + function getHigherVersion(version: string) { + return version.substring(0, version.lastIndexOf(".")) + } } catch (error) { core.setFailed(error.message); } From 4a04cfa3c7d96eee8ddae7f386e350136186ca74 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 18:29:10 +0100 Subject: [PATCH 15/49] rigth major version --- dist/setup/index.js | 4 ++-- src/setup-java.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index af5bcc0b9..37b7af53f 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105077,13 +105077,13 @@ function run() { } catch (error) { core.debug(`${error.toString()}`); + const majorMinorVersion = getHigherVersion(stringVersion); try { - const majorMinorVersion = getHigherVersion(stringVersion); yield installVersion(majorMinorVersion); } catch (error) { core.debug(`${error.toString()}`); - const majorVersion = getHigherVersion(stringVersion); + const majorVersion = getHigherVersion(majorMinorVersion); yield installVersion(majorVersion); } } diff --git a/src/setup-java.ts b/src/setup-java.ts index 9fd9a0484..b48cec9d5 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -43,12 +43,12 @@ async function run() { await installVersion(stringVersion) } catch (error) { core.debug(`${error.toString()}`) + const majorMinorVersion = getHigherVersion(stringVersion) try { - const majorMinorVersion = getHigherVersion(stringVersion) await installVersion(majorMinorVersion) } catch (error) { core.debug(`${error.toString()}`) - const majorVersion = getHigherVersion(stringVersion) + const majorVersion = getHigherVersion(majorMinorVersion) await installVersion(majorVersion) } } From d0a3b38995733c7cc00e5ae207a6d16bbb93c9f3 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 19:06:00 +0100 Subject: [PATCH 16/49] update version splitter --- dist/setup/index.js | 30 +++++++++++------------------- src/setup-java.ts | 31 +++++++++++++------------------ 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 37b7af53f..455c00d90 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105044,7 +105044,6 @@ const constants = __importStar(__nccwpck_require__(9042)); const cache_1 = __nccwpck_require__(4810); const path = __importStar(__nccwpck_require__(1017)); const distribution_factory_1 = __nccwpck_require__(924); -const semver = __importStar(__nccwpck_require__(1383)); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -105064,29 +105063,22 @@ function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file"); const versionFileName = '.java-version'; const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); - const semverRegExp = /(\d+\.\d+\.\d+|\d+\.\d+|\d+$)/; - const version = semverRegExp.test(contents) ? RegExp.$1 : ""; - const coercedVer = semver.coerce(version); - const validVer = semver.valid(coercedVer); - if (validVer === null) { - throw new Error("No version found"); - } - const stringVersion = validVer; - try { - yield installVersion(stringVersion); - } - catch (error) { - core.debug(`${error.toString()}`); - const majorMinorVersion = getHigherVersion(stringVersion); + const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/; + let version = semverRegExp.test(contents) ? RegExp.$1 : ""; + let installed = false; + while (!installed && version != "") { try { - yield installVersion(majorMinorVersion); + yield installVersion(version); + installed = true; } catch (error) { core.debug(`${error.toString()}`); - const majorVersion = getHigherVersion(majorMinorVersion); - yield installVersion(majorVersion); + version = getHigherVersion(version); } } + if (!installed) { + throw new Error("Сan't install appropriate version from .java-version file"); + } } for (const [index, version] of versions.entries()) { yield installVersion(version, index); @@ -105121,7 +105113,7 @@ function run() { }); } function getHigherVersion(version) { - return version.substring(0, version.lastIndexOf(".")); + return version.split("-")[0] === version ? version.substring(0, version.lastIndexOf(".")) : version.split("-")[0]; } } catch (error) { diff --git a/src/setup-java.ts b/src/setup-java.ts index b48cec9d5..c094deacd 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -31,27 +31,21 @@ async function run() { core.debug("JAVA_VERSION input is empty, looking for .java-version file") const versionFileName = '.java-version' const contents = fs.readFileSync(versionFileName).toString().trim(); - const semverRegExp = /(\d+\.\d+\.\d+|\d+\.\d+|\d+$)/ - const version = semverRegExp.test(contents) ? RegExp.$1 : ""; - const coercedVer = semver.coerce(version) - const validVer = semver.valid(coercedVer) - if (validVer === null) { - throw new Error("No version found") - } - const stringVersion = validVer as string; - try { - await installVersion(stringVersion) - } catch (error) { - core.debug(`${error.toString()}`) - const majorMinorVersion = getHigherVersion(stringVersion) + const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/ + let version = semverRegExp.test(contents) ? RegExp.$1 : ""; + let installed = false; + while (!installed && version != "") { try { - await installVersion(majorMinorVersion) + await installVersion(version) + installed = true } catch (error) { - core.debug(`${error.toString()}`) - const majorVersion = getHigherVersion(majorMinorVersion) - await installVersion(majorVersion) + core.debug(`${error.toString()}`); + version = getHigherVersion(version) } } + if (!installed) { + throw new Error("Сan't install appropriate version from .java-version file") + } } for (const [index, version] of versions.entries()) { @@ -96,8 +90,9 @@ async function run() { } function getHigherVersion(version: string) { - return version.substring(0, version.lastIndexOf(".")) + return version.split("-")[0] === version ? version.substring(0, version.lastIndexOf(".")) : version.split("-")[0] } + } catch (error) { core.setFailed(error.message); } From a4d7bf0a4190411985afdbd9854ca931678cd556 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 19:10:50 +0100 Subject: [PATCH 17/49] added debug --- dist/setup/index.js | 1 + src/setup-java.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/dist/setup/index.js b/dist/setup/index.js index 455c00d90..f7891961d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105068,6 +105068,7 @@ function run() { let installed = false; while (!installed && version != "") { try { + core.debug(`Trying to install version ${version}`); yield installVersion(version); installed = true; } diff --git a/src/setup-java.ts b/src/setup-java.ts index c094deacd..8e1ef2061 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -36,6 +36,7 @@ async function run() { let installed = false; while (!installed && version != "") { try { + core.debug(`Trying to install version ${version}`) await installVersion(version) installed = true } catch (error) { From e2c02857f141cc8f6a7e8d61726782ee55bad0d1 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 24 Nov 2022 19:24:01 +0100 Subject: [PATCH 18/49] remove unused import --- dist/setup/index.js | 15 ++++++++++----- src/setup-java.ts | 37 ++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index cfeb24d21..57b72a340 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105184,13 +105184,16 @@ function run() { toolchainIds = []; } if (!versions.length) { - core.debug("JAVA_VERSION input is empty, looking for .java-version file"); + core.debug('JAVA_VERSION input is empty, looking for .java-version file'); const versionFileName = '.java-version'; - const contents = fs_1.default.readFileSync(versionFileName).toString().trim(); + const contents = fs_1.default + .readFileSync(versionFileName) + .toString() + .trim(); const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/; - let version = semverRegExp.test(contents) ? RegExp.$1 : ""; + let version = semverRegExp.test(contents) ? RegExp.$1 : ''; let installed = false; - while (!installed && version != "") { + while (!installed && version != '') { try { core.debug(`Trying to install version ${version}`); yield installVersion(version); @@ -105238,7 +105241,9 @@ function run() { }); } function getHigherVersion(version) { - return version.split("-")[0] === version ? version.substring(0, version.lastIndexOf(".")) : version.split("-")[0]; + return version.split('-')[0] === version + ? version.substring(0, version.lastIndexOf('.')) + : version.split('-')[0]; } } catch (error) { diff --git a/src/setup-java.ts b/src/setup-java.ts index 8e1ef2061..4164806ea 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -1,4 +1,4 @@ -import fs from "fs"; +import fs from 'fs'; import * as core from '@actions/core'; import * as auth from './auth'; import { getBooleanInput, isCacheFeatureAvailable } from './util'; @@ -8,7 +8,6 @@ import { restore } from './cache'; import * as path from 'path'; import { getJavaDistribution } from './distributions/distribution-factory'; import { JavaInstallerOptions } from './distributions/base-models'; -import * as semver from 'semver'; async function run() { try { @@ -28,29 +27,32 @@ async function run() { } if (!versions.length) { - core.debug("JAVA_VERSION input is empty, looking for .java-version file") - const versionFileName = '.java-version' - const contents = fs.readFileSync(versionFileName).toString().trim(); - const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/ - let version = semverRegExp.test(contents) ? RegExp.$1 : ""; + core.debug('JAVA_VERSION input is empty, looking for .java-version file'); + const versionFileName = '.java-version'; + const contents = fs + .readFileSync(versionFileName) + .toString() + .trim(); + const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/; + let version = semverRegExp.test(contents) ? RegExp.$1 : ''; let installed = false; - while (!installed && version != "") { + while (!installed && version != '') { try { - core.debug(`Trying to install version ${version}`) - await installVersion(version) - installed = true + core.debug(`Trying to install version ${version}`); + await installVersion(version); + installed = true; } catch (error) { core.debug(`${error.toString()}`); - version = getHigherVersion(version) + version = getHigherVersion(version); } } if (!installed) { - throw new Error("Сan't install appropriate version from .java-version file") + throw new Error("Сan't install appropriate version from .java-version file"); } } for (const [index, version] of versions.entries()) { - await installVersion(version, index) + await installVersion(version, index); } core.endGroup(); const matchersPath = path.join(__dirname, '..', '..', '.github'); @@ -61,7 +63,7 @@ async function run() { await restore(cache); } - async function installVersion(version:string, toolchainId = 0 ) { + async function installVersion(version: string, toolchainId = 0) { const installerOptions: JavaInstallerOptions = { architecture, packageType, @@ -91,9 +93,10 @@ async function run() { } function getHigherVersion(version: string) { - return version.split("-")[0] === version ? version.substring(0, version.lastIndexOf(".")) : version.split("-")[0] + return version.split('-')[0] === version + ? version.substring(0, version.lastIndexOf('.')) + : version.split('-')[0]; } - } catch (error) { core.setFailed(error.message); } From 50a98698d08e44e730c7f9e454f63064d21edbc6 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Tue, 29 Nov 2022 10:33:54 +0100 Subject: [PATCH 19/49] update regExp --- src/setup-java.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup-java.ts b/src/setup-java.ts index 4164806ea..f8b99b118 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -33,8 +33,8 @@ async function run() { .readFileSync(versionFileName) .toString() .trim(); - const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/; - let version = semverRegExp.test(contents) ? RegExp.$1 : ''; + const semverRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; + let version = contents.match(semverRegExp)?.groups?.version ? contents.match(semverRegExp)?.groups?.version as string : ''; let installed = false; while (!installed && version != '') { try { From d00ebda289e5e5d5dfcec9ceea431ff2de66696c Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Tue, 29 Nov 2022 11:32:32 +0100 Subject: [PATCH 20/49] build --- dist/setup/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 57b72a340..bf064621d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105169,6 +105169,7 @@ const cache_1 = __nccwpck_require__(4810); const path = __importStar(__nccwpck_require__(1017)); const distribution_factory_1 = __nccwpck_require__(924); function run() { + var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { try { const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION); @@ -105190,8 +105191,8 @@ function run() { .readFileSync(versionFileName) .toString() .trim(); - const semverRegExp = /(\d+\.\d+\.\d+.*ea.*$|\d+\.\d+\.\d+\+\d*$|\d+\.\d+\.\d+|\d+\.\d+|\d+\-ea$|\d+$)/; - let version = semverRegExp.test(contents) ? RegExp.$1 : ''; + const semverRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; + let version = ((_b = (_a = contents.match(semverRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) ? (_d = (_c = contents.match(semverRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version : ''; let installed = false; while (!installed && version != '') { try { From 6d0f35f2d4cc835baf33a47d2737307416a5c895 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Tue, 29 Nov 2022 12:19:56 +0100 Subject: [PATCH 21/49] format & build --- dist/setup/index.js | 4 +++- src/setup-java.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index bf064621d..c2c8f9224 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105192,7 +105192,9 @@ function run() { .toString() .trim(); const semverRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; - let version = ((_b = (_a = contents.match(semverRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) ? (_d = (_c = contents.match(semverRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version : ''; + let version = ((_b = (_a = contents.match(semverRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) + ? (_d = (_c = contents.match(semverRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version + : ''; let installed = false; while (!installed && version != '') { try { diff --git a/src/setup-java.ts b/src/setup-java.ts index f8b99b118..a2e97ec33 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -34,7 +34,9 @@ async function run() { .toString() .trim(); const semverRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; - let version = contents.match(semverRegExp)?.groups?.version ? contents.match(semverRegExp)?.groups?.version as string : ''; + let version = contents.match(semverRegExp)?.groups?.version + ? (contents.match(semverRegExp)?.groups?.version as string) + : ''; let installed = false; while (!installed && version != '') { try { From 40987513b8f4e48b1ad49b8f85974c2599b60551 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 1 Dec 2022 23:44:54 +0100 Subject: [PATCH 22/49] docs changed --- README.md | 2 +- docs/advanced-usage.md | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dcf6f124b..eccbc22c0 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This action allows you to work with Java and Scala projects. ## Usage - - `java-version`: _(required)_ The Java version to set up. Takes a whole or [semver](#supported-version-syntax) Java version. + - `java-version`: The Java version to set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `.java-version` file to be in the repository root. See [more details](docs/advanced-usage.md#Java-version-file) in about `.java-version` file. - `distribution`: _(required)_ Java [distribution](#supported-distributions). diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 6423d06c8..88ecc0c4a 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -16,6 +16,7 @@ - [Publishing using Gradle](#Publishing-using-Gradle) - [Hosted Tool Cache](#Hosted-Tool-Cache) - [Modifying Maven Toolchains](#Modifying-Maven-Toolchains) +- [Java-version file](#Java-version-file) See [action.yml](../action.yml) for more details on task inputs. @@ -478,3 +479,20 @@ steps: something_else something_other ``` + +## Java-version file +If the `java-version` input is not specified, the action will look for a `.java-version` file at the root of the repository. If the file is found, action will try to install the most suitable version. +Action is able to recognize all variants of the version description according to [jenv](https://github.com/jenv/jenv). +Valid entry options: +``` +major versions: 8, 11, 16, 17 +more specific versions: 17.0, 11.0, 11.0.4, 8.0.232, 8.0.282+8 +early access (EA) versions: 15-ea, 15.0.0-ea, 15.0.0-ea.2, 15.0.0+2-ea +versions with specified distribution: openjdk64-11.0.2 +``` +If the file contains multiple versions, only the first one will be recognized. +If action was able to recognize a version in the file that matches the pattern, then attempts will begin to install the most appropriate version. The logic for installing the appropriate version: +action will try to install the specified version. If this version is not available for a given distribution, action will try to install a less specific version according to the algorithm. Attempts will continue until a suitable version is installed or the attempt to install a version specifying only with major tag fails. +Algorithm for selecting the appropriate version: +If a particular patch specification was present in the version (for example, the early access postfix `-ea*` in `major.minor.patch-ea*` notation), action will try to install the version without it in the format `major.minor.patch`. Next, if the install fails again, action will try to install the `major.minor` version. On failure, action will try to install the `major` version and fail on failure. +If the version was originally specified not in full format, then the process will be similar, but it will not start from the first step. \ No newline at end of file From 4f2a9f72942b58702125b07c63ec4c2092a7026c Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 1 Dec 2022 23:48:31 +0100 Subject: [PATCH 23/49] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eccbc22c0..38e2e1db9 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This action allows you to work with Java and Scala projects. ## Usage - - `java-version`: The Java version to set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `.java-version` file to be in the repository root. See [more details](docs/advanced-usage.md#Java-version-file) in about `.java-version` file. + - `java-version`: The Java version to set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `.java-version` file to be in the repository root. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file). - `distribution`: _(required)_ Java [distribution](#supported-distributions). From 098617936ce26693de057da1f1a9e2920e0f26f6 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Mon, 5 Dec 2022 10:37:48 +0100 Subject: [PATCH 24/49] build --- dist/cleanup/index.js | 162 ++++++++++++++++++++++++------------------ dist/setup/index.js | 162 ++++++++++++++++++++++++------------------ 2 files changed, 186 insertions(+), 138 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 459a71bcd..1a34693d5 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -53331,10 +53331,10 @@ function populateMaps (extensions, types) { module.exports = minimatch minimatch.Minimatch = Minimatch -var path = { sep: '/' } -try { - path = __nccwpck_require__(1017) -} catch (er) {} +var path = (function () { try { return __nccwpck_require__(1017) } catch (e) {}}()) || { + sep: '/' +} +minimatch.sep = path.sep var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} var expand = __nccwpck_require__(3717) @@ -53386,43 +53386,64 @@ function filter (pattern, options) { } function ext (a, b) { - a = a || {} b = b || {} var t = {} - Object.keys(b).forEach(function (k) { - t[k] = b[k] - }) Object.keys(a).forEach(function (k) { t[k] = a[k] }) + Object.keys(b).forEach(function (k) { + t[k] = b[k] + }) return t } minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch + if (!def || typeof def !== 'object' || !Object.keys(def).length) { + return minimatch + } var orig = minimatch var m = function minimatch (p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)) + return orig(p, pattern, ext(def, options)) } m.Minimatch = function Minimatch (pattern, options) { return new orig.Minimatch(pattern, ext(def, options)) } + m.Minimatch.defaults = function defaults (options) { + return orig.defaults(ext(def, options)).Minimatch + } + + m.filter = function filter (pattern, options) { + return orig.filter(pattern, ext(def, options)) + } + + m.defaults = function defaults (options) { + return orig.defaults(ext(def, options)) + } + + m.makeRe = function makeRe (pattern, options) { + return orig.makeRe(pattern, ext(def, options)) + } + + m.braceExpand = function braceExpand (pattern, options) { + return orig.braceExpand(pattern, ext(def, options)) + } + + m.match = function (list, pattern, options) { + return orig.match(list, pattern, ext(def, options)) + } return m } Minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch return minimatch.defaults(def).Minimatch } function minimatch (p, pattern, options) { - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } + assertValidPattern(pattern) if (!options) options = {} @@ -53431,9 +53452,6 @@ function minimatch (p, pattern, options) { return false } - // "" only matches "" - if (pattern.trim() === '') return p === '' - return new Minimatch(pattern, options).match(p) } @@ -53442,15 +53460,14 @@ function Minimatch (pattern, options) { return new Minimatch(pattern, options) } - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } + assertValidPattern(pattern) if (!options) options = {} + pattern = pattern.trim() // windows support: need to use /, not \ - if (path.sep !== '/') { + if (!options.allowWindowsEscape && path.sep !== '/') { pattern = pattern.split(path.sep).join('/') } @@ -53461,6 +53478,7 @@ function Minimatch (pattern, options) { this.negate = false this.comment = false this.empty = false + this.partial = !!options.partial // make the set of regexps etc. this.make() @@ -53470,9 +53488,6 @@ Minimatch.prototype.debug = function () {} Minimatch.prototype.make = make function make () { - // don't do it more than once. - if (this._made) return - var pattern = this.pattern var options = this.options @@ -53492,7 +53507,7 @@ function make () { // step 2: expand braces var set = this.globSet = this.braceExpand() - if (options.debug) this.debug = console.error + if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) } this.debug(this.pattern, set) @@ -53572,12 +53587,11 @@ function braceExpand (pattern, options) { pattern = typeof pattern === 'undefined' ? this.pattern : pattern - if (typeof pattern === 'undefined') { - throw new TypeError('undefined pattern') - } + assertValidPattern(pattern) - if (options.nobrace || - !pattern.match(/\{.*\}/)) { + // Thanks to Yeting Li for + // improving this regexp to avoid a ReDOS vulnerability. + if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) { // shortcut. no need to expand. return [pattern] } @@ -53585,6 +53599,17 @@ function braceExpand (pattern, options) { return expand(pattern) } +var MAX_PATTERN_LENGTH = 1024 * 64 +var assertValidPattern = function (pattern) { + if (typeof pattern !== 'string') { + throw new TypeError('invalid pattern') + } + + if (pattern.length > MAX_PATTERN_LENGTH) { + throw new TypeError('pattern is too long') + } +} + // parse a component of the expanded set. // At this point, no pattern may contain "/" in it // so we're going to return a 2d array, where each entry is the full @@ -53599,14 +53624,17 @@ function braceExpand (pattern, options) { Minimatch.prototype.parse = parse var SUBPARSE = {} function parse (pattern, isSub) { - if (pattern.length > 1024 * 64) { - throw new TypeError('pattern is too long') - } + assertValidPattern(pattern) var options = this.options // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '**') { + if (!options.noglobstar) + return GLOBSTAR + else + pattern = '*' + } if (pattern === '') return '' var re = '' @@ -53662,10 +53690,12 @@ function parse (pattern, isSub) { } switch (c) { - case '/': + /* istanbul ignore next */ + case '/': { // completely not allowed, even escaped. // Should already be path-split by now. return false + } case '\\': clearStateChar() @@ -53784,25 +53814,23 @@ function parse (pattern, isSub) { // handle the case where we left a class open. // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue } // finish up the class. @@ -53886,9 +53914,7 @@ function parse (pattern, isSub) { // something that could conceivably capture a dot var addPatternStart = false switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true + case '[': case '.': case '(': addPatternStart = true } // Hack to work around lack of negative lookbehind in JS @@ -53950,7 +53976,7 @@ function parse (pattern, isSub) { var flags = options.nocase ? 'i' : '' try { var regExp = new RegExp('^' + re + '$', flags) - } catch (er) { + } catch (er) /* istanbul ignore next - should be impossible */ { // If it was an invalid regular expression, then it can't match // anything. This trick looks for a character after the end of // the string, which is of course impossible, except in multi-line @@ -54008,7 +54034,7 @@ function makeRe () { try { this.regexp = new RegExp(re, flags) - } catch (ex) { + } catch (ex) /* istanbul ignore next - should be impossible */ { this.regexp = false } return this.regexp @@ -54026,8 +54052,8 @@ minimatch.match = function (list, pattern, options) { return list } -Minimatch.prototype.match = match -function match (f, partial) { +Minimatch.prototype.match = function match (f, partial) { + if (typeof partial === 'undefined') partial = this.partial this.debug('match', f, this.pattern) // short-circuit in the case of busted things. // comments, etc. @@ -54109,6 +54135,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // should be impossible. // some invalid regexp stuff in the set. + /* istanbul ignore if */ if (p === false) return false if (p === GLOBSTAR) { @@ -54182,6 +54209,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // no match was found. // However, in partial mode, we can't say this is necessarily over. // If there's more *pattern* left, then + /* istanbul ignore if */ if (partial) { // ran out of file this.debug('\n>>> no match, partial?', file, fr, pattern, pr) @@ -54195,11 +54223,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // patterns with magic have been turned into regexps. var hit if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } + hit = f === p this.debug('string match', p, f, hit) } else { hit = f.match(p) @@ -54230,16 +54254,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // this is ok if we're doing the match as part of // a glob fs traversal. return partial - } else if (pi === pl) { + } else /* istanbul ignore else */ if (pi === pl) { // ran out of pattern, still have file left. // this is only acceptable if we're on the very last // empty segment of a file with a trailing slash. // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') - return emptyFileEnd + return (fi === fl - 1) && (file[fi] === '') } // should be unreachable. + /* istanbul ignore next */ throw new Error('wtf?') } diff --git a/dist/setup/index.js b/dist/setup/index.js index c2c8f9224..c665957b9 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -82352,10 +82352,10 @@ function populateMaps (extensions, types) { module.exports = minimatch minimatch.Minimatch = Minimatch -var path = { sep: '/' } -try { - path = __nccwpck_require__(1017) -} catch (er) {} +var path = (function () { try { return __nccwpck_require__(1017) } catch (e) {}}()) || { + sep: '/' +} +minimatch.sep = path.sep var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} var expand = __nccwpck_require__(9850) @@ -82407,43 +82407,64 @@ function filter (pattern, options) { } function ext (a, b) { - a = a || {} b = b || {} var t = {} - Object.keys(b).forEach(function (k) { - t[k] = b[k] - }) Object.keys(a).forEach(function (k) { t[k] = a[k] }) + Object.keys(b).forEach(function (k) { + t[k] = b[k] + }) return t } minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch + if (!def || typeof def !== 'object' || !Object.keys(def).length) { + return minimatch + } var orig = minimatch var m = function minimatch (p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)) + return orig(p, pattern, ext(def, options)) } m.Minimatch = function Minimatch (pattern, options) { return new orig.Minimatch(pattern, ext(def, options)) } + m.Minimatch.defaults = function defaults (options) { + return orig.defaults(ext(def, options)).Minimatch + } + + m.filter = function filter (pattern, options) { + return orig.filter(pattern, ext(def, options)) + } + + m.defaults = function defaults (options) { + return orig.defaults(ext(def, options)) + } + + m.makeRe = function makeRe (pattern, options) { + return orig.makeRe(pattern, ext(def, options)) + } + + m.braceExpand = function braceExpand (pattern, options) { + return orig.braceExpand(pattern, ext(def, options)) + } + + m.match = function (list, pattern, options) { + return orig.match(list, pattern, ext(def, options)) + } return m } Minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch return minimatch.defaults(def).Minimatch } function minimatch (p, pattern, options) { - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } + assertValidPattern(pattern) if (!options) options = {} @@ -82452,9 +82473,6 @@ function minimatch (p, pattern, options) { return false } - // "" only matches "" - if (pattern.trim() === '') return p === '' - return new Minimatch(pattern, options).match(p) } @@ -82463,15 +82481,14 @@ function Minimatch (pattern, options) { return new Minimatch(pattern, options) } - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } + assertValidPattern(pattern) if (!options) options = {} + pattern = pattern.trim() // windows support: need to use /, not \ - if (path.sep !== '/') { + if (!options.allowWindowsEscape && path.sep !== '/') { pattern = pattern.split(path.sep).join('/') } @@ -82482,6 +82499,7 @@ function Minimatch (pattern, options) { this.negate = false this.comment = false this.empty = false + this.partial = !!options.partial // make the set of regexps etc. this.make() @@ -82491,9 +82509,6 @@ Minimatch.prototype.debug = function () {} Minimatch.prototype.make = make function make () { - // don't do it more than once. - if (this._made) return - var pattern = this.pattern var options = this.options @@ -82513,7 +82528,7 @@ function make () { // step 2: expand braces var set = this.globSet = this.braceExpand() - if (options.debug) this.debug = console.error + if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) } this.debug(this.pattern, set) @@ -82593,12 +82608,11 @@ function braceExpand (pattern, options) { pattern = typeof pattern === 'undefined' ? this.pattern : pattern - if (typeof pattern === 'undefined') { - throw new TypeError('undefined pattern') - } + assertValidPattern(pattern) - if (options.nobrace || - !pattern.match(/\{.*\}/)) { + // Thanks to Yeting Li for + // improving this regexp to avoid a ReDOS vulnerability. + if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) { // shortcut. no need to expand. return [pattern] } @@ -82606,6 +82620,17 @@ function braceExpand (pattern, options) { return expand(pattern) } +var MAX_PATTERN_LENGTH = 1024 * 64 +var assertValidPattern = function (pattern) { + if (typeof pattern !== 'string') { + throw new TypeError('invalid pattern') + } + + if (pattern.length > MAX_PATTERN_LENGTH) { + throw new TypeError('pattern is too long') + } +} + // parse a component of the expanded set. // At this point, no pattern may contain "/" in it // so we're going to return a 2d array, where each entry is the full @@ -82620,14 +82645,17 @@ function braceExpand (pattern, options) { Minimatch.prototype.parse = parse var SUBPARSE = {} function parse (pattern, isSub) { - if (pattern.length > 1024 * 64) { - throw new TypeError('pattern is too long') - } + assertValidPattern(pattern) var options = this.options // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '**') { + if (!options.noglobstar) + return GLOBSTAR + else + pattern = '*' + } if (pattern === '') return '' var re = '' @@ -82683,10 +82711,12 @@ function parse (pattern, isSub) { } switch (c) { - case '/': + /* istanbul ignore next */ + case '/': { // completely not allowed, even escaped. // Should already be path-split by now. return false + } case '\\': clearStateChar() @@ -82805,25 +82835,23 @@ function parse (pattern, isSub) { // handle the case where we left a class open. // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i) - try { - RegExp('[' + cs + ']') - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE) - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' - hasMagic = hasMagic || sp[1] - inClass = false - continue - } + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i) + try { + RegExp('[' + cs + ']') + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE) + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' + hasMagic = hasMagic || sp[1] + inClass = false + continue } // finish up the class. @@ -82907,9 +82935,7 @@ function parse (pattern, isSub) { // something that could conceivably capture a dot var addPatternStart = false switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true + case '[': case '.': case '(': addPatternStart = true } // Hack to work around lack of negative lookbehind in JS @@ -82971,7 +82997,7 @@ function parse (pattern, isSub) { var flags = options.nocase ? 'i' : '' try { var regExp = new RegExp('^' + re + '$', flags) - } catch (er) { + } catch (er) /* istanbul ignore next - should be impossible */ { // If it was an invalid regular expression, then it can't match // anything. This trick looks for a character after the end of // the string, which is of course impossible, except in multi-line @@ -83029,7 +83055,7 @@ function makeRe () { try { this.regexp = new RegExp(re, flags) - } catch (ex) { + } catch (ex) /* istanbul ignore next - should be impossible */ { this.regexp = false } return this.regexp @@ -83047,8 +83073,8 @@ minimatch.match = function (list, pattern, options) { return list } -Minimatch.prototype.match = match -function match (f, partial) { +Minimatch.prototype.match = function match (f, partial) { + if (typeof partial === 'undefined') partial = this.partial this.debug('match', f, this.pattern) // short-circuit in the case of busted things. // comments, etc. @@ -83130,6 +83156,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // should be impossible. // some invalid regexp stuff in the set. + /* istanbul ignore if */ if (p === false) return false if (p === GLOBSTAR) { @@ -83203,6 +83230,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // no match was found. // However, in partial mode, we can't say this is necessarily over. // If there's more *pattern* left, then + /* istanbul ignore if */ if (partial) { // ran out of file this.debug('\n>>> no match, partial?', file, fr, pattern, pr) @@ -83216,11 +83244,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // patterns with magic have been turned into regexps. var hit if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase() - } else { - hit = f === p - } + hit = f === p this.debug('string match', p, f, hit) } else { hit = f.match(p) @@ -83251,16 +83275,16 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) { // this is ok if we're doing the match as part of // a glob fs traversal. return partial - } else if (pi === pl) { + } else /* istanbul ignore else */ if (pi === pl) { // ran out of pattern, still have file left. // this is only acceptable if we're on the very last // empty segment of a file with a trailing slash. // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') - return emptyFileEnd + return (fi === fl - 1) && (file[fi] === '') } // should be unreachable. + /* istanbul ignore next */ throw new Error('wtf?') } From 5e09f33af6ce1fae80c2eaa28d444516acbc7826 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Wed, 7 Dec 2022 08:54:15 +0100 Subject: [PATCH 25/49] add java-version-file input --- src/constants.ts | 1 + src/setup-java.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index ad8709e7a..e4c8ad14f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,6 @@ export const MACOS_JAVA_CONTENT_POSTFIX = 'Contents/Home'; export const INPUT_JAVA_VERSION = 'java-version'; +export const INPUT_JAVA_VERSION_FILE = 'java-version-file'; export const INPUT_ARCHITECTURE = 'architecture'; export const INPUT_JAVA_PACKAGE = 'java-package'; export const INPUT_DISTRIBUTION = 'distribution'; diff --git a/src/setup-java.ts b/src/setup-java.ts index a2e97ec33..0d00179d0 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -13,6 +13,7 @@ async function run() { try { const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION); const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); + const versionFile = core.getInput(constants.INPUT_JAVA_VERSION_FILE); const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); const jdkFile = core.getInput(constants.INPUT_JDK_FILE); @@ -26,11 +27,14 @@ async function run() { toolchainIds = []; } + if (!versions.length && !versionFile) { + throw new Error("Java-version or java-version-file input expected"); + } + if (!versions.length) { - core.debug('JAVA_VERSION input is empty, looking for .java-version file'); - const versionFileName = '.java-version'; + core.debug('Java-version input is empty, looking for java-version-file input'); const contents = fs - .readFileSync(versionFileName) + .readFileSync(versionFile) .toString() .trim(); const semverRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; From c91175d89e0871feb090a61fe04575852805c0b6 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Wed, 7 Dec 2022 08:59:32 +0100 Subject: [PATCH 26/49] docs changes --- README.md | 4 +++- docs/advanced-usage.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 38e2e1db9..436f80053 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ This action allows you to work with Java and Scala projects. ## Usage - - `java-version`: The Java version to set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `.java-version` file to be in the repository root. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file). + - `java-version`: The Java version to set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file). + + - `java-version-file`: The path to the `.java-version` file. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file). - `distribution`: _(required)_ Java [distribution](#supported-distributions). diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 88ecc0c4a..94fa95641 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -481,7 +481,7 @@ steps: ``` ## Java-version file -If the `java-version` input is not specified, the action will look for a `.java-version` file at the root of the repository. If the file is found, action will try to install the most suitable version. +If the `java-version-file` input is specified, the action will try to extract the version from the file and install the most suitable version. Action is able to recognize all variants of the version description according to [jenv](https://github.com/jenv/jenv). Valid entry options: ``` From e1d88bf0e5bf04b18daaebedcd678ac7c418a3a8 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Wed, 7 Dec 2022 09:07:21 +0100 Subject: [PATCH 27/49] e2e tests --- .github/workflows/e2e-versions.yml | 97 +++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 449cbe52a..7335ef3a3 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -254,4 +254,99 @@ jobs: run: bash __tests__/verify-java.sh "${{ matrix.version }}" "${{ steps.setup-java.outputs.path }}" shell: bash - # Only Microsoft provides AArch64. However, GitHub-hosted runners do not support this architecture. \ No newline at end of file + setup-java-version-both-version-inputs-presents: + name: ${{ matrix.distribution }} version (should be from input) - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft', 'corretto' ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Create .java-version file + shell: bash + run: echo "8" > .java-version + - name: setup-java + uses: ./ + id: setup-java + with: + distribution: ${{ matrix.distribution }} + java-version: 11 + java-version-file: '.java-version' + - name: Verify Java + run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" + shell: bash + + setup-java-version-from-file-major-notation: + name: ${{ matrix.distribution }} version from file X - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft', 'corretto' ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Create .java-version file + shell: bash + run: echo "11" > .java-version + - name: setup-java + uses: ./ + id: setup-java + with: + distribution: ${{ matrix.distribution }} + java-version-file: '.java-version' + - name: Verify Java + run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}" + shell: bash + + setup-java-version-from-file-major-minor-patch-notation: + name: ${{ matrix.distribution }} version from file X.Y.Z - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft', ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Create .java-version file + shell: bash + run: echo "11.0.2" > .java-version + - name: setup-java + uses: ./ + id: setup-java + with: + distribution: ${{ matrix.distribution }} + java-version-file: '.java-version' + - name: Verify Java + run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}" + shell: bash + + setup-java-version-from-file-major-minor-patch-with-dist: + name: ${{ matrix.distribution }} version from file 'openjdk64-11.0.2' - ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft', ] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Create .java-version file + shell: bash + run: echo "openjdk64-11.0.2" > .java-version + - name: setup-java + uses: ./ + id: setup-java + with: + distribution: ${{ matrix.distribution }} + java-version-file: '.java-version' + - name: Verify Java + run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}" + shell: bash \ No newline at end of file From 1c29312d99162ea0ef3f0c9ec9b2831c6c96a68e Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Wed, 7 Dec 2022 09:23:19 +0100 Subject: [PATCH 28/49] fix tests --- .github/workflows/e2e-versions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 7335ef3a3..bcdd09c68 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -310,7 +310,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft', ] + distribution: [ 'adopt', 'adopt-openj9', 'zulu', 'liberica', ] steps: - name: Checkout uses: actions/checkout@v3 @@ -334,7 +334,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft', ] + distribution: ['adopt', 'adopt-openj9', 'zulu', 'liberica', ] steps: - name: Checkout uses: actions/checkout@v3 From c69760f666328e5e8024adb2f3cea03b6608edb0 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Wed, 7 Dec 2022 09:23:48 +0100 Subject: [PATCH 29/49] add input in action --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index f67c642d3..2c0f7aba3 100644 --- a/action.yml +++ b/action.yml @@ -5,7 +5,8 @@ author: 'GitHub' inputs: java-version: description: 'The Java version to set up. Takes a whole or semver Java version. See examples of supported syntax in README file' - required: true + java-version-file: + description: 'The path to the `.java-version` file. See examples of supported syntax in README file' distribution: description: 'Java distribution. See the list of supported distributions in README file' required: true From 1e74ea6a75e84b4871a1d87df152bb2222477f38 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Wed, 7 Dec 2022 09:25:35 +0100 Subject: [PATCH 30/49] code format --- src/setup-java.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup-java.ts b/src/setup-java.ts index 0d00179d0..9e4346ca4 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -42,7 +42,7 @@ async function run() { ? (contents.match(semverRegExp)?.groups?.version as string) : ''; let installed = false; - while (!installed && version != '') { + while (!installed && version) { try { core.debug(`Trying to install version ${version}`); await installVersion(version); From 5a85bfb40dc781ada7c5c797b25248b2cb88126d Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Wed, 7 Dec 2022 09:26:15 +0100 Subject: [PATCH 31/49] build --- dist/cleanup/index.js | 3 ++- dist/setup/index.js | 14 +++++++++----- src/setup-java.ts | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 1a34693d5..08037ec42 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -68480,9 +68480,10 @@ else { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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_FILE = 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_JAVA_VERSION_FILE = 'java-version-file'; exports.INPUT_ARCHITECTURE = 'architecture'; exports.INPUT_JAVA_PACKAGE = 'java-package'; exports.INPUT_DISTRIBUTION = 'distribution'; diff --git a/dist/setup/index.js b/dist/setup/index.js index c665957b9..e4e8fa2dd 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -103582,9 +103582,10 @@ function isProbablyGradleDaemonProblem(packageManager, error) { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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_FILE = 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_JAVA_VERSION_FILE = 'java-version-file'; exports.INPUT_ARCHITECTURE = 'architecture'; exports.INPUT_JAVA_PACKAGE = 'java-package'; exports.INPUT_DISTRIBUTION = 'distribution'; @@ -105198,6 +105199,7 @@ function run() { try { const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION); const distributionName = core.getInput(constants.INPUT_DISTRIBUTION, { required: true }); + const versionFile = core.getInput(constants.INPUT_JAVA_VERSION_FILE); const architecture = core.getInput(constants.INPUT_ARCHITECTURE); const packageType = core.getInput(constants.INPUT_JAVA_PACKAGE); const jdkFile = core.getInput(constants.INPUT_JDK_FILE); @@ -105208,11 +105210,13 @@ function run() { if (versions.length !== toolchainIds.length) { toolchainIds = []; } + if (!versions.length && !versionFile) { + throw new Error('Java-version or java-version-file input expected'); + } if (!versions.length) { - core.debug('JAVA_VERSION input is empty, looking for .java-version file'); - const versionFileName = '.java-version'; + core.debug('Java-version input is empty, looking for java-version-file input'); const contents = fs_1.default - .readFileSync(versionFileName) + .readFileSync(versionFile) .toString() .trim(); const semverRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; @@ -105220,7 +105224,7 @@ function run() { ? (_d = (_c = contents.match(semverRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version : ''; let installed = false; - while (!installed && version != '') { + while (!installed && version) { try { core.debug(`Trying to install version ${version}`); yield installVersion(version); diff --git a/src/setup-java.ts b/src/setup-java.ts index 9e4346ca4..13ac29110 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -28,7 +28,7 @@ async function run() { } if (!versions.length && !versionFile) { - throw new Error("Java-version or java-version-file input expected"); + throw new Error('Java-version or java-version-file input expected'); } if (!versions.length) { From 43f5042dba4d1b6db7ac1e8d83f0307495ab6fca Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 10:40:03 +0100 Subject: [PATCH 32/49] change version match logic --- src/constants.ts | 2 + src/setup-java.ts | 150 +++++++++++++++++++++++++++++----------------- 2 files changed, 98 insertions(+), 54 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index e4c8ad14f..48b085b1e 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -27,3 +27,5 @@ export const MVN_SETTINGS_FILE = 'settings.xml'; export const MVN_TOOLCHAINS_FILE = 'toolchains.xml'; export const INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; export const INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; + +export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'] diff --git a/src/setup-java.ts b/src/setup-java.ts index 13ac29110..b695295c7 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -8,6 +8,7 @@ import { restore } from './cache'; import * as path from 'path'; import { getJavaDistribution } from './distributions/distribution-factory'; import { JavaInstallerOptions } from './distributions/base-models'; +import * as semver from 'semver'; async function run() { try { @@ -31,34 +32,33 @@ async function run() { throw new Error('Java-version or java-version-file input expected'); } + const installerInputsOptions: installerInputsOptions = { + architecture, + packageType, + checkLatest, + distributionName, + jdkFile, + toolchainIds + }; + if (!versions.length) { core.debug('Java-version input is empty, looking for java-version-file input'); - const contents = fs + const content = fs .readFileSync(versionFile) .toString() .trim(); - const semverRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; - let version = contents.match(semverRegExp)?.groups?.version - ? (contents.match(semverRegExp)?.groups?.version as string) - : ''; - let installed = false; - while (!installed && version) { - try { - core.debug(`Trying to install version ${version}`); - await installVersion(version); - installed = true; - } catch (error) { - core.debug(`${error.toString()}`); - version = getHigherVersion(version); - } - } - if (!installed) { - throw new Error("Сan't install appropriate version from .java-version file"); + + const version = getVersionFromFileContent(content, distributionName) + + if (!version) { + throw new Error(`No supported version was found in file ${versionFile}`); } + + await installVersion(version as string, installerInputsOptions); } for (const [index, version] of versions.entries()) { - await installVersion(version, index); + await installVersion(version, installerInputsOptions, index); } core.endGroup(); const matchersPath = path.join(__dirname, '..', '..', '.github'); @@ -68,44 +68,86 @@ async function run() { if (cache && isCacheFeatureAvailable()) { await restore(cache); } - - async function installVersion(version: string, toolchainId = 0) { - const installerOptions: JavaInstallerOptions = { - architecture, - packageType, - version, - checkLatest - }; - - const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile); - if (!distribution) { - throw new Error(`No supported distribution was found for input ${distributionName}`); - } - - const result = await distribution.setupJava(); - await toolchains.configureToolchains( - version, - distributionName, - result.path, - toolchainIds[toolchainId] - ); - - core.info(''); - core.info('Java configuration:'); - core.info(` Distribution: ${distributionName}`); - core.info(` Version: ${result.version}`); - core.info(` Path: ${result.path}`); - core.info(''); - } - - function getHigherVersion(version: string) { - return version.split('-')[0] === version - ? version.substring(0, version.lastIndexOf('.')) - : version.split('-')[0]; - } } catch (error) { core.setFailed(error.message); } } run(); + +async function installVersion(version: string, options: installerInputsOptions, toolchainId = 0) { + const { + distributionName, + jdkFile, + architecture, + packageType, + checkLatest, + toolchainIds + } = options; + + const installerOptions: JavaInstallerOptions = { + architecture, + packageType, + checkLatest, + version + }; + + const distribution = getJavaDistribution(distributionName, installerOptions, jdkFile); + if (!distribution) { + throw new Error(`No supported distribution was found for input ${distributionName}`); + } + + const result = await distribution.setupJava(); + await toolchains.configureToolchains( + version, + distributionName, + result.path, + toolchainIds[toolchainId] + ); + + core.info(''); + core.info('Java configuration:'); + core.info(` Distribution: ${distributionName}`); + core.info(` Version: ${result.version}`); + core.info(` Path: ${result.path}`); + core.info(''); +} + +interface installerInputsOptions { + architecture: string; + packageType: string; + checkLatest: boolean; + distributionName: string; + jdkFile: string; + toolchainIds: Array; +} + +function getVersionFromFileContent(content: string, distributionName: string): string | null { + const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; + const fileContent = content.match(javaVersionRegExp)?.groups?.version + ? (content.match(javaVersionRegExp)?.groups?.version as string) + : ''; + if (!fileContent) { + return null + } + const tentativeVersion = avoidOldNotation(fileContent); + + let version = semver.validRange(tentativeVersion) + ? tentativeVersion + : semver.coerce(tentativeVersion); + + if (!version) { + return null + } + + if (constants.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { + version = semver.major(version).toString(); + } + + return version.toString(); +} + +// By convention, action expects version 8 in the format `8.*` instead of `1.8` +function avoidOldNotation(content: string): string { + return content.substring(0, 2) === '1.' ? content.substring(2) : content; +} \ No newline at end of file From d1dae85a6e82b60080f272b0c7e22a65a739c270 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 10:41:49 +0100 Subject: [PATCH 33/49] upd docs --- README.md | 2 +- docs/advanced-usage.md | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 436f80053..8e11502d5 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This action allows you to work with Java and Scala projects. ## Usage - - `java-version`: The Java version to set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file). + - `java-version`: The Java version to set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified. - `java-version-file`: The path to the `.java-version` file. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file). diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 94fa95641..481fc53ec 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -481,18 +481,13 @@ steps: ``` ## Java-version file -If the `java-version-file` input is specified, the action will try to extract the version from the file and install the most suitable version. +If the `java-version-file` input is specified, the action will try to extract the version from the file and install it. Action is able to recognize all variants of the version description according to [jenv](https://github.com/jenv/jenv). Valid entry options: ``` major versions: 8, 11, 16, 17 -more specific versions: 17.0, 11.0, 11.0.4, 8.0.232, 8.0.282+8 +more specific versions: 1.8.0.2, 17.0, 11.0, 11.0.4, 8.0.232, 8.0.282+8 early access (EA) versions: 15-ea, 15.0.0-ea, 15.0.0-ea.2, 15.0.0+2-ea versions with specified distribution: openjdk64-11.0.2 ``` If the file contains multiple versions, only the first one will be recognized. -If action was able to recognize a version in the file that matches the pattern, then attempts will begin to install the most appropriate version. The logic for installing the appropriate version: -action will try to install the specified version. If this version is not available for a given distribution, action will try to install a less specific version according to the algorithm. Attempts will continue until a suitable version is installed or the attempt to install a version specifying only with major tag fails. -Algorithm for selecting the appropriate version: -If a particular patch specification was present in the version (for example, the early access postfix `-ea*` in `major.minor.patch-ea*` notation), action will try to install the version without it in the format `major.minor.patch`. Next, if the install fails again, action will try to install the `major.minor` version. On failure, action will try to install the `major` version and fail on failure. -If the version was originally specified not in full format, then the process will be similar, but it will not start from the first step. \ No newline at end of file From 0143667d3dd927c15b4671505856cec6ec574c55 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 10:44:33 +0100 Subject: [PATCH 34/49] update tests --- .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 bcdd09c68..a1c6540cc 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -349,4 +349,4 @@ jobs: java-version-file: '.java-version' - name: Verify Java run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}" - shell: bash \ No newline at end of file + shell: bash From f68f88a1bc071459162bb0280eaab9f52b9211a2 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 10:46:41 +0100 Subject: [PATCH 35/49] format & build --- dist/cleanup/index.js | 3 +- dist/setup/index.js | 114 ++++++++++++++++++++++++------------------ src/constants.ts | 2 +- src/setup-java.ts | 12 ++--- 4 files changed, 74 insertions(+), 57 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 08037ec42..b34d7cdc0 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -68480,7 +68480,7 @@ else { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; +exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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_FILE = 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_JAVA_VERSION_FILE = 'java-version-file'; @@ -68506,6 +68506,7 @@ exports.MVN_SETTINGS_FILE = 'settings.xml'; exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; +exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index e4e8fa2dd..66300feb0 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -103582,7 +103582,7 @@ function isProbablyGradleDaemonProblem(packageManager, error) { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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_FILE = exports.INPUT_JAVA_VERSION = exports.MACOS_JAVA_CONTENT_POSTFIX = void 0; +exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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_FILE = 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_JAVA_VERSION_FILE = 'java-version-file'; @@ -103608,6 +103608,7 @@ exports.MVN_SETTINGS_FILE = 'settings.xml'; exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; +exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; /***/ }), @@ -105193,8 +105194,8 @@ const constants = __importStar(__nccwpck_require__(9042)); const cache_1 = __nccwpck_require__(4810); const path = __importStar(__nccwpck_require__(1017)); const distribution_factory_1 = __nccwpck_require__(924); +const semver = __importStar(__nccwpck_require__(1383)); function run() { - var _a, _b, _c, _d; return __awaiter(this, void 0, void 0, function* () { try { const versions = core.getMultilineInput(constants.INPUT_JAVA_VERSION); @@ -105213,34 +105214,28 @@ function run() { if (!versions.length && !versionFile) { throw new Error('Java-version or java-version-file input expected'); } + const installerInputsOptions = { + architecture, + packageType, + checkLatest, + distributionName, + jdkFile, + toolchainIds + }; if (!versions.length) { core.debug('Java-version input is empty, looking for java-version-file input'); - const contents = fs_1.default + const content = fs_1.default .readFileSync(versionFile) .toString() .trim(); - const semverRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; - let version = ((_b = (_a = contents.match(semverRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) - ? (_d = (_c = contents.match(semverRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version - : ''; - let installed = false; - while (!installed && version) { - try { - core.debug(`Trying to install version ${version}`); - yield installVersion(version); - installed = true; - } - catch (error) { - core.debug(`${error.toString()}`); - version = getHigherVersion(version); - } - } - if (!installed) { - throw new Error("Сan't install appropriate version from .java-version file"); + const version = getVersionFromFileContent(content, distributionName); + if (!version) { + throw new Error(`No supported version was found in file ${versionFile}`); } + yield installVersion(version, installerInputsOptions); } for (const [index, version] of versions.entries()) { - yield installVersion(version, index); + yield installVersion(version, installerInputsOptions, index); } core.endGroup(); const matchersPath = path.join(__dirname, '..', '..', '.github'); @@ -105249,33 +105244,6 @@ function run() { if (cache && util_1.isCacheFeatureAvailable()) { yield cache_1.restore(cache); } - function installVersion(version, toolchainId = 0) { - return __awaiter(this, void 0, void 0, function* () { - const installerOptions = { - architecture, - packageType, - version, - checkLatest - }; - const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile); - if (!distribution) { - throw new Error(`No supported distribution was found for input ${distributionName}`); - } - const result = yield distribution.setupJava(); - yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[toolchainId]); - core.info(''); - core.info('Java configuration:'); - core.info(` Distribution: ${distributionName}`); - core.info(` Version: ${result.version}`); - core.info(` Path: ${result.path}`); - core.info(''); - }); - } - function getHigherVersion(version) { - return version.split('-')[0] === version - ? version.substring(0, version.lastIndexOf('.')) - : version.split('-')[0]; - } } catch (error) { core.setFailed(error.message); @@ -105283,6 +105251,54 @@ function run() { }); } run(); +function installVersion(version, options, toolchainId = 0) { + return __awaiter(this, void 0, void 0, function* () { + const { distributionName, jdkFile, architecture, packageType, checkLatest, toolchainIds } = options; + const installerOptions = { + architecture, + packageType, + checkLatest, + version + }; + const distribution = distribution_factory_1.getJavaDistribution(distributionName, installerOptions, jdkFile); + if (!distribution) { + throw new Error(`No supported distribution was found for input ${distributionName}`); + } + const result = yield distribution.setupJava(); + yield toolchains.configureToolchains(version, distributionName, result.path, toolchainIds[toolchainId]); + core.info(''); + core.info('Java configuration:'); + core.info(` Distribution: ${distributionName}`); + core.info(` Version: ${result.version}`); + core.info(` Path: ${result.path}`); + core.info(''); + }); +} +function getVersionFromFileContent(content, distributionName) { + var _a, _b, _c, _d; + const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; + const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) + ? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version + : ''; + if (!fileContent) { + return null; + } + const tentativeVersion = avoidOldNotation(fileContent); + let version = semver.validRange(tentativeVersion) + ? tentativeVersion + : semver.coerce(tentativeVersion); + if (!version) { + return null; + } + if (constants.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { + version = semver.major(version).toString(); + } + return version.toString(); +} +// By convention, action expects version 8 in the format `8.*` instead of `1.8` +function avoidOldNotation(content) { + return content.substring(0, 2) === '1.' ? content.substring(2) : content; +} /***/ }), diff --git a/src/constants.ts b/src/constants.ts index 48b085b1e..9aa213fa9 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -28,4 +28,4 @@ export const MVN_TOOLCHAINS_FILE = 'toolchains.xml'; export const INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; export const INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; -export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'] +export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; diff --git a/src/setup-java.ts b/src/setup-java.ts index b695295c7..345be60ae 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -47,13 +47,13 @@ async function run() { .readFileSync(versionFile) .toString() .trim(); - - const version = getVersionFromFileContent(content, distributionName) + + const version = getVersionFromFileContent(content, distributionName); if (!version) { throw new Error(`No supported version was found in file ${versionFile}`); } - + await installVersion(version as string, installerInputsOptions); } @@ -128,7 +128,7 @@ function getVersionFromFileContent(content: string, distributionName: string): s ? (content.match(javaVersionRegExp)?.groups?.version as string) : ''; if (!fileContent) { - return null + return null; } const tentativeVersion = avoidOldNotation(fileContent); @@ -137,7 +137,7 @@ function getVersionFromFileContent(content: string, distributionName: string): s : semver.coerce(tentativeVersion); if (!version) { - return null + return null; } if (constants.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { @@ -150,4 +150,4 @@ function getVersionFromFileContent(content: string, distributionName: string): s // By convention, action expects version 8 in the format `8.*` instead of `1.8` function avoidOldNotation(content: string): string { return content.substring(0, 2) === '1.' ? content.substring(2) : content; -} \ No newline at end of file +} From 95a0d310904058b754e46acb1af3e74ad7d335a4 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 11:09:32 +0100 Subject: [PATCH 36/49] remove correto --- .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 a1c6540cc..24c21e171 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -286,7 +286,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft', 'corretto' ] + distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft' ] steps: - name: Checkout uses: actions/checkout@v3 From 78a90d38d312cf5eaafc3aa503ff65ae686847c1 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 11:58:25 +0100 Subject: [PATCH 37/49] remove lib from tests --- .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 24c21e171..31696e591 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -310,7 +310,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: [ 'adopt', 'adopt-openj9', 'zulu', 'liberica', ] + distribution: [ 'adopt', 'adopt-openj9', 'zulu' ] steps: - name: Checkout uses: actions/checkout@v3 From 26b4abc15978879cdecbd97686be40d3217c9a82 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 12:30:33 +0100 Subject: [PATCH 38/49] smaller tests matrix --- .github/workflows/e2e-versions.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 31696e591..9e1cbd6c5 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -261,7 +261,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft', 'corretto' ] + distribution: ['temurin', 'zulu', 'microsoft' ] steps: - name: Checkout uses: actions/checkout@v3 @@ -286,7 +286,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['temurin', 'adopt', 'adopt-openj9', 'zulu', 'liberica', 'microsoft' ] + distribution: ['temurin', 'zulu', 'liberica', 'microsoft' ] steps: - name: Checkout uses: actions/checkout@v3 @@ -334,7 +334,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['adopt', 'adopt-openj9', 'zulu', 'liberica', ] + distribution: ['adopt', 'zulu', 'liberica' ] steps: - name: Checkout uses: actions/checkout@v3 From d28f3e22c6078e2f2037b9eee53c56233e009179 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 12:31:13 +0100 Subject: [PATCH 39/49] fix review points --- dist/setup/index.js | 2 +- src/setup-java.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 66300feb0..6366f1dec 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105297,7 +105297,7 @@ function getVersionFromFileContent(content, distributionName) { } // By convention, action expects version 8 in the format `8.*` instead of `1.8` function avoidOldNotation(content) { - return content.substring(0, 2) === '1.' ? content.substring(2) : content; + return content.startsWith('1.') ? content.substring(2) : content; } diff --git a/src/setup-java.ts b/src/setup-java.ts index 345be60ae..107e1cb2e 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -149,5 +149,5 @@ function getVersionFromFileContent(content: string, distributionName: string): s // By convention, action expects version 8 in the format `8.*` instead of `1.8` function avoidOldNotation(content: string): string { - return content.substring(0, 2) === '1.' ? content.substring(2) : content; + return content.startsWith('1.') ? content.substring(2) : content; } From c13e4b13ba2f7fc864ea16a0d4afd253052302eb Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 15:28:21 +0100 Subject: [PATCH 40/49] fix review points --- src/setup-java.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/setup-java.ts b/src/setup-java.ts index 107e1cb2e..7978f22bd 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -29,7 +29,7 @@ async function run() { } if (!versions.length && !versionFile) { - throw new Error('Java-version or java-version-file input expected'); + throw new Error('java-version or java-version-file input expected'); } const installerInputsOptions: installerInputsOptions = { @@ -42,7 +42,7 @@ async function run() { }; if (!versions.length) { - core.debug('Java-version input is empty, looking for java-version-file input'); + core.debug('java-version input is empty, looking for java-version-file input'); const content = fs .readFileSync(versionFile) .toString() From 291b946ea5d2d6858065257aed50d8c574f196f1 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 15:32:14 +0100 Subject: [PATCH 41/49] fix review points --- src/setup-java.ts | 32 +------------------------------- src/util.ts | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/setup-java.ts b/src/setup-java.ts index 7978f22bd..916d184b6 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -1,14 +1,13 @@ import fs from 'fs'; import * as core from '@actions/core'; import * as auth from './auth'; -import { getBooleanInput, isCacheFeatureAvailable } from './util'; +import { getBooleanInput, isCacheFeatureAvailable, getVersionFromFileContent, avoidOldNotation } from './util'; import * as toolchains from './toolchains'; import * as constants from './constants'; import { restore } from './cache'; import * as path from 'path'; import { getJavaDistribution } from './distributions/distribution-factory'; import { JavaInstallerOptions } from './distributions/base-models'; -import * as semver from 'semver'; async function run() { try { @@ -122,32 +121,3 @@ interface installerInputsOptions { toolchainIds: Array; } -function getVersionFromFileContent(content: string, distributionName: string): string | null { - const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; - const fileContent = content.match(javaVersionRegExp)?.groups?.version - ? (content.match(javaVersionRegExp)?.groups?.version as string) - : ''; - if (!fileContent) { - return null; - } - const tentativeVersion = avoidOldNotation(fileContent); - - let version = semver.validRange(tentativeVersion) - ? tentativeVersion - : semver.coerce(tentativeVersion); - - if (!version) { - return null; - } - - if (constants.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { - version = semver.major(version).toString(); - } - - return version.toString(); -} - -// By convention, action expects version 8 in the format `8.*` instead of `1.8` -function avoidOldNotation(content: string): string { - return content.startsWith('1.') ? content.substring(2) : content; -} diff --git a/src/util.ts b/src/util.ts index 10f18c5fe..4ad22a1f9 100644 --- a/src/util.ts +++ b/src/util.ts @@ -6,7 +6,7 @@ import * as cache from '@actions/cache'; import * as core from '@actions/core'; import * as tc from '@actions/tool-cache'; -import { INPUT_JOB_STATUS } from './constants'; +import { INPUT_JOB_STATUS, DISTRIBUTIONS_ONLY_MAJOR_VERSION } from './constants'; export function getTempDir() { let tempDirectory = process.env['RUNNER_TEMP'] || os.tmpdir(); @@ -99,3 +99,34 @@ export function isCacheFeatureAvailable(): boolean { return true; } + + +export function getVersionFromFileContent(content: string, distributionName: string): string | null { + const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; + const fileContent = content.match(javaVersionRegExp)?.groups?.version + ? (content.match(javaVersionRegExp)?.groups?.version as string) + : ''; + if (!fileContent) { + return null; + } + const tentativeVersion = avoidOldNotation(fileContent); + + let version = semver.validRange(tentativeVersion) + ? tentativeVersion + : semver.coerce(tentativeVersion); + + if (!version) { + return null; + } + + if (DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { + version = semver.major(version).toString(); + } + + return version.toString(); +} + +// By convention, action expects version 8 in the format `8.*` instead of `1.8` +export function avoidOldNotation(content: string): string { + return content.startsWith('1.') ? content.substring(2) : content; +} From a2ae8283cbbdaf85da7f99b106f4791e667b2de1 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 15:32:34 +0100 Subject: [PATCH 42/49] build --- dist/cleanup/index.js | 29 +++++++++++++++++++- dist/setup/index.js | 61 ++++++++++++++++++++++--------------------- 2 files changed, 59 insertions(+), 31 deletions(-) diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index b34d7cdc0..4c9a3602d 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -68624,7 +68624,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +exports.avoidOldNotation = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; const os_1 = __importDefault(__nccwpck_require__(2037)); const path_1 = __importDefault(__nccwpck_require__(1017)); const fs = __importStar(__nccwpck_require__(7147)); @@ -68720,6 +68720,33 @@ function isCacheFeatureAvailable() { return true; } exports.isCacheFeatureAvailable = isCacheFeatureAvailable; +function getVersionFromFileContent(content, distributionName) { + var _a, _b, _c, _d; + const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; + const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) + ? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version + : ''; + if (!fileContent) { + return null; + } + const tentativeVersion = avoidOldNotation(fileContent); + let version = semver.validRange(tentativeVersion) + ? tentativeVersion + : semver.coerce(tentativeVersion); + if (!version) { + return null; + } + if (constants_1.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { + version = semver.major(version).toString(); + } + return version.toString(); +} +exports.getVersionFromFileContent = getVersionFromFileContent; +// By convention, action expects version 8 in the format `8.*` instead of `1.8` +function avoidOldNotation(content) { + return content.startsWith('1.') ? content.substring(2) : content; +} +exports.avoidOldNotation = avoidOldNotation; /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index 6366f1dec..33f8b90f1 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -105194,7 +105194,6 @@ const constants = __importStar(__nccwpck_require__(9042)); const cache_1 = __nccwpck_require__(4810); const path = __importStar(__nccwpck_require__(1017)); const distribution_factory_1 = __nccwpck_require__(924); -const semver = __importStar(__nccwpck_require__(1383)); function run() { return __awaiter(this, void 0, void 0, function* () { try { @@ -105212,7 +105211,7 @@ function run() { toolchainIds = []; } if (!versions.length && !versionFile) { - throw new Error('Java-version or java-version-file input expected'); + throw new Error('java-version or java-version-file input expected'); } const installerInputsOptions = { architecture, @@ -105223,12 +105222,12 @@ function run() { toolchainIds }; if (!versions.length) { - core.debug('Java-version input is empty, looking for java-version-file input'); + core.debug('java-version input is empty, looking for java-version-file input'); const content = fs_1.default .readFileSync(versionFile) .toString() .trim(); - const version = getVersionFromFileContent(content, distributionName); + const version = util_1.getVersionFromFileContent(content, distributionName); if (!version) { throw new Error(`No supported version was found in file ${versionFile}`); } @@ -105274,31 +105273,6 @@ function installVersion(version, options, toolchainId = 0) { core.info(''); }); } -function getVersionFromFileContent(content, distributionName) { - var _a, _b, _c, _d; - const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; - const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) - ? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version - : ''; - if (!fileContent) { - return null; - } - const tentativeVersion = avoidOldNotation(fileContent); - let version = semver.validRange(tentativeVersion) - ? tentativeVersion - : semver.coerce(tentativeVersion); - if (!version) { - return null; - } - if (constants.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { - version = semver.major(version).toString(); - } - return version.toString(); -} -// By convention, action expects version 8 in the format `8.*` instead of `1.8` -function avoidOldNotation(content) { - return content.startsWith('1.') ? content.substring(2) : content; -} /***/ }), @@ -105500,7 +105474,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +exports.avoidOldNotation = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; const os_1 = __importDefault(__nccwpck_require__(2037)); const path_1 = __importDefault(__nccwpck_require__(1017)); const fs = __importStar(__nccwpck_require__(7147)); @@ -105596,6 +105570,33 @@ function isCacheFeatureAvailable() { return true; } exports.isCacheFeatureAvailable = isCacheFeatureAvailable; +function getVersionFromFileContent(content, distributionName) { + var _a, _b, _c, _d; + const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; + const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) + ? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version + : ''; + if (!fileContent) { + return null; + } + const tentativeVersion = avoidOldNotation(fileContent); + let version = semver.validRange(tentativeVersion) + ? tentativeVersion + : semver.coerce(tentativeVersion); + if (!version) { + return null; + } + if (constants_1.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { + version = semver.major(version).toString(); + } + return version.toString(); +} +exports.getVersionFromFileContent = getVersionFromFileContent; +// By convention, action expects version 8 in the format `8.*` instead of `1.8` +function avoidOldNotation(content) { + return content.startsWith('1.') ? content.substring(2) : content; +} +exports.avoidOldNotation = avoidOldNotation; /***/ }), From 10d2aa6bfd9e0c53c66ac2ab5177c9cb727d3f38 Mon Sep 17 00:00:00 2001 From: Evgenii Korolevskii Date: Thu, 8 Dec 2022 15:35:32 +0100 Subject: [PATCH 43/49] rebuild --- src/setup-java.ts | 8 ++++++-- src/util.ts | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/setup-java.ts b/src/setup-java.ts index 916d184b6..a253b13e7 100644 --- a/src/setup-java.ts +++ b/src/setup-java.ts @@ -1,7 +1,12 @@ import fs from 'fs'; import * as core from '@actions/core'; import * as auth from './auth'; -import { getBooleanInput, isCacheFeatureAvailable, getVersionFromFileContent, avoidOldNotation } from './util'; +import { + getBooleanInput, + isCacheFeatureAvailable, + getVersionFromFileContent, + avoidOldNotation +} from './util'; import * as toolchains from './toolchains'; import * as constants from './constants'; import { restore } from './cache'; @@ -120,4 +125,3 @@ interface installerInputsOptions { jdkFile: string; toolchainIds: Array; } - diff --git a/src/util.ts b/src/util.ts index 4ad22a1f9..9303e7f40 100644 --- a/src/util.ts +++ b/src/util.ts @@ -100,8 +100,10 @@ export function isCacheFeatureAvailable(): boolean { return true; } - -export function getVersionFromFileContent(content: string, distributionName: string): string | null { +export function getVersionFromFileContent( + content: string, + distributionName: string +): string | null { const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; const fileContent = content.match(javaVersionRegExp)?.groups?.version ? (content.match(javaVersionRegExp)?.groups?.version as string) From a7975de1a7b11aed3712a6b0075398db8480bcad Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Fri, 9 Dec 2022 12:29:13 +0100 Subject: [PATCH 44/49] Add fix for major coretto version and ea. (#1) * Fix typo in README.md (#419) `diractory` -> `directory` * Revert "Add support for Oracle JDK (#401)" (#421) This reverts commit 6cdf39a6b6d2b0dd01e76d547cb9d448ccdd4f7c. Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com> * adding check for prerelease * add debug lines * add minor fix * expand e2e tests with corretto Co-authored-by: Ashley <73482956+ascopes@users.noreply.github.com> Co-authored-by: Brian Cristante <33549821+brcrista@users.noreply.github.com> --- .github/workflows/e2e-versions.yml | 18 +- README.md | 3 +- .../distributors/oracle-installer.test.ts | 97 - __tests__/verify-java.sh | 2 +- dist/cleanup/index.js | 1055 +- dist/setup/index.js | 25815 ++++++++-------- docs/advanced-usage.md | 14 - src/distributions/distribution-factory.ts | 6 +- src/distributions/oracle/installer.ts | 103 - src/distributions/oracle/models.ts | 1 - src/setup-java.ts | 10 +- src/util.ts | 15 +- 12 files changed, 13393 insertions(+), 13746 deletions(-) delete mode 100644 __tests__/distributors/oracle-installer.test.ts delete mode 100644 src/distributions/oracle/installer.ts delete mode 100644 src/distributions/oracle/models.ts diff --git a/.github/workflows/e2e-versions.yml b/.github/workflows/e2e-versions.yml index 9e1cbd6c5..efc4e7408 100644 --- a/.github/workflows/e2e-versions.yml +++ b/.github/workflows/e2e-versions.yml @@ -25,16 +25,6 @@ jobs: exclude: - distribution: microsoft version: 8 - include: - - distribution: oracle - os: macos-latest - version: 17 - - distribution: oracle - os: windows-latest - version: 19 - - distribution: oracle - os: ubuntu-latest - version: 19 steps: - name: Checkout uses: actions/checkout@v3 @@ -61,10 +51,6 @@ jobs: - '11.0' - '8.0.302' - '16.0.2+7' - include: - - distribution: oracle - os: ubuntu-latest - version: '19.0.1' steps: - name: Checkout uses: actions/checkout@v3 @@ -261,7 +247,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['temurin', 'zulu', 'microsoft' ] + distribution: ['temurin', 'microsoft', 'corretto' ] steps: - name: Checkout uses: actions/checkout@v3 @@ -286,7 +272,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - distribution: ['temurin', 'zulu', 'liberica', 'microsoft' ] + distribution: ['temurin', 'zulu', 'liberica', 'microsoft', 'corretto' ] steps: - name: Checkout uses: actions/checkout@v3 diff --git a/README.md b/README.md index 8e11502d5..cde2cd858 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ This action allows you to work with Java and Scala projects. - `server-password`: Environment variable name for password or token for authentication to the Apache Maven repository. Default is GITHUB_TOKEN. - - `settings-path`: Maven related setting to point to the diractory where the settings.xml file will be written. Default is ~/.m2. + - `settings-path`: Maven related setting to point to the directory where the settings.xml file will be written. Default is ~/.m2. - `gpg-private-key`: GPG private key to import. Default is empty string.' @@ -101,7 +101,6 @@ Currently, the following distributions are supported: | `liberica` | Liberica JDK | [Link](https://bell-sw.com/) | [Link](https://bell-sw.com/liberica_eula/) | | `microsoft` | Microsoft Build of OpenJDK | [Link](https://www.microsoft.com/openjdk) | [Link](https://docs.microsoft.com/java/openjdk/faq) | `corretto` | Amazon Corretto Build of OpenJDK | [Link](https://aws.amazon.com/corretto/) | [Link](https://aws.amazon.com/corretto/faqs/) -| `oracle` | Oracle JDK | [Link](https://www.oracle.com/java/technologies/downloads/) | [Link](https://java.com/freeuselicense) **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. diff --git a/__tests__/distributors/oracle-installer.test.ts b/__tests__/distributors/oracle-installer.test.ts deleted file mode 100644 index 86cba9203..000000000 --- a/__tests__/distributors/oracle-installer.test.ts +++ /dev/null @@ -1,97 +0,0 @@ -import { OracleDistribution } from '../../src/distributions/oracle/installer'; -import os from 'os'; -import * as core from '@actions/core'; -import { getDownloadArchiveExtension } from '../../src/util'; - -describe('findPackageForDownload', () => { - let distribution: OracleDistribution; - let spyDebug: jest.SpyInstance; - - beforeEach(() => { - distribution = new OracleDistribution({ - version: '', - architecture: 'x64', - packageType: 'jdk', - checkLatest: false - }); - - spyDebug = jest.spyOn(core, 'debug'); - spyDebug.mockImplementation(() => {}); - }); - - it.each([ - [ - '19', - '19', - 'https://download.oracle.com/java/19/latest/jdk-19_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' - ], - [ - '19.0.1', - '19.0.1', - 'https://download.oracle.com/java/19/archive/jdk-19.0.1_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' - ], - [ - '18.0.2.1', - '18.0.2.1', - 'https://download.oracle.com/java/18/archive/jdk-18.0.2.1_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' - ], - [ - '17', - '17', - 'https://download.oracle.com/java/17/latest/jdk-17_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' - ], - [ - '17.0.1', - '17.0.1', - 'https://download.oracle.com/java/17/archive/jdk-17.0.1_{{OS_TYPE}}-x64_bin.{{ARCHIVE_TYPE}}' - ] - ])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => { - const result = await distribution['findPackageForDownload'](input); - expect(result.version).toBe(expectedVersion); - const osType = distribution.getPlatform(); - const archiveType = getDownloadArchiveExtension(); - const url = expectedUrl.replace('{{OS_TYPE}}', osType).replace('{{ARCHIVE_TYPE}}', archiveType); - expect(result.url).toBe(url); - }); - - it.each([ - ['amd64', 'x64'], - ['arm64', 'aarch64'] - ])( - 'defaults to os.arch(): %s mapped to distro arch: %s', - async (osArch: string, distroArch: string) => { - jest.spyOn(os, 'arch').mockReturnValue(osArch); - jest.spyOn(os, 'platform').mockReturnValue('linux'); - - const version = '17'; - const distro = new OracleDistribution({ - version, - architecture: '', // to get default value - packageType: 'jdk', - checkLatest: false - }); - - const osType = distribution.getPlatform(); - if (osType === 'windows' && distroArch == 'aarch64') { - return; // skip, aarch64 is not available for Windows - } - const archiveType = getDownloadArchiveExtension(); - const result = await distro['findPackageForDownload'](version); - const expectedUrl = `https://download.oracle.com/java/17/latest/jdk-17_${osType}-${distroArch}_bin.${archiveType}`; - - expect(result.url).toBe(expectedUrl); - } - ); - - it('should throw an error', async () => { - await expect(distribution['findPackageForDownload']('8')).rejects.toThrow( - /Oracle JDK is only supported for JDK 17 and later/ - ); - await expect(distribution['findPackageForDownload']('11')).rejects.toThrow( - /Oracle JDK is only supported for JDK 17 and later/ - ); - await expect(distribution['findPackageForDownload']('18')).rejects.toThrow( - /Could not find Oracle JDK for SemVer */ - ); - }); -}); diff --git a/__tests__/verify-java.sh b/__tests__/verify-java.sh index 069d9008a..1bad5d357 100755 --- a/__tests__/verify-java.sh +++ b/__tests__/verify-java.sh @@ -24,7 +24,7 @@ fi ACTUAL_JAVA_VERSION="$(java -version 2>&1)" echo "Found java version: $ACTUAL_JAVA_VERSION" -GREP_RESULT=$(echo $ACTUAL_JAVA_VERSION | grep -E "^(openjdk|java) version \"$EXPECTED_JAVA_VERSION") +GREP_RESULT=$(echo $ACTUAL_JAVA_VERSION | grep "^openjdk version \"$EXPECTED_JAVA_VERSION") if [ -z "$GREP_RESULT" ]; then echo "::error::Unexpected version" echo "Expected version: $EXPECTED_JAVA_VERSION" diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index 4c9a3602d..2d9cede8e 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -68188,187 +68188,187 @@ try { /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; - -/** - * @fileoverview this file provides methods handling dependency cache - */ -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.save = exports.restore = void 0; -const path_1 = __nccwpck_require__(1017); -const os_1 = __importDefault(__nccwpck_require__(2037)); -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const glob = __importStar(__nccwpck_require__(8090)); -const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'; -const CACHE_MATCHED_KEY = 'cache-matched-key'; -const CACHE_KEY_PREFIX = 'setup-java'; -const supportedPackageManager = [ - { - id: 'maven', - path: [path_1.join(os_1.default.homedir(), '.m2', 'repository')], - // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven - pattern: ['**/pom.xml'] - }, - { - id: 'gradle', - path: [path_1.join(os_1.default.homedir(), '.gradle', 'caches'), path_1.join(os_1.default.homedir(), '.gradle', 'wrapper')], - // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle - pattern: [ - '**/*.gradle*', - '**/gradle-wrapper.properties', - 'buildSrc/**/Versions.kt', - 'buildSrc/**/Dependencies.kt', - 'gradle/*.versions.toml' - ] - }, - { - id: 'sbt', - path: [ - path_1.join(os_1.default.homedir(), '.ivy2', 'cache'), - path_1.join(os_1.default.homedir(), '.sbt'), - getCoursierCachePath(), - // Some files should not be cached to avoid resolution problems. - // In particular the resolution of snapshots (ideological gap between maven/ivy). - '!' + path_1.join(os_1.default.homedir(), '.sbt', '*.lock'), - '!' + path_1.join(os_1.default.homedir(), '**', 'ivydata-*.properties') - ], - pattern: ['**/*.sbt', '**/project/build.properties', '**/project/**.{scala,sbt}'] - } -]; -function getCoursierCachePath() { - if (os_1.default.type() === 'Linux') - return path_1.join(os_1.default.homedir(), '.cache', 'coursier'); - if (os_1.default.type() === 'Darwin') - return path_1.join(os_1.default.homedir(), 'Library', 'Caches', 'Coursier'); - return path_1.join(os_1.default.homedir(), 'AppData', 'Local', 'Coursier', 'Cache'); -} -function findPackageManager(id) { - const packageManager = supportedPackageManager.find(packageManager => packageManager.id === id); - if (packageManager === undefined) { - throw new Error(`unknown package manager specified: ${id}`); - } - return packageManager; -} -/** - * A function that generates a cache key to use. - * Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". - * If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-). - * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key} - */ -function computeCacheKey(packageManager) { - return __awaiter(this, void 0, void 0, function* () { - const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); - return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; - }); -} -/** - * Restore the dependency cache - * @param id ID of the package manager, should be "maven" or "gradle" - */ -function restore(id) { - return __awaiter(this, void 0, void 0, function* () { - const packageManager = findPackageManager(id); - const primaryKey = yield computeCacheKey(packageManager); - core.debug(`primary key is ${primaryKey}`); - core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey); - if (primaryKey.endsWith('-')) { - throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); - } - // No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269) - const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey); - if (matchedKey) { - core.saveState(CACHE_MATCHED_KEY, matchedKey); - core.setOutput('cache-hit', matchedKey === primaryKey); - core.info(`Cache restored from key: ${matchedKey}`); - } - else { - core.setOutput('cache-hit', false); - core.info(`${packageManager.id} cache is not found`); - } - }); -} -exports.restore = restore; -/** - * Save the dependency cache - * @param id ID of the package manager, should be "maven" or "gradle" - */ -function save(id) { - return __awaiter(this, void 0, void 0, function* () { - const packageManager = findPackageManager(id); - const matchedKey = core.getState(CACHE_MATCHED_KEY); - // Inputs are re-evaluated before the post action, so we want the original key used for restore - const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); - if (!primaryKey) { - core.warning('Error retrieving key from state.'); - return; - } - else if (matchedKey === primaryKey) { - // no change in target directories - core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); - return; - } - try { - yield cache.saveCache(packageManager.path, primaryKey); - core.info(`Cache saved with the key: ${primaryKey}`); - } - catch (error) { - if (error.name === cache.ReserveCacheError.name) { - core.info(error.message); - } - else { - if (isProbablyGradleDaemonProblem(packageManager, error)) { - core.warning('Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.'); - } - throw error; - } - } - }); -} -exports.save = save; -/** - * @param packageManager the specified package manager by user - * @param error the error thrown by the saveCache - * @returns true if the given error seems related to the {@link https://github.com/actions/cache/issues/454|running Gradle Daemon issue}. - * @see {@link https://github.com/actions/cache/issues/454#issuecomment-840493935|why --no-daemon is necessary} - */ -function isProbablyGradleDaemonProblem(packageManager, error) { - if (packageManager.id !== 'gradle' || process.env['RUNNER_OS'] !== 'Windows') { - return false; - } - const message = error.message || ''; - return message.startsWith('Tar failed with error: '); -} + +/** + * @fileoverview this file provides methods handling dependency cache + */ +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.save = exports.restore = void 0; +const path_1 = __nccwpck_require__(1017); +const os_1 = __importDefault(__nccwpck_require__(2037)); +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const glob = __importStar(__nccwpck_require__(8090)); +const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key'; +const CACHE_MATCHED_KEY = 'cache-matched-key'; +const CACHE_KEY_PREFIX = 'setup-java'; +const supportedPackageManager = [ + { + id: 'maven', + path: [path_1.join(os_1.default.homedir(), '.m2', 'repository')], + // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven + pattern: ['**/pom.xml'] + }, + { + id: 'gradle', + path: [path_1.join(os_1.default.homedir(), '.gradle', 'caches'), path_1.join(os_1.default.homedir(), '.gradle', 'wrapper')], + // https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---gradle + pattern: [ + '**/*.gradle*', + '**/gradle-wrapper.properties', + 'buildSrc/**/Versions.kt', + 'buildSrc/**/Dependencies.kt', + 'gradle/*.versions.toml' + ] + }, + { + id: 'sbt', + path: [ + path_1.join(os_1.default.homedir(), '.ivy2', 'cache'), + path_1.join(os_1.default.homedir(), '.sbt'), + getCoursierCachePath(), + // Some files should not be cached to avoid resolution problems. + // In particular the resolution of snapshots (ideological gap between maven/ivy). + '!' + path_1.join(os_1.default.homedir(), '.sbt', '*.lock'), + '!' + path_1.join(os_1.default.homedir(), '**', 'ivydata-*.properties') + ], + pattern: ['**/*.sbt', '**/project/build.properties', '**/project/**.{scala,sbt}'] + } +]; +function getCoursierCachePath() { + if (os_1.default.type() === 'Linux') + return path_1.join(os_1.default.homedir(), '.cache', 'coursier'); + if (os_1.default.type() === 'Darwin') + return path_1.join(os_1.default.homedir(), 'Library', 'Caches', 'Coursier'); + return path_1.join(os_1.default.homedir(), 'AppData', 'Local', 'Coursier', 'Cache'); +} +function findPackageManager(id) { + const packageManager = supportedPackageManager.find(packageManager => packageManager.id === id); + if (packageManager === undefined) { + throw new Error(`unknown package manager specified: ${id}`); + } + return packageManager; +} +/** + * A function that generates a cache key to use. + * Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". + * If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-). + * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key} + */ +function computeCacheKey(packageManager) { + return __awaiter(this, void 0, void 0, function* () { + const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); + return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; + }); +} +/** + * Restore the dependency cache + * @param id ID of the package manager, should be "maven" or "gradle" + */ +function restore(id) { + return __awaiter(this, void 0, void 0, function* () { + const packageManager = findPackageManager(id); + const primaryKey = yield computeCacheKey(packageManager); + core.debug(`primary key is ${primaryKey}`); + core.saveState(STATE_CACHE_PRIMARY_KEY, primaryKey); + if (primaryKey.endsWith('-')) { + throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); + } + // No "restoreKeys" is set, to start with a clear cache after dependency update (see https://github.com/actions/setup-java/issues/269) + const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey); + if (matchedKey) { + core.saveState(CACHE_MATCHED_KEY, matchedKey); + core.setOutput('cache-hit', matchedKey === primaryKey); + core.info(`Cache restored from key: ${matchedKey}`); + } + else { + core.setOutput('cache-hit', false); + core.info(`${packageManager.id} cache is not found`); + } + }); +} +exports.restore = restore; +/** + * Save the dependency cache + * @param id ID of the package manager, should be "maven" or "gradle" + */ +function save(id) { + return __awaiter(this, void 0, void 0, function* () { + const packageManager = findPackageManager(id); + const matchedKey = core.getState(CACHE_MATCHED_KEY); + // Inputs are re-evaluated before the post action, so we want the original key used for restore + const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY); + if (!primaryKey) { + core.warning('Error retrieving key from state.'); + return; + } + else if (matchedKey === primaryKey) { + // no change in target directories + core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`); + return; + } + try { + yield cache.saveCache(packageManager.path, primaryKey); + core.info(`Cache saved with the key: ${primaryKey}`); + } + catch (error) { + if (error.name === cache.ReserveCacheError.name) { + core.info(error.message); + } + else { + if (isProbablyGradleDaemonProblem(packageManager, error)) { + core.warning('Failed to save Gradle cache on Windows. If tar.exe reported "Permission denied", try to run Gradle with `--no-daemon` option. Refer to https://github.com/actions/cache/issues/454 for details.'); + } + throw error; + } + } + }); +} +exports.save = save; +/** + * @param packageManager the specified package manager by user + * @param error the error thrown by the saveCache + * @returns true if the given error seems related to the {@link https://github.com/actions/cache/issues/454|running Gradle Daemon issue}. + * @see {@link https://github.com/actions/cache/issues/454#issuecomment-840493935|why --no-daemon is necessary} + */ +function isProbablyGradleDaemonProblem(packageManager, error) { + if (packageManager.id !== 'gradle' || process.env['RUNNER_OS'] !== 'Windows') { + return false; + } + const message = error.message || ''; + return message.startsWith('Tar failed with error: '); +} /***/ }), @@ -68377,99 +68377,99 @@ function isProbablyGradleDaemonProblem(packageManager, error) { /***/ (function(__unused_webpack_module, exports, __nccwpck_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()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.run = void 0; -const core = __importStar(__nccwpck_require__(2186)); -const gpg = __importStar(__nccwpck_require__(3759)); -const constants = __importStar(__nccwpck_require__(9042)); -const util_1 = __nccwpck_require__(2629); -const cache_1 = __nccwpck_require__(4810); -function removePrivateKeyFromKeychain() { - 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 due to: ${error.message}`); - } - } - }); -} -/** - * Check given input and run a save process for the specified package manager - * @returns Promise that will be resolved when the save process finishes - */ -function saveCache() { - return __awaiter(this, void 0, void 0, function* () { - const jobStatus = util_1.isJobStatusSuccess(); - const cache = core.getInput(constants.INPUT_CACHE); - return jobStatus && cache ? cache_1.save(cache) : Promise.resolve(); - }); -} -/** - * The save process is best-effort, and it should not make the workflow fail - * even though this process throws an error. - * @param promise the promise to ignore error from - * @returns Promise that will ignore error reported by the given promise - */ -function ignoreError(promise) { - return __awaiter(this, void 0, void 0, function* () { - return new Promise(resolve => { - promise - .catch(error => { - core.warning(error); - resolve(void 0); - }) - .then(resolve); - }); - }); -} -function run() { - return __awaiter(this, void 0, void 0, function* () { - yield removePrivateKeyFromKeychain(); - yield ignoreError(saveCache()); - }); -} -exports.run = run; -if (require.main === require.cache[eval('__filename')]) { - run(); -} -else { - // https://nodejs.org/api/modules.html#modules_accessing_the_main_module - core.info('the script is loaded as a module, so skipping the execution'); -} + +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.run = void 0; +const core = __importStar(__nccwpck_require__(2186)); +const gpg = __importStar(__nccwpck_require__(3759)); +const constants = __importStar(__nccwpck_require__(9042)); +const util_1 = __nccwpck_require__(2629); +const cache_1 = __nccwpck_require__(4810); +function removePrivateKeyFromKeychain() { + 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 due to: ${error.message}`); + } + } + }); +} +/** + * Check given input and run a save process for the specified package manager + * @returns Promise that will be resolved when the save process finishes + */ +function saveCache() { + return __awaiter(this, void 0, void 0, function* () { + const jobStatus = util_1.isJobStatusSuccess(); + const cache = core.getInput(constants.INPUT_CACHE); + return jobStatus && cache ? cache_1.save(cache) : Promise.resolve(); + }); +} +/** + * The save process is best-effort, and it should not make the workflow fail + * even though this process throws an error. + * @param promise the promise to ignore error from + * @returns Promise that will ignore error reported by the given promise + */ +function ignoreError(promise) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise(resolve => { + promise + .catch(error => { + core.warning(error); + resolve(void 0); + }) + .then(resolve); + }); + }); +} +function run() { + return __awaiter(this, void 0, void 0, function* () { + yield removePrivateKeyFromKeychain(); + yield ignoreError(saveCache()); + }); +} +exports.run = run; +if (require.main === require.cache[eval('__filename')]) { + run(); +} +else { + // https://nodejs.org/api/modules.html#modules_accessing_the_main_module + core.info('the script is loaded as a module, so skipping the execution'); +} /***/ }), @@ -68478,35 +68478,35 @@ else { /***/ ((__unused_webpack_module, exports) => { "use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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_FILE = 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_JAVA_VERSION_FILE = 'java-version-file'; -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.INPUT_CACHE = 'cache'; -exports.INPUT_JOB_STATUS = 'job-status'; -exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; -exports.M2_DIR = '.m2'; -exports.MVN_SETTINGS_FILE = 'settings.xml'; -exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; -exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; -exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; -exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = exports.INPUT_MVN_TOOLCHAIN_VENDOR = exports.INPUT_MVN_TOOLCHAIN_ID = exports.MVN_TOOLCHAINS_FILE = exports.MVN_SETTINGS_FILE = exports.M2_DIR = exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = exports.INPUT_JOB_STATUS = exports.INPUT_CACHE = 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_FILE = 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_JAVA_VERSION_FILE = 'java-version-file'; +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.INPUT_CACHE = 'cache'; +exports.INPUT_JOB_STATUS = 'job-status'; +exports.STATE_GPG_PRIVATE_KEY_FINGERPRINT = 'gpg-private-key-fingerprint'; +exports.M2_DIR = '.m2'; +exports.MVN_SETTINGS_FILE = 'settings.xml'; +exports.MVN_TOOLCHAINS_FILE = 'toolchains.xml'; +exports.INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id'; +exports.INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor'; +exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; /***/ }), @@ -68515,74 +68515,74 @@ exports.DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']; /***/ (function(__unused_webpack_module, exports, __nccwpck_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()); - }); -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.deleteKey = exports.importKey = exports.PRIVATE_KEY_FILE = void 0; -const fs = __importStar(__nccwpck_require__(7147)); -const path = __importStar(__nccwpck_require__(1017)); -const io = __importStar(__nccwpck_require__(7436)); -const exec = __importStar(__nccwpck_require__(1514)); -const util = __importStar(__nccwpck_require__(2629)); -exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); -const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; -function importKey(privateKey) { - return __awaiter(this, void 0, void 0, function* () { - fs.writeFileSync(exports.PRIVATE_KEY_FILE, privateKey, { - encoding: 'utf-8', - flag: 'w' - }); - let output = ''; - const options = { - silent: true, - listeners: { - stdout: (data) => { - output += data.toString(); - } - } - }; - yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); - yield io.rmRF(exports.PRIVATE_KEY_FILE); - const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); - return match && match[0]; - }); -} -exports.importKey = importKey; -function deleteKey(keyFingerprint) { - return __awaiter(this, void 0, void 0, function* () { - yield exec.exec('gpg', ['--batch', '--yes', '--delete-secret-and-public-key', keyFingerprint], { - silent: true - }); - }); -} -exports.deleteKey = deleteKey; + +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.deleteKey = exports.importKey = exports.PRIVATE_KEY_FILE = void 0; +const fs = __importStar(__nccwpck_require__(7147)); +const path = __importStar(__nccwpck_require__(1017)); +const io = __importStar(__nccwpck_require__(7436)); +const exec = __importStar(__nccwpck_require__(1514)); +const util = __importStar(__nccwpck_require__(2629)); +exports.PRIVATE_KEY_FILE = path.join(util.getTempDir(), 'private-key.asc'); +const PRIVATE_KEY_FINGERPRINT_REGEX = /\w{40}/; +function importKey(privateKey) { + return __awaiter(this, void 0, void 0, function* () { + fs.writeFileSync(exports.PRIVATE_KEY_FILE, privateKey, { + encoding: 'utf-8', + flag: 'w' + }); + let output = ''; + const options = { + silent: true, + listeners: { + stdout: (data) => { + output += data.toString(); + } + } + }; + yield exec.exec('gpg', ['--batch', '--import-options', 'import-show', '--import', exports.PRIVATE_KEY_FILE], options); + yield io.rmRF(exports.PRIVATE_KEY_FILE); + const match = output.match(PRIVATE_KEY_FINGERPRINT_REGEX); + return match && match[0]; + }); +} +exports.importKey = importKey; +function deleteKey(keyFingerprint) { + return __awaiter(this, void 0, void 0, function* () { + yield exec.exec('gpg', ['--batch', '--yes', '--delete-secret-and-public-key', keyFingerprint], { + silent: true + }); + }); +} +exports.deleteKey = deleteKey; /***/ }), @@ -68591,162 +68591,163 @@ exports.deleteKey = deleteKey; /***/ (function(__unused_webpack_module, exports, __nccwpck_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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.avoidOldNotation = exports.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; -const os_1 = __importDefault(__nccwpck_require__(2037)); -const path_1 = __importDefault(__nccwpck_require__(1017)); -const fs = __importStar(__nccwpck_require__(7147)); -const semver = __importStar(__nccwpck_require__(1383)); -const cache = __importStar(__nccwpck_require__(7799)); -const core = __importStar(__nccwpck_require__(2186)); -const tc = __importStar(__nccwpck_require__(7784)); -const constants_1 = __nccwpck_require__(9042); -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; -function isJobStatusSuccess() { - const jobStatus = core.getInput(constants_1.INPUT_JOB_STATUS); - return jobStatus === 'success'; -} -exports.isJobStatusSuccess = isJobStatusSuccess; -function isGhes() { - const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; -} -exports.isGhes = isGhes; -function isCacheFeatureAvailable() { - if (!cache.isFeatureAvailable()) { - if (isGhes()) { - throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'); - } - else { - core.warning('The runner was not able to contact the cache service. Caching will be skipped'); - } - return false; - } - return true; -} -exports.isCacheFeatureAvailable = isCacheFeatureAvailable; -function getVersionFromFileContent(content, distributionName) { - var _a, _b, _c, _d; - const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; - const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) - ? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version - : ''; - if (!fileContent) { - return null; - } - const tentativeVersion = avoidOldNotation(fileContent); - let version = semver.validRange(tentativeVersion) - ? tentativeVersion - : semver.coerce(tentativeVersion); - if (!version) { - return null; - } - if (constants_1.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { - version = semver.major(version).toString(); - } - return version.toString(); -} -exports.getVersionFromFileContent = getVersionFromFileContent; -// By convention, action expects version 8 in the format `8.*` instead of `1.8` -function avoidOldNotation(content) { - return content.startsWith('1.') ? content.substring(2) : content; -} -exports.avoidOldNotation = avoidOldNotation; + +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.getVersionFromFileContent = exports.isCacheFeatureAvailable = exports.isGhes = exports.isJobStatusSuccess = exports.getToolcachePath = exports.isVersionSatisfies = exports.getDownloadArchiveExtension = exports.extractJdkFile = exports.getVersionFromToolcachePath = exports.getBooleanInput = exports.getTempDir = void 0; +const os_1 = __importDefault(__nccwpck_require__(2037)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const fs = __importStar(__nccwpck_require__(7147)); +const semver = __importStar(__nccwpck_require__(1383)); +const cache = __importStar(__nccwpck_require__(7799)); +const core = __importStar(__nccwpck_require__(2186)); +const tc = __importStar(__nccwpck_require__(7784)); +const constants_1 = __nccwpck_require__(9042); +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; +function isJobStatusSuccess() { + const jobStatus = core.getInput(constants_1.INPUT_JOB_STATUS); + return jobStatus === 'success'; +} +exports.isJobStatusSuccess = isJobStatusSuccess; +function isGhes() { + const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); + return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; +} +exports.isGhes = isGhes; +function isCacheFeatureAvailable() { + if (!cache.isFeatureAvailable()) { + if (isGhes()) { + throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'); + } + else { + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + } + return false; + } + return true; +} +exports.isCacheFeatureAvailable = isCacheFeatureAvailable; +function getVersionFromFileContent(content, distributionName) { + var _a, _b, _c, _d, _e; + const javaVersionRegExp = /(?(?<=(^|\s|\-))(\d+\S*))(\s|$)/; + const fileContent = ((_b = (_a = content.match(javaVersionRegExp)) === null || _a === void 0 ? void 0 : _a.groups) === null || _b === void 0 ? void 0 : _b.version) + ? (_d = (_c = content.match(javaVersionRegExp)) === null || _c === void 0 ? void 0 : _c.groups) === null || _d === void 0 ? void 0 : _d.version + : ''; + if (!fileContent) { + return null; + } + core.debug(`Version from file '${fileContent}'`); + const tentativeVersion = avoidOldNotation(fileContent); + const rawVersion = tentativeVersion.split('-')[0]; + let version = semver.validRange(rawVersion) ? tentativeVersion : semver.coerce(tentativeVersion); + core.debug(`Range version from file is '${version}'`); + if (!version) { + return null; + } + if (constants_1.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) { + const coerceVersion = (_e = semver.coerce(version)) !== null && _e !== void 0 ? _e : version; + version = semver.major(coerceVersion).toString(); + } + return version.toString(); +} +exports.getVersionFromFileContent = getVersionFromFileContent; +// By convention, action expects version 8 in the format `8.*` instead of `1.8` +function avoidOldNotation(content) { + return content.startsWith('1.') ? content.substring(2) : content; +} /***/ }), diff --git a/dist/setup/index.js b/dist/setup/index.js index 33f8b90f1..e19da8dd0 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -12763,312 +12763,312 @@ exports.AbortSignal = AbortSignal; /***/ 9268: /***/ ((module) => { -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -/* global global, define, System, Reflect, Promise */ -var __extends; -var __assign; -var __rest; -var __decorate; -var __param; -var __metadata; -var __awaiter; -var __generator; -var __exportStar; -var __values; -var __read; -var __spread; -var __spreadArrays; -var __spreadArray; -var __await; -var __asyncGenerator; -var __asyncDelegator; -var __asyncValues; -var __makeTemplateObject; -var __importStar; -var __importDefault; -var __classPrivateFieldGet; -var __classPrivateFieldSet; -var __createBinding; -(function (factory) { - var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); - } - else if ( true && typeof module.exports === "object") { - factory(createExporter(root, createExporter(module.exports))); - } - else { - factory(createExporter(root)); - } - function createExporter(exports, previous) { - if (exports !== root) { - if (typeof Object.create === "function") { - Object.defineProperty(exports, "__esModule", { value: true }); - } - else { - exports.__esModule = true; - } - } - return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; - } -}) -(function (exporter) { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - - __extends = function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - - __assign = Object.assign || function (t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - - __rest = function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - }; - - __decorate = function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - - __param = function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } - }; - - __metadata = function (metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); - }; - - __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()); - }); - }; - - __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 }; - } - }; - - __exportStar = function(m, o) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); - }; - - __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]; - }); - - __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."); - }; - - __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; - }; - - /** @deprecated */ - __spread = function () { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; - }; - - /** @deprecated */ - __spreadArrays = function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; - }; - - __spreadArray = function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); - }; - - __await = function (v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); - }; - - __asyncGenerator = function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - }; - - __asyncDelegator = function (o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } - }; - - __asyncValues = function (o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } - }; - - __makeTemplateObject = function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; - }; - - var __setModuleDefault = Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - }) : function(o, v) { - o["default"] = v; - }; - - __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; - }; - - __importDefault = function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - - __classPrivateFieldGet = function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); - }; - - __classPrivateFieldSet = function (receiver, state, value, kind, f) { - if (kind === "m") throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; - }; - - exporter("__extends", __extends); - exporter("__assign", __assign); - exporter("__rest", __rest); - exporter("__decorate", __decorate); - exporter("__param", __param); - exporter("__metadata", __metadata); - exporter("__awaiter", __awaiter); - exporter("__generator", __generator); - exporter("__exportStar", __exportStar); - exporter("__createBinding", __createBinding); - exporter("__values", __values); - exporter("__read", __read); - exporter("__spread", __spread); - exporter("__spreadArrays", __spreadArrays); - exporter("__spreadArray", __spreadArray); - exporter("__await", __await); - exporter("__asyncGenerator", __asyncGenerator); - exporter("__asyncDelegator", __asyncDelegator); - exporter("__asyncValues", __asyncValues); - exporter("__makeTemplateObject", __makeTemplateObject); - exporter("__importStar", __importStar); - exporter("__importDefault", __importDefault); - exporter("__classPrivateFieldGet", __classPrivateFieldGet); - exporter("__classPrivateFieldSet", __classPrivateFieldSet); -}); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global global, define, System, Reflect, Promise */ +var __extends; +var __assign; +var __rest; +var __decorate; +var __param; +var __metadata; +var __awaiter; +var __generator; +var __exportStar; +var __values; +var __read; +var __spread; +var __spreadArrays; +var __spreadArray; +var __await; +var __asyncGenerator; +var __asyncDelegator; +var __asyncValues; +var __makeTemplateObject; +var __importStar; +var __importDefault; +var __classPrivateFieldGet; +var __classPrivateFieldSet; +var __createBinding; +(function (factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); + } + else if ( true && typeof module.exports === "object") { + factory(createExporter(root, createExporter(module.exports))); + } + else { + factory(createExporter(root)); + } + function createExporter(exports, previous) { + if (exports !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + } + return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; + } +}) +(function (exporter) { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + + __extends = function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + + __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + + __rest = function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; + }; + + __decorate = function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + + __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + }; + + __metadata = function (metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + }; + + __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()); + }); + }; + + __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 }; + } + }; + + __exportStar = function(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); + }; + + __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]; + }); + + __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."); + }; + + __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; + }; + + /** @deprecated */ + __spread = function () { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + }; + + /** @deprecated */ + __spreadArrays = function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; + }; + + __spreadArray = function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); + }; + + __await = function (v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + }; + + __asyncGenerator = function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + }; + + __asyncDelegator = function (o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + }; + + __asyncValues = function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + }; + + __makeTemplateObject = function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + }; + + var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + }) : function(o, v) { + o["default"] = v; + }; + + __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; + }; + + __importDefault = function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + + __classPrivateFieldGet = function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); + }; + + __classPrivateFieldSet = function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; + }; + + exporter("__extends", __extends); + exporter("__assign", __assign); + exporter("__rest", __rest); + exporter("__decorate", __decorate); + exporter("__param", __param); + exporter("__metadata", __metadata); + exporter("__awaiter", __awaiter); + exporter("__generator", __generator); + exporter("__exportStar", __exportStar); + exporter("__createBinding", __createBinding); + exporter("__values", __values); + exporter("__read", __read); + exporter("__spread", __spread); + exporter("__spreadArrays", __spreadArrays); + exporter("__spreadArray", __spreadArray); + exporter("__await", __await); + exporter("__asyncGenerator", __asyncGenerator); + exporter("__asyncDelegator", __asyncDelegator); + exporter("__asyncValues", __asyncValues); + exporter("__makeTemplateObject", __makeTemplateObject); + exporter("__importStar", __importStar); + exporter("__importDefault", __importDefault); + exporter("__classPrivateFieldGet", __classPrivateFieldGet); + exporter("__classPrivateFieldSet", __classPrivateFieldSet); +}); /***/ }), @@ -21547,312 +21547,312 @@ module.exports = '4.0.0' /***/ 2107: /***/ ((module) => { -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -/* global global, define, System, Reflect, Promise */ -var __extends; -var __assign; -var __rest; -var __decorate; -var __param; -var __metadata; -var __awaiter; -var __generator; -var __exportStar; -var __values; -var __read; -var __spread; -var __spreadArrays; -var __spreadArray; -var __await; -var __asyncGenerator; -var __asyncDelegator; -var __asyncValues; -var __makeTemplateObject; -var __importStar; -var __importDefault; -var __classPrivateFieldGet; -var __classPrivateFieldSet; -var __createBinding; -(function (factory) { - var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); - } - else if ( true && typeof module.exports === "object") { - factory(createExporter(root, createExporter(module.exports))); - } - else { - factory(createExporter(root)); - } - function createExporter(exports, previous) { - if (exports !== root) { - if (typeof Object.create === "function") { - Object.defineProperty(exports, "__esModule", { value: true }); - } - else { - exports.__esModule = true; - } - } - return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; - } -}) -(function (exporter) { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - - __extends = function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - - __assign = Object.assign || function (t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - - __rest = function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - }; - - __decorate = function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - - __param = function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } - }; - - __metadata = function (metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); - }; - - __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()); - }); - }; - - __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 }; - } - }; - - __exportStar = function(m, o) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); - }; - - __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]; - }); - - __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."); - }; - - __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; - }; - - /** @deprecated */ - __spread = function () { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; - }; - - /** @deprecated */ - __spreadArrays = function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; - }; - - __spreadArray = function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); - }; - - __await = function (v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); - }; - - __asyncGenerator = function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - }; - - __asyncDelegator = function (o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } - }; - - __asyncValues = function (o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } - }; - - __makeTemplateObject = function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; - }; - - var __setModuleDefault = Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - }) : function(o, v) { - o["default"] = v; - }; - - __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; - }; - - __importDefault = function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - - __classPrivateFieldGet = function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); - }; - - __classPrivateFieldSet = function (receiver, state, value, kind, f) { - if (kind === "m") throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; - }; - - exporter("__extends", __extends); - exporter("__assign", __assign); - exporter("__rest", __rest); - exporter("__decorate", __decorate); - exporter("__param", __param); - exporter("__metadata", __metadata); - exporter("__awaiter", __awaiter); - exporter("__generator", __generator); - exporter("__exportStar", __exportStar); - exporter("__createBinding", __createBinding); - exporter("__values", __values); - exporter("__read", __read); - exporter("__spread", __spread); - exporter("__spreadArrays", __spreadArrays); - exporter("__spreadArray", __spreadArray); - exporter("__await", __await); - exporter("__asyncGenerator", __asyncGenerator); - exporter("__asyncDelegator", __asyncDelegator); - exporter("__asyncValues", __asyncValues); - exporter("__makeTemplateObject", __makeTemplateObject); - exporter("__importStar", __importStar); - exporter("__importDefault", __importDefault); - exporter("__classPrivateFieldGet", __classPrivateFieldGet); - exporter("__classPrivateFieldSet", __classPrivateFieldSet); -}); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global global, define, System, Reflect, Promise */ +var __extends; +var __assign; +var __rest; +var __decorate; +var __param; +var __metadata; +var __awaiter; +var __generator; +var __exportStar; +var __values; +var __read; +var __spread; +var __spreadArrays; +var __spreadArray; +var __await; +var __asyncGenerator; +var __asyncDelegator; +var __asyncValues; +var __makeTemplateObject; +var __importStar; +var __importDefault; +var __classPrivateFieldGet; +var __classPrivateFieldSet; +var __createBinding; +(function (factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); + } + else if ( true && typeof module.exports === "object") { + factory(createExporter(root, createExporter(module.exports))); + } + else { + factory(createExporter(root)); + } + function createExporter(exports, previous) { + if (exports !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + } + return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; + } +}) +(function (exporter) { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + + __extends = function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + + __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + + __rest = function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; + }; + + __decorate = function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + + __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + }; + + __metadata = function (metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + }; + + __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()); + }); + }; + + __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 }; + } + }; + + __exportStar = function(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); + }; + + __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]; + }); + + __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."); + }; + + __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; + }; + + /** @deprecated */ + __spread = function () { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + }; + + /** @deprecated */ + __spreadArrays = function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; + }; + + __spreadArray = function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); + }; + + __await = function (v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + }; + + __asyncGenerator = function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + }; + + __asyncDelegator = function (o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + }; + + __asyncValues = function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + }; + + __makeTemplateObject = function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + }; + + var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + }) : function(o, v) { + o["default"] = v; + }; + + __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; + }; + + __importDefault = function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + + __classPrivateFieldGet = function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); + }; + + __classPrivateFieldSet = function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; + }; + + exporter("__extends", __extends); + exporter("__assign", __assign); + exporter("__rest", __rest); + exporter("__decorate", __decorate); + exporter("__param", __param); + exporter("__metadata", __metadata); + exporter("__awaiter", __awaiter); + exporter("__generator", __generator); + exporter("__exportStar", __exportStar); + exporter("__createBinding", __createBinding); + exporter("__values", __values); + exporter("__read", __read); + exporter("__spread", __spread); + exporter("__spreadArrays", __spreadArrays); + exporter("__spreadArray", __spreadArray); + exporter("__await", __await); + exporter("__asyncGenerator", __asyncGenerator); + exporter("__asyncDelegator", __asyncDelegator); + exporter("__asyncValues", __asyncValues); + exporter("__makeTemplateObject", __makeTemplateObject); + exporter("__importStar", __importStar); + exporter("__importDefault", __importDefault); + exporter("__classPrivateFieldGet", __classPrivateFieldGet); + exporter("__classPrivateFieldSet", __classPrivateFieldSet); +}); /***/ }), @@ -23347,312 +23347,312 @@ exports.getPagedAsyncIterator = getPagedAsyncIterator; /***/ 6429: /***/ ((module) => { -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -/* global global, define, System, Reflect, Promise */ -var __extends; -var __assign; -var __rest; -var __decorate; -var __param; -var __metadata; -var __awaiter; -var __generator; -var __exportStar; -var __values; -var __read; -var __spread; -var __spreadArrays; -var __spreadArray; -var __await; -var __asyncGenerator; -var __asyncDelegator; -var __asyncValues; -var __makeTemplateObject; -var __importStar; -var __importDefault; -var __classPrivateFieldGet; -var __classPrivateFieldSet; -var __createBinding; -(function (factory) { - var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); - } - else if ( true && typeof module.exports === "object") { - factory(createExporter(root, createExporter(module.exports))); - } - else { - factory(createExporter(root)); - } - function createExporter(exports, previous) { - if (exports !== root) { - if (typeof Object.create === "function") { - Object.defineProperty(exports, "__esModule", { value: true }); - } - else { - exports.__esModule = true; - } - } - return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; - } -}) -(function (exporter) { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - - __extends = function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - - __assign = Object.assign || function (t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - - __rest = function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - }; - - __decorate = function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - - __param = function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } - }; - - __metadata = function (metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); - }; - - __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()); - }); - }; - - __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 }; - } - }; - - __exportStar = function(m, o) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); - }; - - __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]; - }); - - __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."); - }; - - __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; - }; - - /** @deprecated */ - __spread = function () { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; - }; - - /** @deprecated */ - __spreadArrays = function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; - }; - - __spreadArray = function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); - }; - - __await = function (v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); - }; - - __asyncGenerator = function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - }; - - __asyncDelegator = function (o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } - }; - - __asyncValues = function (o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } - }; - - __makeTemplateObject = function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; - }; - - var __setModuleDefault = Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - }) : function(o, v) { - o["default"] = v; - }; - - __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; - }; - - __importDefault = function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - - __classPrivateFieldGet = function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); - }; - - __classPrivateFieldSet = function (receiver, state, value, kind, f) { - if (kind === "m") throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; - }; - - exporter("__extends", __extends); - exporter("__assign", __assign); - exporter("__rest", __rest); - exporter("__decorate", __decorate); - exporter("__param", __param); - exporter("__metadata", __metadata); - exporter("__awaiter", __awaiter); - exporter("__generator", __generator); - exporter("__exportStar", __exportStar); - exporter("__createBinding", __createBinding); - exporter("__values", __values); - exporter("__read", __read); - exporter("__spread", __spread); - exporter("__spreadArrays", __spreadArrays); - exporter("__spreadArray", __spreadArray); - exporter("__await", __await); - exporter("__asyncGenerator", __asyncGenerator); - exporter("__asyncDelegator", __asyncDelegator); - exporter("__asyncValues", __asyncValues); - exporter("__makeTemplateObject", __makeTemplateObject); - exporter("__importStar", __importStar); - exporter("__importDefault", __importDefault); - exporter("__classPrivateFieldGet", __classPrivateFieldGet); - exporter("__classPrivateFieldSet", __classPrivateFieldSet); -}); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global global, define, System, Reflect, Promise */ +var __extends; +var __assign; +var __rest; +var __decorate; +var __param; +var __metadata; +var __awaiter; +var __generator; +var __exportStar; +var __values; +var __read; +var __spread; +var __spreadArrays; +var __spreadArray; +var __await; +var __asyncGenerator; +var __asyncDelegator; +var __asyncValues; +var __makeTemplateObject; +var __importStar; +var __importDefault; +var __classPrivateFieldGet; +var __classPrivateFieldSet; +var __createBinding; +(function (factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); + } + else if ( true && typeof module.exports === "object") { + factory(createExporter(root, createExporter(module.exports))); + } + else { + factory(createExporter(root)); + } + function createExporter(exports, previous) { + if (exports !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + } + return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; + } +}) +(function (exporter) { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + + __extends = function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + + __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + + __rest = function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; + }; + + __decorate = function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + + __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + }; + + __metadata = function (metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + }; + + __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()); + }); + }; + + __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 }; + } + }; + + __exportStar = function(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); + }; + + __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]; + }); + + __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."); + }; + + __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; + }; + + /** @deprecated */ + __spread = function () { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + }; + + /** @deprecated */ + __spreadArrays = function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; + }; + + __spreadArray = function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); + }; + + __await = function (v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + }; + + __asyncGenerator = function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + }; + + __asyncDelegator = function (o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + }; + + __asyncValues = function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + }; + + __makeTemplateObject = function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + }; + + var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + }) : function(o, v) { + o["default"] = v; + }; + + __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; + }; + + __importDefault = function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + + __classPrivateFieldGet = function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); + }; + + __classPrivateFieldSet = function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; + }; + + exporter("__extends", __extends); + exporter("__assign", __assign); + exporter("__rest", __rest); + exporter("__decorate", __decorate); + exporter("__param", __param); + exporter("__metadata", __metadata); + exporter("__awaiter", __awaiter); + exporter("__generator", __generator); + exporter("__exportStar", __exportStar); + exporter("__createBinding", __createBinding); + exporter("__values", __values); + exporter("__read", __read); + exporter("__spread", __spread); + exporter("__spreadArrays", __spreadArrays); + exporter("__spreadArray", __spreadArray); + exporter("__await", __await); + exporter("__asyncGenerator", __asyncGenerator); + exporter("__asyncDelegator", __asyncDelegator); + exporter("__asyncValues", __asyncValues); + exporter("__makeTemplateObject", __makeTemplateObject); + exporter("__importStar", __importStar); + exporter("__importDefault", __importDefault); + exporter("__classPrivateFieldGet", __classPrivateFieldGet); + exporter("__classPrivateFieldSet", __classPrivateFieldSet); +}); /***/ }), @@ -48891,312 +48891,312 @@ exports.newPipeline = newPipeline; /***/ 679: /***/ ((module) => { -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -/* global global, define, System, Reflect, Promise */ -var __extends; -var __assign; -var __rest; -var __decorate; -var __param; -var __metadata; -var __awaiter; -var __generator; -var __exportStar; -var __values; -var __read; -var __spread; -var __spreadArrays; -var __spreadArray; -var __await; -var __asyncGenerator; -var __asyncDelegator; -var __asyncValues; -var __makeTemplateObject; -var __importStar; -var __importDefault; -var __classPrivateFieldGet; -var __classPrivateFieldSet; -var __createBinding; -(function (factory) { - var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; - if (typeof define === "function" && define.amd) { - define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); - } - else if ( true && typeof module.exports === "object") { - factory(createExporter(root, createExporter(module.exports))); - } - else { - factory(createExporter(root)); - } - function createExporter(exports, previous) { - if (exports !== root) { - if (typeof Object.create === "function") { - Object.defineProperty(exports, "__esModule", { value: true }); - } - else { - exports.__esModule = true; - } - } - return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; - } -}) -(function (exporter) { - var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; - - __extends = function (d, b) { - if (typeof b !== "function" && b !== null) - throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; - - __assign = Object.assign || function (t) { - for (var s, i = 1, n = arguments.length; i < n; i++) { - s = arguments[i]; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - - __rest = function (s, e) { - var t = {}; - for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) - t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") - for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) - t[p[i]] = s[p[i]]; - } - return t; - }; - - __decorate = function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; - }; - - __param = function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } - }; - - __metadata = function (metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); - }; - - __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()); - }); - }; - - __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 }; - } - }; - - __exportStar = function(m, o) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); - }; - - __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]; - }); - - __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."); - }; - - __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; - }; - - /** @deprecated */ - __spread = function () { - for (var ar = [], i = 0; i < arguments.length; i++) - ar = ar.concat(__read(arguments[i])); - return ar; - }; - - /** @deprecated */ - __spreadArrays = function () { - for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; - for (var r = Array(s), k = 0, i = 0; i < il; i++) - for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) - r[k] = a[j]; - return r; - }; - - __spreadArray = function (to, from, pack) { - if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { - if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); - }; - - __await = function (v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); - }; - - __asyncGenerator = function (thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } - function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } - function fulfill(value) { resume("next", value); } - function reject(value) { resume("throw", value); } - function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } - }; - - __asyncDelegator = function (o) { - var i, p; - return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } - }; - - __asyncValues = function (o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); - function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } - function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } - }; - - __makeTemplateObject = function (cooked, raw) { - if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } - return cooked; - }; - - var __setModuleDefault = Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); - }) : function(o, v) { - o["default"] = v; - }; - - __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; - }; - - __importDefault = function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; - }; - - __classPrivateFieldGet = function (receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); - }; - - __classPrivateFieldSet = function (receiver, state, value, kind, f) { - if (kind === "m") throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; - }; - - exporter("__extends", __extends); - exporter("__assign", __assign); - exporter("__rest", __rest); - exporter("__decorate", __decorate); - exporter("__param", __param); - exporter("__metadata", __metadata); - exporter("__awaiter", __awaiter); - exporter("__generator", __generator); - exporter("__exportStar", __exportStar); - exporter("__createBinding", __createBinding); - exporter("__values", __values); - exporter("__read", __read); - exporter("__spread", __spread); - exporter("__spreadArrays", __spreadArrays); - exporter("__spreadArray", __spreadArray); - exporter("__await", __await); - exporter("__asyncGenerator", __asyncGenerator); - exporter("__asyncDelegator", __asyncDelegator); - exporter("__asyncValues", __asyncValues); - exporter("__makeTemplateObject", __makeTemplateObject); - exporter("__importStar", __importStar); - exporter("__importDefault", __importDefault); - exporter("__classPrivateFieldGet", __classPrivateFieldGet); - exporter("__classPrivateFieldSet", __classPrivateFieldSet); -}); +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global global, define, System, Reflect, Promise */ +var __extends; +var __assign; +var __rest; +var __decorate; +var __param; +var __metadata; +var __awaiter; +var __generator; +var __exportStar; +var __values; +var __read; +var __spread; +var __spreadArrays; +var __spreadArray; +var __await; +var __asyncGenerator; +var __asyncDelegator; +var __asyncValues; +var __makeTemplateObject; +var __importStar; +var __importDefault; +var __classPrivateFieldGet; +var __classPrivateFieldSet; +var __createBinding; +(function (factory) { + var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; + if (typeof define === "function" && define.amd) { + define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); }); + } + else if ( true && typeof module.exports === "object") { + factory(createExporter(root, createExporter(module.exports))); + } + else { + factory(createExporter(root)); + } + function createExporter(exports, previous) { + if (exports !== root) { + if (typeof Object.create === "function") { + Object.defineProperty(exports, "__esModule", { value: true }); + } + else { + exports.__esModule = true; + } + } + return function (id, v) { return exports[id] = previous ? previous(id, v) : v; }; + } +}) +(function (exporter) { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + + __extends = function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + + __assign = Object.assign || function (t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + + __rest = function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; + }; + + __decorate = function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; + }; + + __param = function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } + }; + + __metadata = function (metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); + }; + + __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()); + }); + }; + + __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 }; + } + }; + + __exportStar = function(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); + }; + + __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]; + }); + + __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."); + }; + + __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; + }; + + /** @deprecated */ + __spread = function () { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; + }; + + /** @deprecated */ + __spreadArrays = function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; + }; + + __spreadArray = function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); + }; + + __await = function (v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); + }; + + __asyncGenerator = function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } + }; + + __asyncDelegator = function (o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } + }; + + __asyncValues = function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } + }; + + __makeTemplateObject = function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; + }; + + var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + }) : function(o, v) { + o["default"] = v; + }; + + __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; + }; + + __importDefault = function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + + __classPrivateFieldGet = function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); + }; + + __classPrivateFieldSet = function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; + }; + + exporter("__extends", __extends); + exporter("__assign", __assign); + exporter("__rest", __rest); + exporter("__decorate", __decorate); + exporter("__param", __param); + exporter("__metadata", __metadata); + exporter("__awaiter", __awaiter); + exporter("__generator", __generator); + exporter("__exportStar", __exportStar); + exporter("__createBinding", __createBinding); + exporter("__values", __values); + exporter("__read", __read); + exporter("__spread", __spread); + exporter("__spreadArrays", __spreadArrays); + exporter("__spreadArray", __spreadArray); + exporter("__await", __await); + exporter("__asyncGenerator", __asyncGenerator); + exporter("__asyncDelegator", __asyncDelegator); + exporter("__asyncValues", __asyncValues); + exporter("__makeTemplateObject", __makeTemplateObject); + exporter("__importStar", __importStar); + exporter("__importDefault", __importDefault); + exporter("__classPrivateFieldGet", __classPrivateFieldGet); + exporter("__classPrivateFieldSet", __classPrivateFieldSet); +}); /***/ }), @@ -85838,1966 +85838,1966 @@ exports.parseURL = __nccwpck_require__(33).parseURL; /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; + +const punycode = __nccwpck_require__(5477); +const tr46 = __nccwpck_require__(2299); + +const specialSchemes = { + ftp: 21, + file: null, + gopher: 70, + http: 80, + https: 443, + ws: 80, + wss: 443 +}; + +const failure = Symbol("failure"); + +function countSymbols(str) { + return punycode.ucs2.decode(str).length; +} + +function at(input, idx) { + const c = input[idx]; + return isNaN(c) ? undefined : String.fromCodePoint(c); +} + +function isASCIIDigit(c) { + return c >= 0x30 && c <= 0x39; +} + +function isASCIIAlpha(c) { + return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); +} + +function isASCIIAlphanumeric(c) { + return isASCIIAlpha(c) || isASCIIDigit(c); +} + +function isASCIIHex(c) { + return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66); +} + +function isSingleDot(buffer) { + return buffer === "." || buffer.toLowerCase() === "%2e"; +} + +function isDoubleDot(buffer) { + buffer = buffer.toLowerCase(); + return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e"; +} + +function isWindowsDriveLetterCodePoints(cp1, cp2) { + return isASCIIAlpha(cp1) && (cp2 === 58 || cp2 === 124); +} + +function isWindowsDriveLetterString(string) { + return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|"); +} + +function isNormalizedWindowsDriveLetterString(string) { + return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && string[1] === ":"; +} + +function containsForbiddenHostCodePoint(string) { + return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/) !== -1; +} + +function containsForbiddenHostCodePointExcludingPercent(string) { + return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/) !== -1; +} + +function isSpecialScheme(scheme) { + return specialSchemes[scheme] !== undefined; +} + +function isSpecial(url) { + return isSpecialScheme(url.scheme); +} + +function defaultPort(scheme) { + return specialSchemes[scheme]; +} + +function percentEncode(c) { + let hex = c.toString(16).toUpperCase(); + if (hex.length === 1) { + hex = "0" + hex; + } + + return "%" + hex; +} + +function utf8PercentEncode(c) { + const buf = new Buffer(c); + + let str = ""; + + for (let i = 0; i < buf.length; ++i) { + str += percentEncode(buf[i]); + } + + return str; +} + +function utf8PercentDecode(str) { + const input = new Buffer(str); + const output = []; + for (let i = 0; i < input.length; ++i) { + if (input[i] !== 37) { + output.push(input[i]); + } else if (input[i] === 37 && isASCIIHex(input[i + 1]) && isASCIIHex(input[i + 2])) { + output.push(parseInt(input.slice(i + 1, i + 3).toString(), 16)); + i += 2; + } else { + output.push(input[i]); + } + } + return new Buffer(output).toString(); +} + +function isC0ControlPercentEncode(c) { + return c <= 0x1F || c > 0x7E; +} + +const extraPathPercentEncodeSet = new Set([32, 34, 35, 60, 62, 63, 96, 123, 125]); +function isPathPercentEncode(c) { + return isC0ControlPercentEncode(c) || extraPathPercentEncodeSet.has(c); +} + +const extraUserinfoPercentEncodeSet = + new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]); +function isUserinfoPercentEncode(c) { + return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c); +} + +function percentEncodeChar(c, encodeSetPredicate) { + const cStr = String.fromCodePoint(c); + + if (encodeSetPredicate(c)) { + return utf8PercentEncode(cStr); + } + + return cStr; +} + +function parseIPv4Number(input) { + let R = 10; + + if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") { + input = input.substring(2); + R = 16; + } else if (input.length >= 2 && input.charAt(0) === "0") { + input = input.substring(1); + R = 8; + } + + if (input === "") { + return 0; + } + + const regex = R === 10 ? /[^0-9]/ : (R === 16 ? /[^0-9A-Fa-f]/ : /[^0-7]/); + if (regex.test(input)) { + return failure; + } + + return parseInt(input, R); +} + +function parseIPv4(input) { + const parts = input.split("."); + if (parts[parts.length - 1] === "") { + if (parts.length > 1) { + parts.pop(); + } + } + + if (parts.length > 4) { + return input; + } + + const numbers = []; + for (const part of parts) { + if (part === "") { + return input; + } + const n = parseIPv4Number(part); + if (n === failure) { + return input; + } + + numbers.push(n); + } + + for (let i = 0; i < numbers.length - 1; ++i) { + if (numbers[i] > 255) { + return failure; + } + } + if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) { + return failure; + } + + let ipv4 = numbers.pop(); + let counter = 0; + + for (const n of numbers) { + ipv4 += n * Math.pow(256, 3 - counter); + ++counter; + } + + return ipv4; +} + +function serializeIPv4(address) { + let output = ""; + let n = address; + + for (let i = 1; i <= 4; ++i) { + output = String(n % 256) + output; + if (i !== 4) { + output = "." + output; + } + n = Math.floor(n / 256); + } + + return output; +} + +function parseIPv6(input) { + const address = [0, 0, 0, 0, 0, 0, 0, 0]; + let pieceIndex = 0; + let compress = null; + let pointer = 0; + + input = punycode.ucs2.decode(input); + + if (input[pointer] === 58) { + if (input[pointer + 1] !== 58) { + return failure; + } + + pointer += 2; + ++pieceIndex; + compress = pieceIndex; + } + + while (pointer < input.length) { + if (pieceIndex === 8) { + return failure; + } + + if (input[pointer] === 58) { + if (compress !== null) { + return failure; + } + ++pointer; + ++pieceIndex; + compress = pieceIndex; + continue; + } + + let value = 0; + let length = 0; + + while (length < 4 && isASCIIHex(input[pointer])) { + value = value * 0x10 + parseInt(at(input, pointer), 16); + ++pointer; + ++length; + } + + if (input[pointer] === 46) { + if (length === 0) { + return failure; + } + + pointer -= length; + + if (pieceIndex > 6) { + return failure; + } + + let numbersSeen = 0; + + while (input[pointer] !== undefined) { + let ipv4Piece = null; + + if (numbersSeen > 0) { + if (input[pointer] === 46 && numbersSeen < 4) { + ++pointer; + } else { + return failure; + } + } + + if (!isASCIIDigit(input[pointer])) { + return failure; + } + + while (isASCIIDigit(input[pointer])) { + const number = parseInt(at(input, pointer)); + if (ipv4Piece === null) { + ipv4Piece = number; + } else if (ipv4Piece === 0) { + return failure; + } else { + ipv4Piece = ipv4Piece * 10 + number; + } + if (ipv4Piece > 255) { + return failure; + } + ++pointer; + } + + address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece; + + ++numbersSeen; + + if (numbersSeen === 2 || numbersSeen === 4) { + ++pieceIndex; + } + } + + if (numbersSeen !== 4) { + return failure; + } + + break; + } else if (input[pointer] === 58) { + ++pointer; + if (input[pointer] === undefined) { + return failure; + } + } else if (input[pointer] !== undefined) { + return failure; + } + + address[pieceIndex] = value; + ++pieceIndex; + } + + if (compress !== null) { + let swaps = pieceIndex - compress; + pieceIndex = 7; + while (pieceIndex !== 0 && swaps > 0) { + const temp = address[compress + swaps - 1]; + address[compress + swaps - 1] = address[pieceIndex]; + address[pieceIndex] = temp; + --pieceIndex; + --swaps; + } + } else if (compress === null && pieceIndex !== 8) { + return failure; + } + + return address; +} + +function serializeIPv6(address) { + let output = ""; + const seqResult = findLongestZeroSequence(address); + const compress = seqResult.idx; + let ignore0 = false; + + for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) { + if (ignore0 && address[pieceIndex] === 0) { + continue; + } else if (ignore0) { + ignore0 = false; + } + + if (compress === pieceIndex) { + const separator = pieceIndex === 0 ? "::" : ":"; + output += separator; + ignore0 = true; + continue; + } + + output += address[pieceIndex].toString(16); + + if (pieceIndex !== 7) { + output += ":"; + } + } + + return output; +} + +function parseHost(input, isSpecialArg) { + if (input[0] === "[") { + if (input[input.length - 1] !== "]") { + return failure; + } + + return parseIPv6(input.substring(1, input.length - 1)); + } + + if (!isSpecialArg) { + return parseOpaqueHost(input); + } + + const domain = utf8PercentDecode(input); + const asciiDomain = tr46.toASCII(domain, false, tr46.PROCESSING_OPTIONS.NONTRANSITIONAL, false); + if (asciiDomain === null) { + return failure; + } + + if (containsForbiddenHostCodePoint(asciiDomain)) { + return failure; + } + + const ipv4Host = parseIPv4(asciiDomain); + if (typeof ipv4Host === "number" || ipv4Host === failure) { + return ipv4Host; + } + + return asciiDomain; +} + +function parseOpaqueHost(input) { + if (containsForbiddenHostCodePointExcludingPercent(input)) { + return failure; + } + + let output = ""; + const decoded = punycode.ucs2.decode(input); + for (let i = 0; i < decoded.length; ++i) { + output += percentEncodeChar(decoded[i], isC0ControlPercentEncode); + } + return output; +} + +function findLongestZeroSequence(arr) { + let maxIdx = null; + let maxLen = 1; // only find elements > 1 + let currStart = null; + let currLen = 0; + + for (let i = 0; i < arr.length; ++i) { + if (arr[i] !== 0) { + if (currLen > maxLen) { + maxIdx = currStart; + maxLen = currLen; + } + + currStart = null; + currLen = 0; + } else { + if (currStart === null) { + currStart = i; + } + ++currLen; + } + } + + // if trailing zeros + if (currLen > maxLen) { + maxIdx = currStart; + maxLen = currLen; + } + + return { + idx: maxIdx, + len: maxLen + }; +} + +function serializeHost(host) { + if (typeof host === "number") { + return serializeIPv4(host); + } + + // IPv6 serializer + if (host instanceof Array) { + return "[" + serializeIPv6(host) + "]"; + } + + return host; +} + +function trimControlChars(url) { + return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, ""); +} + +function trimTabAndNewline(url) { + return url.replace(/\u0009|\u000A|\u000D/g, ""); +} + +function shortenPath(url) { + const path = url.path; + if (path.length === 0) { + return; + } + if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) { + return; + } + + path.pop(); +} + +function includesCredentials(url) { + return url.username !== "" || url.password !== ""; +} + +function cannotHaveAUsernamePasswordPort(url) { + return url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file"; +} + +function isNormalizedWindowsDriveLetter(string) { + return /^[A-Za-z]:$/.test(string); +} + +function URLStateMachine(input, base, encodingOverride, url, stateOverride) { + this.pointer = 0; + this.input = input; + this.base = base || null; + this.encodingOverride = encodingOverride || "utf-8"; + this.stateOverride = stateOverride; + this.url = url; + this.failure = false; + this.parseError = false; + + if (!this.url) { + this.url = { + scheme: "", + username: "", + password: "", + host: null, + port: null, + path: [], + query: null, + fragment: null, + + cannotBeABaseURL: false + }; + + const res = trimControlChars(this.input); + if (res !== this.input) { + this.parseError = true; + } + this.input = res; + } + + const res = trimTabAndNewline(this.input); + if (res !== this.input) { + this.parseError = true; + } + this.input = res; + + this.state = stateOverride || "scheme start"; + + this.buffer = ""; + this.atFlag = false; + this.arrFlag = false; + this.passwordTokenSeenFlag = false; + + this.input = punycode.ucs2.decode(this.input); + + for (; this.pointer <= this.input.length; ++this.pointer) { + const c = this.input[this.pointer]; + const cStr = isNaN(c) ? undefined : String.fromCodePoint(c); + + // exec state machine + const ret = this["parse " + this.state](c, cStr); + if (!ret) { + break; // terminate algorithm + } else if (ret === failure) { + this.failure = true; + break; + } + } +} + +URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) { + if (isASCIIAlpha(c)) { + this.buffer += cStr.toLowerCase(); + this.state = "scheme"; + } else if (!this.stateOverride) { + this.state = "no scheme"; + --this.pointer; + } else { + this.parseError = true; + return failure; + } + + return true; +}; + +URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) { + if (isASCIIAlphanumeric(c) || c === 43 || c === 45 || c === 46) { + this.buffer += cStr.toLowerCase(); + } else if (c === 58) { + if (this.stateOverride) { + if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) { + return false; + } + + if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) { + return false; + } + + if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") { + return false; + } + + if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) { + return false; + } + } + this.url.scheme = this.buffer; + this.buffer = ""; + if (this.stateOverride) { + return false; + } + if (this.url.scheme === "file") { + if (this.input[this.pointer + 1] !== 47 || this.input[this.pointer + 2] !== 47) { + this.parseError = true; + } + this.state = "file"; + } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) { + this.state = "special relative or authority"; + } else if (isSpecial(this.url)) { + this.state = "special authority slashes"; + } else if (this.input[this.pointer + 1] === 47) { + this.state = "path or authority"; + ++this.pointer; + } else { + this.url.cannotBeABaseURL = true; + this.url.path.push(""); + this.state = "cannot-be-a-base-URL path"; + } + } else if (!this.stateOverride) { + this.buffer = ""; + this.state = "no scheme"; + this.pointer = -1; + } else { + this.parseError = true; + return failure; + } + + return true; +}; + +URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) { + if (this.base === null || (this.base.cannotBeABaseURL && c !== 35)) { + return failure; + } else if (this.base.cannotBeABaseURL && c === 35) { + this.url.scheme = this.base.scheme; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.url.cannotBeABaseURL = true; + this.state = "fragment"; + } else if (this.base.scheme === "file") { + this.state = "file"; + --this.pointer; + } else { + this.state = "relative"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) { + if (c === 47 && this.input[this.pointer + 1] === 47) { + this.state = "special authority ignore slashes"; + ++this.pointer; + } else { + this.parseError = true; + this.state = "relative"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) { + if (c === 47) { + this.state = "authority"; + } else { + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse relative"] = function parseRelative(c) { + this.url.scheme = this.base.scheme; + if (isNaN(c)) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + } else if (c === 47) { + this.state = "relative slash"; + } else if (c === 63) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.state = "fragment"; + } else if (isSpecial(this.url) && c === 92) { + this.parseError = true; + this.state = "relative slash"; + } else { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.url.path = this.base.path.slice(0, this.base.path.length - 1); + + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) { + if (isSpecial(this.url) && (c === 47 || c === 92)) { + if (c === 92) { + this.parseError = true; + } + this.state = "special authority ignore slashes"; + } else if (c === 47) { + this.state = "authority"; + } else { + this.url.username = this.base.username; + this.url.password = this.base.password; + this.url.host = this.base.host; + this.url.port = this.base.port; + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) { + if (c === 47 && this.input[this.pointer + 1] === 47) { + this.state = "special authority ignore slashes"; + ++this.pointer; + } else { + this.parseError = true; + this.state = "special authority ignore slashes"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) { + if (c !== 47 && c !== 92) { + this.state = "authority"; + --this.pointer; + } else { + this.parseError = true; + } + + return true; +}; + +URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) { + if (c === 64) { + this.parseError = true; + if (this.atFlag) { + this.buffer = "%40" + this.buffer; + } + this.atFlag = true; + + // careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars + const len = countSymbols(this.buffer); + for (let pointer = 0; pointer < len; ++pointer) { + const codePoint = this.buffer.codePointAt(pointer); + + if (codePoint === 58 && !this.passwordTokenSeenFlag) { + this.passwordTokenSeenFlag = true; + continue; + } + const encodedCodePoints = percentEncodeChar(codePoint, isUserinfoPercentEncode); + if (this.passwordTokenSeenFlag) { + this.url.password += encodedCodePoints; + } else { + this.url.username += encodedCodePoints; + } + } + this.buffer = ""; + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92)) { + if (this.atFlag && this.buffer === "") { + this.parseError = true; + return failure; + } + this.pointer -= countSymbols(this.buffer) + 1; + this.buffer = ""; + this.state = "host"; + } else { + this.buffer += cStr; + } + + return true; +}; + +URLStateMachine.prototype["parse hostname"] = +URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) { + if (this.stateOverride && this.url.scheme === "file") { + --this.pointer; + this.state = "file host"; + } else if (c === 58 && !this.arrFlag) { + if (this.buffer === "") { + this.parseError = true; + return failure; + } + + const host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + + this.url.host = host; + this.buffer = ""; + this.state = "port"; + if (this.stateOverride === "hostname") { + return false; + } + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92)) { + --this.pointer; + if (isSpecial(this.url) && this.buffer === "") { + this.parseError = true; + return failure; + } else if (this.stateOverride && this.buffer === "" && + (includesCredentials(this.url) || this.url.port !== null)) { + this.parseError = true; + return false; + } + + const host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + + this.url.host = host; + this.buffer = ""; + this.state = "path start"; + if (this.stateOverride) { + return false; + } + } else { + if (c === 91) { + this.arrFlag = true; + } else if (c === 93) { + this.arrFlag = false; + } + this.buffer += cStr; + } + + return true; +}; + +URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) { + if (isASCIIDigit(c)) { + this.buffer += cStr; + } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || + (isSpecial(this.url) && c === 92) || + this.stateOverride) { + if (this.buffer !== "") { + const port = parseInt(this.buffer); + if (port > Math.pow(2, 16) - 1) { + this.parseError = true; + return failure; + } + this.url.port = port === defaultPort(this.url.scheme) ? null : port; + this.buffer = ""; + } + if (this.stateOverride) { + return false; + } + this.state = "path start"; + --this.pointer; + } else { + this.parseError = true; + return failure; + } + + return true; +}; + +const fileOtherwiseCodePoints = new Set([47, 92, 63, 35]); + +URLStateMachine.prototype["parse file"] = function parseFile(c) { + this.url.scheme = "file"; + + if (c === 47 || c === 92) { + if (c === 92) { + this.parseError = true; + } + this.state = "file slash"; + } else if (this.base !== null && this.base.scheme === "file") { + if (isNaN(c)) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + } else if (c === 63) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + this.url.query = this.base.query; + this.url.fragment = ""; + this.state = "fragment"; + } else { + if (this.input.length - this.pointer - 1 === 0 || // remaining consists of 0 code points + !isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) || + (this.input.length - this.pointer - 1 >= 2 && // remaining has at least 2 code points + !fileOtherwiseCodePoints.has(this.input[this.pointer + 2]))) { + this.url.host = this.base.host; + this.url.path = this.base.path.slice(); + shortenPath(this.url); + } else { + this.parseError = true; + } + + this.state = "path"; + --this.pointer; + } + } else { + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) { + if (c === 47 || c === 92) { + if (c === 92) { + this.parseError = true; + } + this.state = "file host"; + } else { + if (this.base !== null && this.base.scheme === "file") { + if (isNormalizedWindowsDriveLetterString(this.base.path[0])) { + this.url.path.push(this.base.path[0]); + } else { + this.url.host = this.base.host; + } + } + this.state = "path"; + --this.pointer; + } + + return true; +}; + +URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) { + if (isNaN(c) || c === 47 || c === 92 || c === 63 || c === 35) { + --this.pointer; + if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) { + this.parseError = true; + this.state = "path"; + } else if (this.buffer === "") { + this.url.host = ""; + if (this.stateOverride) { + return false; + } + this.state = "path start"; + } else { + let host = parseHost(this.buffer, isSpecial(this.url)); + if (host === failure) { + return failure; + } + if (host === "localhost") { + host = ""; + } + this.url.host = host; + + if (this.stateOverride) { + return false; + } + + this.buffer = ""; + this.state = "path start"; + } + } else { + this.buffer += cStr; + } + + return true; +}; + +URLStateMachine.prototype["parse path start"] = function parsePathStart(c) { + if (isSpecial(this.url)) { + if (c === 92) { + this.parseError = true; + } + this.state = "path"; + + if (c !== 47 && c !== 92) { + --this.pointer; + } + } else if (!this.stateOverride && c === 63) { + this.url.query = ""; + this.state = "query"; + } else if (!this.stateOverride && c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } else if (c !== undefined) { + this.state = "path"; + if (c !== 47) { + --this.pointer; + } + } + + return true; +}; + +URLStateMachine.prototype["parse path"] = function parsePath(c) { + if (isNaN(c) || c === 47 || (isSpecial(this.url) && c === 92) || + (!this.stateOverride && (c === 63 || c === 35))) { + if (isSpecial(this.url) && c === 92) { + this.parseError = true; + } + + if (isDoubleDot(this.buffer)) { + shortenPath(this.url); + if (c !== 47 && !(isSpecial(this.url) && c === 92)) { + this.url.path.push(""); + } + } else if (isSingleDot(this.buffer) && c !== 47 && + !(isSpecial(this.url) && c === 92)) { + this.url.path.push(""); + } else if (!isSingleDot(this.buffer)) { + if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) { + if (this.url.host !== "" && this.url.host !== null) { + this.parseError = true; + this.url.host = ""; + } + this.buffer = this.buffer[0] + ":"; + } + this.url.path.push(this.buffer); + } + this.buffer = ""; + if (this.url.scheme === "file" && (c === undefined || c === 63 || c === 35)) { + while (this.url.path.length > 1 && this.url.path[0] === "") { + this.parseError = true; + this.url.path.shift(); + } + } + if (c === 63) { + this.url.query = ""; + this.state = "query"; + } + if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } + } else { + // TODO: If c is not a URL code point and not "%", parse error. + + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + this.buffer += percentEncodeChar(c, isPathPercentEncode); + } + + return true; +}; + +URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCannotBeABaseURLPath(c) { + if (c === 63) { + this.url.query = ""; + this.state = "query"; + } else if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } else { + // TODO: Add: not a URL code point + if (!isNaN(c) && c !== 37) { + this.parseError = true; + } + + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + if (!isNaN(c)) { + this.url.path[0] = this.url.path[0] + percentEncodeChar(c, isC0ControlPercentEncode); + } + } + + return true; +}; + +URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) { + if (isNaN(c) || (!this.stateOverride && c === 35)) { + if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") { + this.encodingOverride = "utf-8"; + } + + const buffer = new Buffer(this.buffer); // TODO: Use encoding override instead + for (let i = 0; i < buffer.length; ++i) { + if (buffer[i] < 0x21 || buffer[i] > 0x7E || buffer[i] === 0x22 || buffer[i] === 0x23 || + buffer[i] === 0x3C || buffer[i] === 0x3E) { + this.url.query += percentEncode(buffer[i]); + } else { + this.url.query += String.fromCodePoint(buffer[i]); + } + } + + this.buffer = ""; + if (c === 35) { + this.url.fragment = ""; + this.state = "fragment"; + } + } else { + // TODO: If c is not a URL code point and not "%", parse error. + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + this.buffer += cStr; + } + + return true; +}; + +URLStateMachine.prototype["parse fragment"] = function parseFragment(c) { + if (isNaN(c)) { // do nothing + } else if (c === 0x0) { + this.parseError = true; + } else { + // TODO: If c is not a URL code point and not "%", parse error. + if (c === 37 && + (!isASCIIHex(this.input[this.pointer + 1]) || + !isASCIIHex(this.input[this.pointer + 2]))) { + this.parseError = true; + } + + this.url.fragment += percentEncodeChar(c, isC0ControlPercentEncode); + } + + return true; +}; + +function serializeURL(url, excludeFragment) { + let output = url.scheme + ":"; + if (url.host !== null) { + output += "//"; + + if (url.username !== "" || url.password !== "") { + output += url.username; + if (url.password !== "") { + output += ":" + url.password; + } + output += "@"; + } + + output += serializeHost(url.host); + + if (url.port !== null) { + output += ":" + url.port; + } + } else if (url.host === null && url.scheme === "file") { + output += "//"; + } + + if (url.cannotBeABaseURL) { + output += url.path[0]; + } else { + for (const string of url.path) { + output += "/" + string; + } + } + + if (url.query !== null) { + output += "?" + url.query; + } + + if (!excludeFragment && url.fragment !== null) { + output += "#" + url.fragment; + } + + return output; +} + +function serializeOrigin(tuple) { + let result = tuple.scheme + "://"; + result += serializeHost(tuple.host); + + if (tuple.port !== null) { + result += ":" + tuple.port; + } + + return result; +} + +module.exports.serializeURL = serializeURL; + +module.exports.serializeURLOrigin = function (url) { + // https://url.spec.whatwg.org/#concept-url-origin + switch (url.scheme) { + case "blob": + try { + return module.exports.serializeURLOrigin(module.exports.parseURL(url.path[0])); + } catch (e) { + // serializing an opaque origin returns "null" + return "null"; + } + case "ftp": + case "gopher": + case "http": + case "https": + case "ws": + case "wss": + return serializeOrigin({ + scheme: url.scheme, + host: url.host, + port: url.port + }); + case "file": + // spec says "exercise to the reader", chrome says "file://" + return "file://"; + default: + // serializing an opaque origin returns "null" + return "null"; + } +}; + +module.exports.basicURLParse = function (input, options) { + if (options === undefined) { + options = {}; + } + + const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride); + if (usm.failure) { + return "failure"; + } + + return usm.url; +}; + +module.exports.setTheUsername = function (url, username) { + url.username = ""; + const decoded = punycode.ucs2.decode(username); + for (let i = 0; i < decoded.length; ++i) { + url.username += percentEncodeChar(decoded[i], isUserinfoPercentEncode); + } +}; + +module.exports.setThePassword = function (url, password) { + url.password = ""; + const decoded = punycode.ucs2.decode(password); + for (let i = 0; i < decoded.length; ++i) { + url.password += percentEncodeChar(decoded[i], isUserinfoPercentEncode); + } +}; + +module.exports.serializeHost = serializeHost; + +module.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort; + +module.exports.serializeInteger = function (integer) { + return String(integer); +}; + +module.exports.parseURL = function (input, options) { + if (options === undefined) { + options = {}; + } + + // We don't handle blobs, so this just delegates: + return module.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride }); +}; -const punycode = __nccwpck_require__(5477); -const tr46 = __nccwpck_require__(2299); -const specialSchemes = { - ftp: 21, - file: null, - gopher: 70, - http: 80, - https: 443, - ws: 80, - wss: 443 -}; +/***/ }), -const failure = Symbol("failure"); +/***/ 276: +/***/ ((module) => { -function countSymbols(str) { - return punycode.ucs2.decode(str).length; -} +"use strict"; -function at(input, idx) { - const c = input[idx]; - return isNaN(c) ? undefined : String.fromCodePoint(c); -} -function isASCIIDigit(c) { - return c >= 0x30 && c <= 0x39; -} +module.exports.mixin = function mixin(target, source) { + const keys = Object.getOwnPropertyNames(source); + for (let i = 0; i < keys.length; ++i) { + Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i])); + } +}; -function isASCIIAlpha(c) { - return (c >= 0x41 && c <= 0x5A) || (c >= 0x61 && c <= 0x7A); -} +module.exports.wrapperSymbol = Symbol("wrapper"); +module.exports.implSymbol = Symbol("impl"); -function isASCIIAlphanumeric(c) { - return isASCIIAlpha(c) || isASCIIDigit(c); -} +module.exports.wrapperForImpl = function (impl) { + return impl[module.exports.wrapperSymbol]; +}; -function isASCIIHex(c) { - return isASCIIDigit(c) || (c >= 0x41 && c <= 0x46) || (c >= 0x61 && c <= 0x66); -} +module.exports.implForWrapper = function (wrapper) { + return wrapper[module.exports.implSymbol]; +}; -function isSingleDot(buffer) { - return buffer === "." || buffer.toLowerCase() === "%2e"; -} -function isDoubleDot(buffer) { - buffer = buffer.toLowerCase(); - return buffer === ".." || buffer === "%2e." || buffer === ".%2e" || buffer === "%2e%2e"; -} -function isWindowsDriveLetterCodePoints(cp1, cp2) { - return isASCIIAlpha(cp1) && (cp2 === 58 || cp2 === 124); -} +/***/ }), -function isWindowsDriveLetterString(string) { - return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && (string[1] === ":" || string[1] === "|"); -} +/***/ 9975: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { -function isNormalizedWindowsDriveLetterString(string) { - return string.length === 2 && isASCIIAlpha(string.codePointAt(0)) && string[1] === ":"; -} +"use strict"; +/*eslint no-var:0, prefer-arrow-callback: 0, object-shorthand: 0 */ -function containsForbiddenHostCodePoint(string) { - return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/) !== -1; -} -function containsForbiddenHostCodePointExcludingPercent(string) { - return string.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/) !== -1; -} -function isSpecialScheme(scheme) { - return specialSchemes[scheme] !== undefined; -} +var Punycode = __nccwpck_require__(5477); -function isSpecial(url) { - return isSpecialScheme(url.scheme); -} -function defaultPort(scheme) { - return specialSchemes[scheme]; -} +var internals = {}; -function percentEncode(c) { - let hex = c.toString(16).toUpperCase(); - if (hex.length === 1) { - hex = "0" + hex; - } - return "%" + hex; -} +// +// Read rules from file. +// +internals.rules = (__nccwpck_require__(3704).map)(function (rule) { -function utf8PercentEncode(c) { - const buf = new Buffer(c); + return { + rule: rule, + suffix: rule.replace(/^(\*\.|\!)/, ''), + punySuffix: -1, + wildcard: rule.charAt(0) === '*', + exception: rule.charAt(0) === '!' + }; +}); - let str = ""; - for (let i = 0; i < buf.length; ++i) { - str += percentEncode(buf[i]); - } +// +// Check is given string ends with `suffix`. +// +internals.endsWith = function (str, suffix) { - return str; -} + return str.indexOf(suffix, str.length - suffix.length) !== -1; +}; -function utf8PercentDecode(str) { - const input = new Buffer(str); - const output = []; - for (let i = 0; i < input.length; ++i) { - if (input[i] !== 37) { - output.push(input[i]); - } else if (input[i] === 37 && isASCIIHex(input[i + 1]) && isASCIIHex(input[i + 2])) { - output.push(parseInt(input.slice(i + 1, i + 3).toString(), 16)); - i += 2; - } else { - output.push(input[i]); - } - } - return new Buffer(output).toString(); -} -function isC0ControlPercentEncode(c) { - return c <= 0x1F || c > 0x7E; -} +// +// Find rule for a given domain. +// +internals.findRule = function (domain) { -const extraPathPercentEncodeSet = new Set([32, 34, 35, 60, 62, 63, 96, 123, 125]); -function isPathPercentEncode(c) { - return isC0ControlPercentEncode(c) || extraPathPercentEncodeSet.has(c); -} + var punyDomain = Punycode.toASCII(domain); + return internals.rules.reduce(function (memo, rule) { -const extraUserinfoPercentEncodeSet = - new Set([47, 58, 59, 61, 64, 91, 92, 93, 94, 124]); -function isUserinfoPercentEncode(c) { - return isPathPercentEncode(c) || extraUserinfoPercentEncodeSet.has(c); -} + if (rule.punySuffix === -1){ + rule.punySuffix = Punycode.toASCII(rule.suffix); + } + if (!internals.endsWith(punyDomain, '.' + rule.punySuffix) && punyDomain !== rule.punySuffix) { + return memo; + } + // This has been commented out as it never seems to run. This is because + // sub tlds always appear after their parents and we never find a shorter + // match. + //if (memo) { + // var memoSuffix = Punycode.toASCII(memo.suffix); + // if (memoSuffix.length >= punySuffix.length) { + // return memo; + // } + //} + return rule; + }, null); +}; -function percentEncodeChar(c, encodeSetPredicate) { - const cStr = String.fromCodePoint(c); - if (encodeSetPredicate(c)) { - return utf8PercentEncode(cStr); - } +// +// Error codes and messages. +// +exports.errorCodes = { + DOMAIN_TOO_SHORT: 'Domain name too short.', + DOMAIN_TOO_LONG: 'Domain name too long. It should be no more than 255 chars.', + LABEL_STARTS_WITH_DASH: 'Domain name label can not start with a dash.', + LABEL_ENDS_WITH_DASH: 'Domain name label can not end with a dash.', + LABEL_TOO_LONG: 'Domain name label should be at most 63 chars long.', + LABEL_TOO_SHORT: 'Domain name label should be at least 1 character long.', + LABEL_INVALID_CHARS: 'Domain name label can only contain alphanumeric characters or dashes.' +}; - return cStr; -} -function parseIPv4Number(input) { - let R = 10; +// +// Validate domain name and throw if not valid. +// +// From wikipedia: +// +// Hostnames are composed of series of labels concatenated with dots, as are all +// domain names. Each label must be between 1 and 63 characters long, and the +// entire hostname (including the delimiting dots) has a maximum of 255 chars. +// +// Allowed chars: +// +// * `a-z` +// * `0-9` +// * `-` but not as a starting or ending character +// * `.` as a separator for the textual portions of a domain name +// +// * http://en.wikipedia.org/wiki/Domain_name +// * http://en.wikipedia.org/wiki/Hostname +// +internals.validate = function (input) { - if (input.length >= 2 && input.charAt(0) === "0" && input.charAt(1).toLowerCase() === "x") { - input = input.substring(2); - R = 16; - } else if (input.length >= 2 && input.charAt(0) === "0") { - input = input.substring(1); - R = 8; - } + // Before we can validate we need to take care of IDNs with unicode chars. + var ascii = Punycode.toASCII(input); - if (input === "") { - return 0; + if (ascii.length < 1) { + return 'DOMAIN_TOO_SHORT'; } - - const regex = R === 10 ? /[^0-9]/ : (R === 16 ? /[^0-9A-Fa-f]/ : /[^0-7]/); - if (regex.test(input)) { - return failure; + if (ascii.length > 255) { + return 'DOMAIN_TOO_LONG'; } - return parseInt(input, R); -} + // Check each part's length and allowed chars. + var labels = ascii.split('.'); + var label; -function parseIPv4(input) { - const parts = input.split("."); - if (parts[parts.length - 1] === "") { - if (parts.length > 1) { - parts.pop(); + for (var i = 0; i < labels.length; ++i) { + label = labels[i]; + if (!label.length) { + return 'LABEL_TOO_SHORT'; } - } - - if (parts.length > 4) { - return input; - } - - const numbers = []; - for (const part of parts) { - if (part === "") { - return input; + if (label.length > 63) { + return 'LABEL_TOO_LONG'; } - const n = parseIPv4Number(part); - if (n === failure) { - return input; + if (label.charAt(0) === '-') { + return 'LABEL_STARTS_WITH_DASH'; } - - numbers.push(n); - } - - for (let i = 0; i < numbers.length - 1; ++i) { - if (numbers[i] > 255) { - return failure; + if (label.charAt(label.length - 1) === '-') { + return 'LABEL_ENDS_WITH_DASH'; } - } - if (numbers[numbers.length - 1] >= Math.pow(256, 5 - numbers.length)) { - return failure; - } - - let ipv4 = numbers.pop(); - let counter = 0; - - for (const n of numbers) { - ipv4 += n * Math.pow(256, 3 - counter); - ++counter; - } - - return ipv4; -} - -function serializeIPv4(address) { - let output = ""; - let n = address; - - for (let i = 1; i <= 4; ++i) { - output = String(n % 256) + output; - if (i !== 4) { - output = "." + output; + if (!/^[a-z0-9\-]+$/.test(label)) { + return 'LABEL_INVALID_CHARS'; } - n = Math.floor(n / 256); } +}; - return output; -} -function parseIPv6(input) { - const address = [0, 0, 0, 0, 0, 0, 0, 0]; - let pieceIndex = 0; - let compress = null; - let pointer = 0; +// +// Public API +// - input = punycode.ucs2.decode(input); - if (input[pointer] === 58) { - if (input[pointer + 1] !== 58) { - return failure; - } +// +// Parse domain. +// +exports.parse = function (input) { - pointer += 2; - ++pieceIndex; - compress = pieceIndex; + if (typeof input !== 'string') { + throw new TypeError('Domain name must be a string.'); } - while (pointer < input.length) { - if (pieceIndex === 8) { - return failure; - } - - if (input[pointer] === 58) { - if (compress !== null) { - return failure; - } - ++pointer; - ++pieceIndex; - compress = pieceIndex; - continue; - } - - let value = 0; - let length = 0; - - while (length < 4 && isASCIIHex(input[pointer])) { - value = value * 0x10 + parseInt(at(input, pointer), 16); - ++pointer; - ++length; - } - - if (input[pointer] === 46) { - if (length === 0) { - return failure; - } - - pointer -= length; - - if (pieceIndex > 6) { - return failure; - } - - let numbersSeen = 0; - - while (input[pointer] !== undefined) { - let ipv4Piece = null; - - if (numbersSeen > 0) { - if (input[pointer] === 46 && numbersSeen < 4) { - ++pointer; - } else { - return failure; - } - } - - if (!isASCIIDigit(input[pointer])) { - return failure; - } - - while (isASCIIDigit(input[pointer])) { - const number = parseInt(at(input, pointer)); - if (ipv4Piece === null) { - ipv4Piece = number; - } else if (ipv4Piece === 0) { - return failure; - } else { - ipv4Piece = ipv4Piece * 10 + number; - } - if (ipv4Piece > 255) { - return failure; - } - ++pointer; - } - - address[pieceIndex] = address[pieceIndex] * 0x100 + ipv4Piece; - - ++numbersSeen; + // Force domain to lowercase. + var domain = input.slice(0).toLowerCase(); - if (numbersSeen === 2 || numbersSeen === 4) { - ++pieceIndex; - } - } + // Handle FQDN. + // TODO: Simply remove trailing dot? + if (domain.charAt(domain.length - 1) === '.') { + domain = domain.slice(0, domain.length - 1); + } - if (numbersSeen !== 4) { - return failure; + // Validate and sanitise input. + var error = internals.validate(domain); + if (error) { + return { + input: input, + error: { + message: exports.errorCodes[error], + code: error } + }; + } - break; - } else if (input[pointer] === 58) { - ++pointer; - if (input[pointer] === undefined) { - return failure; - } - } else if (input[pointer] !== undefined) { - return failure; - } + var parsed = { + input: input, + tld: null, + sld: null, + domain: null, + subdomain: null, + listed: false + }; - address[pieceIndex] = value; - ++pieceIndex; - } + var domainParts = domain.split('.'); - if (compress !== null) { - let swaps = pieceIndex - compress; - pieceIndex = 7; - while (pieceIndex !== 0 && swaps > 0) { - const temp = address[compress + swaps - 1]; - address[compress + swaps - 1] = address[pieceIndex]; - address[pieceIndex] = temp; - --pieceIndex; - --swaps; - } - } else if (compress === null && pieceIndex !== 8) { - return failure; + // Non-Internet TLD + if (domainParts[domainParts.length - 1] === 'local') { + return parsed; } - return address; -} - -function serializeIPv6(address) { - let output = ""; - const seqResult = findLongestZeroSequence(address); - const compress = seqResult.idx; - let ignore0 = false; + var handlePunycode = function () { - for (let pieceIndex = 0; pieceIndex <= 7; ++pieceIndex) { - if (ignore0 && address[pieceIndex] === 0) { - continue; - } else if (ignore0) { - ignore0 = false; + if (!/xn--/.test(domain)) { + return parsed; } - - if (compress === pieceIndex) { - const separator = pieceIndex === 0 ? "::" : ":"; - output += separator; - ignore0 = true; - continue; + if (parsed.domain) { + parsed.domain = Punycode.toASCII(parsed.domain); } + if (parsed.subdomain) { + parsed.subdomain = Punycode.toASCII(parsed.subdomain); + } + return parsed; + }; - output += address[pieceIndex].toString(16); + var rule = internals.findRule(domain); - if (pieceIndex !== 7) { - output += ":"; + // Unlisted tld. + if (!rule) { + if (domainParts.length < 2) { + return parsed; + } + parsed.tld = domainParts.pop(); + parsed.sld = domainParts.pop(); + parsed.domain = [parsed.sld, parsed.tld].join('.'); + if (domainParts.length) { + parsed.subdomain = domainParts.pop(); } + return handlePunycode(); } - return output; -} + // At this point we know the public suffix is listed. + parsed.listed = true; -function parseHost(input, isSpecialArg) { - if (input[0] === "[") { - if (input[input.length - 1] !== "]") { - return failure; - } + var tldParts = rule.suffix.split('.'); + var privateParts = domainParts.slice(0, domainParts.length - tldParts.length); - return parseIPv6(input.substring(1, input.length - 1)); + if (rule.exception) { + privateParts.push(tldParts.shift()); } - if (!isSpecialArg) { - return parseOpaqueHost(input); - } + parsed.tld = tldParts.join('.'); - const domain = utf8PercentDecode(input); - const asciiDomain = tr46.toASCII(domain, false, tr46.PROCESSING_OPTIONS.NONTRANSITIONAL, false); - if (asciiDomain === null) { - return failure; + if (!privateParts.length) { + return handlePunycode(); } - if (containsForbiddenHostCodePoint(asciiDomain)) { - return failure; + if (rule.wildcard) { + tldParts.unshift(privateParts.pop()); + parsed.tld = tldParts.join('.'); } - const ipv4Host = parseIPv4(asciiDomain); - if (typeof ipv4Host === "number" || ipv4Host === failure) { - return ipv4Host; + if (!privateParts.length) { + return handlePunycode(); } - return asciiDomain; -} - -function parseOpaqueHost(input) { - if (containsForbiddenHostCodePointExcludingPercent(input)) { - return failure; - } + parsed.sld = privateParts.pop(); + parsed.domain = [parsed.sld, parsed.tld].join('.'); - let output = ""; - const decoded = punycode.ucs2.decode(input); - for (let i = 0; i < decoded.length; ++i) { - output += percentEncodeChar(decoded[i], isC0ControlPercentEncode); + if (privateParts.length) { + parsed.subdomain = privateParts.join('.'); } - return output; -} -function findLongestZeroSequence(arr) { - let maxIdx = null; - let maxLen = 1; // only find elements > 1 - let currStart = null; - let currLen = 0; + return handlePunycode(); +}; - for (let i = 0; i < arr.length; ++i) { - if (arr[i] !== 0) { - if (currLen > maxLen) { - maxIdx = currStart; - maxLen = currLen; - } - currStart = null; - currLen = 0; - } else { - if (currStart === null) { - currStart = i; - } - ++currLen; - } - } +// +// Get domain. +// +exports.get = function (domain) { - // if trailing zeros - if (currLen > maxLen) { - maxIdx = currStart; - maxLen = currLen; + if (!domain) { + return null; } + return exports.parse(domain).domain || null; +}; - return { - idx: maxIdx, - len: maxLen - }; -} - -function serializeHost(host) { - if (typeof host === "number") { - return serializeIPv4(host); - } - // IPv6 serializer - if (host instanceof Array) { - return "[" + serializeIPv6(host) + "]"; - } +// +// Check whether domain belongs to a known public suffix. +// +exports.isValid = function (domain) { - return host; -} + var parsed = exports.parse(domain); + return Boolean(parsed.domain && parsed.listed); +}; -function trimControlChars(url) { - return url.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g, ""); -} -function trimTabAndNewline(url) { - return url.replace(/\u0009|\u000A|\u000D/g, ""); -} +/***/ }), -function shortenPath(url) { - const path = url.path; - if (path.length === 0) { - return; - } - if (url.scheme === "file" && path.length === 1 && isNormalizedWindowsDriveLetter(path[0])) { - return; - } +/***/ 2043: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - path.pop(); -} +;(function (sax) { // wrapper for non-node envs + sax.parser = function (strict, opt) { return new SAXParser(strict, opt) } + sax.SAXParser = SAXParser + sax.SAXStream = SAXStream + sax.createStream = createStream -function includesCredentials(url) { - return url.username !== "" || url.password !== ""; -} + // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. + // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), + // since that's the earliest that a buffer overrun could occur. This way, checks are + // as rare as required, but as often as necessary to ensure never crossing this bound. + // Furthermore, buffers are only tested at most once per write(), so passing a very + // large string into write() might have undesirable effects, but this is manageable by + // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme + // edge case, result in creating at most one complete copy of the string passed in. + // Set to Infinity to have unlimited buffers. + sax.MAX_BUFFER_LENGTH = 64 * 1024 -function cannotHaveAUsernamePasswordPort(url) { - return url.host === null || url.host === "" || url.cannotBeABaseURL || url.scheme === "file"; -} + var buffers = [ + 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', + 'procInstName', 'procInstBody', 'entity', 'attribName', + 'attribValue', 'cdata', 'script' + ] -function isNormalizedWindowsDriveLetter(string) { - return /^[A-Za-z]:$/.test(string); -} + sax.EVENTS = [ + 'text', + 'processinginstruction', + 'sgmldeclaration', + 'doctype', + 'comment', + 'opentagstart', + 'attribute', + 'opentag', + 'closetag', + 'opencdata', + 'cdata', + 'closecdata', + 'error', + 'end', + 'ready', + 'script', + 'opennamespace', + 'closenamespace' + ] -function URLStateMachine(input, base, encodingOverride, url, stateOverride) { - this.pointer = 0; - this.input = input; - this.base = base || null; - this.encodingOverride = encodingOverride || "utf-8"; - this.stateOverride = stateOverride; - this.url = url; - this.failure = false; - this.parseError = false; + function SAXParser (strict, opt) { + if (!(this instanceof SAXParser)) { + return new SAXParser(strict, opt) + } - if (!this.url) { - this.url = { - scheme: "", - username: "", - password: "", - host: null, - port: null, - path: [], - query: null, - fragment: null, + var parser = this + clearBuffers(parser) + parser.q = parser.c = '' + parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH + parser.opt = opt || {} + parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags + parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase' + parser.tags = [] + parser.closed = parser.closedRoot = parser.sawRoot = false + parser.tag = parser.error = null + parser.strict = !!strict + parser.noscript = !!(strict || parser.opt.noscript) + parser.state = S.BEGIN + parser.strictEntities = parser.opt.strictEntities + parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES) + parser.attribList = [] - cannotBeABaseURL: false - }; + // namespaces form a prototype chain. + // it always points at the current tag, + // which protos to its parent tag. + if (parser.opt.xmlns) { + parser.ns = Object.create(rootNS) + } - const res = trimControlChars(this.input); - if (res !== this.input) { - this.parseError = true; + // mostly just for error reporting + parser.trackPosition = parser.opt.position !== false + if (parser.trackPosition) { + parser.position = parser.line = parser.column = 0 } - this.input = res; + emit(parser, 'onready') } - const res = trimTabAndNewline(this.input); - if (res !== this.input) { - this.parseError = true; + if (!Object.create) { + Object.create = function (o) { + function F () {} + F.prototype = o + var newf = new F() + return newf + } } - this.input = res; - - this.state = stateOverride || "scheme start"; - - this.buffer = ""; - this.atFlag = false; - this.arrFlag = false; - this.passwordTokenSeenFlag = false; - this.input = punycode.ucs2.decode(this.input); - - for (; this.pointer <= this.input.length; ++this.pointer) { - const c = this.input[this.pointer]; - const cStr = isNaN(c) ? undefined : String.fromCodePoint(c); - - // exec state machine - const ret = this["parse " + this.state](c, cStr); - if (!ret) { - break; // terminate algorithm - } else if (ret === failure) { - this.failure = true; - break; + if (!Object.keys) { + Object.keys = function (o) { + var a = [] + for (var i in o) if (o.hasOwnProperty(i)) a.push(i) + return a } } -} -URLStateMachine.prototype["parse scheme start"] = function parseSchemeStart(c, cStr) { - if (isASCIIAlpha(c)) { - this.buffer += cStr.toLowerCase(); - this.state = "scheme"; - } else if (!this.stateOverride) { - this.state = "no scheme"; - --this.pointer; - } else { - this.parseError = true; - return failure; - } + function checkBufferLength (parser) { + var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10) + var maxActual = 0 + for (var i = 0, l = buffers.length; i < l; i++) { + var len = parser[buffers[i]].length + if (len > maxAllowed) { + // Text/cdata nodes can get big, and since they're buffered, + // we can get here under normal conditions. + // Avoid issues by emitting the text node now, + // so at least it won't get any bigger. + switch (buffers[i]) { + case 'textNode': + closeText(parser) + break - return true; -}; + case 'cdata': + emitNode(parser, 'oncdata', parser.cdata) + parser.cdata = '' + break -URLStateMachine.prototype["parse scheme"] = function parseScheme(c, cStr) { - if (isASCIIAlphanumeric(c) || c === 43 || c === 45 || c === 46) { - this.buffer += cStr.toLowerCase(); - } else if (c === 58) { - if (this.stateOverride) { - if (isSpecial(this.url) && !isSpecialScheme(this.buffer)) { - return false; - } + case 'script': + emitNode(parser, 'onscript', parser.script) + parser.script = '' + break - if (!isSpecial(this.url) && isSpecialScheme(this.buffer)) { - return false; + default: + error(parser, 'Max buffer length exceeded: ' + buffers[i]) + } } + maxActual = Math.max(maxActual, len) + } + // schedule the next check for the earliest possible buffer overrun. + var m = sax.MAX_BUFFER_LENGTH - maxActual + parser.bufferCheckPosition = m + parser.position + } - if ((includesCredentials(this.url) || this.url.port !== null) && this.buffer === "file") { - return false; - } + function clearBuffers (parser) { + for (var i = 0, l = buffers.length; i < l; i++) { + parser[buffers[i]] = '' + } + } - if (this.url.scheme === "file" && (this.url.host === "" || this.url.host === null)) { - return false; - } + function flushBuffers (parser) { + closeText(parser) + if (parser.cdata !== '') { + emitNode(parser, 'oncdata', parser.cdata) + parser.cdata = '' } - this.url.scheme = this.buffer; - this.buffer = ""; - if (this.stateOverride) { - return false; + if (parser.script !== '') { + emitNode(parser, 'onscript', parser.script) + parser.script = '' } - if (this.url.scheme === "file") { - if (this.input[this.pointer + 1] !== 47 || this.input[this.pointer + 2] !== 47) { - this.parseError = true; - } - this.state = "file"; - } else if (isSpecial(this.url) && this.base !== null && this.base.scheme === this.url.scheme) { - this.state = "special relative or authority"; - } else if (isSpecial(this.url)) { - this.state = "special authority slashes"; - } else if (this.input[this.pointer + 1] === 47) { - this.state = "path or authority"; - ++this.pointer; - } else { - this.url.cannotBeABaseURL = true; - this.url.path.push(""); - this.state = "cannot-be-a-base-URL path"; - } - } else if (!this.stateOverride) { - this.buffer = ""; - this.state = "no scheme"; - this.pointer = -1; - } else { - this.parseError = true; - return failure; } - return true; -}; + SAXParser.prototype = { + end: function () { end(this) }, + write: write, + resume: function () { this.error = null; return this }, + close: function () { return this.write(null) }, + flush: function () { flushBuffers(this) } + } -URLStateMachine.prototype["parse no scheme"] = function parseNoScheme(c) { - if (this.base === null || (this.base.cannotBeABaseURL && c !== 35)) { - return failure; - } else if (this.base.cannotBeABaseURL && c === 35) { - this.url.scheme = this.base.scheme; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - this.url.fragment = ""; - this.url.cannotBeABaseURL = true; - this.state = "fragment"; - } else if (this.base.scheme === "file") { - this.state = "file"; - --this.pointer; - } else { - this.state = "relative"; - --this.pointer; + var Stream + try { + Stream = (__nccwpck_require__(2781).Stream) + } catch (ex) { + Stream = function () {} } - return true; -}; - -URLStateMachine.prototype["parse special relative or authority"] = function parseSpecialRelativeOrAuthority(c) { - if (c === 47 && this.input[this.pointer + 1] === 47) { - this.state = "special authority ignore slashes"; - ++this.pointer; - } else { - this.parseError = true; - this.state = "relative"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse path or authority"] = function parsePathOrAuthority(c) { - if (c === 47) { - this.state = "authority"; - } else { - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse relative"] = function parseRelative(c) { - this.url.scheme = this.base.scheme; - if (isNaN(c)) { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - } else if (c === 47) { - this.state = "relative slash"; - } else if (c === 63) { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(); - this.url.query = ""; - this.state = "query"; - } else if (c === 35) { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - this.url.fragment = ""; - this.state = "fragment"; - } else if (isSpecial(this.url) && c === 92) { - this.parseError = true; - this.state = "relative slash"; - } else { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.url.path = this.base.path.slice(0, this.base.path.length - 1); - - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse relative slash"] = function parseRelativeSlash(c) { - if (isSpecial(this.url) && (c === 47 || c === 92)) { - if (c === 92) { - this.parseError = true; - } - this.state = "special authority ignore slashes"; - } else if (c === 47) { - this.state = "authority"; - } else { - this.url.username = this.base.username; - this.url.password = this.base.password; - this.url.host = this.base.host; - this.url.port = this.base.port; - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse special authority slashes"] = function parseSpecialAuthoritySlashes(c) { - if (c === 47 && this.input[this.pointer + 1] === 47) { - this.state = "special authority ignore slashes"; - ++this.pointer; - } else { - this.parseError = true; - this.state = "special authority ignore slashes"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse special authority ignore slashes"] = function parseSpecialAuthorityIgnoreSlashes(c) { - if (c !== 47 && c !== 92) { - this.state = "authority"; - --this.pointer; - } else { - this.parseError = true; - } - - return true; -}; - -URLStateMachine.prototype["parse authority"] = function parseAuthority(c, cStr) { - if (c === 64) { - this.parseError = true; - if (this.atFlag) { - this.buffer = "%40" + this.buffer; - } - this.atFlag = true; - - // careful, this is based on buffer and has its own pointer (this.pointer != pointer) and inner chars - const len = countSymbols(this.buffer); - for (let pointer = 0; pointer < len; ++pointer) { - const codePoint = this.buffer.codePointAt(pointer); - - if (codePoint === 58 && !this.passwordTokenSeenFlag) { - this.passwordTokenSeenFlag = true; - continue; - } - const encodedCodePoints = percentEncodeChar(codePoint, isUserinfoPercentEncode); - if (this.passwordTokenSeenFlag) { - this.url.password += encodedCodePoints; - } else { - this.url.username += encodedCodePoints; - } - } - this.buffer = ""; - } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || - (isSpecial(this.url) && c === 92)) { - if (this.atFlag && this.buffer === "") { - this.parseError = true; - return failure; - } - this.pointer -= countSymbols(this.buffer) + 1; - this.buffer = ""; - this.state = "host"; - } else { - this.buffer += cStr; - } - - return true; -}; - -URLStateMachine.prototype["parse hostname"] = -URLStateMachine.prototype["parse host"] = function parseHostName(c, cStr) { - if (this.stateOverride && this.url.scheme === "file") { - --this.pointer; - this.state = "file host"; - } else if (c === 58 && !this.arrFlag) { - if (this.buffer === "") { - this.parseError = true; - return failure; - } - - const host = parseHost(this.buffer, isSpecial(this.url)); - if (host === failure) { - return failure; - } - - this.url.host = host; - this.buffer = ""; - this.state = "port"; - if (this.stateOverride === "hostname") { - return false; - } - } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || - (isSpecial(this.url) && c === 92)) { - --this.pointer; - if (isSpecial(this.url) && this.buffer === "") { - this.parseError = true; - return failure; - } else if (this.stateOverride && this.buffer === "" && - (includesCredentials(this.url) || this.url.port !== null)) { - this.parseError = true; - return false; - } - - const host = parseHost(this.buffer, isSpecial(this.url)); - if (host === failure) { - return failure; - } - - this.url.host = host; - this.buffer = ""; - this.state = "path start"; - if (this.stateOverride) { - return false; - } - } else { - if (c === 91) { - this.arrFlag = true; - } else if (c === 93) { - this.arrFlag = false; - } - this.buffer += cStr; - } - - return true; -}; - -URLStateMachine.prototype["parse port"] = function parsePort(c, cStr) { - if (isASCIIDigit(c)) { - this.buffer += cStr; - } else if (isNaN(c) || c === 47 || c === 63 || c === 35 || - (isSpecial(this.url) && c === 92) || - this.stateOverride) { - if (this.buffer !== "") { - const port = parseInt(this.buffer); - if (port > Math.pow(2, 16) - 1) { - this.parseError = true; - return failure; - } - this.url.port = port === defaultPort(this.url.scheme) ? null : port; - this.buffer = ""; - } - if (this.stateOverride) { - return false; - } - this.state = "path start"; - --this.pointer; - } else { - this.parseError = true; - return failure; - } - - return true; -}; - -const fileOtherwiseCodePoints = new Set([47, 92, 63, 35]); - -URLStateMachine.prototype["parse file"] = function parseFile(c) { - this.url.scheme = "file"; - - if (c === 47 || c === 92) { - if (c === 92) { - this.parseError = true; - } - this.state = "file slash"; - } else if (this.base !== null && this.base.scheme === "file") { - if (isNaN(c)) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - } else if (c === 63) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - this.url.query = ""; - this.state = "query"; - } else if (c === 35) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - this.url.query = this.base.query; - this.url.fragment = ""; - this.state = "fragment"; - } else { - if (this.input.length - this.pointer - 1 === 0 || // remaining consists of 0 code points - !isWindowsDriveLetterCodePoints(c, this.input[this.pointer + 1]) || - (this.input.length - this.pointer - 1 >= 2 && // remaining has at least 2 code points - !fileOtherwiseCodePoints.has(this.input[this.pointer + 2]))) { - this.url.host = this.base.host; - this.url.path = this.base.path.slice(); - shortenPath(this.url); - } else { - this.parseError = true; - } - - this.state = "path"; - --this.pointer; - } - } else { - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse file slash"] = function parseFileSlash(c) { - if (c === 47 || c === 92) { - if (c === 92) { - this.parseError = true; - } - this.state = "file host"; - } else { - if (this.base !== null && this.base.scheme === "file") { - if (isNormalizedWindowsDriveLetterString(this.base.path[0])) { - this.url.path.push(this.base.path[0]); - } else { - this.url.host = this.base.host; - } - } - this.state = "path"; - --this.pointer; - } - - return true; -}; - -URLStateMachine.prototype["parse file host"] = function parseFileHost(c, cStr) { - if (isNaN(c) || c === 47 || c === 92 || c === 63 || c === 35) { - --this.pointer; - if (!this.stateOverride && isWindowsDriveLetterString(this.buffer)) { - this.parseError = true; - this.state = "path"; - } else if (this.buffer === "") { - this.url.host = ""; - if (this.stateOverride) { - return false; - } - this.state = "path start"; - } else { - let host = parseHost(this.buffer, isSpecial(this.url)); - if (host === failure) { - return failure; - } - if (host === "localhost") { - host = ""; - } - this.url.host = host; - - if (this.stateOverride) { - return false; - } + var streamWraps = sax.EVENTS.filter(function (ev) { + return ev !== 'error' && ev !== 'end' + }) - this.buffer = ""; - this.state = "path start"; - } - } else { - this.buffer += cStr; + function createStream (strict, opt) { + return new SAXStream(strict, opt) } - return true; -}; - -URLStateMachine.prototype["parse path start"] = function parsePathStart(c) { - if (isSpecial(this.url)) { - if (c === 92) { - this.parseError = true; - } - this.state = "path"; - - if (c !== 47 && c !== 92) { - --this.pointer; - } - } else if (!this.stateOverride && c === 63) { - this.url.query = ""; - this.state = "query"; - } else if (!this.stateOverride && c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } else if (c !== undefined) { - this.state = "path"; - if (c !== 47) { - --this.pointer; + function SAXStream (strict, opt) { + if (!(this instanceof SAXStream)) { + return new SAXStream(strict, opt) } - } - return true; -}; + Stream.apply(this) -URLStateMachine.prototype["parse path"] = function parsePath(c) { - if (isNaN(c) || c === 47 || (isSpecial(this.url) && c === 92) || - (!this.stateOverride && (c === 63 || c === 35))) { - if (isSpecial(this.url) && c === 92) { - this.parseError = true; - } + this._parser = new SAXParser(strict, opt) + this.writable = true + this.readable = true - if (isDoubleDot(this.buffer)) { - shortenPath(this.url); - if (c !== 47 && !(isSpecial(this.url) && c === 92)) { - this.url.path.push(""); - } - } else if (isSingleDot(this.buffer) && c !== 47 && - !(isSpecial(this.url) && c === 92)) { - this.url.path.push(""); - } else if (!isSingleDot(this.buffer)) { - if (this.url.scheme === "file" && this.url.path.length === 0 && isWindowsDriveLetterString(this.buffer)) { - if (this.url.host !== "" && this.url.host !== null) { - this.parseError = true; - this.url.host = ""; - } - this.buffer = this.buffer[0] + ":"; - } - this.url.path.push(this.buffer); - } - this.buffer = ""; - if (this.url.scheme === "file" && (c === undefined || c === 63 || c === 35)) { - while (this.url.path.length > 1 && this.url.path[0] === "") { - this.parseError = true; - this.url.path.shift(); - } - } - if (c === 63) { - this.url.query = ""; - this.state = "query"; - } - if (c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } - } else { - // TODO: If c is not a URL code point and not "%", parse error. + var me = this - if (c === 37 && - (!isASCIIHex(this.input[this.pointer + 1]) || - !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; + this._parser.onend = function () { + me.emit('end') } - this.buffer += percentEncodeChar(c, isPathPercentEncode); - } - - return true; -}; + this._parser.onerror = function (er) { + me.emit('error', er) -URLStateMachine.prototype["parse cannot-be-a-base-URL path"] = function parseCannotBeABaseURLPath(c) { - if (c === 63) { - this.url.query = ""; - this.state = "query"; - } else if (c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } else { - // TODO: Add: not a URL code point - if (!isNaN(c) && c !== 37) { - this.parseError = true; + // if didn't throw, then means error was handled. + // go ahead and clear error, so we can write again. + me._parser.error = null } - if (c === 37 && - (!isASCIIHex(this.input[this.pointer + 1]) || - !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } + this._decoder = null - if (!isNaN(c)) { - this.url.path[0] = this.url.path[0] + percentEncodeChar(c, isC0ControlPercentEncode); - } + streamWraps.forEach(function (ev) { + Object.defineProperty(me, 'on' + ev, { + get: function () { + return me._parser['on' + ev] + }, + set: function (h) { + if (!h) { + me.removeAllListeners(ev) + me._parser['on' + ev] = h + return h + } + me.on(ev, h) + }, + enumerable: true, + configurable: false + }) + }) } - return true; -}; - -URLStateMachine.prototype["parse query"] = function parseQuery(c, cStr) { - if (isNaN(c) || (!this.stateOverride && c === 35)) { - if (!isSpecial(this.url) || this.url.scheme === "ws" || this.url.scheme === "wss") { - this.encodingOverride = "utf-8"; + SAXStream.prototype = Object.create(Stream.prototype, { + constructor: { + value: SAXStream } + }) - const buffer = new Buffer(this.buffer); // TODO: Use encoding override instead - for (let i = 0; i < buffer.length; ++i) { - if (buffer[i] < 0x21 || buffer[i] > 0x7E || buffer[i] === 0x22 || buffer[i] === 0x23 || - buffer[i] === 0x3C || buffer[i] === 0x3E) { - this.url.query += percentEncode(buffer[i]); - } else { - this.url.query += String.fromCodePoint(buffer[i]); + SAXStream.prototype.write = function (data) { + if (typeof Buffer === 'function' && + typeof Buffer.isBuffer === 'function' && + Buffer.isBuffer(data)) { + if (!this._decoder) { + var SD = (__nccwpck_require__(1576).StringDecoder) + this._decoder = new SD('utf8') } + data = this._decoder.write(data) } - this.buffer = ""; - if (c === 35) { - this.url.fragment = ""; - this.state = "fragment"; - } - } else { - // TODO: If c is not a URL code point and not "%", parse error. - if (c === 37 && - (!isASCIIHex(this.input[this.pointer + 1]) || - !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; - } - - this.buffer += cStr; + this._parser.write(data.toString()) + this.emit('data', data) + return true } - return true; -}; - -URLStateMachine.prototype["parse fragment"] = function parseFragment(c) { - if (isNaN(c)) { // do nothing - } else if (c === 0x0) { - this.parseError = true; - } else { - // TODO: If c is not a URL code point and not "%", parse error. - if (c === 37 && - (!isASCIIHex(this.input[this.pointer + 1]) || - !isASCIIHex(this.input[this.pointer + 2]))) { - this.parseError = true; + SAXStream.prototype.end = function (chunk) { + if (chunk && chunk.length) { + this.write(chunk) } - - this.url.fragment += percentEncodeChar(c, isC0ControlPercentEncode); + this._parser.end() + return true } - return true; -}; - -function serializeURL(url, excludeFragment) { - let output = url.scheme + ":"; - if (url.host !== null) { - output += "//"; - - if (url.username !== "" || url.password !== "") { - output += url.username; - if (url.password !== "") { - output += ":" + url.password; + SAXStream.prototype.on = function (ev, handler) { + var me = this + if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) { + me._parser['on' + ev] = function () { + var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments) + args.splice(0, 0, ev) + me.emit.apply(me, args) } - output += "@"; - } - - output += serializeHost(url.host); - - if (url.port !== null) { - output += ":" + url.port; - } - } else if (url.host === null && url.scheme === "file") { - output += "//"; - } - - if (url.cannotBeABaseURL) { - output += url.path[0]; - } else { - for (const string of url.path) { - output += "/" + string; } - } - - if (url.query !== null) { - output += "?" + url.query; - } - - if (!excludeFragment && url.fragment !== null) { - output += "#" + url.fragment; - } - - return output; -} - -function serializeOrigin(tuple) { - let result = tuple.scheme + "://"; - result += serializeHost(tuple.host); - if (tuple.port !== null) { - result += ":" + tuple.port; + return Stream.prototype.on.call(me, ev, handler) } - return result; -} - -module.exports.serializeURL = serializeURL; - -module.exports.serializeURLOrigin = function (url) { - // https://url.spec.whatwg.org/#concept-url-origin - switch (url.scheme) { - case "blob": - try { - return module.exports.serializeURLOrigin(module.exports.parseURL(url.path[0])); - } catch (e) { - // serializing an opaque origin returns "null" - return "null"; - } - case "ftp": - case "gopher": - case "http": - case "https": - case "ws": - case "wss": - return serializeOrigin({ - scheme: url.scheme, - host: url.host, - port: url.port - }); - case "file": - // spec says "exercise to the reader", chrome says "file://" - return "file://"; - default: - // serializing an opaque origin returns "null" - return "null"; - } -}; + // this really needs to be replaced with character classes. + // XML allows all manner of ridiculous numbers and digits. + var CDATA = '[CDATA[' + var DOCTYPE = 'DOCTYPE' + var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace' + var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/' + var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE } -module.exports.basicURLParse = function (input, options) { - if (options === undefined) { - options = {}; - } + // http://www.w3.org/TR/REC-xml/#NT-NameStartChar + // This implementation works on strings, a single character at a time + // as such, it cannot ever support astral-plane characters (10000-EFFFF) + // without a significant breaking change to either this parser, or the + // JavaScript language. Implementation of an emoji-capable xml parser + // is left as an exercise for the reader. + var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ - const usm = new URLStateMachine(input, options.baseURL, options.encodingOverride, options.url, options.stateOverride); - if (usm.failure) { - return "failure"; - } + var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/ - return usm.url; -}; + var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ + var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/ -module.exports.setTheUsername = function (url, username) { - url.username = ""; - const decoded = punycode.ucs2.decode(username); - for (let i = 0; i < decoded.length; ++i) { - url.username += percentEncodeChar(decoded[i], isUserinfoPercentEncode); + function isWhitespace (c) { + return c === ' ' || c === '\n' || c === '\r' || c === '\t' } -}; -module.exports.setThePassword = function (url, password) { - url.password = ""; - const decoded = punycode.ucs2.decode(password); - for (let i = 0; i < decoded.length; ++i) { - url.password += percentEncodeChar(decoded[i], isUserinfoPercentEncode); + function isQuote (c) { + return c === '"' || c === '\'' } -}; - -module.exports.serializeHost = serializeHost; - -module.exports.cannotHaveAUsernamePasswordPort = cannotHaveAUsernamePasswordPort; -module.exports.serializeInteger = function (integer) { - return String(integer); -}; - -module.exports.parseURL = function (input, options) { - if (options === undefined) { - options = {}; + function isAttribEnd (c) { + return c === '>' || isWhitespace(c) } - // We don't handle blobs, so this just delegates: - return module.exports.basicURLParse(input, { baseURL: options.baseURL, encodingOverride: options.encodingOverride }); -}; - - -/***/ }), - -/***/ 276: -/***/ ((module) => { - -"use strict"; - - -module.exports.mixin = function mixin(target, source) { - const keys = Object.getOwnPropertyNames(source); - for (let i = 0; i < keys.length; ++i) { - Object.defineProperty(target, keys[i], Object.getOwnPropertyDescriptor(source, keys[i])); + function isMatch (regex, c) { + return regex.test(c) } -}; - -module.exports.wrapperSymbol = Symbol("wrapper"); -module.exports.implSymbol = Symbol("impl"); - -module.exports.wrapperForImpl = function (impl) { - return impl[module.exports.wrapperSymbol]; -}; - -module.exports.implForWrapper = function (wrapper) { - return wrapper[module.exports.implSymbol]; -}; - - - -/***/ }), - -/***/ 9975: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; -/*eslint no-var:0, prefer-arrow-callback: 0, object-shorthand: 0 */ - - - -var Punycode = __nccwpck_require__(5477); - - -var internals = {}; - - -// -// Read rules from file. -// -internals.rules = (__nccwpck_require__(3704).map)(function (rule) { - - return { - rule: rule, - suffix: rule.replace(/^(\*\.|\!)/, ''), - punySuffix: -1, - wildcard: rule.charAt(0) === '*', - exception: rule.charAt(0) === '!' - }; -}); - - -// -// Check is given string ends with `suffix`. -// -internals.endsWith = function (str, suffix) { - - return str.indexOf(suffix, str.length - suffix.length) !== -1; -}; - - -// -// Find rule for a given domain. -// -internals.findRule = function (domain) { - - var punyDomain = Punycode.toASCII(domain); - return internals.rules.reduce(function (memo, rule) { - - if (rule.punySuffix === -1){ - rule.punySuffix = Punycode.toASCII(rule.suffix); - } - if (!internals.endsWith(punyDomain, '.' + rule.punySuffix) && punyDomain !== rule.punySuffix) { - return memo; - } - // This has been commented out as it never seems to run. This is because - // sub tlds always appear after their parents and we never find a shorter - // match. - //if (memo) { - // var memoSuffix = Punycode.toASCII(memo.suffix); - // if (memoSuffix.length >= punySuffix.length) { - // return memo; - // } - //} - return rule; - }, null); -}; - -// -// Error codes and messages. -// -exports.errorCodes = { - DOMAIN_TOO_SHORT: 'Domain name too short.', - DOMAIN_TOO_LONG: 'Domain name too long. It should be no more than 255 chars.', - LABEL_STARTS_WITH_DASH: 'Domain name label can not start with a dash.', - LABEL_ENDS_WITH_DASH: 'Domain name label can not end with a dash.', - LABEL_TOO_LONG: 'Domain name label should be at most 63 chars long.', - LABEL_TOO_SHORT: 'Domain name label should be at least 1 character long.', - LABEL_INVALID_CHARS: 'Domain name label can only contain alphanumeric characters or dashes.' -}; - - -// -// Validate domain name and throw if not valid. -// -// From wikipedia: -// -// Hostnames are composed of series of labels concatenated with dots, as are all -// domain names. Each label must be between 1 and 63 characters long, and the -// entire hostname (including the delimiting dots) has a maximum of 255 chars. -// -// Allowed chars: -// -// * `a-z` -// * `0-9` -// * `-` but not as a starting or ending character -// * `.` as a separator for the textual portions of a domain name -// -// * http://en.wikipedia.org/wiki/Domain_name -// * http://en.wikipedia.org/wiki/Hostname -// -internals.validate = function (input) { - - // Before we can validate we need to take care of IDNs with unicode chars. - var ascii = Punycode.toASCII(input); - - if (ascii.length < 1) { - return 'DOMAIN_TOO_SHORT'; - } - if (ascii.length > 255) { - return 'DOMAIN_TOO_LONG'; + function notMatch (regex, c) { + return !isMatch(regex, c) } - // Check each part's length and allowed chars. - var labels = ascii.split('.'); - var label; - - for (var i = 0; i < labels.length; ++i) { - label = labels[i]; - if (!label.length) { - return 'LABEL_TOO_SHORT'; - } - if (label.length > 63) { - return 'LABEL_TOO_LONG'; - } - if (label.charAt(0) === '-') { - return 'LABEL_STARTS_WITH_DASH'; - } - if (label.charAt(label.length - 1) === '-') { - return 'LABEL_ENDS_WITH_DASH'; - } - if (!/^[a-z0-9\-]+$/.test(label)) { - return 'LABEL_INVALID_CHARS'; - } + var S = 0 + sax.STATE = { + BEGIN: S++, // leading byte order mark or whitespace + BEGIN_WHITESPACE: S++, // leading whitespace + TEXT: S++, // general stuff + TEXT_ENTITY: S++, // & and such. + OPEN_WAKA: S++, // < + SGML_DECL: S++, // + SCRIPT: S++, //