@descent-vtt/spec-graph 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"regex.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/regex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,2EAA2E;AAC3E,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,sCAAsC;IAC7B,MAAM,CAAS;IAExB,YAAY,OAAe,EAAE,MAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,GAAG,IAAI,CAAC;AAsBzB,mFAAmF;AACnF,MAAM,GAAG,GAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;AAC/F,MAAM,KAAK,GAAqB,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAC/C,MAAM,IAAI,GAAqB;IAC7B,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;CACb,CAAC;AACF,iEAAiE;AACjE,MAAM,KAAK,GAAqB;IAC9B,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,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,CAAC,CAAC,CAAC;YAC5E,MAAM,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;YACpF,OAAO,CAAC,MAAM,KAAK,KAAK,CAAC,KAAK,CAAC,SAAS,KAAK,eAAe,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * A regular-expression matcher that cannot backtrack.\n *\n * Written for spec-graph, whose `~=` selector used to hand a user-supplied\n * string to `RegExp` and wait (spec-graph ADR-0017), and moved here so that\n * every tool that accepts a pattern from configuration or from a document can\n * run it unattended in CI without a pattern deciding how long CI takes.\n *\n * The cost is neither theoretical nor exotic. `^([A-Za-z0-9_]+[ ]?)+$` is what\n * somebody writes to say \"the title is words separated by single spaces\", and\n * against a title that does not match, V8 tries one branch per way of cutting\n * each word into pieces:\n *\n * ```text\n * RegExp here\n * the quick brown fox jumps over the lazy dog! 0.9s 11us\n * the quick brown fox jumps over the lazy dog and! 5.4s 12us\n * the quick brown fox jumps over the lazy dog and keeps! 103s 13us\n * ```\n *\n * So a pattern here is compiled to a non-deterministic finite automaton and\n * simulated over the subject one character at a time (Thompson, 1968), keeping\n * a set of live states instead of a stack of choices. Each state is visited at\n * most once per position, which makes the work O(pattern x subject), growing\n * with the subject and not with the pattern's ambiguity.\n *\n * What it costs is a dialect. Backreferences and lookaround are not regular and\n * have no place in a linear automaton, so they are rejected while compiling,\n * with a message and an offset, rather than accepted and then slow.\n *\n * The dialect is JavaScript's without the `u` flag, character for character,\n * and is held to that by a differential test against `RegExp`: code units,\n * not code points, and `i` folding by the specification's `Canonicalize`.\n * Matching is unanchored and, unless `ignoreCase: false` is passed,\n * case-insensitive, which is what spec-graph's `~=` has always been. There\n * are no captures: nothing asks where a match was, only whether there was one.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Errors */\n/* -------------------------------------------------------------------------- */\n\n/** A pattern that will not compile, and where in it the problem starts. */\nexport class RegexError extends Error {\n /** Offset into the pattern source. */\n readonly offset: number;\n\n constructor(message: string, offset: number) {\n super(message);\n this.name = 'RegexError';\n this.offset = offset;\n }\n}\n\n/**\n * Ceiling on the compiled program.\n *\n * Counted repetition is compiled by copying - `(ab){20}` is twenty copies -\n * which is part of what keeps the simulation flat, and also what makes\n * `(a{99}){99}` into ten thousand states. The bound has to live somewhere, and\n * a number checked while compiling is the only place it can be enforced without\n * measuring anything at match time.\n *\n * Far above any real selector: the widest pattern in this repository's own\n * tests compiles to seventeen states.\n */\nconst MAX_PROGRAM = 4096;\n\n/* -------------------------------------------------------------------------- */\n/* Character sets */\n/* -------------------------------------------------------------------------- */\n\n/** An inclusive range of UTF-16 code units. */\ntype Range = readonly [number, number];\n\n/**\n * A set of code units, as inclusive ranges.\n *\n * Code units rather than code points, because that is what a `RegExp` without\n * the `u` flag matches: `.` consumes one half of a surrogate pair, and so does\n * this. Agreeing with the engine this replaced matters more than being right\n * about astral planes, which no selector in any corpus has asked about.\n */\ninterface CharSet {\n readonly negated: boolean;\n readonly ranges: readonly Range[];\n}\n\n/** `.` - anything but a line terminator, which is the default `RegExp` reading. */\nconst DOT: CharSet = { negated: true, ranges: [[0x0a, 0x0a], [0x0d, 0x0d], [0x2028, 0x2029]] };\nconst DIGIT: readonly Range[] = [[0x30, 0x39]];\nconst WORD: readonly Range[] = [\n [0x30, 0x39],\n [0x41, 0x5a],\n [0x5f, 0x5f],\n [0x61, 0x7a],\n];\n/** `\\s`, taken from the specification rather than guessed at. */\nconst SPACE: readonly Range[] = [\n [0x09, 0x0d],\n [0x20, 0x20],\n [0xa0, 0xa0],\n [0x1680, 0x1680],\n [0x2000, 0x200a],\n [0x2028, 0x2029],\n [0x202f, 0x202f],\n [0x205f, 0x205f],\n [0x3000, 0x3000],\n [0xfeff, 0xfeff],\n];\n\n/**\n * Folds a code unit the way a case-insensitive `RegExp` does.\n *\n * This is `Canonicalize` from the language specification, non-Unicode mode:\n * upper-case the character, keep it unchanged if that produced anything other\n * than one code unit, and keep it unchanged if upper-casing dragged a\n * non-ASCII character into ASCII. The last clause is the one nobody expects and\n * the reason U+017F (long s) does not match `s`.\n */\nfunction canonical(code: number): number {\n // Every subject a glob sees is mostly ASCII, where the answer needs no string.\n // The general path below gives the same answer here, only slower.\n if (code < 128) return code >= 97 && code <= 122 ? code - 32 : code;\n const upper = String.fromCharCode(code).toUpperCase();\n if (upper.length !== 1) return code;\n const folded = upper.charCodeAt(0);\n if (code >= 128 && folded < 128) return code;\n return folded;\n}\n\n/**\n * Whether a set accepts a code unit, case-insensitively.\n *\n * The specification canonicalises both sides: a character matches a set when\n * *some* member of the set folds to the same thing it does. A single-character\n * member can be asked that exactly. A range cannot without a fold table for\n * every code unit, so a range is asked the question backwards - does the\n * character, or either of its own case forms, fall inside it - which is exact\n * for every character whose fold is its own case change, and therefore for\n * every range anyone has written.\n */\nfunction accepts(set: CharSet, code: number): boolean {\n const folded = canonical(code);\n let hit = false;\n for (let i = 0; i < set.ranges.length; i += 1) {\n const [low, high] = set.ranges[i] as Range;\n if (low === high ? low === code || canonical(low) === folded : inRange(low, high, code)) {\n hit = true;\n break;\n }\n }\n return set.negated ? !hit : hit;\n}\n\n/**\n * Whether some member of a range folds to the same thing a code unit does.\n *\n * Asked backwards, by trying the character's own case forms against the raw\n * range - and then checking that the form found there really does fold to the\n * same place, which is the part that is easy to leave out. U+017F upper-cases\n * to `S`, so without that check it matches `[A-Z]`, and it must not: the fold\n * keeps it outside ASCII, which is the same clause `isWordChar` gets wrong if\n * nobody is watching. The differential corpus caught both.\n */\nfunction inRange(low: number, high: number, code: number): boolean {\n if (code >= low && code <= high) return true;\n // An ASCII character's only other case form is its ASCII letter twin, and the\n // two always fold together - so the loop below would ask exactly this.\n if (code < 128) {\n const twin = code >= 65 && code <= 90 ? code + 32 : code >= 97 && code <= 122 ? code - 32 : -1;\n return twin >= low && twin <= high;\n }\n const folded = canonical(code);\n const char = String.fromCharCode(code);\n for (const variant of [char.toLowerCase(), char.toUpperCase()]) {\n if (variant.length !== 1) continue;\n const candidate = variant.charCodeAt(0);\n if (candidate >= low && candidate <= high && canonical(candidate) === folded) return true;\n }\n return false;\n}\n\n/**\n * Whether a set accepts a code unit as written.\n *\n * What `RegExp` does without the `i` flag, and so none of the folding above\n * applies - which also means none of its one divergence does.\n */\nfunction acceptsExactly(set: CharSet, code: number): boolean {\n return within(set.ranges, code) !== set.negated;\n}\n\nfunction within(ranges: readonly Range[], code: number): boolean {\n for (let i = 0; i < ranges.length; i += 1) {\n const range = ranges[i] as Range;\n if (code >= range[0] && code <= range[1]) return true;\n }\n return false;\n}\n\n/**\n * Word characters for `\\b`, which is exactly `\\w` here.\n *\n * The specification does widen this set under case-insensitivity - to every\n * character that folds into it, which is U+017F (long s) and U+212A (the\n * Kelvin sign) - but only in Unicode mode, where `Canonicalize` has no clause\n * keeping a non-ASCII character out of ASCII. This is the non-Unicode dialect,\n * so both stay outside and the table for `\\w` answers for `\\b` as well.\n *\n * Written down because the first version of this function widened the set, and\n * the differential test against `RegExp` is what said otherwise. Reading the\n * clause was not enough; running it was. See spec-graph ADR-0017.\n */\nfunction isWordChar(code: number): boolean {\n return within(WORD, code);\n}\n\n/* -------------------------------------------------------------------------- */\n/* Syntax tree */\n/* -------------------------------------------------------------------------- */\n\ntype Assertion = 'start' | 'end' | 'word-boundary' | 'not-word-boundary';\n\ntype Node =\n | { readonly kind: 'empty' }\n | { readonly kind: 'char'; readonly set: CharSet }\n | { readonly kind: 'assert'; readonly assertion: Assertion }\n | { readonly kind: 'concat'; readonly parts: readonly Node[] }\n | { readonly kind: 'alternate'; readonly options: readonly Node[] }\n | { readonly kind: 'repeat'; readonly node: Node; readonly min: number; readonly max: number };\n\n/* -------------------------------------------------------------------------- */\n/* Parsing */\n/* -------------------------------------------------------------------------- */\n\nclass PatternParser {\n private readonly source: string;\n private position = 0;\n\n constructor(source: string) {\n this.source = source;\n }\n\n parse(): Node {\n const node = this.parseAlternation();\n // Every character is an atom except the two that close something, and\n // `parseSequence` stops on both, so anything left over is an unopened `)`.\n if (this.position < this.source.length) throw new RegexError('unmatched \")\"', this.position);\n return node;\n }\n\n private parseAlternation(): Node {\n const options: Node[] = [this.parseSequence()];\n while (this.peek() === '|') {\n this.position += 1;\n options.push(this.parseSequence());\n }\n return options.length === 1 ? (options[0] as Node) : { kind: 'alternate', options };\n }\n\n private parseSequence(): Node {\n const parts: Node[] = [];\n for (;;) {\n const char = this.peek();\n if (char === undefined || char === '|' || char === ')') break;\n parts.push(this.parseQuantified());\n }\n if (parts.length === 0) return { kind: 'empty' };\n return parts.length === 1 ? (parts[0] as Node) : { kind: 'concat', parts };\n }\n\n private parseQuantified(): Node {\n const start = this.position;\n // A group makes its contents quantifiable: `RegExp` rejects `\\b*` and\n // accepts `(\\b)*`, which is the same nothing said twice, and this parser\n // treats a group as transparent - so whether one was written is the only\n // thing left that distinguishes the two.\n const grouped = this.peek() === '(';\n const atom = this.parseAtom();\n const bounds = this.parseQuantifier();\n if (bounds === null) return atom;\n if (atom.kind === 'assert' && !grouped) {\n throw new RegexError('nothing to repeat: a quantifier cannot follow an anchor', start);\n }\n return { kind: 'repeat', node: atom, min: bounds.min, max: bounds.max };\n }\n\n /** `*`, `+`, `?`, `{n}`, `{n,}`, `{n,m}`, and a trailing `?` that is ignored. */\n private parseQuantifier(): { min: number; max: number } | null {\n const char = this.peek();\n let bounds: { min: number; max: number } | null = null;\n\n if (char === '*') bounds = { min: 0, max: Infinity };\n else if (char === '+') bounds = { min: 1, max: Infinity };\n else if (char === '?') bounds = { min: 0, max: 1 };\n\n if (bounds !== null) this.position += 1;\n else if (char === '{') bounds = this.parseBraces();\n if (bounds === null) return null;\n\n // Laziness decides *which* match is found, and nothing here asks: the\n // question is whether one exists, and a lazy quantifier accepts the same\n // language as a greedy one.\n if (this.peek() === '?') this.position += 1;\n return bounds;\n }\n\n /**\n * Reads `{n,m}`, or nothing.\n *\n * A `{` that does not open a counted repetition is a literal brace, which is\n * what `RegExp` does with `a{` and what any pattern written against a\n * document full of `{0}` placeholders depends on.\n */\n private parseBraces(): { min: number; max: number } | null {\n const match = /^\\{(\\d+)(?:(,)(\\d*))?\\}/.exec(this.source.slice(this.position));\n if (!match) return null;\n const min = Number(match[1]);\n const max = match[2] === undefined ? min : match[3] === '' ? Infinity : Number(match[3]);\n if (min > max) throw new RegexError('numbers out of order in a counted repetition', this.position);\n this.position += (match[0] as string).length;\n return { min, max };\n }\n\n private parseAtom(): Node {\n const start = this.position;\n const char = this.peek();\n\n switch (char) {\n case undefined:\n throw new RegexError('pattern ends where an expression was expected', start);\n case '(':\n return this.parseGroup();\n case '[':\n return { kind: 'char', set: this.parseClass() };\n case '.':\n this.position += 1;\n return { kind: 'char', set: DOT };\n case '^':\n this.position += 1;\n return { kind: 'assert', assertion: 'start' };\n case '$':\n this.position += 1;\n return { kind: 'assert', assertion: 'end' };\n case '*':\n case '+':\n throw new RegexError(`nothing to repeat before \"${char}\"`, start);\n case '\\\\':\n return this.parseEscape();\n default:\n this.position += 1;\n return { kind: 'char', set: literal(char.charCodeAt(0)) };\n }\n }\n\n /**\n * A group, which is never a capture.\n *\n * `(a)` and `(?:a)` compile to the same automaton because nothing downstream\n * can ask what `(a)` caught. A named group is accepted and its name dropped,\n * so a pattern copied out of somewhere else keeps working.\n */\n private parseGroup(): Node {\n const start = this.position;\n this.position += 1;\n\n if (this.source.startsWith('?:', this.position)) {\n this.position += 2;\n } else if (this.peek() === '?') {\n const named = /^\\?<([A-Za-z_$][\\w$]*)>/.exec(this.source.slice(this.position));\n if (named) {\n this.position += (named[0] as string).length;\n } else if (/^\\?(?:=|!|<=|<!)/.test(this.source.slice(this.position))) {\n throw new RegexError(\n 'lookaround is not supported: an automaton that cannot backtrack cannot look ahead - use ^= $= or *= for a fixed prefix, suffix or substring',\n start,\n );\n } else {\n throw new RegexError('unsupported group: expected (?:...) or (?<name>...)', start);\n }\n }\n\n const inner = this.parseAlternation();\n if (this.peek() !== ')') throw new RegexError('unmatched \"(\"', start);\n this.position += 1;\n return inner;\n }\n\n /**\n * Reads a `[...]` class.\n *\n * `[]` matches nothing and `[^]` matches anything, which reads like a mistake\n * and is what every JavaScript engine does: the class ends at the first `]`,\n * even when that `]` is the first character inside it.\n */\n private parseClass(): CharSet {\n const start = this.position;\n this.position += 1;\n const negated = this.peek() === '^';\n if (negated) this.position += 1;\n\n const ranges: Range[] = [];\n while (this.position < this.source.length && this.peek() !== ']') {\n const low = this.parseClassAtom();\n // A `-` between two single characters is a range. Anywhere else - at\n // either end of the class, or beside a `\\d`-style set, which has no\n // endpoint - it is a literal hyphen, exactly as Annex B has it.\n if (this.peek() !== '-' || this.source[this.position + 1] === ']' || this.position + 1 >= this.source.length) {\n push(ranges, low);\n continue;\n }\n const dash = this.position;\n this.position += 1;\n const high = this.parseClassAtom();\n if (typeof low === 'number' && typeof high === 'number') {\n if (low > high) throw new RegexError('characters out of order in a character class', dash);\n ranges.push([low, high]);\n continue;\n }\n push(ranges, low);\n ranges.push([0x2d, 0x2d]);\n push(ranges, high);\n }\n\n if (this.peek() !== ']') throw new RegexError('unterminated character class', start);\n this.position += 1;\n return { negated, ranges };\n }\n\n /** One member of a class: a code unit, or a whole set for `\\d` and its kind. */\n private parseClassAtom(): number | readonly Range[] {\n if (this.peek() !== '\\\\') {\n const code = (this.peek() as string).charCodeAt(0);\n this.position += 1;\n return code;\n }\n // `\\b` is a backspace inside a class and a word boundary outside one, which\n // is the only place the two readings of an escape diverge.\n if (this.source[this.position + 1] === 'b') {\n this.position += 2;\n return 0x08;\n }\n if (this.source[this.position + 1] === 'B') {\n throw new RegexError('\"\\\\B\" is an assertion, not a character, so it cannot be in a class', this.position);\n }\n const set = this.parseCharacterEscape();\n if (!set.negated && set.ranges.length === 1) {\n const [low, high] = set.ranges[0] as Range;\n if (low === high) return low;\n }\n return set.negated ? invert(set.ranges) : set.ranges;\n }\n\n /** An escape outside a class, where `\\b` and `\\B` are assertions. */\n private parseEscape(): Node {\n const next = this.source[this.position + 1];\n if (next === 'b' || next === 'B') {\n this.position += 2;\n return { kind: 'assert', assertion: next === 'b' ? 'word-boundary' : 'not-word-boundary' };\n }\n return { kind: 'char', set: this.parseCharacterEscape() };\n }\n\n /** Every escape that stands for a character or a set of them. */\n private parseCharacterEscape(): CharSet {\n const start = this.position;\n this.position += 1;\n const char = this.peek();\n if (char === undefined) throw new RegexError('pattern ends with a backslash', start);\n this.position += 1;\n\n switch (char) {\n case 'd':\n return { negated: false, ranges: DIGIT };\n case 'D':\n return { negated: true, ranges: DIGIT };\n case 'w':\n return { negated: false, ranges: WORD };\n case 'W':\n return { negated: true, ranges: WORD };\n case 's':\n return { negated: false, ranges: SPACE };\n case 'S':\n return { negated: true, ranges: SPACE };\n case 'n':\n return literal(0x0a);\n case 'r':\n return literal(0x0d);\n case 't':\n return literal(0x09);\n case 'f':\n return literal(0x0c);\n case 'v':\n return literal(0x0b);\n case '0':\n if (/^\\d/.test(this.source.slice(this.position))) {\n throw new RegexError('an octal escape is not supported - write \\\\xHH or \\\\uHHHH', start);\n }\n return literal(0);\n case 'x':\n return literal(this.readHex(2, start));\n case 'u':\n return literal(this.readHex(4, start));\n case 'c': {\n const letter = this.peek();\n if (letter === undefined || !/[A-Za-z]/.test(letter)) {\n throw new RegexError('expected a letter after \"\\\\c\"', start);\n }\n this.position += 1;\n return literal(letter.charCodeAt(0) % 32);\n }\n case 'k':\n throw new RegexError(\n 'a named backreference is not supported: a backreference is not a regular expression, and this is an automaton',\n start,\n );\n case 'p':\n case 'P':\n throw new RegexError(\n `\"\\\\${char}\" needs a table of Unicode properties, which this matcher does not carry - write the characters out as a [class]`,\n start,\n );\n default:\n if (/[1-9]/.test(char)) {\n throw new RegexError(\n 'a backreference is not supported: it is not a regular expression, and this is an automaton',\n start,\n );\n }\n if (/[A-Za-z]/.test(char)) {\n // `RegExp` reads an unknown letter escape as the letter itself, so\n // `\\A` quietly matches a capital A and `\\z` a lower-case z. Saying so\n // is worth more than agreeing with a rule nobody wanted.\n throw new RegexError(`unknown escape \"\\\\${char}\"`, start);\n }\n return literal(char.charCodeAt(0));\n }\n }\n\n private readHex(digits: number, start: number): number {\n const raw = this.source.slice(this.position, this.position + digits);\n if (raw.length !== digits || !/^[0-9a-fA-F]+$/.test(raw)) {\n throw new RegexError(`expected ${digits} hex digits after \"\\\\${this.source[start + 1] as string}\"`, start);\n }\n this.position += digits;\n return Number.parseInt(raw, 16);\n }\n\n private peek(): string | undefined {\n return this.source[this.position];\n }\n}\n\nfunction literal(code: number): CharSet {\n return { negated: false, ranges: [[code, code]] };\n}\n\nfunction push(ranges: Range[], atom: number | readonly Range[]): void {\n if (typeof atom === 'number') ranges.push([atom, atom]);\n else ranges.push(...atom);\n}\n\n/**\n * Complement of a range list, so `[\\D]` can sit inside a class.\n *\n * A negated escape is a set with no endpoints, and a class is a union of\n * ranges, so the only way to put one inside the other is to spell out what it\n * leaves.\n */\nfunction invert(ranges: readonly Range[]): readonly Range[] {\n const sorted = [...ranges].sort((a, b) => a[0] - b[0]);\n const out: Range[] = [];\n let cursor = 0;\n for (const [low, high] of sorted) {\n if (low > cursor) out.push([cursor, low - 1]);\n cursor = Math.max(cursor, high + 1);\n }\n if (cursor <= 0xffff) out.push([cursor, 0xffff]);\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Compilation */\n/* -------------------------------------------------------------------------- */\n\ninterface Split {\n readonly op: 'split';\n /** Where the first branch starts. */\n x: number;\n /** Where the second branch starts. */\n y: number;\n}\n\ninterface Jump {\n readonly op: 'jump';\n to: number;\n}\n\ntype Instruction =\n | { readonly op: 'char'; readonly set: CharSet }\n | Split\n | Jump\n | { readonly op: 'assert'; readonly assertion: Assertion }\n | { readonly op: 'match' };\n\nclass Compiler {\n readonly code: Instruction[] = [];\n\n private add<T extends Instruction>(instruction: T): T {\n if (this.code.length >= MAX_PROGRAM) {\n throw new RegexError(\n `pattern is too large: counted repetition is compiled by copying, and this needs more than ${MAX_PROGRAM} states`,\n 0,\n );\n }\n this.code.push(instruction);\n return instruction;\n }\n\n get here(): number {\n return this.code.length;\n }\n\n emitMatch(): void {\n this.add({ op: 'match' });\n }\n\n compile(node: Node): void {\n switch (node.kind) {\n case 'empty':\n return;\n case 'char':\n this.add({ op: 'char', set: node.set });\n return;\n case 'assert':\n this.add({ op: 'assert', assertion: node.assertion });\n return;\n case 'concat':\n for (const part of node.parts) this.compile(part);\n return;\n case 'alternate': {\n // One split per option but the last. Each split falls through to its\n // own branch and points its second arm at the next split; each branch\n // ends in a jump past all of them.\n const ends: Jump[] = [];\n for (let i = 0; i < node.options.length - 1; i += 1) {\n const split = this.add({ op: 'split', x: 0, y: 0 });\n split.x = this.here;\n this.compile(node.options[i] as Node);\n ends.push(this.add({ op: 'jump', to: 0 }));\n split.y = this.here;\n }\n this.compile(node.options[node.options.length - 1] as Node);\n for (const end of ends) end.to = this.here;\n return;\n }\n case 'repeat':\n this.repeat(node.node, node.min, node.max);\n return;\n }\n }\n\n private repeat(node: Node, min: number, max: number): void {\n for (let i = 0; i < min; i += 1) this.compile(node);\n\n if (max === Infinity) {\n const split = this.add({ op: 'split', x: 0, y: 0 });\n const body = this.here;\n split.x = body;\n this.compile(node);\n this.add({ op: 'jump', to: body - 1 });\n split.y = this.here;\n return;\n }\n\n // `{2,5}` is two copies and then three optional ones, each able to leave\n // for the far end rather than for the next copy.\n const exits: Split[] = [];\n for (let i = min; i < max; i += 1) {\n const split = this.add({ op: 'split', x: 0, y: 0 });\n split.x = this.here;\n exits.push(split);\n this.compile(node);\n }\n for (const split of exits) split.y = this.here;\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Simulation */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A compiled pattern. Reusable and safe to cache.\n *\n * Not reentrant, which nothing can ask of it: `test` is synchronous and calls\n * out to nothing, and the buffers it keeps between subjects are what make it\n * cheap enough to run against every path a walk visits.\n */\nexport interface RegexMatcher {\n /** True when the pattern matches anywhere in the subject. */\n test(subject: string): boolean;\n /** State count. Published for the size test, and for nothing else. */\n readonly size: number;\n}\n\nexport interface RegexOptions {\n /** Fold case the way the `i` flag does. On unless set to `false`. */\n readonly ignoreCase?: boolean | undefined;\n}\n\n/**\n * Compiles a pattern into a matcher.\n *\n * Throws {@link RegexError} on anything it cannot run in linear time, which\n * is the point: the alternative to a message here is a build that stops.\n */\nexport function compileRegex(source: string, options: RegexOptions = {}): RegexMatcher {\n const tree = new PatternParser(source).parse();\n const compiler = new Compiler();\n compiler.compile(tree);\n compiler.emitMatch();\n // A pattern that begins by asserting the start of the subject cannot match\n // anywhere else, so the simulation stops seeding new threads at every\n // position. Nothing depends on this being noticed - it is the difference\n // between one pass and two over a long body.\n const machine = new Machine(compiler.code, startsAnchored(tree), options.ignoreCase !== false);\n return {\n size: compiler.code.length,\n test: (subject: string): boolean => machine.test(subject),\n };\n}\n\n/** True when every path through the pattern opens by asserting the start. */\nfunction startsAnchored(node: Node): boolean {\n switch (node.kind) {\n case 'assert':\n return node.assertion === 'start';\n case 'concat': {\n const first = node.parts[0];\n return first !== undefined && startsAnchored(first);\n }\n case 'alternate':\n return node.options.every((option) => startsAnchored(option));\n case 'repeat':\n return node.min > 0 && startsAnchored(node.node);\n default:\n return false;\n }\n}\n\nconst OP_CHAR = 0;\nconst OP_SPLIT = 1;\nconst OP_JUMP = 2;\nconst OP_ASSERT = 3;\nconst OP_MATCH = 4;\n\n/** Fills the slots of states that are not characters, where nothing reads it. */\nconst NOTHING: CharSet = { negated: false, ranges: [] };\n\n/**\n * The simulation, over the program flattened into typed arrays.\n *\n * The compiler's instructions are objects of five shapes, and one loop reading\n * `op` off all five is a megamorphic property read on every step. Simulated that\n * way, with a fresh visited table per subject, a glob cost about 3.5\n * microseconds a path and a path that failed on its first character still paid\n * half a microsecond for the allocation. Flat arrays and buffers kept between\n * subjects bring those to 0.6 and 0.04 - `RegExp` takes 0.06 - which matters\n * because a walk tests every path it visits against every pattern.\n */\nclass Machine {\n private readonly ops: Uint8Array;\n /** A split's first branch, or a jump's target. */\n private readonly first: Int32Array;\n /** A split's second branch. */\n private readonly second: Int32Array;\n private readonly sets: CharSet[];\n private readonly assertions: Assertion[];\n private readonly anchored: boolean;\n private readonly ignoreCase: boolean;\n\n /**\n * The position each state was last reached at. One visit per state per\n * position is exactly what turns the exponent into a product.\n */\n private readonly visited: Int32Array;\n /** Each visit pushes at most two states, so this cannot overflow. */\n private readonly stack: Int32Array;\n private live: Int32Array;\n private next: Int32Array;\n\n constructor(code: readonly Instruction[], anchored: boolean, ignoreCase: boolean) {\n const size = code.length;\n this.ops = new Uint8Array(size);\n this.first = new Int32Array(size);\n this.second = new Int32Array(size);\n this.sets = new Array<CharSet>(size).fill(NOTHING);\n this.assertions = new Array<Assertion>(size).fill('start');\n this.anchored = anchored;\n this.ignoreCase = ignoreCase;\n this.visited = new Int32Array(size).fill(-1);\n this.stack = new Int32Array(2 * size + 1);\n this.live = new Int32Array(size);\n this.next = new Int32Array(size);\n\n code.forEach((instruction, pc) => {\n switch (instruction.op) {\n case 'char':\n this.ops[pc] = OP_CHAR;\n this.sets[pc] = instruction.set;\n break;\n case 'split':\n this.ops[pc] = OP_SPLIT;\n this.first[pc] = instruction.x;\n this.second[pc] = instruction.y;\n break;\n case 'jump':\n this.ops[pc] = OP_JUMP;\n this.first[pc] = instruction.to;\n break;\n case 'assert':\n this.ops[pc] = OP_ASSERT;\n this.assertions[pc] = instruction.assertion;\n break;\n case 'match':\n this.ops[pc] = OP_MATCH;\n break;\n }\n });\n }\n\n test(subject: string): boolean {\n const length = subject.length;\n this.visited.fill(-1);\n\n let live = this.live;\n let next = this.next;\n let alive = 0;\n\n for (let position = 0; position <= length; position += 1) {\n if (position === 0 || !this.anchored) {\n alive = this.seed(live, alive, 0, subject, position);\n if (alive < 0) return true;\n } else if (alive === 0) {\n // An anchored pattern gets one chance, and every thread from it has died.\n return false;\n }\n\n if (position === length) return false;\n const char = subject.charCodeAt(position);\n let arriving = 0;\n for (let i = 0; i < alive; i += 1) {\n const pc = live[i] as number;\n const set = this.sets[pc] as CharSet;\n if (!(this.ignoreCase ? accepts(set, char) : acceptsExactly(set, char))) continue;\n arriving = this.seed(next, arriving, pc + 1, subject, position + 1);\n if (arriving < 0) return true;\n }\n const spent = live;\n live = next;\n next = spent;\n alive = arriving;\n }\n\n return false;\n }\n\n /**\n * Follows every zero-width transition out of one state, appending the\n * character states it reaches to `list`.\n *\n * Returns the new length of the list, or -1 the moment a thread reaches the\n * end of the pattern: the only question is whether a match exists, so there\n * is no leftmost-longest to settle and no captures to keep, and the first\n * thread to arrive is the answer.\n *\n * A stray thread at state 0 changes no answer: an unanchored pattern seeds it\n * at every position anyway, and an anchored one opens by asserting the start.\n * That makes two mutants here equivalent, with no test to write - the loop\n * running once past an empty stack, and a jump read as a split, both of which\n * add exactly that thread.\n */\n private seed(list: Int32Array, length: number, start: number, subject: string, position: number): number {\n const { ops, first, second, visited, stack } = this;\n let count = length;\n let top = 0;\n stack[top++] = start;\n while (top > 0) {\n const pc = stack[--top] as number;\n if (visited[pc] === position) continue;\n visited[pc] = position;\n switch (ops[pc]) {\n case OP_MATCH:\n return -1;\n case OP_JUMP:\n stack[top++] = first[pc] as number;\n break;\n case OP_SPLIT:\n stack[top++] = second[pc] as number;\n stack[top++] = first[pc] as number;\n break;\n case OP_ASSERT:\n if (holds(this.assertions[pc] as Assertion, subject, position)) stack[top++] = pc + 1;\n break;\n default:\n list[count++] = pc;\n }\n }\n return count;\n }\n}\n\nfunction holds(assertion: Assertion, subject: string, position: number): boolean {\n switch (assertion) {\n case 'start':\n return position === 0;\n case 'end':\n return position === subject.length;\n default: {\n const before = position > 0 && isWordChar(subject.charCodeAt(position - 1));\n const after = position < subject.length && isWordChar(subject.charCodeAt(position));\n return (before !== after) === (assertion === 'word-boundary');\n }\n }\n}\n"]}
1
+ {"version":3,"file":"regex.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/regex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G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esContent":["/**\n * A regular-expression matcher that cannot backtrack.\n *\n * Written for spec-graph, whose `~=` selector used to hand a user-supplied\n * string to `RegExp` and wait (spec-graph ADR-0017), and moved here so that\n * every tool that accepts a pattern from configuration or from a document can\n * run it unattended in CI without a pattern deciding how long CI takes.\n *\n * The cost is neither theoretical nor exotic. `^([A-Za-z0-9_]+[ ]?)+$` is what\n * somebody writes to say \"the title is words separated by single spaces\", and\n * against a title that does not match, V8 tries one branch per way of cutting\n * each word into pieces:\n *\n * ```text\n * RegExp here\n * the quick brown fox jumps over the lazy dog! 0.9s 11us\n * the quick brown fox jumps over the lazy dog and! 5.4s 12us\n * the quick brown fox jumps over the lazy dog and keeps! 103s 13us\n * ```\n *\n * So a pattern here is compiled to a non-deterministic finite automaton and\n * simulated over the subject one character at a time (Thompson, 1968), keeping\n * a set of live states instead of a stack of choices. Each state is visited at\n * most once per position, which makes the work O(pattern x subject), growing\n * with the subject and not with the pattern's ambiguity.\n *\n * What it costs is a dialect. Backreferences and lookaround are not regular and\n * have no place in a linear automaton, so they are rejected while compiling,\n * with a message and an offset, rather than accepted and then slow.\n *\n * The dialect is JavaScript's without the `u` flag, character for character,\n * and is held to that by a differential test against `RegExp`: code units,\n * not code points, and `i` folding by the specification's `Canonicalize`.\n * Matching is unanchored and, unless `ignoreCase: false` is passed,\n * case-insensitive, which is what spec-graph's `~=` has always been. There\n * are no captures: nothing asks where a match was, only whether there was one.\n */\n\n/* -------------------------------------------------------------------------- */\n/* Errors */\n/* -------------------------------------------------------------------------- */\n\n/** A pattern that will not compile, and where in it the problem starts. */\nexport class RegexError extends Error {\n /** Offset into the pattern source. */\n readonly offset: number;\n\n constructor(message: string, offset: number) {\n super(message);\n this.name = 'RegexError';\n this.offset = offset;\n }\n}\n\n/**\n * Ceiling on the compiled program.\n *\n * Counted repetition is compiled by copying - `(ab){20}` is twenty copies -\n * which is part of what keeps the simulation flat, and also what makes\n * `(a{99}){99}` into ten thousand states. The bound has to live somewhere, and\n * a number checked while compiling is the only place it can be enforced without\n * measuring anything at match time.\n *\n * Far above any real selector: the widest pattern in this repository's own\n * tests compiles to seventeen states.\n */\nconst MAX_PROGRAM = 4096;\n\n/* -------------------------------------------------------------------------- */\n/* Character sets */\n/* -------------------------------------------------------------------------- */\n\n/** An inclusive range of UTF-16 code units. */\ntype Range = readonly [number, number];\n\n/**\n * A set of code units, as inclusive ranges.\n *\n * Code units rather than code points, because that is what a `RegExp` without\n * the `u` flag matches: `.` consumes one half of a surrogate pair, and so does\n * this. Agreeing with the engine this replaced matters more than being right\n * about astral planes, which no selector in any corpus has asked about.\n */\ninterface CharSet {\n readonly negated: boolean;\n readonly ranges: readonly Range[];\n}\n\n/** `.` - anything but a line terminator, which is the default `RegExp` reading. */\nconst DOT: CharSet = { negated: true, ranges: [[0x0a, 0x0a], [0x0d, 0x0d], [0x2028, 0x2029]] };\nconst DIGIT: readonly Range[] = [[0x30, 0x39]];\nconst WORD: readonly Range[] = [\n [0x30, 0x39],\n [0x41, 0x5a],\n [0x5f, 0x5f],\n [0x61, 0x7a],\n];\n/** `\\s`, taken from the specification rather than guessed at. */\nconst SPACE: readonly Range[] = [\n [0x09, 0x0d],\n [0x20, 0x20],\n [0xa0, 0xa0],\n [0x1680, 0x1680],\n [0x2000, 0x200a],\n [0x2028, 0x2029],\n [0x202f, 0x202f],\n [0x205f, 0x205f],\n [0x3000, 0x3000],\n [0xfeff, 0xfeff],\n];\n\n/**\n * Folds a code unit the way a case-insensitive `RegExp` does.\n *\n * This is `Canonicalize` from the language specification, non-Unicode mode:\n * upper-case the character, keep it unchanged if that produced anything other\n * than one code unit, and keep it unchanged if upper-casing dragged a\n * non-ASCII character into ASCII. The last clause is the one nobody expects and\n * the reason U+017F (long s) does not match `s`.\n */\nfunction canonical(code: number): number {\n // Every subject a glob sees is mostly ASCII, where the answer needs no string.\n // The general path below gives the same answer here, only slower.\n if (code < 128) return code >= 97 && code <= 122 ? code - 32 : code;\n const upper = String.fromCharCode(code).toUpperCase();\n if (upper.length !== 1) return code;\n const folded = upper.charCodeAt(0);\n if (code >= 128 && folded < 128) return code;\n return folded;\n}\n\n/**\n * Whether a set accepts a code unit, case-insensitively.\n *\n * The specification canonicalises both sides: a character matches a set when\n * *some* member of the set folds to the same thing it does. A single-character\n * member can be asked that exactly. A range cannot without a fold table for\n * every code unit, so a range is asked the question backwards - does the\n * character, or either of its own case forms, fall inside it - which is exact\n * for every character whose fold is its own case change, and therefore for\n * every range anyone has written.\n */\nfunction accepts(set: CharSet, code: number): boolean {\n const folded = canonical(code);\n let hit = false;\n for (let i = 0; i < set.ranges.length; i += 1) {\n const [low, high] = set.ranges[i] as Range;\n if (low === high ? low === code || canonical(low) === folded : inRange(low, high, code)) {\n hit = true;\n break;\n }\n }\n return set.negated ? !hit : hit;\n}\n\n/**\n * Whether some member of a range folds to the same thing a code unit does.\n *\n * Asked backwards, by trying the character's own case forms against the raw\n * range - and then checking that the form found there really does fold to the\n * same place, which is the part that is easy to leave out. U+017F upper-cases\n * to `S`, so without that check it matches `[A-Z]`, and it must not: the fold\n * keeps it outside ASCII, which is the same clause `isWordChar` gets wrong if\n * nobody is watching. The differential corpus caught both.\n */\nfunction inRange(low: number, high: number, code: number): boolean {\n if (code >= low && code <= high) return true;\n // An ASCII character's only other case form is its ASCII letter twin, and the\n // two always fold together - so the loop below would ask exactly this.\n if (code < 128) {\n const twin = code >= 65 && code <= 90 ? code + 32 : code >= 97 && code <= 122 ? code - 32 : -1;\n return twin >= low && twin <= high;\n }\n const folded = canonical(code);\n const char = String.fromCharCode(code);\n for (const variant of [char.toLowerCase(), char.toUpperCase()]) {\n if (variant.length !== 1) continue;\n const candidate = variant.charCodeAt(0);\n if (candidate >= low && candidate <= high && canonical(candidate) === folded) return true;\n }\n return false;\n}\n\n/**\n * Whether a set accepts a code unit as written.\n *\n * What `RegExp` does without the `i` flag, and so none of the folding above\n * applies - which also means none of its one divergence does.\n */\nfunction acceptsExactly(set: CharSet, code: number): boolean {\n return within(set.ranges, code) !== set.negated;\n}\n\nfunction within(ranges: readonly Range[], code: number): boolean {\n for (let i = 0; i < ranges.length; i += 1) {\n const range = ranges[i] as Range;\n if (code >= range[0] && code <= range[1]) return true;\n }\n return false;\n}\n\n/**\n * Word characters for `\\b`, which is exactly `\\w` here.\n *\n * The specification does widen this set under case-insensitivity - to every\n * character that folds into it, which is U+017F (long s) and U+212A (the\n * Kelvin sign) - but only in Unicode mode, where `Canonicalize` has no clause\n * keeping a non-ASCII character out of ASCII. This is the non-Unicode dialect,\n * so both stay outside and the table for `\\w` answers for `\\b` as well.\n *\n * Written down because the first version of this function widened the set, and\n * the differential test against `RegExp` is what said otherwise. Reading the\n * clause was not enough; running it was. See spec-graph ADR-0017.\n */\nfunction isWordChar(code: number): boolean {\n return within(WORD, code);\n}\n\n/* -------------------------------------------------------------------------- */\n/* Syntax tree */\n/* -------------------------------------------------------------------------- */\n\ntype Assertion = 'start' | 'end' | 'word-boundary' | 'not-word-boundary';\n\ntype Node =\n | { readonly kind: 'empty' }\n | { readonly kind: 'char'; readonly set: CharSet }\n | { readonly kind: 'assert'; readonly assertion: Assertion }\n | { readonly kind: 'concat'; readonly parts: readonly Node[] }\n | { readonly kind: 'alternate'; readonly options: readonly Node[] }\n | { readonly kind: 'repeat'; readonly node: Node; readonly min: number; readonly max: number };\n\n/* -------------------------------------------------------------------------- */\n/* Parsing */\n/* -------------------------------------------------------------------------- */\n\nclass PatternParser {\n private readonly source: string;\n private position = 0;\n\n constructor(source: string) {\n this.source = source;\n }\n\n parse(): Node {\n const node = this.parseAlternation();\n // Every character is an atom except the two that close something, and\n // `parseSequence` stops on both, so anything left over is an unopened `)`.\n if (this.position < this.source.length) throw new RegexError('unmatched \")\"', this.position);\n return node;\n }\n\n private parseAlternation(): Node {\n const options: Node[] = [this.parseSequence()];\n while (this.peek() === '|') {\n this.position += 1;\n options.push(this.parseSequence());\n }\n return options.length === 1 ? (options[0] as Node) : { kind: 'alternate', options };\n }\n\n private parseSequence(): Node {\n const parts: Node[] = [];\n for (;;) {\n const char = this.peek();\n if (char === undefined || char === '|' || char === ')') break;\n parts.push(this.parseQuantified());\n }\n if (parts.length === 0) return { kind: 'empty' };\n return parts.length === 1 ? (parts[0] as Node) : { kind: 'concat', parts };\n }\n\n private parseQuantified(): Node {\n const start = this.position;\n // A group makes its contents quantifiable: `RegExp` rejects `\\b*` and\n // accepts `(\\b)*`, which is the same nothing said twice, and this parser\n // treats a group as transparent - so whether one was written is the only\n // thing left that distinguishes the two.\n const grouped = this.peek() === '(';\n const atom = this.parseAtom();\n const bounds = this.parseQuantifier();\n if (bounds === null) return atom;\n if (atom.kind === 'assert' && !grouped) {\n throw new RegexError('nothing to repeat: a quantifier cannot follow an anchor', start);\n }\n return { kind: 'repeat', node: atom, min: bounds.min, max: bounds.max };\n }\n\n /** `*`, `+`, `?`, `{n}`, `{n,}`, `{n,m}`, and a trailing `?` that is ignored. */\n private parseQuantifier(): { min: number; max: number } | null {\n const char = this.peek();\n let bounds: { min: number; max: number } | null = null;\n\n if (char === '*') bounds = { min: 0, max: Infinity };\n else if (char === '+') bounds = { min: 1, max: Infinity };\n else if (char === '?') bounds = { min: 0, max: 1 };\n\n if (bounds !== null) this.position += 1;\n else if (char === '{') bounds = this.parseBraces();\n if (bounds === null) return null;\n\n // Laziness decides *which* match is found, and nothing here asks: the\n // question is whether one exists, and a lazy quantifier accepts the same\n // language as a greedy one.\n if (this.peek() === '?') this.position += 1;\n return bounds;\n }\n\n /**\n * Reads `{n,m}`, or nothing.\n *\n * A `{` that does not open a counted repetition is a literal brace, which is\n * what `RegExp` does with `a{` and what any pattern written against a\n * document full of `{0}` placeholders depends on.\n */\n private parseBraces(): { min: number; max: number } | null {\n const match = /^\\{(\\d+)(?:(,)(\\d*))?\\}/.exec(this.source.slice(this.position));\n if (!match) return null;\n const min = Number(match[1]);\n const max = match[2] === undefined ? min : match[3] === '' ? Infinity : Number(match[3]);\n if (min > max) throw new RegexError('numbers out of order in a counted repetition', this.position);\n this.position += (match[0] as string).length;\n return { min, max };\n }\n\n private parseAtom(): Node {\n const start = this.position;\n const char = this.peek();\n\n switch (char) {\n case undefined:\n throw new RegexError('pattern ends where an expression was expected', start);\n case '(':\n return this.parseGroup();\n case '[':\n return { kind: 'char', set: this.parseClass() };\n case '.':\n this.position += 1;\n return { kind: 'char', set: DOT };\n case '^':\n this.position += 1;\n return { kind: 'assert', assertion: 'start' };\n case '$':\n this.position += 1;\n return { kind: 'assert', assertion: 'end' };\n case '*':\n case '+':\n throw new RegexError(`nothing to repeat before \"${char}\"`, start);\n case '\\\\':\n return this.parseEscape();\n default:\n this.position += 1;\n return { kind: 'char', set: literal(char.charCodeAt(0)) };\n }\n }\n\n /**\n * A group, which is never a capture.\n *\n * `(a)` and `(?:a)` compile to the same automaton because nothing downstream\n * can ask what `(a)` caught. A named group is accepted and its name dropped,\n * so a pattern copied out of somewhere else keeps working.\n */\n private parseGroup(): Node {\n const start = this.position;\n this.position += 1;\n\n if (this.source.startsWith('?:', this.position)) {\n this.position += 2;\n } else if (this.peek() === '?') {\n const named = /^\\?<([A-Za-z_$][\\w$]*)>/.exec(this.source.slice(this.position));\n if (named) {\n this.position += (named[0] as string).length;\n } else if (/^\\?(?:=|!|<=|<!)/.test(this.source.slice(this.position))) {\n throw new RegexError(\n 'lookaround is not supported: an automaton that cannot backtrack cannot look ahead - use ^= $= or *= for a fixed prefix, suffix or substring',\n start,\n );\n } else {\n throw new RegexError('unsupported group: expected (?:...) or (?<name>...)', start);\n }\n }\n\n const inner = this.parseAlternation();\n if (this.peek() !== ')') throw new RegexError('unmatched \"(\"', start);\n this.position += 1;\n return inner;\n }\n\n /**\n * Reads a `[...]` class.\n *\n * `[]` matches nothing and `[^]` matches anything, which reads like a mistake\n * and is what every JavaScript engine does: the class ends at the first `]`,\n * even when that `]` is the first character inside it.\n */\n private parseClass(): CharSet {\n const start = this.position;\n this.position += 1;\n const negated = this.peek() === '^';\n if (negated) this.position += 1;\n\n const ranges: Range[] = [];\n while (this.position < this.source.length && this.peek() !== ']') {\n const low = this.parseClassAtom();\n // A `-` between two single characters is a range. Anywhere else - at\n // either end of the class, or beside a `\\d`-style set, which has no\n // endpoint - it is a literal hyphen, exactly as Annex B has it.\n if (this.peek() !== '-' || this.source[this.position + 1] === ']' || this.position + 1 >= this.source.length) {\n push(ranges, low);\n continue;\n }\n const dash = this.position;\n this.position += 1;\n const high = this.parseClassAtom();\n if (typeof low === 'number' && typeof high === 'number') {\n if (low > high) throw new RegexError('characters out of order in a character class', dash);\n ranges.push([low, high]);\n continue;\n }\n push(ranges, low);\n ranges.push([0x2d, 0x2d]);\n push(ranges, high);\n }\n\n if (this.peek() !== ']') throw new RegexError('unterminated character class', start);\n this.position += 1;\n return { negated, ranges };\n }\n\n /** One member of a class: a code unit, or a whole set for `\\d` and its kind. */\n private parseClassAtom(): number | readonly Range[] {\n if (this.peek() !== '\\\\') {\n const code = (this.peek() as string).charCodeAt(0);\n this.position += 1;\n return code;\n }\n // `\\b` is a backspace inside a class and a word boundary outside one, which\n // is the only place the two readings of an escape diverge.\n if (this.source[this.position + 1] === 'b') {\n this.position += 2;\n return 0x08;\n }\n if (this.source[this.position + 1] === 'B') {\n throw new RegexError('\"\\\\B\" is an assertion, not a character, so it cannot be in a class', this.position);\n }\n const set = this.parseCharacterEscape();\n if (!set.negated && set.ranges.length === 1) {\n const [low, high] = set.ranges[0] as Range;\n if (low === high) return low;\n }\n return set.negated ? invert(set.ranges) : set.ranges;\n }\n\n /** An escape outside a class, where `\\b` and `\\B` are assertions. */\n private parseEscape(): Node {\n const next = this.source[this.position + 1];\n if (next === 'b' || next === 'B') {\n this.position += 2;\n return { kind: 'assert', assertion: next === 'b' ? 'word-boundary' : 'not-word-boundary' };\n }\n return { kind: 'char', set: this.parseCharacterEscape() };\n }\n\n /** Every escape that stands for a character or a set of them. */\n private parseCharacterEscape(): CharSet {\n const start = this.position;\n this.position += 1;\n const char = this.peek();\n if (char === undefined) throw new RegexError('pattern ends with a backslash', start);\n this.position += 1;\n\n switch (char) {\n case 'd':\n return { negated: false, ranges: DIGIT };\n case 'D':\n return { negated: true, ranges: DIGIT };\n case 'w':\n return { negated: false, ranges: WORD };\n case 'W':\n return { negated: true, ranges: WORD };\n case 's':\n return { negated: false, ranges: SPACE };\n case 'S':\n return { negated: true, ranges: SPACE };\n case 'n':\n return literal(0x0a);\n case 'r':\n return literal(0x0d);\n case 't':\n return literal(0x09);\n case 'f':\n return literal(0x0c);\n case 'v':\n return literal(0x0b);\n case '0':\n if (/^\\d/.test(this.source.slice(this.position))) {\n throw new RegexError('an octal escape is not supported - write \\\\xHH or \\\\uHHHH', start);\n }\n return literal(0);\n case 'x':\n return literal(this.readHex(2, start));\n case 'u':\n return literal(this.readHex(4, start));\n case 'c': {\n const letter = this.peek();\n if (letter === undefined || !/[A-Za-z]/.test(letter)) {\n throw new RegexError('expected a letter after \"\\\\c\"', start);\n }\n this.position += 1;\n return literal(letter.charCodeAt(0) % 32);\n }\n case 'k':\n throw new RegexError(\n 'a named backreference is not supported: a backreference is not a regular expression, and this is an automaton',\n start,\n );\n case 'p':\n case 'P':\n throw new RegexError(\n `\"\\\\${char}\" needs a table of Unicode properties, which this matcher does not carry - write the characters out as a [class]`,\n start,\n );\n default:\n if (/[1-9]/.test(char)) {\n throw new RegexError(\n 'a backreference is not supported: it is not a regular expression, and this is an automaton',\n start,\n );\n }\n if (/[A-Za-z]/.test(char)) {\n // `RegExp` reads an unknown letter escape as the letter itself, so\n // `\\A` quietly matches a capital A and `\\z` a lower-case z. Saying so\n // is worth more than agreeing with a rule nobody wanted.\n throw new RegexError(`unknown escape \"\\\\${char}\"`, start);\n }\n return literal(char.charCodeAt(0));\n }\n }\n\n private readHex(digits: number, start: number): number {\n const raw = this.source.slice(this.position, this.position + digits);\n if (raw.length !== digits || !/^[0-9a-fA-F]+$/.test(raw)) {\n throw new RegexError(`expected ${digits} hex digits after \"\\\\${this.source[start + 1]!}\"`, start);\n }\n this.position += digits;\n return Number.parseInt(raw, 16);\n }\n\n private peek(): string | undefined {\n return this.source[this.position];\n }\n}\n\nfunction literal(code: number): CharSet {\n return { negated: false, ranges: [[code, code]] };\n}\n\nfunction push(ranges: Range[], atom: number | readonly Range[]): void {\n if (typeof atom === 'number') ranges.push([atom, atom]);\n else ranges.push(...atom);\n}\n\n/**\n * Complement of a range list, so `[\\D]` can sit inside a class.\n *\n * A negated escape is a set with no endpoints, and a class is a union of\n * ranges, so the only way to put one inside the other is to spell out what it\n * leaves.\n */\nfunction invert(ranges: readonly Range[]): readonly Range[] {\n const sorted = [...ranges].sort((a, b) => a[0] - b[0]);\n const out: Range[] = [];\n let cursor = 0;\n for (const [low, high] of sorted) {\n if (low > cursor) out.push([cursor, low - 1]);\n cursor = Math.max(cursor, high + 1);\n }\n if (cursor <= 0xffff) out.push([cursor, 0xffff]);\n return out;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Compilation */\n/* -------------------------------------------------------------------------- */\n\ninterface Split {\n readonly op: 'split';\n /** Where the first branch starts. */\n x: number;\n /** Where the second branch starts. */\n y: number;\n}\n\ninterface Jump {\n readonly op: 'jump';\n to: number;\n}\n\ntype Instruction =\n | { readonly op: 'char'; readonly set: CharSet }\n | Split\n | Jump\n | { readonly op: 'assert'; readonly assertion: Assertion }\n | { readonly op: 'match' };\n\nclass Compiler {\n readonly code: Instruction[] = [];\n\n private add<T extends Instruction>(instruction: T): T {\n if (this.code.length >= MAX_PROGRAM) {\n throw new RegexError(\n `pattern is too large: counted repetition is compiled by copying, and this needs more than ${MAX_PROGRAM} states`,\n 0,\n );\n }\n this.code.push(instruction);\n return instruction;\n }\n\n get here(): number {\n return this.code.length;\n }\n\n emitMatch(): void {\n this.add({ op: 'match' });\n }\n\n compile(node: Node): void {\n switch (node.kind) {\n case 'empty':\n return;\n case 'char':\n this.add({ op: 'char', set: node.set });\n return;\n case 'assert':\n this.add({ op: 'assert', assertion: node.assertion });\n return;\n case 'concat':\n for (const part of node.parts) this.compile(part);\n return;\n case 'alternate': {\n // One split per option but the last. Each split falls through to its\n // own branch and points its second arm at the next split; each branch\n // ends in a jump past all of them.\n const ends: Jump[] = [];\n for (let i = 0; i < node.options.length - 1; i += 1) {\n const split = this.add({ op: 'split', x: 0, y: 0 });\n split.x = this.here;\n this.compile(node.options[i] as Node);\n ends.push(this.add({ op: 'jump', to: 0 }));\n split.y = this.here;\n }\n this.compile(node.options[node.options.length - 1]!);\n for (const end of ends) end.to = this.here;\n return;\n }\n case 'repeat':\n this.repeat(node.node, node.min, node.max);\n return;\n }\n }\n\n private repeat(node: Node, min: number, max: number): void {\n for (let i = 0; i < min; i += 1) this.compile(node);\n\n if (max === Infinity) {\n const split = this.add({ op: 'split', x: 0, y: 0 });\n const body = this.here;\n split.x = body;\n this.compile(node);\n this.add({ op: 'jump', to: body - 1 });\n split.y = this.here;\n return;\n }\n\n // `{2,5}` is two copies and then three optional ones, each able to leave\n // for the far end rather than for the next copy.\n const exits: Split[] = [];\n for (let i = min; i < max; i += 1) {\n const split = this.add({ op: 'split', x: 0, y: 0 });\n split.x = this.here;\n exits.push(split);\n this.compile(node);\n }\n for (const split of exits) split.y = this.here;\n }\n}\n\n/* -------------------------------------------------------------------------- */\n/* Simulation */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A compiled pattern. Reusable and safe to cache.\n *\n * Not reentrant, which nothing can ask of it: `test` is synchronous and calls\n * out to nothing, and the buffers it keeps between subjects are what make it\n * cheap enough to run against every path a walk visits.\n */\nexport interface RegexMatcher {\n /** True when the pattern matches anywhere in the subject. */\n test(subject: string): boolean;\n /** State count. Published for the size test, and for nothing else. */\n readonly size: number;\n}\n\nexport interface RegexOptions {\n /** Fold case the way the `i` flag does. On unless set to `false`. */\n readonly ignoreCase?: boolean | undefined;\n}\n\n/**\n * Compiles a pattern into a matcher.\n *\n * Throws {@link RegexError} on anything it cannot run in linear time, which\n * is the point: the alternative to a message here is a build that stops.\n */\nexport function compileRegex(source: string, options: RegexOptions = {}): RegexMatcher {\n const tree = new PatternParser(source).parse();\n const compiler = new Compiler();\n compiler.compile(tree);\n compiler.emitMatch();\n // A pattern that begins by asserting the start of the subject cannot match\n // anywhere else, so the simulation stops seeding new threads at every\n // position. Nothing depends on this being noticed - it is the difference\n // between one pass and two over a long body.\n const machine = new Machine(compiler.code, startsAnchored(tree), options.ignoreCase !== false);\n return {\n size: compiler.code.length,\n test: (subject: string): boolean => machine.test(subject),\n };\n}\n\n/** True when every path through the pattern opens by asserting the start. */\nfunction startsAnchored(node: Node): boolean {\n switch (node.kind) {\n case 'assert':\n return node.assertion === 'start';\n case 'concat': {\n const first = node.parts[0];\n return first !== undefined && startsAnchored(first);\n }\n case 'alternate':\n return node.options.every((option) => startsAnchored(option));\n case 'repeat':\n return node.min > 0 && startsAnchored(node.node);\n default:\n return false;\n }\n}\n\nconst OP_CHAR = 0;\nconst OP_SPLIT = 1;\nconst OP_JUMP = 2;\nconst OP_ASSERT = 3;\nconst OP_MATCH = 4;\n\n/** Fills the slots of states that are not characters, where nothing reads it. */\nconst NOTHING: CharSet = { negated: false, ranges: [] };\n\n/**\n * The simulation, over the program flattened into typed arrays.\n *\n * The compiler's instructions are objects of five shapes, and one loop reading\n * `op` off all five is a megamorphic property read on every step. Simulated that\n * way, with a fresh visited table per subject, a glob cost about 3.5\n * microseconds a path and a path that failed on its first character still paid\n * half a microsecond for the allocation. Flat arrays and buffers kept between\n * subjects bring those to 0.6 and 0.04 - `RegExp` takes 0.06 - which matters\n * because a walk tests every path it visits against every pattern.\n */\nclass Machine {\n private readonly ops: Uint8Array;\n /** A split's first branch, or a jump's target. */\n private readonly first: Int32Array;\n /** A split's second branch. */\n private readonly second: Int32Array;\n private readonly sets: CharSet[];\n private readonly assertions: Assertion[];\n private readonly anchored: boolean;\n private readonly ignoreCase: boolean;\n\n /**\n * The position each state was last reached at. One visit per state per\n * position is exactly what turns the exponent into a product.\n */\n private readonly visited: Int32Array;\n /** Each visit pushes at most two states, so this cannot overflow. */\n private readonly stack: Int32Array;\n private live: Int32Array;\n private next: Int32Array;\n\n constructor(code: readonly Instruction[], anchored: boolean, ignoreCase: boolean) {\n const size = code.length;\n this.ops = new Uint8Array(size);\n this.first = new Int32Array(size);\n this.second = new Int32Array(size);\n this.sets = new Array<CharSet>(size).fill(NOTHING);\n this.assertions = new Array<Assertion>(size).fill('start');\n this.anchored = anchored;\n this.ignoreCase = ignoreCase;\n this.visited = new Int32Array(size).fill(-1);\n this.stack = new Int32Array(2 * size + 1);\n this.live = new Int32Array(size);\n this.next = new Int32Array(size);\n\n code.forEach((instruction, pc) => {\n switch (instruction.op) {\n case 'char':\n this.ops[pc] = OP_CHAR;\n this.sets[pc] = instruction.set;\n break;\n case 'split':\n this.ops[pc] = OP_SPLIT;\n this.first[pc] = instruction.x;\n this.second[pc] = instruction.y;\n break;\n case 'jump':\n this.ops[pc] = OP_JUMP;\n this.first[pc] = instruction.to;\n break;\n case 'assert':\n this.ops[pc] = OP_ASSERT;\n this.assertions[pc] = instruction.assertion;\n break;\n case 'match':\n this.ops[pc] = OP_MATCH;\n break;\n }\n });\n }\n\n test(subject: string): boolean {\n const length = subject.length;\n this.visited.fill(-1);\n\n let live = this.live;\n let next = this.next;\n let alive = 0;\n\n for (let position = 0; position <= length; position += 1) {\n if (position === 0 || !this.anchored) {\n alive = this.seed(live, alive, 0, subject, position);\n if (alive < 0) return true;\n } else if (alive === 0) {\n // An anchored pattern gets one chance, and every thread from it has died.\n return false;\n }\n\n if (position === length) return false;\n const char = subject.charCodeAt(position);\n let arriving = 0;\n for (let i = 0; i < alive; i += 1) {\n const pc = live[i] as number;\n const set = this.sets[pc] as CharSet;\n if (!(this.ignoreCase ? accepts(set, char) : acceptsExactly(set, char))) continue;\n arriving = this.seed(next, arriving, pc + 1, subject, position + 1);\n if (arriving < 0) return true;\n }\n const spent = live;\n live = next;\n next = spent;\n alive = arriving;\n }\n\n return false;\n }\n\n /**\n * Follows every zero-width transition out of one state, appending the\n * character states it reaches to `list`.\n *\n * Returns the new length of the list, or -1 the moment a thread reaches the\n * end of the pattern: the only question is whether a match exists, so there\n * is no leftmost-longest to settle and no captures to keep, and the first\n * thread to arrive is the answer.\n *\n * A stray thread at state 0 changes no answer: an unanchored pattern seeds it\n * at every position anyway, and an anchored one opens by asserting the start.\n * That makes two mutants here equivalent, with no test to write - the loop\n * running once past an empty stack, and a jump read as a split, both of which\n * add exactly that thread.\n */\n private seed(list: Int32Array, length: number, start: number, subject: string, position: number): number {\n const { ops, first, second, visited, stack } = this;\n let count = length;\n let top = 0;\n stack[top++] = start;\n while (top > 0) {\n const pc = stack[--top]!;\n if (visited[pc] === position) continue;\n visited[pc] = position;\n switch (ops[pc]) {\n case OP_MATCH:\n return -1;\n case OP_JUMP:\n stack[top++] = first[pc] as number;\n break;\n case OP_SPLIT:\n stack[top++] = second[pc] as number;\n stack[top++] = first[pc] as number;\n break;\n case OP_ASSERT:\n if (holds(this.assertions[pc] as Assertion, subject, position)) stack[top++] = pc + 1;\n break;\n default:\n list[count++] = pc;\n }\n }\n return count;\n }\n}\n\nfunction holds(assertion: Assertion, subject: string, position: number): boolean {\n switch (assertion) {\n case 'start':\n return position === 0;\n case 'end':\n return position === subject.length;\n default: {\n const before = position > 0 && isWordChar(subject.charCodeAt(position - 1));\n const after = position < subject.length && isWordChar(subject.charCodeAt(position));\n return (before !== after) === (assertion === 'word-boundary');\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"lines.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/text/lines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAwBH,MAAM,EAAE,GAAG,EAAE,CAAC;AACd,MAAM,EAAE,GAAG,EAAE,CAAC;AAEd,4DAA4D;AAC5D,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,MAAM,GAAa,CAAC,CAAC,CAAC,CAAC;IAC7B,4EAA4E;IAC5E,mCAAmC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CA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AAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;QAC7D,MAAM,GAAG,GAAG,CAAC;IACf,CAAC;IACD,OAAO,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9D,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACvE,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE;YAAE,IAAI,IAAI,CAAC,CAAC;;YACjD,EAAE,IAAI,CAAC,CAAC;IACf,CAAC;IACD,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/**\n * Lines, offsets and masks.\n *\n * Every finding a spec-* tool reports points at a line and a column, and every\n * structure the scanner builds carries raw offsets rather than copies of the\n * text. Converting between the two is on the hot path, so the line table is\n * built once per file and searched by bisection.\n *\n * All three line terminators end a line - `\\n`, `\\r\\n` and a lone `\\r`, as\n * CommonMark has it - and `\\r\\n` counts once. A Windows checkout of a document\n * must produce the line numbers a POSIX checkout does.\n */\n\nexport interface Position {\n /** UTF-16 offset into the text. */\n readonly offset: number;\n /** 1-based. */\n readonly line: number;\n /** 1-based, in UTF-16 code units. */\n readonly column: number;\n}\n\nexport interface LineIndex {\n /** Number of lines. A final terminator does not open a line of its own. */\n readonly lineCount: number;\n /** Offset at which a 1-based line starts. Out-of-range lines are clamped. */\n lineStart(line: number): number;\n /** Offset just past a 1-based line, before its terminator. */\n lineEnd(line: number): number;\n /** A 1-based line without its terminator. */\n lineText(line: number): string;\n /** The line and column of an offset. Out-of-range offsets are clamped. */\n positionAt(offset: number): Position;\n}\n\nconst LF = 10;\nconst CR = 13;\n\n/** Offsets at which each line starts; index 0 is line 1. */\nexport function lineStarts(text: string): number[] {\n const starts: number[] = [0];\n // One step past the end reads NaN, no terminator, so the bound could be one\n // further and give the same table.\n for (let i = 0; i < text.length; i += 1) {\n const ch = text.charCodeAt(i);\n if (ch === LF) {\n starts.push(i + 1);\n } else if (ch === CR) {\n if (text.charCodeAt(i + 1) === LF) i += 1;\n starts.push(i + 1);\n }\n }\n // A terminator at the very end opens a line that holds nothing; an editor\n // does not count it, and neither does this.\n if (starts.length > 1 && starts[starts.length - 1] === text.length) starts.pop();\n return starts;\n}\n\n/** Builds the line table for a text. */\nexport function createLineIndex(text: string): LineIndex {\n const starts = lineStarts(text);\n const lineCount = starts.length;\n // Each clamp, here and in `positionAt`, answers the bound itself at the\n // bound, so `<=` and `>=` for `<` and `>` give the same answers.\n const clamp = (line: number): number => (line < 1 ? 1 : line > lineCount ? lineCount : line);\n const startOf = (line: number): number => starts[clamp(line) - 1] as number;\n const endOf = (line: number): number => {\n const index = clamp(line);\n const start = starts[index - 1] as number;\n let end = index === lineCount ? text.length : (starts[index] as number);\n // At most two terminator characters, and never past the line's own start.\n // With the table `lineStarts` builds, `end > start` never decides: a line\n // holds no character, terminator included, only in the empty text, and\n // one that holds only `\\n` follows a `\\n`, since a `\\r` before it would\n // have made one `\\r\\n` with it. The guards keep the promise without\n // leaning on that.\n if (end > start && text.charCodeAt(end - 1) === LF) end -= 1;\n if (end > start && text.charCodeAt(end - 1) === CR) end -= 1;\n return end;\n };\n return {\n lineCount,\n lineStart: startOf,\n lineEnd: endOf,\n lineText: (line) => text.slice(startOf(line), endOf(line)),\n positionAt: (offset) => locate(starts, offset < 0 ? 0 : offset > text.length ? text.length : offset),\n };\n}\n\n/**\n * The line and column of an offset, by bisection over a line table.\n *\n * The search is half-open: `high` is one past the last candidate, and it\n * narrows until one is left. There is no `- 1` to get wrong.\n */\nexport function locate(starts: readonly number[], offset: number): Position {\n let low = 0;\n let high = starts.length;\n while (high - low > 1) {\n const mid = (low + high) >> 1;\n if ((starts[mid] as number) <= offset) low = mid;\n else high = mid;\n }\n return { offset, line: low + 1, column: offset - (starts[low] as number) + 1 };\n}\n\n/** A half-open range of offsets. */\nexport interface Range {\n readonly start: number;\n readonly end: number;\n}\n\n/** Sorts and merges ranges; touching ranges merge. Empty ranges vanish. */\nexport function mergeRanges(ranges: readonly Range[]): Range[] {\n const sorted = ranges.filter((r) => r.end > r.start).sort((a, b) => a.start - b.start || a.end - b.end);\n const out: { start: number; end: number }[] = [];\n for (const range of sorted) {\n const last = out[out.length - 1];\n if (last !== undefined && range.start <= last.end) last.end = Math.max(last.end, range.end);\n else out.push({ start: range.start, end: range.end });\n }\n return out;\n}\n\n/** Whether an offset lies in one of a list of merged, sorted ranges. */\nexport function inRanges(merged: readonly Range[], offset: number): boolean {\n let low = 0;\n let high = merged.length;\n while (low < high) {\n const mid = (low + high) >> 1;\n const range = merged[mid] as Range;\n if (offset < range.start) high = mid;\n else if (offset >= range.end) low = mid + 1;\n else return true;\n }\n return false;\n}\n\nconst NOT_A_TERMINATOR = /[^\\n\\r]/g;\n\n/**\n * Blanks the given ranges with spaces, keeping every other character and\n * every line terminator where it was.\n *\n * Offsets survive a mask, which is the point: something found at offset 400\n * of the masked text is at offset 400 of the original, on the same line. The\n * replacement walks UTF-16 code units, so a surrogate pair becomes two spaces\n * and every later offset still lands where it did.\n */\nexport function maskRanges(text: string, ranges: readonly Range[]): string {\n const merged = mergeRanges(ranges);\n // Only a shortcut: with nothing to blank, the loop below gives the text back.\n if (merged.length === 0) return text;\n let out = '';\n let cursor = 0;\n for (const range of merged) {\n const start = Math.min(range.start, text.length);\n const end = Math.min(range.end, text.length);\n out += text.slice(cursor, start);\n out += text.slice(start, end).replace(NOT_A_TERMINATOR, ' ');\n cursor = end;\n }\n return out + text.slice(cursor);\n}\n\n/** A text without a leading byte-order mark. */\nexport function stripBom(text: string): string {\n return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;\n}\n\n/** The terminator a text mostly uses; `\\n` when it has none or they tie. */\nexport function lineEnding(text: string): '\\n' | '\\r\\n' {\n let crlf = 0;\n let lf = 0;\n for (let i = text.indexOf('\\n'); i >= 0; i = text.indexOf('\\n', i + 1)) {\n if (i > 0 && text.charCodeAt(i - 1) === CR) crlf += 1;\n else lf += 1;\n }\n return crlf > lf ? '\\r\\n' : '\\n';\n}\n\n/**\n * The lines of a text, without terminators. Unlike the line table, a final\n * terminator does produce a last, empty line, so that joining the lines with\n * the same terminator gives the text back byte for byte.\n */\nexport function splitLines(text: string): string[] {\n return text.split(/\\r\\n|\\n|\\r/);\n}\n"]}
1
+ {"version":3,"file":"lines.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/text/lines.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAwBH,MAAM,EAAE,GAAG,EAAE,CAAC;AACd,MAAM,EAAE,GAAG,EAAE,CAAC;AAEd,4DAA4D;AAC5D,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,MAAM,GAAa,CAAC,CAAC,CAAC,CAAC;IAC7B,4EAA4E;IAC5E,mCAAmC;IACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,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AAG,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;QAC7D,MAAM,GAAG,GAAG,CAAC;IACf,CAAC;IACD,OAAO,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9D,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,EAAE,GAAG,CAAC,CAAC;IACX,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACvE,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE;YAAE,IAAI,IAAI,CAAC,CAAC;;YACjD,EAAE,IAAI,CAAC,CAAC;IACf,CAAC;IACD,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACnC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;AAClC,CAAC","sourcesContent":["/**\n * Lines, offsets and masks.\n *\n * Every finding a spec-* tool reports points at a line and a column, and every\n * structure the scanner builds carries raw offsets rather than copies of the\n * text. Converting between the two is on the hot path, so the line table is\n * built once per file and searched by bisection.\n *\n * All three line terminators end a line - `\\n`, `\\r\\n` and a lone `\\r`, as\n * CommonMark has it - and `\\r\\n` counts once. A Windows checkout of a document\n * must produce the line numbers a POSIX checkout does.\n */\n\nexport interface Position {\n /** UTF-16 offset into the text. */\n readonly offset: number;\n /** 1-based. */\n readonly line: number;\n /** 1-based, in UTF-16 code units. */\n readonly column: number;\n}\n\nexport interface LineIndex {\n /** Number of lines. A final terminator does not open a line of its own. */\n readonly lineCount: number;\n /** Offset at which a 1-based line starts. Out-of-range lines are clamped. */\n lineStart(line: number): number;\n /** Offset just past a 1-based line, before its terminator. */\n lineEnd(line: number): number;\n /** A 1-based line without its terminator. */\n lineText(line: number): string;\n /** The line and column of an offset. Out-of-range offsets are clamped. */\n positionAt(offset: number): Position;\n}\n\nconst LF = 10;\nconst CR = 13;\n\n/** Offsets at which each line starts; index 0 is line 1. */\nexport function lineStarts(text: string): number[] {\n const starts: number[] = [0];\n // One step past the end reads NaN, no terminator, so the bound could be one\n // further and give the same table.\n for (let i = 0; i < text.length; i += 1) {\n const ch = text.charCodeAt(i);\n if (ch === LF) {\n starts.push(i + 1);\n } else if (ch === CR) {\n if (text.charCodeAt(i + 1) === LF) i += 1;\n starts.push(i + 1);\n }\n }\n // A terminator at the very end opens a line that holds nothing; an editor\n // does not count it, and neither does this.\n if (starts.length > 1 && starts[starts.length - 1] === text.length) starts.pop();\n return starts;\n}\n\n/** Builds the line table for a text. */\nexport function createLineIndex(text: string): LineIndex {\n const starts = lineStarts(text);\n const lineCount = starts.length;\n // Each clamp, here and in `positionAt`, answers the bound itself at the\n // bound, so `<=` and `>=` for `<` and `>` give the same answers.\n const clamp = (line: number): number => (line < 1 ? 1 : line > lineCount ? lineCount : line);\n const startOf = (line: number): number => starts[clamp(line) - 1]!;\n const endOf = (line: number): number => {\n const index = clamp(line);\n const start = starts[index - 1]!;\n let end = index === lineCount ? text.length : (starts[index] as number);\n // At most two terminator characters, and never past the line's own start.\n // With the table `lineStarts` builds, `end > start` never decides: a line\n // holds no character, terminator included, only in the empty text, and\n // one that holds only `\\n` follows a `\\n`, since a `\\r` before it would\n // have made one `\\r\\n` with it. The guards keep the promise without\n // leaning on that.\n if (end > start && text.charCodeAt(end - 1) === LF) end -= 1;\n if (end > start && text.charCodeAt(end - 1) === CR) end -= 1;\n return end;\n };\n return {\n lineCount,\n lineStart: startOf,\n lineEnd: endOf,\n lineText: (line) => text.slice(startOf(line), endOf(line)),\n positionAt: (offset) => locate(starts, offset < 0 ? 0 : offset > text.length ? text.length : offset),\n };\n}\n\n/**\n * The line and column of an offset, by bisection over a line table.\n *\n * The search is half-open: `high` is one past the last candidate, and it\n * narrows until one is left. There is no `- 1` to get wrong.\n */\nexport function locate(starts: readonly number[], offset: number): Position {\n let low = 0;\n let high = starts.length;\n while (high - low > 1) {\n const mid = (low + high) >> 1;\n if ((starts[mid] as number) <= offset) low = mid;\n else high = mid;\n }\n return { offset, line: low + 1, column: offset - (starts[low] as number) + 1 };\n}\n\n/** A half-open range of offsets. */\nexport interface Range {\n readonly start: number;\n readonly end: number;\n}\n\n/** Sorts and merges ranges; touching ranges merge. Empty ranges vanish. */\nexport function mergeRanges(ranges: readonly Range[]): Range[] {\n const sorted = ranges.filter((r) => r.end > r.start).sort((a, b) => a.start - b.start || a.end - b.end);\n const out: { start: number; end: number }[] = [];\n for (const range of sorted) {\n const last = out[out.length - 1];\n if (last !== undefined && range.start <= last.end) last.end = Math.max(last.end, range.end);\n else out.push({ start: range.start, end: range.end });\n }\n return out;\n}\n\n/** Whether an offset lies in one of a list of merged, sorted ranges. */\nexport function inRanges(merged: readonly Range[], offset: number): boolean {\n let low = 0;\n let high = merged.length;\n while (low < high) {\n const mid = (low + high) >> 1;\n const range = merged[mid] as Range;\n if (offset < range.start) high = mid;\n else if (offset >= range.end) low = mid + 1;\n else return true;\n }\n return false;\n}\n\nconst NOT_A_TERMINATOR = /[^\\n\\r]/g;\n\n/**\n * Blanks the given ranges with spaces, keeping every other character and\n * every line terminator where it was.\n *\n * Offsets survive a mask, which is the point: something found at offset 400\n * of the masked text is at offset 400 of the original, on the same line. The\n * replacement walks UTF-16 code units, so a surrogate pair becomes two spaces\n * and every later offset still lands where it did.\n */\nexport function maskRanges(text: string, ranges: readonly Range[]): string {\n const merged = mergeRanges(ranges);\n // Only a shortcut: with nothing to blank, the loop below gives the text back.\n if (merged.length === 0) return text;\n let out = '';\n let cursor = 0;\n for (const range of merged) {\n const start = Math.min(range.start, text.length);\n const end = Math.min(range.end, text.length);\n out += text.slice(cursor, start);\n out += text.slice(start, end).replace(NOT_A_TERMINATOR, ' ');\n cursor = end;\n }\n return out + text.slice(cursor);\n}\n\n/** A text without a leading byte-order mark. */\nexport function stripBom(text: string): string {\n return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;\n}\n\n/** The terminator a text mostly uses; `\\n` when it has none or they tie. */\nexport function lineEnding(text: string): '\\n' | '\\r\\n' {\n let crlf = 0;\n let lf = 0;\n for (let i = text.indexOf('\\n'); i >= 0; i = text.indexOf('\\n', i + 1)) {\n if (i > 0 && text.charCodeAt(i - 1) === CR) crlf += 1;\n else lf += 1;\n }\n return crlf > lf ? '\\r\\n' : '\\n';\n}\n\n/**\n * The lines of a text, without terminators. Unlike the line table, a final\n * terminator does produce a last, empty line, so that joining the lines with\n * the same terminator gives the text back byte for byte.\n */\nexport function splitLines(text: string): string[] {\n return text.split(/\\r\\n|\\n|\\r/);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"width.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/text/width.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;GASG;AACH,MAAM,IAAI,GAAsB;IAC9B,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IA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AC,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;;;GAIG;AACH,SAAS,MAAM,CAAC,KAAa;IAC3B,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,OAAO,GAAG,GAAG,IAAI,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,KAAK,GAAI,IAAI,CAAC,CAAC,GAAG,GAAG,CAAY;YAAE,IAAI,GAAG,GAAG,CAAC;aAC7C,IAAI,KAAK,GAAI,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAY;YAAE,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;;YACzD,OAAO,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * How many columns of a terminal a text takes, for a tool that lines up the\n * columns of a table it prints: `.padEnd` counts UTF-16 units, and `已接受`\n * is three of them and six columns.\n *\n * Counted per grapheme cluster, as a terminal draws one: a cluster takes the\n * width of the first character in it that shows, and what follows that\n * character - a combining mark, a variation selector, a joiner and what it\n * joins - adds nothing.\n *\n * - An East Asian Wide or Fullwidth character takes two: Han, kana and\n * hangul, full-width forms, and most emoji.\n * - So does an emoji sequence, whatever its first character's own width: an\n * emoji and the presentation selector U+FE0F (`❤` with it, and a keycap),\n * a modifier base and a skin tone (`☝` with one), and a flag, two\n * regional indicators.\n * - A cluster of nothing that shows takes none: combining marks, format\n * characters - the zero-width space and joiners, the byte-order mark, the\n * bidirectional controls - and control characters. A soft hyphen shows, as\n * terminals draw one.\n * - Everything else takes one, East Asian Ambiguous included, as a terminal\n * draws it outside a legacy East Asian mode.\n *\n * The widths are the table below, fixed. Grapheme clusters and general\n * categories are the runtime's, and a runtime knows the characters of its\n * own Unicode version: only a character assigned after the older of two\n * hosts' versions can be counted differently on them.\n */\n\n/**\n * The East Asian Wide and Fullwidth code points of Unicode 16.0.0\n * (EastAsianWidth-16.0.0.txt), the unassigned ones its `@missing` lines\n * make Wide included, as the first and last of each run, in order.\n *\n * 16.0 is the version both supported lines have: Node 22.16.0 reports\n * `process.versions.unicode` 16.0, and Node 24.18.1 17.0, which Node 22 does\n * not ship. A character is counted as the older line knows it; one 17.0\n * added counts one, as it does on a host that cannot name it.\n */\nconst WIDE: readonly number[] = [\n 0x1100, 0x115f, 0x231a, 0x231b, 0x2329, 0x232a, 0x23e9, 0x23ec, 0x23f0, 0x23f0, 0x23f3, 0x23f3,\n 0x25fd, 0x25fe, 0x2614, 0x2615, 0x2630, 0x2637, 0x2648, 0x2653, 0x267f, 0x267f, 0x268a, 0x268f,\n 0x2693, 0x2693, 0x26a1, 0x26a1, 0x26aa, 0x26ab, 0x26bd, 0x26be, 0x26c4, 0x26c5, 0x26ce, 0x26ce,\n 0x26d4, 0x26d4, 0x26ea, 0x26ea, 0x26f2, 0x26f3, 0x26f5, 0x26f5, 0x26fa, 0x26fa, 0x26fd, 0x26fd,\n 0x2705, 0x2705, 0x270a, 0x270b, 0x2728, 0x2728, 0x274c, 0x274c, 0x274e, 0x274e, 0x2753, 0x2755,\n 0x2757, 0x2757, 0x2795, 0x2797, 0x27b0, 0x27b0, 0x27bf, 0x27bf, 0x2b1b, 0x2b1c, 0x2b50, 0x2b50,\n 0x2b55, 0x2b55, 0x2e80, 0x2e99, 0x2e9b, 0x2ef3, 0x2f00, 0x2fd5, 0x2ff0, 0x303e, 0x3041, 0x3096,\n 0x3099, 0x30ff, 0x3105, 0x312f, 0x3131, 0x318e, 0x3190, 0x31e5, 0x31ef, 0x321e, 0x3220, 0x3247,\n 0x3250, 0xa48c, 0xa490, 0xa4c6, 0xa960, 0xa97c, 0xac00, 0xd7a3, 0xf900, 0xfaff, 0xfe10, 0xfe19,\n 0xfe30, 0xfe52, 0xfe54, 0xfe66, 0xfe68, 0xfe6b, 0xff01, 0xff60, 0xffe0, 0xffe6, 0x16fe0, 0x16fe4,\n 0x16ff0, 0x16ff1, 0x17000, 0x187f7, 0x18800, 0x18cd5, 0x18cff, 0x18d08, 0x1aff0, 0x1aff3,\n 0x1aff5, 0x1affb, 0x1affd, 0x1affe, 0x1b000, 0x1b122, 0x1b132, 0x1b132, 0x1b150, 0x1b152,\n 0x1b155, 0x1b155, 0x1b164, 0x1b167, 0x1b170, 0x1b2fb, 0x1d300, 0x1d356, 0x1d360, 0x1d376,\n 0x1f004, 0x1f004, 0x1f0cf, 0x1f0cf, 0x1f18e, 0x1f18e, 0x1f191, 0x1f19a, 0x1f200, 0x1f202,\n 0x1f210, 0x1f23b, 0x1f240, 0x1f248, 0x1f250, 0x1f251, 0x1f260, 0x1f265, 0x1f300, 0x1f320,\n 0x1f32d, 0x1f335, 0x1f337, 0x1f37c, 0x1f37e, 0x1f393, 0x1f3a0, 0x1f3ca, 0x1f3cf, 0x1f3d3,\n 0x1f3e0, 0x1f3f0, 0x1f3f4, 0x1f3f4, 0x1f3f8, 0x1f43e, 0x1f440, 0x1f440, 0x1f442, 0x1f4fc,\n 0x1f4ff, 0x1f53d, 0x1f54b, 0x1f54e, 0x1f550, 0x1f567, 0x1f57a, 0x1f57a, 0x1f595, 0x1f596,\n 0x1f5a4, 0x1f5a4, 0x1f5fb, 0x1f64f, 0x1f680, 0x1f6c5, 0x1f6cc, 0x1f6cc, 0x1f6d0, 0x1f6d2,\n 0x1f6d5, 0x1f6d7, 0x1f6dc, 0x1f6df, 0x1f6eb, 0x1f6ec, 0x1f6f4, 0x1f6fc, 0x1f7e0, 0x1f7eb,\n 0x1f7f0, 0x1f7f0, 0x1f90c, 0x1f93a, 0x1f93c, 0x1f945, 0x1f947, 0x1f9ff, 0x1fa70, 0x1fa7c,\n 0x1fa80, 0x1fa89, 0x1fa8f, 0x1fac6, 0x1face, 0x1fadc, 0x1fadf, 0x1fae9, 0x1faf0, 0x1faf8,\n 0x20000, 0x2fffd, 0x30000, 0x3fffd,\n];\n\n/** A character that shows: anything but a control, a format character or a mark, and the soft hyphen. */\nconst SHOWN = /[^\\p{Cc}\\p{Cf}\\p{Mn}\\p{Me}]|\\u00ad/u;\n\n/**\n * The start of an emoji sequence a terminal draws as one wide picture: an\n * emoji and the presentation selector, a modifier base and its modifier, or\n * two regional indicators, a flag.\n */\nconst EMOJI_SEQUENCE = /^(?:\\p{Emoji}\\ufe0f|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}|\\p{Regional_Indicator}{2})/u;\n\n// Made the first time a width is asked for: loading the segmentation rules\n// costs milliseconds that a tool which never measures a string - every one\n// that copies this module for its line tables - would pay on each start.\nlet graphemes: Intl.Segmenter | undefined;\n\n/** The columns a text takes in a terminal. */\nexport function displayWidth(text: string): number {\n // A named locale, so the host's default is never read; clusters are the\n // same in every locale, and they are what a segmenter gives unless told\n // otherwise.\n graphemes ??= new Intl.Segmenter('en');\n let width = 0;\n for (const { segment } of graphemes.segment(text)) width += clusterWidth(segment);\n return width;\n}\n\nfunction clusterWidth(cluster: string): number {\n const at = cluster.search(SHOWN);\n if (at < 0) return 0;\n const shown = cluster.slice(at);\n return isWide(shown.codePointAt(0) as number) || EMOJI_SEQUENCE.test(shown) ? 2 : 1;\n}\n\n/**\n * Whether a code point is in {@link WIDE}, by bisection over its runs. The\n * search is half-open, as `inRanges`'s is: `high` is one past the last run\n * still in question.\n */\nfunction isWide(point: number): boolean {\n let low = 0;\n let high = WIDE.length / 2;\n while (low < high) {\n const mid = (low + high) >> 1;\n if (point < (WIDE[2 * mid] as number)) high = mid;\n else if (point > (WIDE[2 * mid + 1] as number)) low = mid + 1;\n else return true;\n }\n return false;\n}\n"]}
1
+ {"version":3,"file":"width.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/text/width.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;;;;;;GASG;AACH,MAAM,IAAI,GAAsB;IAC9B,MAAM,EAAE,MAAM,EAAE,M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AAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAW,CAAC,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;;;GAIG;AACH,SAAS,MAAM,CAAC,KAAa;IAC3B,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,IAAI,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3B,OAAO,GAAG,GAAG,IAAI,EAAE,CAAC;QAClB,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,GAAG,CAAE;YAAE,IAAI,GAAG,GAAG,CAAC;aAClC,IAAI,KAAK,GAAG,IAAI,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAE;YAAE,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC;;YAC9C,OAAO,IAAI,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["/**\n * How many columns of a terminal a text takes, for a tool that lines up the\n * columns of a table it prints: `.padEnd` counts UTF-16 units, and `已接受`\n * is three of them and six columns.\n *\n * Counted per grapheme cluster, as a terminal draws one: a cluster takes the\n * width of the first character in it that shows, and what follows that\n * character - a combining mark, a variation selector, a joiner and what it\n * joins - adds nothing.\n *\n * - An East Asian Wide or Fullwidth character takes two: Han, kana and\n * hangul, full-width forms, and most emoji.\n * - So does an emoji sequence, whatever its first character's own width: an\n * emoji and the presentation selector U+FE0F (`❤` with it, and a keycap),\n * a modifier base and a skin tone (`☝` with one), and a flag, two\n * regional indicators.\n * - A cluster of nothing that shows takes none: combining marks, format\n * characters - the zero-width space and joiners, the byte-order mark, the\n * bidirectional controls - and control characters. A soft hyphen shows, as\n * terminals draw one.\n * - Everything else takes one, East Asian Ambiguous included, as a terminal\n * draws it outside a legacy East Asian mode.\n *\n * The widths are the table below, fixed. Grapheme clusters and general\n * categories are the runtime's, and a runtime knows the characters of its\n * own Unicode version: only a character assigned after the older of two\n * hosts' versions can be counted differently on them.\n */\n\n/**\n * The East Asian Wide and Fullwidth code points of Unicode 16.0.0\n * (EastAsianWidth-16.0.0.txt), the unassigned ones its `@missing` lines\n * make Wide included, as the first and last of each run, in order.\n *\n * 16.0 is the version both supported lines have: Node 22.16.0 reports\n * `process.versions.unicode` 16.0, and Node 24.18.1 17.0, which Node 22 does\n * not ship. A character is counted as the older line knows it; one 17.0\n * added counts one, as it does on a host that cannot name it.\n */\nconst WIDE: readonly number[] = [\n 0x1100, 0x115f, 0x231a, 0x231b, 0x2329, 0x232a, 0x23e9, 0x23ec, 0x23f0, 0x23f0, 0x23f3, 0x23f3,\n 0x25fd, 0x25fe, 0x2614, 0x2615, 0x2630, 0x2637, 0x2648, 0x2653, 0x267f, 0x267f, 0x268a, 0x268f,\n 0x2693, 0x2693, 0x26a1, 0x26a1, 0x26aa, 0x26ab, 0x26bd, 0x26be, 0x26c4, 0x26c5, 0x26ce, 0x26ce,\n 0x26d4, 0x26d4, 0x26ea, 0x26ea, 0x26f2, 0x26f3, 0x26f5, 0x26f5, 0x26fa, 0x26fa, 0x26fd, 0x26fd,\n 0x2705, 0x2705, 0x270a, 0x270b, 0x2728, 0x2728, 0x274c, 0x274c, 0x274e, 0x274e, 0x2753, 0x2755,\n 0x2757, 0x2757, 0x2795, 0x2797, 0x27b0, 0x27b0, 0x27bf, 0x27bf, 0x2b1b, 0x2b1c, 0x2b50, 0x2b50,\n 0x2b55, 0x2b55, 0x2e80, 0x2e99, 0x2e9b, 0x2ef3, 0x2f00, 0x2fd5, 0x2ff0, 0x303e, 0x3041, 0x3096,\n 0x3099, 0x30ff, 0x3105, 0x312f, 0x3131, 0x318e, 0x3190, 0x31e5, 0x31ef, 0x321e, 0x3220, 0x3247,\n 0x3250, 0xa48c, 0xa490, 0xa4c6, 0xa960, 0xa97c, 0xac00, 0xd7a3, 0xf900, 0xfaff, 0xfe10, 0xfe19,\n 0xfe30, 0xfe52, 0xfe54, 0xfe66, 0xfe68, 0xfe6b, 0xff01, 0xff60, 0xffe0, 0xffe6, 0x16fe0, 0x16fe4,\n 0x16ff0, 0x16ff1, 0x17000, 0x187f7, 0x18800, 0x18cd5, 0x18cff, 0x18d08, 0x1aff0, 0x1aff3,\n 0x1aff5, 0x1affb, 0x1affd, 0x1affe, 0x1b000, 0x1b122, 0x1b132, 0x1b132, 0x1b150, 0x1b152,\n 0x1b155, 0x1b155, 0x1b164, 0x1b167, 0x1b170, 0x1b2fb, 0x1d300, 0x1d356, 0x1d360, 0x1d376,\n 0x1f004, 0x1f004, 0x1f0cf, 0x1f0cf, 0x1f18e, 0x1f18e, 0x1f191, 0x1f19a, 0x1f200, 0x1f202,\n 0x1f210, 0x1f23b, 0x1f240, 0x1f248, 0x1f250, 0x1f251, 0x1f260, 0x1f265, 0x1f300, 0x1f320,\n 0x1f32d, 0x1f335, 0x1f337, 0x1f37c, 0x1f37e, 0x1f393, 0x1f3a0, 0x1f3ca, 0x1f3cf, 0x1f3d3,\n 0x1f3e0, 0x1f3f0, 0x1f3f4, 0x1f3f4, 0x1f3f8, 0x1f43e, 0x1f440, 0x1f440, 0x1f442, 0x1f4fc,\n 0x1f4ff, 0x1f53d, 0x1f54b, 0x1f54e, 0x1f550, 0x1f567, 0x1f57a, 0x1f57a, 0x1f595, 0x1f596,\n 0x1f5a4, 0x1f5a4, 0x1f5fb, 0x1f64f, 0x1f680, 0x1f6c5, 0x1f6cc, 0x1f6cc, 0x1f6d0, 0x1f6d2,\n 0x1f6d5, 0x1f6d7, 0x1f6dc, 0x1f6df, 0x1f6eb, 0x1f6ec, 0x1f6f4, 0x1f6fc, 0x1f7e0, 0x1f7eb,\n 0x1f7f0, 0x1f7f0, 0x1f90c, 0x1f93a, 0x1f93c, 0x1f945, 0x1f947, 0x1f9ff, 0x1fa70, 0x1fa7c,\n 0x1fa80, 0x1fa89, 0x1fa8f, 0x1fac6, 0x1face, 0x1fadc, 0x1fadf, 0x1fae9, 0x1faf0, 0x1faf8,\n 0x20000, 0x2fffd, 0x30000, 0x3fffd,\n];\n\n/** A character that shows: anything but a control, a format character or a mark, and the soft hyphen. */\nconst SHOWN = /[^\\p{Cc}\\p{Cf}\\p{Mn}\\p{Me}]|\\u00ad/u;\n\n/**\n * The start of an emoji sequence a terminal draws as one wide picture: an\n * emoji and the presentation selector, a modifier base and its modifier, or\n * two regional indicators, a flag.\n */\nconst EMOJI_SEQUENCE = /^(?:\\p{Emoji}\\ufe0f|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}|\\p{Regional_Indicator}{2})/u;\n\n// Made the first time a width is asked for: loading the segmentation rules\n// costs milliseconds that a tool which never measures a string - every one\n// that copies this module for its line tables - would pay on each start.\nlet graphemes: Intl.Segmenter | undefined;\n\n/** The columns a text takes in a terminal. */\nexport function displayWidth(text: string): number {\n // A named locale, so the host's default is never read; clusters are the\n // same in every locale, and they are what a segmenter gives unless told\n // otherwise.\n graphemes ??= new Intl.Segmenter('en');\n let width = 0;\n for (const { segment } of graphemes.segment(text)) width += clusterWidth(segment);\n return width;\n}\n\nfunction clusterWidth(cluster: string): number {\n const at = cluster.search(SHOWN);\n if (at < 0) return 0;\n const shown = cluster.slice(at);\n return isWide(shown.codePointAt(0) as number) || EMOJI_SEQUENCE.test(shown) ? 2 : 1;\n}\n\n/**\n * Whether a code point is in {@link WIDE}, by bisection over its runs. The\n * search is half-open, as `inRanges`'s is: `high` is one past the last run\n * still in question.\n */\nfunction isWide(point: number): boolean {\n let low = 0;\n let high = WIDE.length / 2;\n while (low < high) {\n const mid = (low + high) >> 1;\n if (point < WIDE[2 * mid]!) high = mid;\n else if (point > WIDE[2 * mid + 1]!) low = mid + 1;\n else return true;\n }\n return false;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descent-vtt/spec-graph",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "Turn Markdown specs into a verifiable relational graph. Catches ghost handovers, stale premises and broken references in CI.",
5
5
  "keywords": [
6
6
  "adr",