UNPKG

@fedify/fedify

Version:

An ActivityPub server framework

1,546 lines (1,508 loc) 114 kB
import { Temporal } from "@js-temporal/polyfill"; import { URLPattern } from "urlpattern-polyfill"; globalThis.addEventListener = () => {}; import { assertEquals, isWindows } from "../assert_equals-CTYbeopb.js"; import { assert } from "../assert-DmFG7ppO.js"; import { assertInstanceOf } from "../assert_instance_of-CF09JHYM.js"; import "../docloader-C8mmLN-Y.js"; import "../url-kTAI6_KP.js"; import { decode } from "../multibase-DeCHcK8L.js"; import { Activity, Announce, Create, CryptographicKey, Follow, Hashtag, Note, Object as Object$1, OrderedCollectionPage, Person, Place, Question, Source, vocab_exports } from "../vocab-dDpPQ0fF.js"; import { LanguageString } from "../langstr-DbWheeIS.js"; import { test } from "../testing-BZ0dJ4qn.js"; import "../std__assert-vp0TKMS1.js"; import { assertFalse, assertRejects } from "../assert_rejects-C-sxEMM5.js"; import "../assert_is_error-nrwA1GeT.js"; import { assertNotEquals } from "../assert_not_equals-Dc7y-V5Q.js"; import { assertThrows } from "../assert_throws-Cn9C6Jur.js"; import { mockDocumentLoader } from "../docloader-09nVWLAZ.js"; import { ed25519PublicKey, rsaPublicKey1 } from "../keys-CtFc865v.js"; import { pascalCase } from "@es-toolkit/es-toolkit"; import { parseLanguageTag } from "@phensley/language-tag"; import { Validator } from "@cfworker/json-schema"; import { readFile, readdir } from "node:fs/promises"; import { join } from "node:path"; //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/_common/assert_path.js function assertPath(path) { if (typeof path !== "string") throw new TypeError(`Path must be a string, received "${JSON.stringify(path)}"`); } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/_common/from_file_url.js function assertArg$2(url) { url = url instanceof URL ? url : new URL(url); if (url.protocol !== "file:") throw new TypeError(`URL must be a file URL: received "${url.protocol}"`); return url; } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/posix/from_file_url.js /** * Converts a file URL to a path string. * * @example Usage * ```ts * import { fromFileUrl } from "@std/path/posix/from-file-url"; * import { assertEquals } from "@std/assert"; * * assertEquals(fromFileUrl(new URL("file:///home/foo")), "/home/foo"); * ``` * * @param url The file URL to convert. * @returns The path string. */ function fromFileUrl$1(url) { url = assertArg$2(url); return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25")); } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/_common/strip_trailing_separators.js function stripTrailingSeparators(segment, isSep) { if (segment.length <= 1) return segment; let end = segment.length; for (let i = segment.length - 1; i > 0; i--) if (isSep(segment.charCodeAt(i))) end = i; else break; return segment.slice(0, end); } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/_common/constants.js const CHAR_DOT = 46; const CHAR_FORWARD_SLASH = 47; //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/posix/_util.js function isPosixPathSeparator(code) { return code === CHAR_FORWARD_SLASH; } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/windows/from_file_url.js /** * Converts a file URL to a path string. * * @example Usage * ```ts * import { fromFileUrl } from "@std/path/windows/from-file-url"; * import { assertEquals } from "@std/assert"; * * assertEquals(fromFileUrl("file:///home/foo"), "\\home\\foo"); * assertEquals(fromFileUrl("file:///C:/Users/foo"), "C:\\Users\\foo"); * assertEquals(fromFileUrl("file://localhost/home/foo"), "\\home\\foo"); * ``` * * @param url The file URL to convert. * @returns The path string. */ function fromFileUrl$2(url) { url = assertArg$2(url); let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\"); if (url.hostname !== "") path = `\\\\${url.hostname}${path}`; return path; } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/_common/dirname.js function assertArg$1(path) { assertPath(path); if (path.length === 0) return "."; } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/posix/dirname.js /** * Return the directory path of a `path`. * * @example Usage * ```ts * import { dirname } from "@std/path/posix/dirname"; * import { assertEquals } from "@std/assert"; * * assertEquals(dirname("/home/user/Documents/"), "/home/user"); * assertEquals(dirname("/home/user/Documents/image.png"), "/home/user/Documents"); * assertEquals(dirname("https://deno.land/std/path/mod.ts"), "https://deno.land/std/path"); * assertEquals(dirname(new URL("file:///home/user/Documents/image.png")), "/home/user/Documents"); * ``` * * @example Working with URLs * * ```ts * import { dirname } from "@std/path/posix/dirname"; * import { assertEquals } from "@std/assert"; * * assertEquals(dirname("https://deno.land/std/path/mod.ts"), "https://deno.land/std/path"); * assertEquals(dirname("https://deno.land/std/path/mod.ts?a=b"), "https://deno.land/std/path"); * assertEquals(dirname("https://deno.land/std/path/mod.ts#header"), "https://deno.land/std/path"); * ``` * * @param path The path to get the directory from. * @returns The directory path. */ function dirname(path) { if (path instanceof URL) path = fromFileUrl$1(path); assertArg$1(path); let end = -1; let matchedNonSeparator = false; for (let i = path.length - 1; i >= 1; --i) if (isPosixPathSeparator(path.charCodeAt(i))) { if (matchedNonSeparator) { end = i; break; } } else matchedNonSeparator = true; if (end === -1) return isPosixPathSeparator(path.charCodeAt(0)) ? "/" : "."; return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator); } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/from_file_url.js /** * Converts a file URL to a path string. * * @example Usage * ```ts * import { fromFileUrl } from "@std/path/from-file-url"; * import { assertEquals } from "@std/assert"; * * if (Deno.build.os === "windows") { * assertEquals(fromFileUrl("file:///home/foo"), "\\home\\foo"); * assertEquals(fromFileUrl("file:///C:/Users/foo"), "C:\\Users\\foo"); * assertEquals(fromFileUrl("file://localhost/home/foo"), "\\home\\foo"); * } else { * assertEquals(fromFileUrl("file:///home/foo"), "/home/foo"); * } * ``` * * @param url The file URL to convert to a path. * @returns The path string. */ function fromFileUrl(url) { return isWindows ? fromFileUrl$2(url) : fromFileUrl$1(url); } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/_common/normalize.js function assertArg(path) { assertPath(path); if (path.length === 0) return "."; } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/_common/normalize_string.js function normalizeString(path, allowAboveRoot, separator, isPathSeparator) { let res = ""; let lastSegmentLength = 0; let lastSlash = -1; let dots = 0; let code; for (let i = 0; i <= path.length; ++i) { if (i < path.length) code = path.charCodeAt(i); else if (isPathSeparator(code)) break; else code = CHAR_FORWARD_SLASH; if (isPathSeparator(code)) { if (lastSlash === i - 1 || dots === 1) {} else if (lastSlash !== i - 1 && dots === 2) { if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== CHAR_DOT || res.charCodeAt(res.length - 2) !== CHAR_DOT) { if (res.length > 2) { const lastSlashIndex = res.lastIndexOf(separator); if (lastSlashIndex === -1) { res = ""; lastSegmentLength = 0; } else { res = res.slice(0, lastSlashIndex); lastSegmentLength = res.length - 1 - res.lastIndexOf(separator); } lastSlash = i; dots = 0; continue; } else if (res.length === 2 || res.length === 1) { res = ""; lastSegmentLength = 0; lastSlash = i; dots = 0; continue; } } if (allowAboveRoot) { if (res.length > 0) res += `${separator}..`; else res = ".."; lastSegmentLength = 2; } } else { if (res.length > 0) res += separator + path.slice(lastSlash + 1, i); else res = path.slice(lastSlash + 1, i); lastSegmentLength = i - lastSlash - 1; } lastSlash = i; dots = 0; } else if (code === CHAR_DOT && dots !== -1) ++dots; else dots = -1; } return res; } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/posix/normalize.js /** * Normalize the `path`, resolving `'..'` and `'.'` segments. * Note that resolving these segments does not necessarily mean that all will be eliminated. * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`. * * @example Usage * ```ts * import { normalize } from "@std/path/posix/normalize"; * import { assertEquals } from "@std/assert"; * * assertEquals(normalize("/foo/bar//baz/asdf/quux/.."), "/foo/bar/baz/asdf"); * assertEquals(normalize(new URL("file:///foo/bar//baz/asdf/quux/..")), "/foo/bar/baz/asdf/"); * ``` * * @example Working with URLs * * Note: This function will remove the double slashes from a URL's scheme. * Hence, do not pass a full URL to this function. Instead, pass the pathname of * the URL. * * ```ts * import { normalize } from "@std/path/posix/normalize"; * import { assertEquals } from "@std/assert"; * * const url = new URL("https://deno.land"); * url.pathname = normalize("//std//assert//.//mod.ts"); * assertEquals(url.href, "https://deno.land/std/assert/mod.ts"); * * url.pathname = normalize("std/assert/../async/retry.ts"); * assertEquals(url.href, "https://deno.land/std/async/retry.ts"); * ``` * * @param path The path to normalize. * @returns The normalized path. */ function normalize(path) { if (path instanceof URL) path = fromFileUrl$1(path); assertArg(path); const isAbsolute = isPosixPathSeparator(path.charCodeAt(0)); const trailingSeparator = isPosixPathSeparator(path.charCodeAt(path.length - 1)); path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator); if (path.length === 0 && !isAbsolute) path = "."; if (path.length > 0 && trailingSeparator) path += "/"; if (isAbsolute) return `/${path}`; return path; } //#endregion //#region node_modules/.pnpm/@jsr+std__path@1.1.1/node_modules/@jsr/std__path/posix/join.js /** * Join all given a sequence of `paths`,then normalizes the resulting path. * * @example Usage * ```ts * import { join } from "@std/path/posix/join"; * import { assertEquals } from "@std/assert"; * * assertEquals(join("/foo", "bar", "baz/asdf", "quux", ".."), "/foo/bar/baz/asdf"); * assertEquals(join(new URL("file:///foo"), "bar", "baz/asdf", "quux", ".."), "/foo/bar/baz/asdf"); * ``` * * @example Working with URLs * ```ts * import { join } from "@std/path/posix/join"; * import { assertEquals } from "@std/assert"; * * const url = new URL("https://deno.land"); * url.pathname = join("std", "path", "mod.ts"); * assertEquals(url.href, "https://deno.land/std/path/mod.ts"); * * url.pathname = join("//std", "path/", "/mod.ts"); * assertEquals(url.href, "https://deno.land/std/path/mod.ts"); * ``` * * @param path The path to join. This can be string or file URL. * @param paths The paths to join. * @returns The joined path. */ function join$1(path, ...paths) { if (path === void 0) return "."; if (path instanceof URL) path = fromFileUrl$1(path); paths = path ? [path, ...paths] : paths; paths.forEach((path$1) => assertPath(path$1)); const joined = paths.filter((path$1) => path$1.length > 0).join("/"); return joined === "" ? "." : normalize(joined); } //#endregion //#region node_modules/.pnpm/@jsr+std__url@1.0.0-rc.3/node_modules/@jsr/std__url/_strip.js /** * Strips any hash (eg. `#header`) or search parameters (eg. `?foo=bar`) from the provided URL. * * (Mutates the original url provided) * @param url to be stripped. */ function strip(url) { url.hash = ""; url.search = ""; } //#endregion //#region node_modules/.pnpm/@jsr+std__url@1.0.0-rc.3/node_modules/@jsr/std__url/dirname.js /** * Returns the directory path URL of a URL or URL string. * * The directory path is the portion of a URL up to but excluding the final path * segment. URL queries and hashes are ignored. * * @param url URL to extract the directory from. * @returns The directory path URL of the URL. * * @example Usage * ```ts * import { dirname } from "@std/url/dirname"; * import { assertEquals } from "@std/assert"; * * assertEquals(dirname("https://deno.land/std/path/mod.ts"), new URL("https://deno.land/std/path")); * assertEquals(dirname(new URL("https://deno.land/std/path/mod.ts")), new URL("https://deno.land/std/path")); * ``` * * @deprecated Use * {@linkcode https://jsr.io/@std/path/doc/posix/~/dirname | @std/path/posix/dirname} * instead (examples included). `@std/url` will be removed in the future. */ function dirname$1(url) { url = new URL(url); strip(url); url.pathname = dirname(url.pathname); return url; } //#endregion //#region node_modules/.pnpm/@jsr+std__url@1.0.0-rc.3/node_modules/@jsr/std__url/join.js /** * Joins a base URL or URL string, and a sequence of path segments together, * then normalizes the resulting URL. * * @param url Base URL to be joined with the paths and normalized. * @param paths Array of path segments to be joined to the base URL. * @returns A complete URL containing the base URL joined with the paths. * * @example Usage * * ```ts * import { join } from "@std/url/join"; * import { assertEquals } from "@std/assert"; * * assertEquals(join("https://deno.land/", "std", "path", "mod.ts").href, "https://deno.land/std/path/mod.ts"); * assertEquals(join("https://deno.land", "//std", "path/", "/mod.ts").href, "https://deno.land/std/path/mod.ts"); * ``` * * @deprecated Use * {@linkcode https://jsr.io/@std/path/doc/posix/~/join | @std/path/posix/join} * instead (examples included). `@std/url` will be removed in the future. */ function join$2(url, ...paths) { url = new URL(url); url.pathname = join$1(url.pathname, ...paths); return url; } //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_chars.js const TAB = 9; const LINE_FEED = 10; const CARRIAGE_RETURN = 13; const SPACE = 32; const EXCLAMATION = 33; const DOUBLE_QUOTE = 34; const SHARP = 35; const PERCENT = 37; const AMPERSAND = 38; const SINGLE_QUOTE = 39; const ASTERISK = 42; const PLUS = 43; const COMMA = 44; const MINUS = 45; const DOT = 46; const COLON = 58; const SMALLER_THAN = 60; const GREATER_THAN = 62; const QUESTION = 63; const COMMERCIAL_AT = 64; const LEFT_SQUARE_BRACKET = 91; const BACKSLASH = 92; const RIGHT_SQUARE_BRACKET = 93; const GRAVE_ACCENT = 96; const LEFT_CURLY_BRACKET = 123; const VERTICAL_LINE = 124; const RIGHT_CURLY_BRACKET = 125; function isEOL(c) { return c === LINE_FEED || c === CARRIAGE_RETURN; } function isWhiteSpace(c) { return c === TAB || c === SPACE; } function isWhiteSpaceOrEOL(c) { return isWhiteSpace(c) || isEOL(c); } function isFlowIndicator(c) { return c === COMMA || c === LEFT_SQUARE_BRACKET || c === RIGHT_SQUARE_BRACKET || c === LEFT_CURLY_BRACKET || c === RIGHT_CURLY_BRACKET; } //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/binary.js const BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r"; function resolveYamlBinary(data) { if (data === null) return false; let code; let bitlen = 0; const max = data.length; const map$1 = BASE64_MAP; for (let idx = 0; idx < max; idx++) { code = map$1.indexOf(data.charAt(idx)); if (code > 64) continue; if (code < 0) return false; bitlen += 6; } return bitlen % 8 === 0; } function constructYamlBinary(data) { const input = data.replace(/[\r\n=]/g, ""); const max = input.length; const map$1 = BASE64_MAP; const result = []; let bits = 0; for (let idx = 0; idx < max; idx++) { if (idx % 4 === 0 && idx) { result.push(bits >> 16 & 255); result.push(bits >> 8 & 255); result.push(bits & 255); } bits = bits << 6 | map$1.indexOf(input.charAt(idx)); } const tailbits = max % 4 * 6; if (tailbits === 0) { result.push(bits >> 16 & 255); result.push(bits >> 8 & 255); result.push(bits & 255); } else if (tailbits === 18) { result.push(bits >> 10 & 255); result.push(bits >> 2 & 255); } else if (tailbits === 12) result.push(bits >> 4 & 255); return new Uint8Array(result); } function representYamlBinary(object) { const max = object.length; const map$1 = BASE64_MAP; let result = ""; let bits = 0; for (let idx = 0; idx < max; idx++) { if (idx % 3 === 0 && idx) { result += map$1[bits >> 18 & 63]; result += map$1[bits >> 12 & 63]; result += map$1[bits >> 6 & 63]; result += map$1[bits & 63]; } bits = (bits << 8) + object[idx]; } const tail = max % 3; if (tail === 0) { result += map$1[bits >> 18 & 63]; result += map$1[bits >> 12 & 63]; result += map$1[bits >> 6 & 63]; result += map$1[bits & 63]; } else if (tail === 2) { result += map$1[bits >> 10 & 63]; result += map$1[bits >> 4 & 63]; result += map$1[bits << 2 & 63]; result += map$1[64]; } else if (tail === 1) { result += map$1[bits >> 2 & 63]; result += map$1[bits << 4 & 63]; result += map$1[64]; result += map$1[64]; } return result; } function isBinary(obj) { return obj instanceof Uint8Array; } const binary = { tag: "tag:yaml.org,2002:binary", construct: constructYamlBinary, kind: "scalar", predicate: isBinary, represent: representYamlBinary, resolve: resolveYamlBinary }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/bool.js const YAML_TRUE_BOOLEANS = [ "true", "True", "TRUE" ]; const YAML_FALSE_BOOLEANS = [ "false", "False", "FALSE" ]; const YAML_BOOLEANS = [...YAML_TRUE_BOOLEANS, ...YAML_FALSE_BOOLEANS]; const bool = { tag: "tag:yaml.org,2002:bool", kind: "scalar", defaultStyle: "lowercase", predicate: (value) => typeof value === "boolean" || value instanceof Boolean, construct: (data) => YAML_TRUE_BOOLEANS.includes(data), resolve: (data) => YAML_BOOLEANS.includes(data), represent: { lowercase: (object) => { const value = object instanceof Boolean ? object.valueOf() : object; return value ? "true" : "false"; }, uppercase: (object) => { const value = object instanceof Boolean ? object.valueOf() : object; return value ? "TRUE" : "FALSE"; }, camelcase: (object) => { const value = object instanceof Boolean ? object.valueOf() : object; return value ? "True" : "False"; } } }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_utils.js function isObject(value) { return value !== null && typeof value === "object"; } function isNegativeZero(i) { return i === 0 && Number.NEGATIVE_INFINITY === 1 / i; } function isPlainObject(object) { return Object.prototype.toString.call(object) === "[object Object]"; } //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/float.js const YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"); function resolveYamlFloat(data) { if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") return false; return true; } function constructYamlFloat(data) { let value = data.replace(/_/g, "").toLowerCase(); const sign = value[0] === "-" ? -1 : 1; if (value[0] && "+-".includes(value[0])) value = value.slice(1); if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; if (value === ".nan") return NaN; return sign * parseFloat(value); } const SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; function representYamlFloat(object, style) { const value = object instanceof Number ? object.valueOf() : object; if (isNaN(value)) switch (style) { case "lowercase": return ".nan"; case "uppercase": return ".NAN"; case "camelcase": return ".NaN"; } else if (Number.POSITIVE_INFINITY === value) switch (style) { case "lowercase": return ".inf"; case "uppercase": return ".INF"; case "camelcase": return ".Inf"; } else if (Number.NEGATIVE_INFINITY === value) switch (style) { case "lowercase": return "-.inf"; case "uppercase": return "-.INF"; case "camelcase": return "-.Inf"; } else if (isNegativeZero(value)) return "-0.0"; const res = value.toString(10); return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res; } function isFloat(object) { if (object instanceof Number) object = object.valueOf(); return typeof object === "number" && (object % 1 !== 0 || isNegativeZero(object)); } const float = { tag: "tag:yaml.org,2002:float", construct: constructYamlFloat, defaultStyle: "lowercase", kind: "scalar", predicate: isFloat, represent: representYamlFloat, resolve: resolveYamlFloat }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/int.js function isCharCodeInRange(c, lower, upper) { return lower <= c && c <= upper; } function isHexCode(c) { return isCharCodeInRange(c, 48, 57) || isCharCodeInRange(c, 65, 70) || isCharCodeInRange(c, 97, 102); } function isOctCode(c) { return isCharCodeInRange(c, 48, 55); } function isDecCode(c) { return isCharCodeInRange(c, 48, 57); } function resolveYamlInteger(data) { const max = data.length; let index = 0; let hasDigits = false; if (!max) return false; let ch = data[index]; if (ch === "-" || ch === "+") ch = data[++index]; if (ch === "0") { if (index + 1 === max) return true; ch = data[++index]; if (ch === "b") { index++; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (ch !== "0" && ch !== "1") return false; hasDigits = true; } return hasDigits && ch !== "_"; } if (ch === "x") { index++; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (!isHexCode(data.charCodeAt(index))) return false; hasDigits = true; } return hasDigits && ch !== "_"; } for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (!isOctCode(data.charCodeAt(index))) return false; hasDigits = true; } return hasDigits && ch !== "_"; } if (ch === "_") return false; for (; index < max; index++) { ch = data[index]; if (ch === "_") continue; if (!isDecCode(data.charCodeAt(index))) return false; hasDigits = true; } if (!hasDigits || ch === "_") return false; return /^(:[0-5]?[0-9])+$/.test(data.slice(index)); } function constructYamlInteger(data) { let value = data; if (value.includes("_")) value = value.replace(/_/g, ""); let sign = 1; let ch = value[0]; if (ch === "-" || ch === "+") { if (ch === "-") sign = -1; value = value.slice(1); ch = value[0]; } if (value === "0") return 0; if (ch === "0") { if (value[1] === "b") return sign * parseInt(value.slice(2), 2); if (value[1] === "x") return sign * parseInt(value, 16); return sign * parseInt(value, 8); } return sign * parseInt(value, 10); } function isInteger(object) { if (object instanceof Number) object = object.valueOf(); return typeof object === "number" && object % 1 === 0 && !isNegativeZero(object); } const int = { tag: "tag:yaml.org,2002:int", construct: constructYamlInteger, defaultStyle: "decimal", kind: "scalar", predicate: isInteger, represent: { binary(object) { const value = object instanceof Number ? object.valueOf() : object; return value >= 0 ? `0b${value.toString(2)}` : `-0b${value.toString(2).slice(1)}`; }, octal(object) { const value = object instanceof Number ? object.valueOf() : object; return value >= 0 ? `0${value.toString(8)}` : `-0${value.toString(8).slice(1)}`; }, decimal(object) { const value = object instanceof Number ? object.valueOf() : object; return value.toString(10); }, hexadecimal(object) { const value = object instanceof Number ? object.valueOf() : object; return value >= 0 ? `0x${value.toString(16).toUpperCase()}` : `-0x${value.toString(16).toUpperCase().slice(1)}`; } }, resolve: resolveYamlInteger }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/map.js const map = { tag: "tag:yaml.org,2002:map", resolve() { return true; }, construct(data) { return data !== null ? data : {}; }, kind: "mapping" }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/merge.js const merge = { tag: "tag:yaml.org,2002:merge", kind: "scalar", resolve: (data) => data === "<<" || data === null, construct: (data) => data }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/nil.js const nil = { tag: "tag:yaml.org,2002:null", kind: "scalar", defaultStyle: "lowercase", predicate: (object) => object === null, construct: () => null, resolve: (data) => { return data === "~" || data === "null" || data === "Null" || data === "NULL"; }, represent: { lowercase: () => "null", uppercase: () => "NULL", camelcase: () => "Null" } }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/omap.js function resolveYamlOmap(data) { const objectKeys = /* @__PURE__ */ new Set(); for (const object of data) { if (!isPlainObject(object)) return false; const keys = Object.keys(object); if (keys.length !== 1) return false; for (const key of keys) { if (objectKeys.has(key)) return false; objectKeys.add(key); } } return true; } const omap = { tag: "tag:yaml.org,2002:omap", kind: "sequence", resolve: resolveYamlOmap, construct(data) { return data; } }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/pairs.js function resolveYamlPairs(data) { if (data === null) return true; return data.every((it) => isPlainObject(it) && Object.keys(it).length === 1); } const pairs = { tag: "tag:yaml.org,2002:pairs", construct(data) { return data?.flatMap(Object.entries) ?? []; }, kind: "sequence", resolve: resolveYamlPairs }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/regexp.js const REGEXP = /^\/(?<regexp>[\s\S]+)\/(?<modifiers>[gismuy]*)$/; const regexp = { tag: "tag:yaml.org,2002:js/regexp", kind: "scalar", resolve(data) { if (data === null || !data.length) return false; if (data.charAt(0) === "/") { const groups = data.match(REGEXP)?.groups; if (!groups) return false; const modifiers = groups.modifiers ?? ""; if (new Set(modifiers).size < modifiers.length) return false; } return true; }, construct(data) { const { regexp: regexp$1 = data, modifiers = "" } = data.match(REGEXP)?.groups ?? {}; return new RegExp(regexp$1, modifiers); }, predicate: (object) => object instanceof RegExp, represent: (object) => object.toString() }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/seq.js const seq = { tag: "tag:yaml.org,2002:seq", kind: "sequence", resolve: () => true, construct: (data) => data !== null ? data : [] }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/set.js const set = { tag: "tag:yaml.org,2002:set", kind: "mapping", construct: (data) => data !== null ? data : {}, resolve: (data) => { if (data === null) return true; return Object.values(data).every((it) => it === null); } }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/str.js const str = { tag: "tag:yaml.org,2002:str", kind: "scalar", resolve: () => true, construct: (data) => data !== null ? data : "" }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/timestamp.js const YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"); const YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"); function resolveYamlTimestamp(data) { if (data === null) return false; if (YAML_DATE_REGEXP.exec(data) !== null) return true; if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; return false; } function constructYamlTimestamp(data) { let match = YAML_DATE_REGEXP.exec(data); if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); if (match === null) throw new Error("Cannot construct YAML timestamp: date resolve error"); const year = +match[1]; const month = +match[2] - 1; const day = +match[3]; if (!match[4]) return new Date(Date.UTC(year, month, day)); const hour = +match[4]; const minute = +match[5]; const second = +match[6]; let fraction = 0; if (match[7]) { let partFraction = match[7].slice(0, 3); while (partFraction.length < 3) partFraction += "0"; fraction = +partFraction; } let delta = null; if (match[9] && match[10]) { const tzHour = +match[10]; const tzMinute = +(match[11] || 0); delta = (tzHour * 60 + tzMinute) * 6e4; if (match[9] === "-") delta = -delta; } const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); if (delta) date.setTime(date.getTime() - delta); return date; } function representYamlTimestamp(date) { return date.toISOString(); } const timestamp = { tag: "tag:yaml.org,2002:timestamp", construct: constructYamlTimestamp, predicate(object) { return object instanceof Date; }, kind: "scalar", represent: representYamlTimestamp, resolve: resolveYamlTimestamp }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_type/undefined.js const undefinedType = { tag: "tag:yaml.org,2002:js/undefined", kind: "scalar", resolve() { return true; }, construct() { return void 0; }, predicate(object) { return typeof object === "undefined"; }, represent() { return ""; } }; //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_schema.js function createTypeMap(implicitTypes, explicitTypes) { const result = { fallback: /* @__PURE__ */ new Map(), mapping: /* @__PURE__ */ new Map(), scalar: /* @__PURE__ */ new Map(), sequence: /* @__PURE__ */ new Map() }; const fallbackMap = result.fallback; for (const type of [...implicitTypes, ...explicitTypes]) { const map$1 = result[type.kind]; map$1.set(type.tag, type); fallbackMap.set(type.tag, type); } return result; } function createSchema({ explicitTypes = [], implicitTypes = [], include }) { if (include) { implicitTypes.push(...include.implicitTypes); explicitTypes.push(...include.explicitTypes); } const typeMap = createTypeMap(implicitTypes, explicitTypes); return { implicitTypes, explicitTypes, typeMap }; } /** * Standard YAML's failsafe schema. * * @see {@link http://www.yaml.org/spec/1.2/spec.html#id2802346} */ const FAILSAFE_SCHEMA = createSchema({ explicitTypes: [ str, seq, map ] }); /** * Standard YAML's JSON schema. * * @see {@link http://www.yaml.org/spec/1.2/spec.html#id2803231} */ const JSON_SCHEMA = createSchema({ implicitTypes: [ nil, bool, int, float ], include: FAILSAFE_SCHEMA }); /** * Standard YAML's core schema. * * @see {@link http://www.yaml.org/spec/1.2/spec.html#id2804923} */ const CORE_SCHEMA = createSchema({ include: JSON_SCHEMA }); /** * Default YAML schema. It is not described in the YAML specification. */ const DEFAULT_SCHEMA = createSchema({ explicitTypes: [ binary, omap, pairs, set ], implicitTypes: [timestamp, merge], include: CORE_SCHEMA }); /*** * Extends JS-YAML default schema with additional JavaScript types * It is not described in the YAML specification. * Functions are no longer supported for security reasons. * * @example * ```ts * import { parse } from "@std/yaml"; * * const data = parse( * ` * regexp: * simple: !!js/regexp foobar * modifiers: !!js/regexp /foobar/mi * undefined: !!js/undefined ~ * `, * { schema: "extended" }, * ); * ``` */ const EXTENDED_SCHEMA = createSchema({ explicitTypes: [regexp, undefinedType], include: DEFAULT_SCHEMA }); const SCHEMA_MAP = new Map([ ["core", CORE_SCHEMA], ["default", DEFAULT_SCHEMA], ["failsafe", FAILSAFE_SCHEMA], ["json", JSON_SCHEMA], ["extended", EXTENDED_SCHEMA] ]); //#endregion //#region node_modules/.pnpm/@jsr+std__yaml@1.0.9/node_modules/@jsr/std__yaml/_loader_state.js const CONTEXT_FLOW_IN = 1; const CONTEXT_FLOW_OUT = 2; const CONTEXT_BLOCK_IN = 3; const CONTEXT_BLOCK_OUT = 4; const CHOMPING_CLIP = 1; const CHOMPING_STRIP = 2; const CHOMPING_KEEP = 3; const PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; const PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; const PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; const PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; const PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; const ESCAPED_HEX_LENGTHS = new Map([ [120, 2], [117, 4], [85, 8] ]); const SIMPLE_ESCAPE_SEQUENCES = new Map([ [48, "\0"], [97, "\x07"], [98, "\b"], [116, " "], [9, " "], [110, "\n"], [118, "\v"], [102, "\f"], [114, "\r"], [101, "\x1B"], [32, " "], [34, "\""], [47, "/"], [92, "\\"], [78, "…"], [95, "\xA0"], [76, "\u2028"], [80, "\u2029"] ]); /** * Converts a hexadecimal character code to its decimal value. */ function hexCharCodeToNumber(charCode) { if (48 <= charCode && charCode <= 57) return charCode - 48; const lc = charCode | 32; if (97 <= lc && lc <= 102) return lc - 97 + 10; return -1; } /** * Converts a decimal character code to its decimal value. */ function decimalCharCodeToNumber(charCode) { if (48 <= charCode && charCode <= 57) return charCode - 48; return -1; } /** * Converts a Unicode code point to a string. */ function codepointToChar(codepoint) { if (codepoint <= 65535) return String.fromCharCode(codepoint); return String.fromCharCode((codepoint - 65536 >> 10) + 55296, (codepoint - 65536 & 1023) + 56320); } const INDENT = 4; const MAX_LENGTH = 75; const DELIMITERS = "\0\r\n…\u2028\u2029"; function getSnippet(buffer, position) { if (!buffer) return null; let start = position; let end = position; let head = ""; let tail = ""; while (start > 0 && !DELIMITERS.includes(buffer.charAt(start - 1))) { start--; if (position - start > MAX_LENGTH / 2 - 1) { head = " ... "; start += 5; break; } } while (end < buffer.length && !DELIMITERS.includes(buffer.charAt(end))) { end++; if (end - position > MAX_LENGTH / 2 - 1) { tail = " ... "; end -= 5; break; } } const snippet = buffer.slice(start, end); const indent = " ".repeat(INDENT); const caretIndent = " ".repeat(INDENT + position - start + head.length); return `${indent + head + snippet + tail}\n${caretIndent}^`; } function markToString(buffer, position, line, column) { let where = `at line ${line + 1}, column ${column + 1}`; const snippet = getSnippet(buffer, position); if (snippet) where += `:\n${snippet}`; return where; } var LoaderState = class { input; length; lineIndent = 0; lineStart = 0; position = 0; line = 0; onWarning; allowDuplicateKeys; implicitTypes; typeMap; checkLineBreaks = false; tagMap = /* @__PURE__ */ new Map(); anchorMap = /* @__PURE__ */ new Map(); tag; anchor; kind; result = ""; constructor(input, { schema = DEFAULT_SCHEMA, onWarning, allowDuplicateKeys = false }) { this.input = input; this.onWarning = onWarning; this.allowDuplicateKeys = allowDuplicateKeys; this.implicitTypes = schema.implicitTypes; this.typeMap = schema.typeMap; this.length = input.length; this.readIndent(); } skipWhitespaces() { let ch = this.peek(); while (isWhiteSpace(ch)) ch = this.next(); } skipComment() { let ch = this.peek(); if (ch !== SHARP) return; ch = this.next(); while (ch !== 0 && !isEOL(ch)) ch = this.next(); } readIndent() { let char = this.peek(); while (char === SPACE) { this.lineIndent += 1; char = this.next(); } } peek(offset = 0) { return this.input.charCodeAt(this.position + offset); } next() { this.position += 1; return this.peek(); } #createError(message) { const mark = markToString(this.input, this.position, this.line, this.position - this.lineStart); return /* @__PURE__ */ new SyntaxError(`${message} ${mark}`); } dispatchWarning(message) { const error = this.#createError(message); this.onWarning?.(error); } yamlDirectiveHandler(args) { if (args.length !== 1) throw this.#createError("Cannot handle YAML directive: YAML directive accepts exactly one argument"); const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); if (match === null) throw this.#createError("Cannot handle YAML directive: ill-formed argument"); const major = parseInt(match[1], 10); const minor = parseInt(match[2], 10); if (major !== 1) throw this.#createError("Cannot handle YAML directive: unacceptable YAML version"); this.checkLineBreaks = minor < 2; if (minor !== 1 && minor !== 2) this.dispatchWarning("Cannot handle YAML directive: unsupported YAML version"); return args[0] ?? null; } tagDirectiveHandler(args) { if (args.length !== 2) throw this.#createError(`Cannot handle tag directive: directive accepts exactly two arguments, received ${args.length}`); const handle = args[0]; const prefix = args[1]; if (!PATTERN_TAG_HANDLE.test(handle)) throw this.#createError(`Cannot handle tag directive: ill-formed handle (first argument) in "${handle}"`); if (this.tagMap.has(handle)) throw this.#createError(`Cannot handle tag directive: previously declared suffix for "${handle}" tag handle`); if (!PATTERN_TAG_URI.test(prefix)) throw this.#createError("Cannot handle tag directive: ill-formed tag prefix (second argument) of the TAG directive"); this.tagMap.set(handle, prefix); } captureSegment(start, end, checkJson) { if (start < end) { const result = this.input.slice(start, end); if (checkJson) for (let position = 0; position < result.length; position++) { const character = result.charCodeAt(position); if (!(character === 9 || 32 <= character && character <= 1114111)) throw this.#createError(`Expected valid JSON character: received "${character}"`); } else if (PATTERN_NON_PRINTABLE.test(result)) throw this.#createError("Stream contains non-printable characters"); this.result += result; } } readBlockSequence(nodeIndent) { let detected = false; const tag = this.tag; const anchor = this.anchor; const result = []; if (this.anchor !== null && typeof this.anchor !== "undefined") this.anchorMap.set(this.anchor, result); let ch = this.peek(); while (ch !== 0) { if (ch !== MINUS) break; const following = this.peek(1); if (!isWhiteSpaceOrEOL(following)) break; detected = true; this.position++; if (this.skipSeparationSpace(true, -1)) { if (this.lineIndent <= nodeIndent) { result.push(null); ch = this.peek(); continue; } } const line = this.line; this.composeNode({ parentIndent: nodeIndent, nodeContext: CONTEXT_BLOCK_IN, allowToSeek: false, allowCompact: true }); result.push(this.result); this.skipSeparationSpace(true, -1); ch = this.peek(); if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) throw this.#createError("Cannot read block sequence: bad indentation of a sequence entry"); else if (this.lineIndent < nodeIndent) break; } if (detected) { this.tag = tag; this.anchor = anchor; this.kind = "sequence"; this.result = result; return true; } return false; } mergeMappings(destination, source, overridableKeys) { if (!isObject(source)) throw this.#createError("Cannot merge mappings: the provided source object is unacceptable"); for (const [key, value] of Object.entries(source)) { if (Object.hasOwn(destination, key)) continue; Object.defineProperty(destination, key, { value, writable: true, enumerable: true, configurable: true }); overridableKeys.add(key); } } storeMappingPair(result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) { if (Array.isArray(keyNode)) { keyNode = Array.prototype.slice.call(keyNode); for (let index = 0; index < keyNode.length; index++) { if (Array.isArray(keyNode[index])) throw this.#createError("Cannot store mapping pair: nested arrays are not supported inside keys"); if (typeof keyNode === "object" && isPlainObject(keyNode[index])) keyNode[index] = "[object Object]"; } } if (typeof keyNode === "object" && isPlainObject(keyNode)) keyNode = "[object Object]"; keyNode = String(keyNode); if (keyTag === "tag:yaml.org,2002:merge") if (Array.isArray(valueNode)) for (let index = 0; index < valueNode.length; index++) this.mergeMappings(result, valueNode[index], overridableKeys); else this.mergeMappings(result, valueNode, overridableKeys); else { if (!this.allowDuplicateKeys && !overridableKeys.has(keyNode) && Object.hasOwn(result, keyNode)) { this.line = startLine || this.line; this.position = startPos || this.position; throw this.#createError("Cannot store mapping pair: duplicated key"); } Object.defineProperty(result, keyNode, { value: valueNode, writable: true, enumerable: true, configurable: true }); overridableKeys.delete(keyNode); } return result; } readLineBreak() { const ch = this.peek(); if (ch === LINE_FEED) this.position++; else if (ch === CARRIAGE_RETURN) { this.position++; if (this.peek() === LINE_FEED) this.position++; } else throw this.#createError("Cannot read line: line break not found"); this.line += 1; this.lineStart = this.position; } skipSeparationSpace(allowComments, checkIndent) { let lineBreaks = 0; let ch = this.peek(); while (ch !== 0) { this.skipWhitespaces(); ch = this.peek(); if (allowComments) { this.skipComment(); ch = this.peek(); } if (isEOL(ch)) { this.readLineBreak(); ch = this.peek(); lineBreaks++; this.lineIndent = 0; this.readIndent(); ch = this.peek(); } else break; } if (checkIndent !== -1 && lineBreaks !== 0 && this.lineIndent < checkIndent) this.dispatchWarning("deficient indentation"); return lineBreaks; } testDocumentSeparator() { let ch = this.peek(); if ((ch === MINUS || ch === DOT) && ch === this.peek(1) && ch === this.peek(2)) { ch = this.peek(3); if (ch === 0 || isWhiteSpaceOrEOL(ch)) return true; } return false; } writeFoldedLines(count) { if (count === 1) this.result += " "; else if (count > 1) this.result += "\n".repeat(count - 1); } readPlainScalar(nodeIndent, withinFlowCollection) { const kind = this.kind; const result = this.result; let ch = this.peek(); if (isWhiteSpaceOrEOL(ch) || isFlowIndicator(ch) || ch === SHARP || ch === AMPERSAND || ch === ASTERISK || ch === EXCLAMATION || ch === VERTICAL_LINE || ch === GREATER_THAN || ch === SINGLE_QUOTE || ch === DOUBLE_QUOTE || ch === PERCENT || ch === COMMERCIAL_AT || ch === GRAVE_ACCENT) return false; let following; if (ch === QUESTION || ch === MINUS) { following = this.peek(1); if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) return false; } this.kind = "scalar"; this.result = ""; let captureEnd = this.position; let captureStart = this.position; let hasPendingContent = false; let line = 0; while (ch !== 0) { if (ch === COLON) { following = this.peek(1); if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) break; } else if (ch === SHARP) { const preceding = this.peek(-1); if (isWhiteSpaceOrEOL(preceding)) break; } else if (this.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) break; else if (isEOL(ch)) { line = this.line; const lineStart = this.lineStart; const lineIndent = this.lineIndent; this.skipSeparationSpace(false, -1); if (this.lineIndent >= nodeIndent) { hasPendingContent = true; ch = this.peek(); continue; } else { this.position = captureEnd; this.line = line; this.lineStart = lineStart; this.lineIndent = lineIndent; break; } } if (hasPendingContent) { this.captureSegment(captureStart, captureEnd, false); this.writeFoldedLines(this.line - line); captureStart = captureEnd = this.position; hasPendingContent = false; } if (!isWhiteSpace(ch)) captureEnd = this.position + 1; ch = this.next(); } this.captureSegment(captureStart, captureEnd, false); if (this.result) return true; this.kind = kind; this.result = result; return false; } readSingleQuotedScalar(nodeIndent) { let ch = this.peek(); if (ch !== SINGLE_QUOTE) return false; this.kind = "scalar"; this.result = ""; this.position++; let captureStart = this.position; let captureEnd = this.position; ch = this.peek(); while (ch !== 0) { if (ch === SINGLE_QUOTE) { this.captureSegment(captureStart, this.position, true); ch = this.next(); if (ch === SINGLE_QUOTE) { captureStart = this.position; this.position++; captureEnd = this.position; } else return true; } else if (isEOL(ch)) { this.captureSegment(captureStart, captureEnd, true); this.writeFoldedLines(this.skipSeparationSpace(false, nodeIndent)); captureStart = captureEnd = this.position; } else if (this.position === this.lineStart && this.testDocumentSeparator()) throw this.#createError("Unexpected end of the document within a single quoted scalar"); else { this.position++; captureEnd = this.position; } ch = this.peek(); } throw this.#createError("Unexpected end of the stream within a single quoted scalar"); } readDoubleQuotedScalar(nodeIndent) { let ch = this.peek(); if (ch !== DOUBLE_QUOTE) return false; this.kind = "scalar"; this.result = ""; this.position++; let captureEnd = this.position; let captureStart = this.position; let tmp; ch = this.peek(); while (ch !== 0) { if (ch === DOUBLE_QUOTE) { this.captureSegment(captureStart, this.position, true); this.position++; return true; } if (ch === BACKSLASH) { this.captureSegment(captureStart, this.position, true); ch = this.next(); if (isEOL(ch)) this.skipSeparationSpace(false, nodeIndent); else if (ch < 256 && SIMPLE_ESCAPE_SEQUENCES.has(ch)) { this.result += SIMPLE_ESCAPE_SEQUENCES.get(ch); this.position++; } else if ((tmp = ESCAPED_HEX_LENGTHS.get(ch) ?? 0) > 0) { let hexLength = tmp; let hexResult = 0; for (; hexLength > 0; hexLength--) { ch = this.next(); if ((tmp = hexCharCodeToNumber(ch)) >= 0) hexResult = (hexResult << 4) + tmp; else throw this.#createError("Cannot read double quoted scalar: expected hexadecimal character"); } this.result += codepointToChar(hexResult); this.position++; } else throw this.#createError("Cannot read double quoted scalar: unknown escape sequence"); captureStart = captureEnd = this.position; } else if (isEOL(ch)) { this.captureSegment(captureStart, captureEnd, true); this.writeFoldedLines(this.skipSeparationSpace(false, nodeIndent)); captureStart = captureEnd = this.position; } else if (this.position === this.lineStart && this.testDocumentSeparator()) throw this.#createError("Unexpected end of the document within a double quoted scalar"); else { this.position++; captureEnd = this.position; } ch = this.peek(); } throw this.#createError("Unexpected end of the stream within a double quoted scalar"); } readFlowCollection(nodeIndent) { let ch = this.peek(); let terminator; let isMapping = true; let result = {}; if (ch === LEFT_SQUARE_BRACKET) { terminator = RIGHT_SQUARE_BRACKET; isMapping = false; result = []; } else if (ch === LEFT_CURLY_BRACKET) terminator = RIGHT_CURLY_BRACKET; else return false; if (this.anchor !== null && typeof this.anchor !== "undefined") this.anchorMap.set(this.anchor, result); ch = this.next(); const tag = this.tag; const anchor = this.anchor; let readNext = true; let valueNode = null; let keyNode = null; let keyTag = null; let isExplicitPair = false; let isPair = false; let following = 0; let line = 0; const overridableKeys = /* @__PURE__ */ new Set(); while (ch !== 0) { this.skipSeparationSpace(true, nodeIndent); ch = this.peek(); if (ch === terminator) { this.position++; this.tag = tag; this.anchor = anchor; this.kind = isMapping ? "mapping" : "sequence"; this.result = result; return true; } if (!readNext) throw this.#createError("Cannot read flow collection: missing comma between flow collection entries"); keyTag = keyNode = valueNode = null; isPair = isExplicitPair = false; if (ch === QUESTION) { following = this.peek(1); if (isWhiteSpaceOrEOL(following)) { isPair = isExplicitPair = true; this.position++; this.skipSeparationSpace(true, nodeIndent); } } line = this.line; this.composeNode({ parentIndent: nodeIndent, nodeContext: CONTEXT_FLOW_IN, allowToSeek: false, allowCompact: true }); keyTag = this.tag || null; keyNode = this.result; this.skipSeparationSpace(true, nodeIndent); ch = this.peek(); if ((isExplicitPair || this.line === line) && ch === COLON