setup-cpp
Version:
Install all the tools required for building and testing C++/C projects.
1 lines • 339 kB
Source Map (JSON)
{"version":3,"file":"index-B06Lzr4G.mjs","sources":["../../../node_modules/.pnpm/@shockpkg+archive-files@3.2.5/node_modules/@shockpkg/archive-files/esm/types.mjs","../../../node_modules/.pnpm/@shockpkg+archive-files@3.2.5/node_modules/@shockpkg/archive-files/esm/util.mjs","../../../node_modules/.pnpm/@shockpkg+archive-files@3.2.5/node_modules/@shockpkg/archive-files/esm/archive.mjs","../../../node_modules/.pnpm/@xmldom+xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/conventions.js","../../../node_modules/.pnpm/@xmldom+xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/dom.js","../../../node_modules/.pnpm/@xmldom+xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/entities.js","../../../node_modules/.pnpm/@xmldom+xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/sax.js","../../../node_modules/.pnpm/@xmldom+xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/dom-parser.js","../../../node_modules/.pnpm/@xmldom+xmldom@0.8.10/node_modules/@xmldom/xmldom/lib/index.js","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/util.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/options.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/value.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/value/boolean.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/value/data.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/value/integer.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/value/real.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/value/string.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/value/dict.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/value/array.mjs","../../../node_modules/.pnpm/@shockpkg+plist-dom@4.0.7/node_modules/@shockpkg/plist-dom/esm/plist.mjs","../../../node_modules/.pnpm/@shockpkg+hdi-mac@3.1.4/node_modules/@shockpkg/hdi-mac/esm/mounter.mjs","../../../node_modules/.pnpm/@shockpkg+archive-files@3.2.5/node_modules/@shockpkg/archive-files/esm/archive/hdi.mjs"],"sourcesContent":["export let PathType = /*#__PURE__*/function (PathType) {\n PathType[\"DIRECTORY\"] = \"directory\";\n PathType[\"FILE\"] = \"file\";\n PathType[\"SYMLINK\"] = \"symlink\";\n PathType[\"RESOURCE_FORK\"] = \"resource-fork\";\n return PathType;\n}({});\n//# sourceMappingURL=types.mjs.map","import { constants as fsConstants } from 'node:fs';\nimport { chmod, lstat, open, readdir, readlink, symlink, utimes } from 'node:fs/promises';\nimport { join as pathJoin } from 'node:path';\nimport { Writable } from 'node:stream';\nimport { pipeline } from 'node:stream/promises';\nimport { PathType } from \"./types.mjs\";\nconst {\n O_WRONLY,\n O_SYMLINK\n} = fsConstants;\nexport const fsLchmodSupported = !!O_SYMLINK;\nexport const fsLutimesSupported = !!O_SYMLINK;\n\n/**\n * Normalize an entry path.\n *\n * @param path Path string.\n * @returns Normalized path.\n */\nexport function pathNormalize(path) {\n return path.replace(/\\\\/g, '/').replace(/([^/])\\/+$/, '$1');\n}\n\n/**\n * Get path to the resource fork pseudo-file.\n *\n * @param path Path string.\n * @returns Resource fork pseudo-file path.\n */\nexport function pathResourceFork(path) {\n return pathJoin(path, '..namedfork', 'rsrc');\n}\n\n/**\n * Get path type from stat object, or null if unsupported.\n *\n * @param stat Stats object.\n * @returns Path type.\n */\nexport function statToPathType(stat) {\n if (stat.isSymbolicLink()) {\n return PathType.SYMLINK;\n }\n if (stat.isDirectory()) {\n return PathType.DIRECTORY;\n }\n if (stat.isFile()) {\n return PathType.FILE;\n }\n return null;\n}\n\n/**\n * Get path type from stat mode, or null if unsupported.\n *\n * @param mode Stat mode.\n * @returns Path type.\n */\nexport function modeToPathType(mode) {\n if (bitwiseAndEqual(mode, 0o0120000)) {\n return PathType.SYMLINK;\n }\n if (bitwiseAndEqual(mode, 0o0040000)) {\n return PathType.DIRECTORY;\n }\n if (bitwiseAndEqual(mode, 0o0100000)) {\n return PathType.FILE;\n }\n return null;\n}\n\n/**\n * Get permission bits from mode value.\n *\n * @param mode Stat mode.\n * @returns Permission bits.\n */\nexport function modePermissionBits(mode) {\n // eslint-disable-next-line no-bitwise\n return mode & 0b111111111;\n}\n\n/**\n * Check if all the bits set.\n *\n * @param value Bits value.\n * @param mask Mask value.\n * @returns True of all the bits set.\n */\nexport function bitwiseAndEqual(value, mask) {\n // eslint-disable-next-line no-bitwise\n return (value & mask) === mask;\n}\n\n/**\n * Read a stream into a buffer.\n * Reading a stream into a buffer should be avoided where possible.\n * This is however useful for some small streams.\n *\n * @param stream Readable stream.\n * @returns Full buffer.\n */\nexport async function streamToBuffer(stream) {\n const datas = [];\n let size = 0;\n await pipeline(stream, new Writable({\n // eslint-disable-next-line jsdoc/require-jsdoc\n write: (data, _encoding, cb) => {\n datas.push(data);\n size += data.length;\n cb();\n }\n }));\n return Buffer.concat(datas, size);\n}\n\n/**\n * Wrapper for lchmod, does nothing on unsupported platforms.\n *\n * @param path File path.\n * @param mode File mode.\n */\nexport async function fsLchmod(path, mode) {\n // Skip if not supported.\n if (!fsLchmodSupported) {\n return;\n }\n\n // eslint-disable-next-line no-bitwise\n const fd = await open(path, O_WRONLY | O_SYMLINK);\n try {\n await fd.chmod(mode);\n } finally {\n await fd.close();\n }\n}\n\n/**\n * Wrapper for utimes.\n *\n * @param path File path.\n * @param atime Access time.\n * @param mtime Modification time.\n */\nexport async function fsUtimes(path, atime, mtime) {\n await utimes(path, atime, mtime);\n}\n\n/**\n * Implementation of lutimes, does nothing on unsupported platforms.\n *\n * @param path File path.\n * @param atime Access time.\n * @param mtime Modification time.\n */\nexport async function fsLutimes(path, atime, mtime) {\n // Skip if not supported.\n if (!fsLutimesSupported) {\n return;\n }\n\n // eslint-disable-next-line no-bitwise\n const fd = await open(path, O_WRONLY | O_SYMLINK);\n try {\n await fd.utimes(atime, mtime);\n } finally {\n await fd.close();\n }\n}\n\n/**\n * A readlink wrapper that returns raw link buffer.\n *\n * @param path Link path.\n * @returns Raw link.\n */\nexport async function fsReadlinkRaw(path) {\n return readlink(path, 'buffer');\n}\n\n/**\n * Wrapper for symlink.\n *\n * @param path Path of symbolic link.\n * @param target Target of symbolic link.\n */\nexport async function fsSymlink(path, target) {\n await symlink(target, path);\n}\n\n/**\n * Wrapper for chmod.\n *\n * @param path File path.\n * @param mode File mode.\n */\nexport async function fsChmod(path, mode) {\n await chmod(path, mode);\n}\n\n/**\n * A readdir wrapper with consistent output.\n *\n * @param path Directory path.\n * @returns Directory listing.\n */\nexport async function fsReaddir(path) {\n return (await readdir(path)).sort();\n}\n\n/**\n * An lstat wrapper.\n *\n * @param path Path string.\n * @returns Stat object.\n */\nexport async function fsLstat(path) {\n return lstat(path);\n}\n\n/**\n * An lstat wrapper returning null if not exist.\n *\n * @param path Path string.\n * @returns Stat object.\n */\nexport async function fsLstatExists(path) {\n try {\n return await fsLstat(path);\n } catch (err) {\n const {\n code\n } = err;\n if (code === 'ENOENT' || code === 'ENOTDIR') {\n return null;\n }\n throw err;\n }\n}\n\n/**\n * Walk file system path.\n * If callback returns false skips recursing a directory.\n * If callback returns null aborts walking.\n *\n * @param base Directory path.\n * @param itter Callback for each entry.\n * @param options Walk options.\n */\nexport async function fsWalk(base, itter, options = {}) {\n const {\n ignoreUnreadableDirectories\n } = options;\n const stack = (await fsReaddir(base)).reverse();\n while (stack.length) {\n const entry = stack.pop();\n const fullPath = pathJoin(base, entry);\n // eslint-disable-next-line no-await-in-loop\n const stat = await fsLstat(fullPath);\n\n // Callback, possibly stop recursion on directory.\n // eslint-disable-next-line no-await-in-loop\n const recurse = await itter(entry, stat);\n if (recurse === null) {\n break;\n }\n if (recurse === false || !stat.isDirectory()) {\n continue;\n }\n\n // Recurse down.\n let subs = [];\n try {\n // eslint-disable-next-line no-await-in-loop\n subs = await fsReaddir(fullPath);\n } catch (err) {\n if (!(err && ignoreUnreadableDirectories && err.code === 'EACCES')) {\n throw err;\n }\n }\n for (let i = subs.length; i--;) {\n stack.push(pathJoin(entry, subs[i]));\n }\n }\n}\n//# sourceMappingURL=util.mjs.map","/* eslint-disable max-classes-per-file */\n\nimport { createWriteStream } from 'node:fs';\nimport { mkdir, rm, writeFile } from 'node:fs/promises';\nimport { dirname, resolve } from 'node:path';\nimport { Readable, pipeline } from 'node:stream';\nimport { promisify } from 'node:util';\nconst pipe = promisify(pipeline);\nimport { PathType } from \"./types.mjs\";\nimport { fsChmod, fsLchmod, fsLstatExists, fsLutimes, fsSymlink, fsUtimes, modePermissionBits, pathNormalize, pathResourceFork, streamToBuffer } from \"./util.mjs\";\n/**\n * Entry object.\n */\nexport class Entry {\n /**\n * Entry archive.\n */\n\n /**\n * Entry type.\n */\n\n /**\n * Entry path.\n */\n\n /**\n * Entry path, raw.\n */\n\n /**\n * Entry size.\n */\n\n /**\n * Entry size, compressed.\n */\n\n /**\n * Entry mode.\n */\n\n /**\n * Entry uid.\n */\n\n /**\n * Entry gid.\n */\n\n /**\n * Entry uname.\n */\n\n /**\n * Entry gname.\n */\n\n /**\n * Entry atime.\n */\n\n /**\n * Entry mtime.\n */\n\n /**\n * Read data.\n */\n\n /**\n * Read rsrc.\n */\n\n /**\n * Read symlink.\n */\n\n /**\n * Entry triggering.\n */\n _triggering = false;\n\n /**\n * Entry triggered.\n */\n _triggered = false;\n\n /**\n * Entry extracted.\n */\n _extracted = false;\n\n /**\n * Entry constructor.\n *\n * @param info Info object.\n */\n constructor(info) {\n this.archive = info.archive;\n this.type = info.type;\n this.pathRaw = info.pathRaw;\n this.path = pathNormalize(info.pathRaw);\n this.size = info.size ?? null;\n this.sizeComp = info.sizeComp ?? null;\n this.mode = info.mode ?? null;\n this.uid = info.uid ?? null;\n this.gid = info.gid ?? null;\n this.uname = info.uname ?? null;\n this.gname = info.gname ?? null;\n this.atime = info.atime ?? null;\n this.mtime = info.mtime ?? null;\n this._readData = info.readData ?? null;\n this._readRsrc = info.readRsrc ?? null;\n this._readSymlink = info.readSymlink ?? null;\n }\n\n /**\n * This entry path includes named volume.\n *\n * @returns Entry has volume name in path.\n */\n get hasNamedVolume() {\n return this.archive.hasNamedVolumes;\n }\n\n /**\n * This entry volume name, or null.\n *\n * @returns Entry path volume name.\n */\n get volumeName() {\n if (this.hasNamedVolume) {\n const {\n path\n } = this;\n return path.slice(0, path.indexOf('/'));\n }\n return null;\n }\n\n /**\n * This entry path without any possible volume name.\n *\n * @returns Entry path without the volume name.\n */\n get volumePath() {\n const {\n path\n } = this;\n if (this.hasNamedVolume) {\n return path.slice(path.indexOf('/') + 1);\n }\n return path;\n }\n\n /**\n * Read entry as stream, or null if nothing to read.\n * Consuming function will need to wait for stream to close.\n *\n * @returns Readable stream or null if nothing to read.\n */\n async stream() {\n this._beginExtract();\n return this._stream();\n }\n\n /**\n * Read entire entry into a Buffer.\n *\n * @returns Buffer or null if nothing to be read.\n */\n async read() {\n this._beginExtract();\n const stream = await this._stream();\n return stream ? streamToBuffer(stream) : null;\n }\n\n /**\n * Extract entry.\n *\n * @param path Extract path.\n * @param options Extract options.\n */\n async extract(path, options = {}) {\n this._beginExtract();\n await this._extract(path, options);\n }\n\n /**\n * Trigger on itterator function.\n *\n * @param itter Itterator function.\n * @returns Return value.\n */\n async trigger(itter) {\n let r;\n if (this._triggered) {\n throw new Error('Archive entry already triggered');\n }\n this._triggered = this._triggering = true;\n try {\n r = await itter(this);\n } finally {\n this._triggering = false;\n }\n return r;\n }\n\n /**\n * Run again after reading.\n *\n * @param path Extract path, relative.\n * @param pathFull An optional full path to be used.\n * @param options Extract options.\n */\n async setAttributes(path, pathFull = null, options = {}) {\n const pathSet = pathFull === null ? path : pathFull;\n const {\n ignorePermissions,\n ignoreTimes\n } = options;\n const {\n type,\n mode,\n atime,\n mtime\n } = this;\n let link = false;\n switch (type) {\n case PathType.FILE:\n {\n break;\n }\n case PathType.RESOURCE_FORK:\n {\n break;\n }\n case PathType.DIRECTORY:\n {\n break;\n }\n case PathType.SYMLINK:\n {\n link = true;\n break;\n }\n default:\n {\n throw new Error(`Unsupported path type: ${type}`);\n }\n }\n const atimeSet = atime || mtime || null;\n const mtimeSet = mtime || atime || null;\n if (!ignorePermissions && mode !== null) {\n const chmod = link ? fsLchmod : fsChmod;\n const modeSet = modePermissionBits(mode);\n await chmod(pathSet, modeSet);\n }\n if (!ignoreTimes && atimeSet && mtimeSet) {\n const utimes = link ? fsLutimes : fsUtimes;\n await utimes(pathSet, atimeSet, mtimeSet);\n }\n }\n\n /**\n * Method to call before begining extraction.\n * Throws error if extraction already started or entry not active.\n */\n _beginExtract() {\n if (!this._triggering) {\n throw new Error('Archive entry is not active');\n }\n if (this._extracted) {\n throw new Error('Archive entry can only be extracted once');\n }\n this._extracted = true;\n }\n\n /**\n * Create an extract error for path that exists.\n *\n * @param path Extract path.\n * @returns Error object.\n */\n _errorExtractPathExists(path) {\n return new Error(`Extract path already exists: ${path}`);\n }\n\n /**\n * Create an extract error for a resource fork not going to a file.\n *\n * @param path Extract path.\n * @returns Error object.\n */\n _errorNoResourceFork(path) {\n return new Error(`Extract path for resource fork not a file: ${path}`);\n }\n\n /**\n * Extract entry.\n *\n * @param path Extract path.\n * @param options Extract options.\n */\n async _extract(path, options) {\n this.archive.afterReadSetAttributesRemove(path);\n const {\n type\n } = this;\n switch (type) {\n case PathType.FILE:\n {\n await this._extractFile(path, options);\n break;\n }\n case PathType.RESOURCE_FORK:\n {\n await this._extractResourceFork(path, options);\n break;\n }\n case PathType.DIRECTORY:\n {\n await this._extractDirectory(path, options);\n break;\n }\n case PathType.SYMLINK:\n {\n await this._extractSymlink(path, options);\n break;\n }\n default:\n {\n throw new Error(`Unsupported path type: ${type}`);\n }\n }\n }\n\n /**\n * Base function for extracting stream to a file.\n *\n * @param path Extract path.\n * @param reader Reader function.\n * @param options Extract options.\n */\n async _extractStreamToFile(path, reader, options) {\n const {\n replace\n } = options;\n\n // Check if something exists at path, optionally removing.\n const stat = await fsLstatExists(path);\n if (stat) {\n // If replacing, then remove, else throw.\n if (replace) {\n await rm(path, {\n recursive: true,\n force: true\n });\n } else {\n throw this._errorExtractPathExists(path);\n }\n } else {\n await mkdir(dirname(path), {\n recursive: true\n });\n }\n\n // Write file.\n await writeFile(path, Buffer.alloc(0));\n const stream = await reader();\n if (stream) {\n await pipe(stream, createWriteStream(path));\n }\n\n // Set attributes.\n await this.setAttributes(path, null, options);\n }\n\n /**\n * Extract as a file.\n *\n * @param path Extract path.\n * @param options Extract options.\n */\n async _extractFile(path, options) {\n const readData = this._readData;\n if (!readData) {\n throw new Error('Internal error');\n }\n await this._extractStreamToFile(path, readData, options);\n }\n\n /**\n * Extract as resource fork to an existing file.\n *\n * @param path Extract path.\n * @param options Extract options.\n */\n async _extractResourceFork(path, options) {\n const readRsrc = this._readRsrc;\n if (!readRsrc) {\n throw new Error('Internal error');\n }\n\n // Optionally extract as a data file.\n if (options.resourceForkAsFile) {\n await this._extractStreamToFile(path, readRsrc, options);\n return;\n }\n\n // Check if file exists at path, else throw.\n const stat = await fsLstatExists(path);\n if (!stat || !stat.isFile()) {\n throw this._errorNoResourceFork(path);\n }\n\n // Create resource fork path.\n const pathRsrc = pathResourceFork(path);\n\n // Write the resource fork.\n const stream = await readRsrc();\n\n // eslint-disable-next-line unicorn/prefer-ternary\n if (stream) {\n await pipe(stream, createWriteStream(pathRsrc));\n } else {\n await writeFile(pathRsrc, Buffer.alloc(0));\n }\n\n // Set attributes.\n await this.setAttributes(path, null, options);\n }\n\n /**\n * Extract as a directory.\n *\n * @param path Extract path.\n * @param options Extract options.\n */\n async _extractDirectory(path, options) {\n const {\n replace\n } = options;\n\n // Check if something exists at path, else create.\n const stat = await fsLstatExists(path);\n if (stat) {\n // If not directory, then remove and replace it, else throw.\n if (!stat.isDirectory()) {\n if (replace) {\n await rm(path, {\n recursive: true,\n force: true\n });\n await mkdir(path, {\n recursive: true\n });\n } else {\n throw this._errorExtractPathExists(path);\n }\n }\n } else {\n await mkdir(path, {\n recursive: true\n });\n }\n\n // Set directory attributes after any children are added.\n this.archive.afterReadSetAttributes(path, this, {\n ...options\n });\n }\n\n /**\n * Extract as a symlink.\n *\n * @param path Extract path.\n * @param options Extract options.\n */\n async _extractSymlink(path, options) {\n const readSymlink = this._readSymlink;\n if (!readSymlink) {\n throw new Error('Internal error');\n }\n const {\n replace,\n symlinkAsFile\n } = options;\n\n // Check if something exists at path, optionally removing.\n const stat = await fsLstatExists(path);\n if (stat) {\n // If replacing, then remove, else throw.\n if (replace) {\n await rm(path, {\n recursive: true,\n force: true\n });\n } else {\n throw this._errorExtractPathExists(path);\n }\n } else {\n // Ensure base directory exists.\n await mkdir(dirname(path), {\n recursive: true\n });\n }\n\n // Read target.\n const target = await readSymlink();\n\n // Create link, optionally as a file.\n // eslint-disable-next-line unicorn/prefer-ternary\n if (symlinkAsFile) {\n await writeFile(path, target);\n } else {\n await fsSymlink(path, target);\n }\n\n // Set attributes.\n await this.setAttributes(path, null, options);\n }\n\n /**\n * Read as stream.\n *\n * @returns Readable stream.\n */\n async _stream() {\n const {\n type\n } = this;\n switch (type) {\n case PathType.FILE:\n {\n return this._streamFile();\n }\n case PathType.RESOURCE_FORK:\n {\n return this._streamResourceFork();\n }\n case PathType.DIRECTORY:\n {\n return this._streamDirectory();\n }\n case PathType.SYMLINK:\n {\n return this._streamSymlink();\n }\n default:\n {\n throw new Error(`Unsupported path type: ${type}`);\n }\n }\n }\n\n /**\n * Read file as stream.\n *\n * @returns Readable stream.\n */\n async _streamFile() {\n const readData = this._readData;\n if (!readData) {\n throw new Error('Internal error');\n }\n return readData();\n }\n\n /**\n * Read resource fork as stream.\n *\n * @returns Readable stream.\n */\n async _streamResourceFork() {\n const readRsrc = this._readRsrc;\n if (!readRsrc) {\n throw new Error('Internal error');\n }\n return readRsrc();\n }\n\n /**\n * Read directory null stream.\n *\n * @returns Null stream.\n */\n async _streamDirectory() {\n return null;\n }\n\n /**\n * Read symlink as stream.\n *\n * @returns Readable stream.\n */\n async _streamSymlink() {\n const readSymlink = this._readSymlink;\n if (!readSymlink) {\n throw new Error('Internal error');\n }\n const r = new Readable({\n // eslint-disable-next-line jsdoc/require-jsdoc\n read: () => {\n readSymlink().then(d => {\n r.push(d);\n // eslint-disable-next-line unicorn/no-array-push-push\n r.push(null);\n }, err => {\n r.emit('error', err);\n });\n }\n });\n return r;\n }\n}\n\n/**\n * Archive object.\n */\nexport class Archive {\n /**\n * List of file extensions, or null.\n */\n static FILE_EXTENSIONS = null;\n\n /**\n * Archive has named volumes that each entry will be under.\n */\n static HAS_NAMED_VOLUMES = false;\n\n /**\n * Entry constructor.\n */\n Entry = Entry;\n\n /**\n * File path.\n */\n\n /**\n * Flag for currently reading.\n */\n _reading = false;\n\n /**\n * Map of entries to set attributes on after reading.\n */\n _afterReadSetAttributes = null;\n\n /**\n * Archive constructor.\n *\n * @param path File path.\n */\n constructor(path) {\n this.path = path;\n }\n\n /**\n * List of file extensions used by this format.\n *\n * @returns List of file extensions.\n */\n get fileExtensions() {\n return this.constructor.FILE_EXTENSIONS || null;\n }\n\n /**\n * Archive has named volumes that each entry will be under.\n *\n * @returns Archive has named volumns.\n */\n get hasNamedVolumes() {\n return this.constructor.HAS_NAMED_VOLUMES;\n }\n\n /**\n * Add an instance to set attributes after the read finishes.\n *\n * @param path Path string.\n * @param entry Entry instance.\n * @param options Extract options.\n */\n afterReadSetAttributes(path, entry, options = {}) {\n const afters = this._afterReadSetAttributes;\n if (!afters) {\n throw new Error('Archive after read callbacks can only be added while reading');\n }\n afters.set(resolve(path), {\n path,\n entry,\n options\n });\n }\n\n /**\n * Remove an instance to set attributes after the read finishes.\n *\n * @param path Path string.\n */\n afterReadSetAttributesRemove(path) {\n const afters = this._afterReadSetAttributes;\n if (!afters) {\n throw new Error('Archive after read callbacks can only be removed while reading');\n }\n afters.delete(resolve(path));\n }\n\n /**\n * Read archive.\n * If the itter callback returns false, reading ends.\n * If the itter callback returns null, skip descent where available.\n *\n * @param itter Async callback for each archive entry.\n */\n async read(itter) {\n if (this._reading) {\n throw new Error('Archive already being read');\n }\n this._reading = true;\n\n // Reset the after entries.\n this._afterReadSetAttributes = new Map();\n\n // Read and handle all the afters, reset after.\n try {\n await this._read(itter);\n await this._afterReadSetAttributesTrigger();\n } finally {\n this._afterReadSetAttributes = null;\n this._reading = false;\n }\n }\n\n /**\n * Run all after read set attributes.\n */\n async _afterReadSetAttributesTrigger() {\n const afters = this._afterReadSetAttributes;\n if (!afters) {\n return;\n }\n\n // Prioritize by path length.\n const resolves = [];\n for (const [resolved] of afters) {\n resolves.push(resolved);\n }\n resolves.sort((a, b) => b.length - a.length);\n for (const resolved of resolves) {\n const ent = afters.get(resolved);\n if (!ent) {\n throw new Error('Internal error');\n }\n const {\n entry,\n path,\n options\n } = ent;\n // eslint-disable-next-line no-await-in-loop\n await entry.setAttributes(path, resolved, options);\n }\n }\n\n /**\n * Read archive, class implementation.\n * If the itter callback returns false, reading ends.\n * If the itter callback returns null, skip descent where available.\n *\n * @param itter Async callback for each archive entry.\n */\n}\n//# sourceMappingURL=archive.mjs.map","'use strict'\n\n/**\n * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.\n *\n * Works with anything that has a `length` property and index access properties, including NodeList.\n *\n * @template {unknown} T\n * @param {Array<T> | ({length:number, [number]: T})} list\n * @param {function (item: T, index: number, list:Array<T> | ({length:number, [number]: T})):boolean} predicate\n * @param {Partial<Pick<ArrayConstructor['prototype'], 'find'>>?} ac `Array.prototype` by default,\n * \t\t\t\tallows injecting a custom implementation in tests\n * @returns {T | undefined}\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\n * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find\n */\nfunction find(list, predicate, ac) {\n\tif (ac === undefined) {\n\t\tac = Array.prototype;\n\t}\n\tif (list && typeof ac.find === 'function') {\n\t\treturn ac.find.call(list, predicate);\n\t}\n\tfor (var i = 0; i < list.length; i++) {\n\t\tif (Object.prototype.hasOwnProperty.call(list, i)) {\n\t\t\tvar item = list[i];\n\t\t\tif (predicate.call(undefined, item, i, list)) {\n\t\t\t\treturn item;\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * \"Shallow freezes\" an object to render it immutable.\n * Uses `Object.freeze` if available,\n * otherwise the immutability is only in the type.\n *\n * Is used to create \"enum like\" objects.\n *\n * @template T\n * @param {T} object the object to freeze\n * @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default,\n * \t\t\t\tallows to inject custom object constructor for tests\n * @returns {Readonly<T>}\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\n */\nfunction freeze(object, oc) {\n\tif (oc === undefined) {\n\t\toc = Object\n\t}\n\treturn oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object\n}\n\n/**\n * Since we can not rely on `Object.assign` we provide a simplified version\n * that is sufficient for our needs.\n *\n * @param {Object} target\n * @param {Object | null | undefined} source\n *\n * @returns {Object} target\n * @throws TypeError if target is not an object\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign\n */\nfunction assign(target, source) {\n\tif (target === null || typeof target !== 'object') {\n\t\tthrow new TypeError('target is not an object')\n\t}\n\tfor (var key in source) {\n\t\tif (Object.prototype.hasOwnProperty.call(source, key)) {\n\t\t\ttarget[key] = source[key]\n\t\t}\n\t}\n\treturn target\n}\n\n/**\n * All mime types that are allowed as input to `DOMParser.parseFromString`\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN\n * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec\n * @see DOMParser.prototype.parseFromString\n */\nvar MIME_TYPE = freeze({\n\t/**\n\t * `text/html`, the only mime type that triggers treating an XML document as HTML.\n\t *\n\t * @see DOMParser.SupportedType.isHTML\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec\n\t */\n\tHTML: 'text/html',\n\n\t/**\n\t * Helper method to check a mime type if it indicates an HTML document\n\t *\n\t * @param {string} [value]\n\t * @returns {boolean}\n\t *\n\t * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/HTML Wikipedia\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN\n\t * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring \t */\n\tisHTML: function (value) {\n\t\treturn value === MIME_TYPE.HTML\n\t},\n\n\t/**\n\t * `application/xml`, the standard mime type for XML documents.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_APPLICATION: 'application/xml',\n\n\t/**\n\t * `text/html`, an alias for `application/xml`.\n\t *\n\t * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303\n\t * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration\n\t * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia\n\t */\n\tXML_TEXT: 'text/xml',\n\n\t/**\n\t * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,\n\t * but is parsed as an XML document.\n\t *\n\t * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec\n\t * @see https://en.wikipedia.org/wiki/XHTML Wikipedia\n\t */\n\tXML_XHTML_APPLICATION: 'application/xhtml+xml',\n\n\t/**\n\t * `image/svg+xml`,\n\t *\n\t * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration\n\t * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1\n\t * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia\n\t */\n\tXML_SVG_IMAGE: 'image/svg+xml',\n})\n\n/**\n * Namespaces that are used in this code base.\n *\n * @see http://www.w3.org/TR/REC-xml-names\n */\nvar NAMESPACE = freeze({\n\t/**\n\t * The XHTML namespace.\n\t *\n\t * @see http://www.w3.org/1999/xhtml\n\t */\n\tHTML: 'http://www.w3.org/1999/xhtml',\n\n\t/**\n\t * Checks if `uri` equals `NAMESPACE.HTML`.\n\t *\n\t * @param {string} [uri]\n\t *\n\t * @see NAMESPACE.HTML\n\t */\n\tisHTML: function (uri) {\n\t\treturn uri === NAMESPACE.HTML\n\t},\n\n\t/**\n\t * The SVG namespace.\n\t *\n\t * @see http://www.w3.org/2000/svg\n\t */\n\tSVG: 'http://www.w3.org/2000/svg',\n\n\t/**\n\t * The `xml:` namespace.\n\t *\n\t * @see http://www.w3.org/XML/1998/namespace\n\t */\n\tXML: 'http://www.w3.org/XML/1998/namespace',\n\n\t/**\n\t * The `xmlns:` namespace\n\t *\n\t * @see https://www.w3.org/2000/xmlns/\n\t */\n\tXMLNS: 'http://www.w3.org/2000/xmlns/',\n})\n\nexports.assign = assign;\nexports.find = find;\nexports.freeze = freeze;\nexports.MIME_TYPE = MIME_TYPE;\nexports.NAMESPACE = NAMESPACE;\n","var conventions = require(\"./conventions\");\n\nvar find = conventions.find;\nvar NAMESPACE = conventions.NAMESPACE;\n\n/**\n * A prerequisite for `[].filter`, to drop elements that are empty\n * @param {string} input\n * @returns {boolean}\n */\nfunction notEmptyString (input) {\n\treturn input !== ''\n}\n/**\n * @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace\n * @see https://infra.spec.whatwg.org/#ascii-whitespace\n *\n * @param {string} input\n * @returns {string[]} (can be empty)\n */\nfunction splitOnASCIIWhitespace(input) {\n\t// U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE\n\treturn input ? input.split(/[\\t\\n\\f\\r ]+/).filter(notEmptyString) : []\n}\n\n/**\n * Adds element as a key to current if it is not already present.\n *\n * @param {Record<string, boolean | undefined>} current\n * @param {string} element\n * @returns {Record<string, boolean | undefined>}\n */\nfunction orderedSetReducer (current, element) {\n\tif (!current.hasOwnProperty(element)) {\n\t\tcurrent[element] = true;\n\t}\n\treturn current;\n}\n\n/**\n * @see https://infra.spec.whatwg.org/#ordered-set\n * @param {string} input\n * @returns {string[]}\n */\nfunction toOrderedSet(input) {\n\tif (!input) return [];\n\tvar list = splitOnASCIIWhitespace(input);\n\treturn Object.keys(list.reduce(orderedSetReducer, {}))\n}\n\n/**\n * Uses `list.indexOf` to implement something like `Array.prototype.includes`,\n * which we can not rely on being available.\n *\n * @param {any[]} list\n * @returns {function(any): boolean}\n */\nfunction arrayIncludes (list) {\n\treturn function(element) {\n\t\treturn list && list.indexOf(element) !== -1;\n\t}\n}\n\nfunction copy(src,dest){\n\tfor(var p in src){\n\t\tif (Object.prototype.hasOwnProperty.call(src, p)) {\n\t\t\tdest[p] = src[p];\n\t\t}\n\t}\n}\n\n/**\n^\\w+\\.prototype\\.([_\\w]+)\\s*=\\s*((?:.*\\{\\s*?[\\r\\n][\\s\\S]*?^})|\\S.*?(?=[;\\r\\n]));?\n^\\w+\\.prototype\\.([_\\w]+)\\s*=\\s*(\\S.*?(?=[;\\r\\n]));?\n */\nfunction _extends(Class,Super){\n\tvar pt = Class.prototype;\n\tif(!(pt instanceof Super)){\n\t\tfunction t(){};\n\t\tt.prototype = Super.prototype;\n\t\tt = new t();\n\t\tcopy(pt,t);\n\t\tClass.prototype = pt = t;\n\t}\n\tif(pt.constructor != Class){\n\t\tif(typeof Class != 'function'){\n\t\t\tconsole.error(\"unknown Class:\"+Class)\n\t\t}\n\t\tpt.constructor = Class\n\t}\n}\n\n// Node Types\nvar NodeType = {}\nvar ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;\nvar ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;\nvar TEXT_NODE = NodeType.TEXT_NODE = 3;\nvar CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;\nvar ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;\nvar ENTITY_NODE = NodeType.ENTITY_NODE = 6;\nvar PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;\nvar COMMENT_NODE = NodeType.COMMENT_NODE = 8;\nvar DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;\nvar DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;\nvar DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;\nvar NOTATION_NODE = NodeType.NOTATION_NODE = 12;\n\n// ExceptionCode\nvar ExceptionCode = {}\nvar ExceptionMessage = {};\nvar INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1]=\"Index size error\"),1);\nvar DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2]=\"DOMString size error\"),2);\nvar HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3]=\"Hierarchy request error\"),3);\nvar WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4]=\"Wrong document\"),4);\nvar INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5]=\"Invalid character\"),5);\nvar NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6]=\"No data allowed\"),6);\nvar NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]=\"No modification allowed\"),7);\nvar NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8]=\"Not found\"),8);\nvar NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9]=\"Not supported\"),9);\nvar INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10]=\"Attribute in use\"),10);\n//level2\nvar INVALID_STATE_ERR \t= ExceptionCode.INVALID_STATE_ERR \t= ((ExceptionMessage[11]=\"Invalid state\"),11);\nvar SYNTAX_ERR \t= ExceptionCode.SYNTAX_ERR \t= ((ExceptionMessage[12]=\"Syntax error\"),12);\nvar INVALID_MODIFICATION_ERR \t= ExceptionCode.INVALID_MODIFICATION_ERR \t= ((ExceptionMessage[13]=\"Invalid modification\"),13);\nvar NAMESPACE_ERR \t= ExceptionCode.NAMESPACE_ERR \t= ((ExceptionMessage[14]=\"Invalid namespace\"),14);\nvar INVALID_ACCESS_ERR \t= ExceptionCode.INVALID_ACCESS_ERR \t= ((ExceptionMessage[15]=\"Invalid access\"),15);\n\n/**\n * DOM Level 2\n * Object DOMException\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html\n * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html\n */\nfunction DOMException(code, message) {\n\tif(message instanceof Error){\n\t\tvar error = message;\n\t}else{\n\t\terror = this;\n\t\tError.call(this, ExceptionMessage[code]);\n\t\tthis.message = ExceptionMessage[code];\n\t\tif(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);\n\t}\n\terror.code = code;\n\tif(message) this.message = this.message + \": \" + message;\n\treturn error;\n};\nDOMException.prototype = Error.prototype;\ncopy(ExceptionCode,DOMException)\n\n/**\n * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177\n * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.\n * The items in the NodeList are accessible via an integral index, starting from 0.\n */\nfunction NodeList() {\n};\nNodeList.prototype = {\n\t/**\n\t * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.\n\t * @standard level1\n\t */\n\tlength:0,\n\t/**\n\t * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.\n\t * @standard level1\n\t * @param index unsigned long\n\t * Index into the collection.\n\t * @return Node\n\t * \tThe node at the indexth position in the NodeList, or null if that is not a valid index.\n\t */\n\titem: function(index) {\n\t\treturn index >= 0 && index < this.length ? this[index] : null;\n\t},\n\ttoString:function(isHTML,nodeFilter){\n\t\tfor(var buf = [], i = 0;i<this.length;i++){\n\t\t\tserializeToString(this[i],buf,isHTML,nodeFilter);\n\t\t}\n\t\treturn buf.join('');\n\t},\n\t/**\n\t * @private\n\t * @param {function (Node):boolean} predicate\n\t * @returns {Node[]}\n\t */\n\tfilter: function (predicate) {\n\t\treturn Array.prototype.filter.call(this, predicate);\n\t},\n\t/**\n\t * @private\n\t * @param {Node} item\n\t * @returns {number}\n\t */\n\tindexOf: function (item) {\n\t\treturn Array.prototype.indexOf.call(this, item);\n\t},\n};\n\nfunction LiveNodeList(node,refresh){\n\tthis._node = node;\n\tthis._refresh = refresh\n\t_updateLiveList(this);\n}\nfunction _updateLiveList(list){\n\tvar inc = list._node._inc || list._node.ownerDocument._inc;\n\tif (list._inc !== inc) {\n\t\tvar ls = list._refresh(list._node);\n\t\t__set__(list,'length',ls.length);\n\t\tif (!list.$$length || ls.length < list.$$length) {\n\t\t\tfor (var i = ls.length; i in list; i++) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(list, i)) {\n\t\t\t\t\tdelete list[i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcopy(ls,list);\n\t\tlist._inc = inc;\n\t}\n}\nLiveNodeList.prototype.item = function(i){\n\t_updateLiveList(this);\n\treturn this[i] || null;\n}\n\n_extends(LiveNodeList,NodeList);\n\n/**\n * Objects implementing the NamedNodeMap interface are used\n * to represent collections of nodes that can be accessed by name.\n * Note that NamedNodeMap does not inherit from NodeList;\n * NamedNodeMaps are not maintained in any particular order.\n * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index,\n * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,\n * and does not imply that the DOM specifies an order to these Nodes.\n * NamedNodeMap objects in the DOM are live.\n * used for attributes or DocumentType entities\n */\nfunction NamedNodeMap() {\n};\n\nfunction _findNodeIndex(list,node){\n\tvar i = list.length;\n\twhile(i--){\n\t\tif(list[i] === node){return i}\n\t}\n}\n\nfunction _addNamedNode(el,list,newAttr,oldAttr){\n\tif(oldAttr){\n\t\tlist[_findNodeIndex(list,oldAttr)] = newAttr;\n\t}else{\n\t\tlist[list.length++] = newAttr;\n\t}\n\tif(el){\n\t\tnewAttr.ownerElement = el;\n\t\tvar doc = el.ownerDocument;\n\t\tif(doc){\n\t\t\toldAttr && _onRemoveAttribute(doc,el,oldAttr);\n\t\t\t_onAddAttribute(doc,el,newAttr);\n\t\t}\n\t}\n}\nfunction _removeNamedNode(el,list,attr){\n\t//console.log('remove attr:'+attr)\n\tvar i = _findNodeIndex(list,attr);\n\tif(i>=0){\n\t\tvar lastIndex = list.length-1\n\t\twhile(i<lastIndex){\n\t\t\tlist[i] = list[++i]\n\t\t}\n\t\tlist.length = lastIndex;\n\t\tif(el){\n\t\t\tvar doc = el.ownerDocument;\n\t\t\tif(doc){\n\t\t\t\t_onRemoveAttribute(doc,el,attr);\n\t\t\t\tattr.ownerElement = null;\n\t\t\t}\n\t\t}\n\t}else{\n\t\tthrow new DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))\n\t}\n}\nNamedNodeMap.prototype = {\n\tlength:0,\n\titem:NodeList.prototype.item,\n\tgetNamedItem: function(key) {\n//\t\tif(key.indexOf(':')>0 || key == 'xmlns'){\n//\t\t\treturn null;\n//\t\t}\n\t\t//console.log()\n\t\tvar i = this.length;\n\t\twhile(i--){\n\t\t\tvar attr = this[i];\n\t\t\t//console.log(attr.nodeName,key)\n\t\t\tif(attr.nodeName == key){\n\t\t\t\treturn attr;\n\t\t\t}\n\t\t}\n\t},\n\tsetNamedItem: function(attr) {\n\t\tvar el = attr.ownerElement;\n\t\tif(el && el!=this._ownerElement){\n\t\t\tthrow new DOMException(INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\tvar oldAttr = this.getNamedItem(attr.nodeName);\n\t\t_addNamedNode(this._ownerElement,this,attr,oldAttr);\n\t\treturn oldAttr;\n\t},\n\t/* returns Node */\n\tsetNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR\n\t\tvar el = attr.ownerElement, oldAttr;\n\t\tif(el && el!=this._ownerElement){\n\t\t\tthrow new DOMException(INUSE_ATTRIBUTE_ERR);\n\t\t}\n\t\toldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);\n\t\t_addNamedNode(this._ownerElement,this,attr,oldAttr);\n\t\treturn oldAttr;\n\t},\n\n\t/* returns Node */\n\tremoveNamedItem: function(key) {\n\t\tvar attr = this.getNamedItem(key);\n\t\t_removeNamedNode(this._ownerElement,this,attr);\n\t\treturn attr;\n\n\n\t},// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR\n\n\t//for level2\n\tremoveNamedItemNS:function(namespaceURI,localName){\n\t\tvar attr = this.getNamedItemNS(namespaceURI,localName);\n\t\t_removeNamedNode(this._ownerElement,this,attr);\n\t\treturn attr;\n\t},\n\tgetNamedItemNS: function(namespaceURI, localName) {\n\t\tvar i = this.length;\n\t\twhile(i--){\n\t\t\tvar node = this[i];\n\t\t\tif(node.localName == localName && node.namespaceURI == namespaceURI){\n\t\t\t\treturn node;\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n};\n\n/**\n * The DOMImplementation interface represents an object providing methods\n * which are not dependent on any particular document.\n * Such an object is returned by the `Document.implementation` property.\n *\n * __The individual methods describe the differences compared to the specs.__\n *\n * @constructor\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN\n * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)\n * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core\n * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core\n * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard\n */\nfunction DOMImplementation() {\n}\n\nDOMImplementation.prototype = {\n\t/**\n\t * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.\n\t * The different implementations fairly diverged in what kind of features were reported.\n\t * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.\n\t *\n\t * @deprecated It is deprecated and modern browsers return true in all cases.\n\t *\n\t * @param {string} feature\n\t * @param {string} [version]\n\t * @returns {boolean} always true\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN\n\t * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard\n\t */\n\thasFeature: function(feature, version) {\n\t\t\treturn true;\n\t},\n\t/**\n\t * Creates an XML Document object of the specified type with its document element.\n\t *\n\t * __It behaves slightly different from the description in the living standard__:\n\t * - There is no interface/class `XMLDocument`, it returns a `Document` instance.\n\t * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.\n\t * - this implementation is not validating names or qualified names\n\t * (when parsing XML strings, the SAX parser takes care of that)\n\t *\n\t * @param {string|null} namespaceURI\n\t * @param {string} qualifiedName\n\t * @param {DocumentType=null} doctype\n\t * @returns {Document}\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core\n\t *\n\t * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract\n\t * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names\n\t * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names\n\t */\n\tcreateDocument: function(namespaceURI, qualifiedName, doctype){\n\t\tvar doc = new Document();\n\t\tdoc.implementation = this;\n\t\tdoc.childNodes = new NodeList();\n\t\tdoc.doctype = doctype || null;\n\t\tif (doctype){\n\t\t\tdoc.appendChild(doctype);\n\t\t}\n\t\tif (qualifiedName){\n\t\t\tvar root = doc.createElementNS(namespaceURI, qualifiedName);\n\t\t\tdoc.appendChild(root);\n\t\t}\n\t\treturn doc;\n\t},\n\t/**\n\t * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.\n\t *\n\t * __This behavior is slightly different from the in the specs__:\n\t * - this implementation is not validating names or qualified names\n\t * (when parsing XML strings, the SAX parser takes care of that)\n\t *\n\t * @param {string} qualifiedName\n\t * @param {string} [publicId]\n\t * @param {string} [systemId]\n\t * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation\n\t * \t\t\t\t or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`\n\t *\n\t * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN\n\t * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core\n\t * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard\n\t *\n\t * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract\n\t * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names\n\t * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names\n\t */\n\tcreateDocumentType: function(qualifiedName, publicId, systemId){\n\t\tvar node = new DocumentType();\n\t\tnode.name = qualifiedName;\n\t\tnode.nodeName = qualifiedName;\n\t\tnode.publicId = publicId || '';\n\t\tnode.systemId = systemId || '';\n\n\t\treturn node;\n\t}\n};\n\n\n/**\n *