diff --git a/dist/index.js b/dist/index.js index be00a71..c2c1d72 100644 --- a/dist/index.js +++ b/dist/index.js @@ -56583,11 +56583,23 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getReleaserTypes = exports.unregisterReleaseType = exports.registerReleaseType = exports.buildStrategy = void 0; +const errors_1 = __nccwpck_require__(93637); +const changelog_notes_factory_1 = __nccwpck_require__(3095); +const versioning_strategy_factory_1 = __nccwpck_require__(11833); +const bazel_1 = __nccwpck_require__(76082); +const dart_1 = __nccwpck_require__(86518); +const dotnet_yoshi_1 = __nccwpck_require__(98175); +const elixir_1 = __nccwpck_require__(91731); +const expo_1 = __nccwpck_require__(181); const go_1 = __nccwpck_require__(45953); const go_yoshi_1 = __nccwpck_require__(6492); +const helm_1 = __nccwpck_require__(97687); +const java_1 = __nccwpck_require__(46892); const java_yoshi_1 = __nccwpck_require__(35330); const java_yoshi_mono_repo_1 = __nccwpck_require__(77664); const krm_blueprint_1 = __nccwpck_require__(76397); +const maven_1 = __nccwpck_require__(60899); +const node_1 = __nccwpck_require__(78957); const ocaml_1 = __nccwpck_require__(72064); const php_1 = __nccwpck_require__(57658); const php_yoshi_1 = __nccwpck_require__(88460); @@ -56598,20 +56610,9 @@ const rust_1 = __nccwpck_require__(43066); const sfdx_1 = __nccwpck_require__(87648); const simple_1 = __nccwpck_require__(10591); const terraform_module_1 = __nccwpck_require__(80908); -const helm_1 = __nccwpck_require__(97687); -const elixir_1 = __nccwpck_require__(91731); -const dart_1 = __nccwpck_require__(86518); -const node_1 = __nccwpck_require__(78957); -const expo_1 = __nccwpck_require__(181); const always_bump_patch_1 = __nccwpck_require__(82926); -const service_pack_1 = __nccwpck_require__(56772); const dependency_manifest_1 = __nccwpck_require__(25029); -const dotnet_yoshi_1 = __nccwpck_require__(98175); -const java_1 = __nccwpck_require__(46892); -const maven_1 = __nccwpck_require__(60899); -const versioning_strategy_factory_1 = __nccwpck_require__(11833); -const changelog_notes_factory_1 = __nccwpck_require__(3095); -const errors_1 = __nccwpck_require__(93637); +const service_pack_1 = __nccwpck_require__(56772); __exportStar(__nccwpck_require__(3095), exports); __exportStar(__nccwpck_require__(56259), exports); __exportStar(__nccwpck_require__(11833), exports); @@ -56655,6 +56656,7 @@ const releasers = { helm: options => new helm_1.Helm(options), elixir: options => new elixir_1.Elixir(options), dart: options => new dart_1.Dart(options), + bazel: options => new bazel_1.Bazel(options), }; async function buildStrategy(options) { var _a; @@ -56751,12 +56753,14 @@ class GitHub { this.getCommitFiles = wrapAsync(async (sha) => { this.logger.debug(`Backfilling file list for commit: ${sha}`); const files = []; - for await (const resp of this.octokit.paginate.iterator(this.octokit.repos.getCommit, { + for await (const resp of this.octokit.paginate.iterator('GET /repos/{owner}/{repo}/commits/{ref}', { owner: this.repository.owner, repo: this.repository.repo, ref: sha, })) { - for (const f of resp.data.files || []) { + // Paginate plugin doesn't have types for listing files on a commit + const data = resp.data; + for (const f of data.files || []) { if (f.filename) { files.push(f.filename); } @@ -57419,7 +57423,7 @@ class GitHub { MERGED: 'closed', }; let results = 0; - for await (const { data: pulls } of this.octokit.paginate.iterator(this.octokit.rest.pulls.list, { + for await (const { data: pulls } of this.octokit.paginate.iterator('GET /repos/{owner}/{repo}/pulls', { state: statusMap[status], owner: this.repository.owner, repo: this.repository.repo, @@ -57629,7 +57633,7 @@ class GitHub { async *tagIterator(options = {}) { const maxResults = options.maxResults || Number.MAX_SAFE_INTEGER; let results = 0; - for await (const response of this.octokit.paginate.iterator(this.octokit.rest.repos.listTags, { + for await (const response of this.octokit.paginate.iterator('GET /repos/{owner}/{repo}/tags', { owner: this.repository.owner, repo: this.repository.repo, })) { @@ -58010,7 +58014,7 @@ Object.defineProperty(exports, "GitHub", ({ enumerable: true, get: function () { exports.configSchema = __nccwpck_require__(38623); exports.manifestSchema = __nccwpck_require__(45314); // x-release-please-start-version -exports.VERSION = '16.5.0'; +exports.VERSION = '16.10.0'; // x-release-please-end //# sourceMappingURL=index.js.map @@ -59317,7 +59321,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin { } return existingCandidate; } - newCandidate(pkg, updatedVersions) { + async newCandidate(pkg, updatedVersions) { const version = updatedVersions.get(pkg.name); if (!version) { throw new Error(`Didn't find updated version for ${pkg.name}`); @@ -60001,7 +60005,7 @@ class MavenWorkspace extends workspace_1.WorkspacePlugin { } return existingCandidate; } - newCandidate(artifact, updatedVersions) { + async newCandidate(artifact, updatedVersions) { const version = updatedVersions.get(artifact.name); if (!version) { throw new Error(`Didn't find updated version for ${artifact.name}`); @@ -60292,6 +60296,7 @@ exports.Merge = Merge; // limitations under the License. Object.defineProperty(exports, "__esModule", ({ value: true })); exports.NodeWorkspace = void 0; +const package_lock_json_1 = __nccwpck_require__(23443); const version_1 = __nccwpck_require__(17348); const pull_request_title_1 = __nccwpck_require__(1158); const pull_request_body_1 = __nccwpck_require__(70774); @@ -60311,6 +60316,8 @@ const package_json_1 = __nccwpck_require__(26588); class NodeWorkspace extends workspace_1.WorkspacePlugin { constructor(github, targetBranch, repositoryConfig, options = {}) { super(github, targetBranch, repositoryConfig, options); + this.strategiesByPath = {}; + this.releasesByPath = {}; this.alwaysLinkLocal = options.alwaysLinkLocal === false ? false : true; this.updatePeerDependencies = options.updatePeerDependencies === true; } @@ -60396,6 +60403,12 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { if (update.path === (0, workspace_1.addPath)(existingCandidate.path, 'package.json')) { update.updater = new composite_1.CompositeUpdater(update.updater, updater); } + else if (update.path === (0, workspace_1.addPath)(existingCandidate.path, 'package-lock.json')) { + update.updater = new package_lock_json_1.PackageLockJson({ + version: newVersion, + versionsMap: updatedVersions, + }); + } else if (update.updater instanceof changelog_1.Changelog) { if (dependencyNotes) { update.updater.changelogEntry = @@ -60420,7 +60433,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { } return existingCandidate; } - newCandidate(pkg, updatedVersions) { + async newCandidate(pkg, updatedVersions) { // Update version of the package const newVersion = updatedVersions.get(pkg.name); if (!newVersion) { @@ -60431,6 +60444,22 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { version: newVersion.toString(), }; const dependencyNotes = getChangelogDepsNotes(pkg, updatedPackage, updatedVersions, this.logger); + const strategy = this.strategiesByPath[updatedPackage.path]; + const latestRelease = this.releasesByPath[updatedPackage.path]; + const basePullRequest = strategy + ? await strategy.buildReleasePullRequest([], latestRelease, false, [], { + newVersion, + }) + : undefined; + if (basePullRequest) { + return this.updateCandidate({ + path: pkg.path, + pullRequest: basePullRequest, + config: { + releaseType: 'node', + }, + }, pkg, updatedVersions); + } const pullRequest = { title: pull_request_title_1.PullRequestTitle.ofTargetBranch(this.targetBranch), body: new pull_request_body_1.PullRequestBody([ @@ -60449,6 +60478,14 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { versionsMap: updatedVersions, }), }, + { + path: (0, workspace_1.addPath)(updatedPackage.path, 'package-lock.json'), + createIfMissing: false, + updater: new package_json_1.PackageJson({ + version: newVersion, + versionsMap: updatedVersions, + }), + }, { path: (0, workspace_1.addPath)(updatedPackage.path, 'CHANGELOG.md'), createIfMissing: false, @@ -60472,7 +60509,32 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { }; } postProcessCandidates(candidates, _updatedVersions) { - // NOP for node workspaces + if (candidates.length === 0) { + return candidates; + } + const [candidate] = candidates; + // check for root lock file in pull request + let hasRootLockFile; + for (let i = 0; i < candidate.pullRequest.updates.length; i++) { + if (candidate.pullRequest.updates[i].path === '.package-lock.json' || + candidate.pullRequest.updates[i].path === './package-lock.json' || + candidate.pullRequest.updates[i].path === 'package-lock.json' || + candidate.pullRequest.updates[i].path === '/package-lock.json') { + hasRootLockFile = true; + break; + } + } + // if there is a root lock file, then there is no additional pull request update necessary. + if (hasRootLockFile) { + return candidates; + } + candidate.pullRequest.updates.push({ + path: 'package-lock.json', + createIfMissing: false, + updater: new package_lock_json_1.PackageLockJson({ + versionsMap: _updatedVersions, + }), + }); return candidates; } async buildGraph(allPackages) { @@ -60508,6 +60570,12 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin { : {}), }; } + async preconfigure(strategiesByPath, _commitsByPath, _releasesByPath) { + // Using preconfigure to siphon releases and strategies. + this.strategiesByPath = strategiesByPath; + this.releasesByPath = _releasesByPath; + return strategiesByPath; + } } exports.NodeWorkspace = NodeWorkspace; function getChangelogDepsNotes(original, updated, updateVersions, logger) { @@ -60740,7 +60808,7 @@ class WorkspacePlugin extends plugin_1.ManifestPlugin { else { // otherwise, build a new pull request with changelog and entry update this.logger.info(`Creating new candidate pull request for ${this.packageNameFromPackage(pkg)}`); - const newCandidate = this.newCandidate(pkg, updatedVersions); + const newCandidate = await this.newCandidate(pkg, updatedVersions); if (newCandidatePaths.has(newCandidate.path)) { this.logger.info(`Already created new candidate for path: ${newCandidate.path}`); } @@ -61111,14 +61179,15 @@ class BaseStrategy { * open for this path/component. Returns undefined if we should not * open a pull request. */ - async buildReleasePullRequest(commits, latestRelease, draft, labels = []) { + async buildReleasePullRequest(commits, latestRelease, draft, labels = [], bumpOnlyOptions) { + var _a; const conventionalCommits = await this.postProcessCommits(commits); this.logger.info(`Considering: ${conventionalCommits.length} commits`); - if (conventionalCommits.length === 0) { + if (!bumpOnlyOptions && conventionalCommits.length === 0) { this.logger.info(`No commits for path: ${this.path}, skipping`); return undefined; } - const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease); + const newVersion = (_a = bumpOnlyOptions === null || bumpOnlyOptions === void 0 ? void 0 : bumpOnlyOptions.newVersion) !== null && _a !== void 0 ? _a : (await this.buildNewVersion(conventionalCommits, latestRelease)); const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits, newVersion); const component = await this.getComponent(); this.logger.debug('component:', component); @@ -61130,7 +61199,7 @@ class BaseStrategy { ? branch_name_1.BranchName.ofComponentTargetBranch(branchComponent, this.targetBranch) : branch_name_1.BranchName.ofTargetBranch(this.targetBranch); const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits); - if (this.changelogEmpty(releaseNotesBody)) { + if (!bumpOnlyOptions && this.changelogEmpty(releaseNotesBody)) { this.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`); return undefined; } @@ -61182,6 +61251,13 @@ class BaseStrategy { const paths = await this.extraFilePaths(extraFile); for (const path of paths) { switch (extraFile.type) { + case 'generic': + extraFileUpdates.push({ + path: this.addPath(path), + createIfMissing: false, + updater: new generic_1.Generic({ version, versionsMap }), + }); + break; case 'json': extraFileUpdates.push({ path: this.addPath(path), @@ -61435,6 +61511,61 @@ exports.BaseStrategy = BaseStrategy; /***/ }), +/***/ 76082: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.Bazel = void 0; +const module_bazel_1 = __nccwpck_require__(75219); +const changelog_1 = __nccwpck_require__(3325); +const base_1 = __nccwpck_require__(95081); +class Bazel extends base_1.BaseStrategy { + constructor(options) { + var _a; + super(options); + this.versionFile = (_a = options.versionFile) !== null && _a !== void 0 ? _a : 'MODULE.bazel'; + } + async buildUpdates(options) { + const updates = []; + const version = options.newVersion; + updates.push({ + path: this.addPath(this.changelogPath), + createIfMissing: true, + updater: new changelog_1.Changelog({ + version, + changelogEntry: options.changelogEntry, + }), + }); + updates.push({ + path: this.addPath(this.versionFile), + createIfMissing: false, + updater: new module_bazel_1.ModuleBazel({ + version, + }), + }); + return updates; + } +} +exports.Bazel = Bazel; +//# sourceMappingURL=bazel.js.map + +/***/ }), + /***/ 86518: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -62601,7 +62732,7 @@ class Java extends base_1.BaseStrategy { this.snapshotLabels = options.snapshotLabels || manifest_1.DEFAULT_SNAPSHOT_LABELS; this.skipSnapshot = (_c = options.skipSnapshot) !== null && _c !== void 0 ? _c : false; } - async buildReleasePullRequest(commits, latestRelease, draft, labels = []) { + async buildReleasePullRequest(commits, latestRelease, draft, labels = [], _bumpOnlyOptions) { if (await this.needsSnapshot(commits, latestRelease)) { this.logger.info('Repository needs a snapshot bump.'); return await this.buildSnapshotPullRequest(latestRelease, draft, this.snapshotLabels); @@ -62882,6 +63013,7 @@ class Node extends base_1.BaseStrategy { var _a; const updates = []; const version = options.newVersion; + const versionsMap = options.versionsMap; const packageName = (_a = (await this.getPackageName())) !== null && _a !== void 0 ? _a : ''; const lockFiles = ['package-lock.json', 'npm-shrinkwrap.json']; lockFiles.forEach(lockFile => { @@ -62890,6 +63022,7 @@ class Node extends base_1.BaseStrategy { createIfMissing: false, updater: new package_lock_json_1.PackageLockJson({ version, + versionsMap, }), }); }); @@ -63110,10 +63243,10 @@ class PHPYoshi extends base_1.BaseStrategy { changelogSections: CHANGELOG_SECTIONS, }); } - async buildReleasePullRequest(commits, latestRelease, draft, labels = []) { + async buildReleasePullRequest(commits, latestRelease, draft, labels = [], bumpOnlyOptions) { var _a, _b, _c; const conventionalCommits = await this.postProcessCommits((0, commit_1.parseConventionalCommits)(commits, this.logger)); - if (conventionalCommits.length === 0) { + if (!bumpOnlyOptions && conventionalCommits.length === 0) { this.logger.info(`No commits for path: ${this.path}, skipping`); return undefined; } @@ -63188,6 +63321,13 @@ class PHPYoshi extends base_1.BaseStrategy { version, }), }); + updates.push({ + path: this.addPath(`${directory}/composer.json`), + createIfMissing: false, + updater: new root_composer_update_packages_1.RootComposerUpdatePackages({ + version, + }), + }); if ((_c = (_b = componentInfo.composer.extra) === null || _b === void 0 ? void 0 : _b.component) === null || _c === void 0 ? void 0 : _c.entry) { updates.push({ path: this.addPath(`${directory}/${componentInfo.composer.extra.component.entry}`), @@ -63245,6 +63385,14 @@ class PHPYoshi extends base_1.BaseStrategy { changelogEntry: options.changelogEntry, }), }); + // update VERSION file + updates.push({ + path: this.addPath('VERSION'), + createIfMissing: false, + updater: new default_1.DefaultUpdater({ + version, + }), + }); // update the aggregate package information in the root composer.json updates.push({ path: this.addPath('composer.json'), @@ -63326,7 +63474,6 @@ class PHP extends base_1.BaseStrategy { const updates = []; const version = options.newVersion; const versionsMap = new Map(); - versionsMap.set('version', version); updates.push({ path: this.addPath(this.changelogPath), createIfMissing: true, @@ -64152,6 +64299,46 @@ exports.BaseXml = BaseXml; /***/ }), +/***/ 75219: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.ModuleBazel = void 0; +const default_1 = __nccwpck_require__(69995); +/** + * Updates a Bazel Module file. + */ +class ModuleBazel extends default_1.DefaultUpdater { + updateContent(content) { + const match = content.match(/module[\s\S]*?\([\s\S]*?version\s*=\s*(['"])(.*?)\1/m); + if (!match) { + return content; + } + const [fullMatch, , version] = match; + const module = fullMatch.replace(version, this.version.toString()); + return content.replace(fullMatch, module); + } +} +exports.ModuleBazel = ModuleBazel; +//# sourceMappingURL=module-bazel.js.map + +/***/ }), + /***/ 23719: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { @@ -65563,7 +65750,7 @@ exports.KRMBlueprintVersion = KRMBlueprintVersion; // See the License for the specific language governing permissions and // limitations under the License. Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.newVersionWithRange = exports.PackageJson = void 0; +exports.updateDependencies = exports.newVersionWithRange = exports.PackageJson = void 0; const json_stringify_1 = __nccwpck_require__(69227); const logger_1 = __nccwpck_require__(68809); const default_1 = __nccwpck_require__(69995); @@ -65574,6 +65761,7 @@ class PackageJson extends default_1.DefaultUpdater { /** * Given initial file contents, return updated contents. * @param {string} content The initial content + * @param logger * @returns {string} The updated content */ updateContent(content, logger = logger_1.logger) { @@ -65604,10 +65792,10 @@ var SUPPORTED_RANGE_PREFIXES; (function (SUPPORTED_RANGE_PREFIXES) { SUPPORTED_RANGE_PREFIXES["CARET"] = "^"; SUPPORTED_RANGE_PREFIXES["TILDE"] = "~"; - SUPPORTED_RANGE_PREFIXES["GREATER_THAN"] = ">"; - SUPPORTED_RANGE_PREFIXES["LESS_THAN"] = "<"; SUPPORTED_RANGE_PREFIXES["EQUAL_OR_GREATER_THAN"] = ">="; SUPPORTED_RANGE_PREFIXES["EQUAL_OR_LESS_THAN"] = "<="; + SUPPORTED_RANGE_PREFIXES["GREATER_THAN"] = ">"; + SUPPORTED_RANGE_PREFIXES["LESS_THAN"] = "<"; })(SUPPORTED_RANGE_PREFIXES || (SUPPORTED_RANGE_PREFIXES = {})); function detectRangePrefix(version) { return (Object.values(SUPPORTED_RANGE_PREFIXES).find(supportedRangePrefix => version.startsWith(supportedRangePrefix)) || ''); @@ -65638,11 +65826,11 @@ function updateDependencies(dependencies, updatedVersions) { const newVersion = updatedVersions.get(depName); if (newVersion) { const oldVersion = dependencies[depName]; - const newVersionString = newVersionWithRange(oldVersion, newVersion); - dependencies[depName] = newVersionString; + dependencies[depName] = newVersionWithRange(oldVersion, newVersion); } } } +exports.updateDependencies = updateDependencies; //# sourceMappingURL=package-json.js.map /***/ }), @@ -65669,21 +65857,60 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.PackageLockJson = void 0; const json_stringify_1 = __nccwpck_require__(69227); const logger_1 = __nccwpck_require__(68809); -const default_1 = __nccwpck_require__(69995); +const package_json_1 = __nccwpck_require__(26588); /** * Updates a Node.js package-lock.json file's version and '' package * version (for a v2 lock file). */ -class PackageLockJson extends default_1.DefaultUpdater { +class PackageLockJson { + constructor(options) { + this.version = options.version; + this.versionsMap = options.versionsMap; + } updateContent(content, logger = logger_1.logger) { const parsed = JSON.parse(content); - logger.info(`updating from ${parsed.version} to ${this.version}`); - parsed.version = this.version.toString(); + if (this.version) { + logger.info(`updating from ${parsed.version} to ${this.version}`); + parsed.version = this.version.toString(); + } if (parsed.lockfileVersion === 2 || parsed.lockfileVersion === 3) { - parsed.packages[''].version = this.version.toString(); + if (this.version) { + parsed.packages[''].version = this.version.toString(); + } + if (this.versionsMap) { + this.versionsMap.forEach((version, name) => { + let pkg = parsed.packages['node_modules/' + name]; + if (!pkg) { + return; + } + // @see https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#packages + if (pkg.link && pkg.resolved) { + pkg = parsed.packages[pkg.resolved]; + if (!pkg) { + return; + } + } + pkg.version = version.toString(); + if (pkg.dependencies) { + (0, package_json_1.updateDependencies)(pkg.dependencies, this.versionsMap); + } + if (pkg.devDependencies) { + (0, package_json_1.updateDependencies)(pkg.devDependencies, this.versionsMap); + } + if (pkg.peerDependencies) { + (0, package_json_1.updateDependencies)(pkg.peerDependencies, this.versionsMap); + } + if (pkg.optionalDependencies) { + (0, package_json_1.updateDependencies)(pkg.optionalDependencies, this.versionsMap); + } + }); + } } if (this.versionsMap) { for (const [, obj] of Object.entries(parsed.packages)) { + if (!obj.name) { + continue; + } const ver = this.versionsMap.get(obj.name); if (ver) { obj.version = ver.toString(); @@ -65958,11 +66185,17 @@ class RootComposerUpdatePackages extends default_1.DefaultUpdater { * @returns {string} The updated content */ updateContent(content, logger = logger_1.logger) { - if (!this.versionsMap || this.versionsMap.size === 0) { + if (!this.version && (!this.versionsMap || this.versionsMap.size === 0)) { logger.info('no updates necessary'); return content; } const parsed = JSON.parse(content); + if (parsed['version']) { + const fromVersion = parsed['version']; + const toVersion = this.version.toString() || '1.0.0'; + parsed['version'] = toVersion; + logger.info(`updating "version" from ${fromVersion} to ${toVersion}`); + } if (this.versionsMap) { for (const [key, version] of this.versionsMap.entries()) { const toVersion = version.toString() || '1.0.0'; @@ -102220,6 +102453,28 @@ var xpath = ( false) ? 0 : exports; (function (exports) { "use strict"; + // namespace nodes are not part of the DOM spec, so we use a custom nodetype for them. + // should NOT be used externally + var NAMESPACE_NODE_NODETYPE = '__namespace'; + + var isNil = function (x) { + return x === null || x === undefined; + }; + + var isValidNodeType = function (nodeType) { + return nodeType === NAMESPACE_NODE_NODETYPE || + (Number.isInteger(nodeType) + && nodeType >= 1 + && nodeType <= 11 + ); + }; + + var isNodeLike = function (value) { + return value + && isValidNodeType(value.nodeType) + && typeof value.nodeName === "string"; + }; + // functional helpers function curry(func) { var slice = Array.prototype.slice, @@ -102286,6 +102541,16 @@ var xpath = ( false) ? 0 : exports; var prototypeConcat = Array.prototype.concat; + var sortNodes = function (nodes, reverse) { + var ns = new XNodeSet(); + + ns.addArray(nodes); + + var sorted = ns.toArray(); + + return reverse ? sorted.reverse() : sorted; + } + // .apply() fails above a certain number of arguments - https://github.com/goto100/xpath/pull/98 var MAX_ARGUMENT_LENGTH = 32767; @@ -102294,10 +102559,10 @@ var xpath = ( false) ? 0 : exports; for (var start = 0; start < arr.length; start += MAX_ARGUMENT_LENGTH) { var chunk = arr.slice(start, start + MAX_ARGUMENT_LENGTH); - + result = prototypeConcat.apply(result, chunk); } - + return result; } @@ -102320,6 +102585,19 @@ var xpath = ( false) ? 0 : exports; return to; } + var NodeTypes = { + ELEMENT_NODE: 1, + ATTRIBUTE_NODE: 2, + TEXT_NODE: 3, + CDATA_SECTION_NODE: 4, + PROCESSING_INSTRUCTION_NODE: 7, + COMMENT_NODE: 8, + DOCUMENT_NODE: 9, + DOCUMENT_TYPE_NODE: 10, + DOCUMENT_FRAGMENT_NODE: 11, + NAMESPACE_NODE: NAMESPACE_NODE_NODETYPE, + }; + // XPathParser /////////////////////////////////////////////////////////////// XPathParser.prototype = new Object(); @@ -103342,6 +103620,13 @@ var xpath = ( false) ? 0 : exports; XPathParser.ACCEPT = 'a'; XPathParser.prototype.parse = function (s) { + if (!s) { + throw new Error('XPath expression unspecified.'); + } + if (typeof s !== 'string'){ + throw new Error('XPath expression must be a string.'); + } + var types; var values; var res = this.tokenize(s); @@ -103420,6 +103705,12 @@ var xpath = ( false) ? 0 : exports; } XPath.prototype.evaluate = function (c) { + var node = c.expressionContextNode; + + if (!(isNil(node) || isNodeLike(node))) { + throw new Error("Context node does not appear to be a valid DOM node."); + } + c.contextNode = c.expressionContextNode; c.contextSize = 1; c.contextPosition = 1; @@ -103890,7 +104181,7 @@ var xpath = ( false) ? 0 : exports; return node; } - PathExpr.applyPredicates = function (predicates, c, nodes) { + var applyPredicates = function (predicates, c, nodes, reverse) { if (predicates.length === 0) { return nodes; } @@ -103911,7 +104202,7 @@ var xpath = ( false) ? 0 : exports; inNodes ); }, - nodes, + sortNodes(nodes, reverse), predicates ); }; @@ -103919,7 +104210,9 @@ var xpath = ( false) ? 0 : exports; PathExpr.getRoot = function (xpc, nodes) { var firstNode = nodes[0]; - if (firstNode.nodeType === 9 /*Node.DOCUMENT_NODE*/) { + // xpc.virtualRoot could possibly provide a root even if firstNode is null, + // so using a guard here instead of throwing. + if (firstNode && firstNode.nodeType === NodeTypes.DOCUMENT_NODE) { return firstNode; } @@ -103927,6 +104220,10 @@ var xpath = ( false) ? 0 : exports; return xpc.virtualRoot; } + if (!firstNode) { + throw new Error('Context node not found when determining document root.'); + } + var ownerDoc = firstNode.ownerDocument; if (ownerDoc) { @@ -103941,8 +104238,25 @@ var xpath = ( false) ? 0 : exports; return n; } + var getPrefixForNamespaceNode = function (attrNode) { + var nm = String(attrNode.name); + + if (nm === "xmlns") { + return ""; + } + + if (nm.substring(0, 6) === "xmlns:") { + return nm.substring(6, nm.length); + } + + return null; + }; + PathExpr.applyStep = function (step, xpc, node) { - var self = this; + if (!node) { + throw new Error('Context node not found when evaluating XPath step: ' + step); + } + var newNodes = []; xpc.contextNode = node; @@ -103953,7 +104267,7 @@ var xpath = ( false) ? 0 : exports; break; } var m; - if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) { + if (xpc.contextNode.nodeType == NodeTypes.ATTRIBUTE_NODE) { m = PathExpr.getOwnerElement(xpc.contextNode); } else { m = xpc.contextNode.parentNode; @@ -103971,7 +104285,7 @@ var xpath = ( false) ? 0 : exports; case Step.ANCESTORORSELF: // look at all the ancestor nodes and the current node - for (var m = xpc.contextNode; m != null; m = m.nodeType == 2 /*Node.ATTRIBUTE_NODE*/ ? PathExpr.getOwnerElement(m) : m.parentNode) { + for (var m = xpc.contextNode; m != null; m = m.nodeType == NodeTypes.ATTRIBUTE_NODE ? PathExpr.getOwnerElement(m) : m.parentNode) { if (step.nodeTest.matches(m, xpc)) { newNodes.push(m); } @@ -104053,7 +104367,7 @@ var xpath = ( false) ? 0 : exports; } else { st.unshift(xpc.contextNode.nextSibling); } - for (var m = xpc.contextNode.parentNode; m != null && m.nodeType != 9 /*Node.DOCUMENT_NODE*/ && m !== xpc.virtualRoot; m = m.parentNode) { + for (var m = xpc.contextNode.parentNode; m != null && m.nodeType != NodeTypes.DOCUMENT_NODE && m !== xpc.virtualRoot; m = m.parentNode) { st.unshift(m.nextSibling); } do { @@ -104083,30 +104397,30 @@ var xpath = ( false) ? 0 : exports; break; case Step.NAMESPACE: - var n = {}; - if (xpc.contextNode.nodeType == 1 /*Node.ELEMENT_NODE*/) { - n["xml"] = XPath.XML_NAMESPACE_URI; - n["xmlns"] = XPath.XMLNS_NAMESPACE_URI; - for (var m = xpc.contextNode; m != null && m.nodeType == 1 /*Node.ELEMENT_NODE*/; m = m.parentNode) { + var nodes = {}; + + if (xpc.contextNode.nodeType == NodeTypes.ELEMENT_NODE) { + // BUG: This only collects the namespaces on the current node, but seemingly + // it should collect all those in scope + nodes["xml"] = new XPathNamespace("xml", null, XPath.XML_NAMESPACE_URI, xpc.contextNode); + + for (var m = xpc.contextNode; m != null && m.nodeType == NodeTypes.ELEMENT_NODE; m = m.parentNode) { for (var k = 0; k < m.attributes.length; k++) { var attr = m.attributes.item(k); - var nm = String(attr.name); - if (nm == "xmlns") { - if (n[""] == undefined) { - n[""] = attr.value; - } - } else if (nm.length > 6 && nm.substring(0, 6) == "xmlns:") { - var pre = nm.substring(6, nm.length); - if (n[pre] == undefined) { - n[pre] = attr.value; - } + + var pre = getPrefixForNamespaceNode(attr); + + if (pre != null && nodes[pre] == undefined) { + nodes[pre] = new XPathNamespace(pre, attr, attr.value, xpc.contextNode); } } } - for (var pre in n) { - var nsn = new XPathNamespace(pre, n[pre], xpc.contextNode); - if (step.nodeTest.matches(nsn, xpc)) { - newNodes.push(nsn); + + for (var pre in nodes) { + var node = nodes[pre]; + + if (step.nodeTest.matches(node, xpc)) { + newNodes.push(node); } } } @@ -104115,7 +104429,7 @@ var xpath = ( false) ? 0 : exports; case Step.PARENT: m = null; if (xpc.contextNode !== xpc.virtualRoot) { - if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) { + if (xpc.contextNode.nodeType == NodeTypes.ATTRIBUTE_NODE) { m = PathExpr.getOwnerElement(xpc.contextNode); } else { m = xpc.contextNode.parentNode; @@ -104176,10 +104490,11 @@ var xpath = ( false) ? 0 : exports; }; function applyStepWithPredicates(step, xpc, node) { - return PathExpr.applyPredicates( + return applyPredicates( step.predicates, xpc, - PathExpr.applyStep(step, xpc, node) + PathExpr.applyStep(step, xpc, node), + includes(REVERSE_AXES, step.axis) ); } @@ -104216,7 +104531,12 @@ var xpath = ( false) ? 0 : exports; } return { - nodes: PathExpr.applyPredicates(this.filterPredicates || [], xpc, ns.toUnsortedArray()) + nodes: applyPredicates( + this.filterPredicates || [], + xpc, + ns.toUnsortedArray(), + false // reverse + ) }; }; @@ -104299,7 +104619,7 @@ var xpath = ( false) ? 0 : exports; } catch (e) { } // Other DOM 1 implementations must use this egregious search - var doc = n.nodeType == 9 /*Node.DOCUMENT_NODE*/ + var doc = n.nodeType == NodeTypes.DOCUMENT_NODE ? n : n.ownerDocument; var elts = doc.getElementsByTagName("*"); @@ -104396,6 +104716,14 @@ var xpath = ( false) ? 0 : exports; [Step.SELF, 'self'] ]); + var REVERSE_AXES = [ + Step.ANCESTOR, + Step.ANCESTORORSELF, + Step.PARENT, + Step.PRECEDING, + Step.PRECEDINGSIBLING + ]; + // NodeTest ////////////////////////////////////////////////////////////////// NodeTest.prototype = new Object(); @@ -104499,7 +104827,13 @@ var xpath = ( false) ? 0 : exports; NodeTest.NAMETESTQNAME, { matches: function (n, xpc) { - return NodeTest.isNodeType([1, 2, XPathNamespace.XPATH_NAMESPACE_NODE])(n) && + return NodeTest.isNodeType( + [ + NodeTypes.ELEMENT_NODE, + NodeTypes.ATTRIBUTE_NODE, + NodeTypes.NAMESPACE_NODE, + ] + )(n) && NodeTest.nameSpaceMatches(this.prefix, xpc, n) && NodeTest.localNameMatches(this.localName, xpc, n); }, @@ -104518,7 +104852,10 @@ var xpath = ( false) ? 0 : exports; NodeTest.PITest = NodeTest.makeNodeTestType(NodeTest.PI, { matches: function (n, xpc) { - return NodeTest.isNodeType([7])(n) && (n.target || n.nodeName) === this.name; + return NodeTest.isNodeType( + [NodeTypes.PROCESSING_INSTRUCTION_NODE] + )(n) && + (n.target || n.nodeName) === this.name; }, toString: function () { return wrap('processing-instruction("', '")', this.name); @@ -104528,13 +104865,48 @@ var xpath = ( false) ? 0 : exports; // singletons // elements, attributes, namespaces - NodeTest.nameTestAny = NodeTest.makeNodeTypeTest(NodeTest.NAMETESTANY, [1, 2, XPathNamespace.XPATH_NAMESPACE_NODE], '*'); + NodeTest.nameTestAny = NodeTest.makeNodeTypeTest( + NodeTest.NAMETESTANY, + [ + NodeTypes.ELEMENT_NODE, + NodeTypes.ATTRIBUTE_NODE, + NodeTypes.NAMESPACE_NODE, + ], + '*' + ); // text, cdata - NodeTest.textTest = NodeTest.makeNodeTypeTest(NodeTest.TEXT, [3, 4], 'text()'); - NodeTest.commentTest = NodeTest.makeNodeTypeTest(NodeTest.COMMENT, [8], 'comment()'); + NodeTest.textTest = NodeTest.makeNodeTypeTest( + NodeTest.TEXT, + [ + NodeTypes.TEXT_NODE, + NodeTypes.CDATA_SECTION_NODE, + ], + 'text()' + ); + NodeTest.commentTest = NodeTest.makeNodeTypeTest( + NodeTest.COMMENT, + [NodeTypes.COMMENT_NODE], + 'comment()' + ); // elements, attributes, text, cdata, PIs, comments, document nodes - NodeTest.nodeTest = NodeTest.makeNodeTypeTest(NodeTest.NODE, [1, 2, 3, 4, 7, 8, 9], 'node()'); - NodeTest.anyPiTest = NodeTest.makeNodeTypeTest(NodeTest.PI, [7], 'processing-instruction()'); + NodeTest.nodeTest = NodeTest.makeNodeTypeTest( + NodeTest.NODE, + [ + NodeTypes.ELEMENT_NODE, + NodeTypes.ATTRIBUTE_NODE, + NodeTypes.TEXT_NODE, + NodeTypes.CDATA_SECTION_NODE, + NodeTypes.PROCESSING_INSTRUCTION_NODE, + NodeTypes.COMMENT_NODE, + NodeTypes.DOCUMENT_NODE, + ], + 'node()' + ); + NodeTest.anyPiTest = NodeTest.makeNodeTypeTest( + NodeTest.PI, + [NodeTypes.PROCESSING_INSTRUCTION_NODE], + 'processing-instruction()' + ); // VariableReference ///////////////////////////////////////////////////////// @@ -105162,8 +105534,8 @@ var xpath = ( false) ? 0 : exports; n2Par = n2.parentNode || n2.ownerElement; } - var n1isAttr = Utilities.isAttribute(n1); - var n2isAttr = Utilities.isAttribute(n2); + var n1isAttr = isAttributeLike(n1); + var n2isAttr = isAttributeLike(n2); if (n1isAttr && !n2isAttr) { return -1; @@ -105172,15 +105544,35 @@ var xpath = ( false) ? 0 : exports; return 1; } + // xml namespace node comes before others. namespace nodes before non-namespace nodes + if (n1.isXPathNamespace) { + if (n1.nodeValue === XPath.XML_NAMESPACE_URI) { + return -1; + } + + if (!n2.isXPathNamespace) { + return -1; + } + + if (n2.nodeValue === XPath.XML_NAMESPACE_URI) { + return 1; + } + } else if (n2.isXPathNamespace) { + return 1; + } + if (n1Par) { - var cn = n1isAttr ? n1Par.attributes : n1Par.childNodes, - len = cn.length; + var cn = n1isAttr ? n1Par.attributes : n1Par.childNodes; + var len = cn.length; + var n1Compare = n1.baseNode || n1; + var n2Compare = n2.baseNode || n2; + for (var i = 0; i < len; i += 1) { var n = cn[i]; - if (n === n1) { + if (n === n1Compare) { return -1; } - if (n === n2) { + if (n === n2Compare) { return 1; } } @@ -105282,12 +105674,12 @@ var xpath = ( false) ? 0 : exports; }; XNodeSet.prototype.stringForNode = function (n) { - if (n.nodeType == 9 /*Node.DOCUMENT_NODE*/ || - n.nodeType == 1 /*Node.ELEMENT_NODE */ || - n.nodeType === 11 /*Node.DOCUMENT_FRAGMENT*/) { + if (n.nodeType == NodeTypes.DOCUMENT_NODE || + n.nodeType == NodeTypes.ELEMENT_NODE || + n.nodeType === NodeTypes.DOCUMENT_FRAGMENT_NODE) { return this.stringForContainerNode(n); } - if (n.nodeType === 2 /* Node.ATTRIBUTE_NODE */) { + if (n.nodeType === NodeTypes.ATTRIBUTE_NODE) { return n.value || n.nodeValue; } if (n.isNamespaceNode) { @@ -105451,16 +105843,17 @@ var xpath = ( false) ? 0 : exports; XPathNamespace.prototype.constructor = XPathNamespace; XPathNamespace.superclass = Object.prototype; - function XPathNamespace(pre, ns, p) { + function XPathNamespace(pre, node, uri, p) { this.isXPathNamespace = true; + this.baseNode = node; this.ownerDocument = p.ownerDocument; - this.nodeName = "#namespace"; + this.nodeName = pre; this.prefix = pre; this.localName = pre; - this.namespaceURI = ns; - this.nodeValue = ns; + this.namespaceURI = null; + this.nodeValue = uri; this.ownerElement = p; - this.nodeType = XPathNamespace.XPATH_NAMESPACE_NODE; + this.nodeType = NodeTypes.NAMESPACE_NODE; } XPathNamespace.prototype.toString = function () { @@ -105571,14 +105964,14 @@ var xpath = ( false) ? 0 : exports; } else if (prefix == "xmlns") { return XPath.XMLNS_NAMESPACE_URI; } - if (n.nodeType == 9 /*Node.DOCUMENT_NODE*/) { + if (n.nodeType == NodeTypes.DOCUMENT_NODE) { n = n.documentElement; - } else if (n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) { + } else if (n.nodeType == NodeTypes.ATTRIBUTE_NODE) { n = PathExpr.getOwnerElement(n); - } else if (n.nodeType != 1 /*Node.ELEMENT_NODE*/) { + } else if (n.nodeType != NodeTypes.ELEMENT_NODE) { n = n.parentNode; } - while (n != null && n.nodeType == 1 /*Node.ELEMENT_NODE*/) { + while (n != null && n.nodeType == NodeTypes.ELEMENT_NODE) { var nnm = n.attributes; for (var i = 0; i < nnm.length; i++) { var a = nnm.item(i); @@ -105637,7 +106030,7 @@ var xpath = ( false) ? 0 : exports; var ids = id.split(/[\x0d\x0a\x09\x20]+/); var count = 0; var ns = new XNodeSet(); - var doc = c.contextNode.nodeType == 9 /*Node.DOCUMENT_NODE*/ + var doc = c.contextNode.nodeType == NodeTypes.DOCUMENT_NODE ? c.contextNode : c.contextNode.ownerDocument; for (var i = 0; i < ids.length; i++) { @@ -105682,6 +106075,7 @@ var xpath = ( false) ? 0 : exports; Functions.namespaceURI = function () { var c = arguments[0]; var n; + if (arguments.length == 1) { n = c.contextNode; } else if (arguments.length == 2) { @@ -105689,10 +106083,11 @@ var xpath = ( false) ? 0 : exports; } else { throw new Error("Function namespace-uri expects (node-set?)"); } + if (n == null) { return new XString(""); } - return new XString(n.namespaceURI); + return new XString(n.namespaceURI || ''); }; Functions.name = function () { @@ -105708,11 +106103,11 @@ var xpath = ( false) ? 0 : exports; if (n == null) { return new XString(""); } - if (n.nodeType == 1 /*Node.ELEMENT_NODE*/) { + if (n.nodeType == NodeTypes.ELEMENT_NODE) { return new XString(n.nodeName); - } else if (n.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) { + } else if (n.nodeType == NodeTypes.ATTRIBUTE_NODE) { return new XString(n.name || n.nodeName); - } else if (n.nodeType === 7 /*Node.PROCESSING_INSTRUCTION_NODE*/) { + } else if (n.nodeType === NodeTypes.PROCESSING_INSTRUCTION_NODE) { return new XString(n.target || n.nodeName); } else if (n.localName == null) { return new XString(""); @@ -105907,7 +106302,7 @@ var xpath = ( false) ? 0 : exports; throw new Error("Function lang expects (string)"); } var lang; - for (var n = c.contextNode; n != null && n.nodeType != 9 /*Node.DOCUMENT_NODE*/; n = n.parentNode) { + for (var n = c.contextNode; n != null && n.nodeType != NodeTypes.DOCUMENT_NODE; n = n.parentNode) { var a = n.getAttributeNS(XPath.XML_NAMESPACE_URI, "lang"); if (a != null) { lang = String(a); @@ -105975,8 +106370,13 @@ var xpath = ( false) ? 0 : exports; var Utilities = new Object(); - Utilities.isAttribute = function (val) { - return val && (val.nodeType === 2 || val.ownerElement); + // Returns true if the node is an attribute node or namespace node + var isAttributeLike = function (val) { + return val && ( + val.nodeType === NodeTypes.ATTRIBUTE_NODE || + val.ownerElement || + val.isXPathNamespace + ); } Utilities.splitQName = function (qn) { @@ -106346,17 +106746,17 @@ var xpath = ( false) ? 0 : exports; Utilities.coalesceText = function (n) { for (var m = n.firstChild; m != null; m = m.nextSibling) { - if (m.nodeType == 3 /*Node.TEXT_NODE*/ || m.nodeType == 4 /*Node.CDATA_SECTION_NODE*/) { + if (m.nodeType == NodeTypes.TEXT_NODE || m.nodeType == NodeTypes.CDATA_SECTION_NODE) { var s = m.nodeValue; var first = m; m = m.nextSibling; - while (m != null && (m.nodeType == 3 /*Node.TEXT_NODE*/ || m.nodeType == 4 /*Node.CDATA_SECTION_NODE*/)) { + while (m != null && (m.nodeType == NodeTypes.TEXT_NODE || m.nodeType == NodeTypes.CDATA_SECTION_NODE)) { s += m.nodeValue; var del = m; m = m.nextSibling; del.parentNode.removeChild(del); } - if (first.nodeType == 4 /*Node.CDATA_SECTION_NODE*/) { + if (first.nodeType == NodeTypes.CDATA_SECTION_NODE) { var p = first.parentNode; if (first.nextSibling == null) { p.removeChild(first); @@ -106372,7 +106772,7 @@ var xpath = ( false) ? 0 : exports; if (m == null) { break; } - } else if (m.nodeType == 1 /*Node.ELEMENT_NODE*/) { + } else if (m.nodeType == NodeTypes.ELEMENT_NODE) { Utilities.coalesceText(m); } } @@ -106394,7 +106794,7 @@ var xpath = ( false) ? 0 : exports; Utilities.getElementById = function (n, id) { // Note that this does not check the DTD to check for actual // attributes of type ID, so this may be a bit wrong. - if (n.nodeType == 1 /*Node.ELEMENT_NODE*/) { + if (n.nodeType == NodeTypes.ELEMENT_NODE) { if (n.getAttribute("id") == id || n.getAttributeNS(null, "id") == id) { return n; @@ -106463,7 +106863,7 @@ var xpath = ( false) ? 0 : exports; } XPathExpression.getOwnerDocument = function (n) { - return n.nodeType === 9 /*Node.DOCUMENT_NODE*/ ? n : n.ownerDocument; + return n.nodeType === NodeTypes.DOCUMENT_NODE ? n : n.ownerDocument; } XPathExpression.detectHtmlDom = function (n) { @@ -106486,6 +106886,7 @@ var xpath = ( false) ? 0 : exports; this.context.caseInsensitive = XPathExpression.detectHtmlDom(n); var result = this.xpath.evaluate(this.context); + return new XPathResult(result, t); } @@ -106869,49 +107270,49 @@ var xpath = ( false) ? 0 : exports; assign( exports, { - XPath, - XPathParser, - XPathResult, + XPath: XPath, + XPathParser: XPathParser, + XPathResult: XPathResult, - Step, - PathExpr, - NodeTest, - LocationPath, + Step: Step, + PathExpr: PathExpr, + NodeTest: NodeTest, + LocationPath: LocationPath, - OrOperation, - AndOperation, + OrOperation: OrOperation, + AndOperation: AndOperation, - BarOperation, + BarOperation: BarOperation, - EqualsOperation, - NotEqualOperation, - LessThanOperation, - GreaterThanOperation, - LessThanOrEqualOperation, - GreaterThanOrEqualOperation, + EqualsOperation: EqualsOperation, + NotEqualOperation: NotEqualOperation, + LessThanOperation: LessThanOperation, + GreaterThanOperation: GreaterThanOperation, + LessThanOrEqualOperation: LessThanOrEqualOperation, + GreaterThanOrEqualOperation: GreaterThanOrEqualOperation, - PlusOperation, - MinusOperation, - MultiplyOperation, - DivOperation, - ModOperation, - UnaryMinusOperation, + PlusOperation: PlusOperation, + MinusOperation: MinusOperation, + MultiplyOperation: MultiplyOperation, + DivOperation: DivOperation, + ModOperation: ModOperation, + UnaryMinusOperation: UnaryMinusOperation, - FunctionCall, - VariableReference, + FunctionCall: FunctionCall, + VariableReference: VariableReference, - XPathContext, + XPathContext: XPathContext, - XNodeSet, - XBoolean, - XString, - XNumber, + XNodeSet: XNodeSet, + XBoolean: XBoolean, + XString: XString, + XNumber: XNumber, - NamespaceResolver, - FunctionResolver, - VariableResolver, + NamespaceResolver: NamespaceResolver, + FunctionResolver: FunctionResolver, + VariableResolver: VariableResolver, - Utilities, + Utilities: Utilities, } ); @@ -106962,6 +107363,32 @@ var xpath = ( false) ? 0 : exports; return exports.select(e, doc, true); }; + var isArrayOfNodes = function (value) { + return Array.isArray(value) && value.every(isNodeLike); + }; + + var isNodeOfType = function (type) { + return function (value) { + return isNodeLike(value) && value.nodeType === type; + }; + }; + + assign( + exports, + { + isNodeLike: isNodeLike, + isArrayOfNodes: isArrayOfNodes, + isElement: isNodeOfType(NodeTypes.ELEMENT_NODE), + isAttribute: isNodeOfType(NodeTypes.ATTRIBUTE_NODE), + isTextNode: isNodeOfType(NodeTypes.TEXT_NODE), + isCDATASection: isNodeOfType(NodeTypes.CDATA_SECTION_NODE), + isProcessingInstruction: isNodeOfType(NodeTypes.PROCESSING_INSTRUCTION_NODE), + isComment: isNodeOfType(NodeTypes.COMMENT_NODE), + isDocumentNode: isNodeOfType(NodeTypes.DOCUMENT_NODE), + isDocumentTypeNode: isNodeOfType(NodeTypes.DOCUMENT_TYPE_NODE), + isDocumentFragment: isNodeOfType(NodeTypes.DOCUMENT_FRAGMENT_NODE), + } + ); // end non-node wrapper })(xpath); @@ -116181,7 +116608,7 @@ module.exports = {"i8":"4.3.0"}; /***/ ((module) => { "use strict"; -module.exports = {"i8":"16.5.0"}; +module.exports = {"i8":"16.10.0"}; /***/ }),