@descent-vtt/spec-harness 0.2.0 → 0.3.1
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +107 -0
- package/README.md +3 -3
- package/dist/commands.js +8 -1
- package/dist/commands.js.map +1 -1
- package/dist/context.d.ts +7 -1
- package/dist/context.js +14 -2
- package/dist/context.js.map +1 -1
- package/dist/document.d.ts +6 -0
- package/dist/document.js.map +1 -1
- package/dist/git.d.ts +8 -1
- package/dist/git.js +8 -5
- package/dist/git.js.map +1 -1
- package/dist/reader.js +3 -1
- package/dist/reader.js.map +1 -1
- package/dist/round.js +1 -1
- package/dist/round.js.map +1 -1
- package/dist/sandbox.d.ts +3 -1
- package/dist/sandbox.js +129 -30
- package/dist/sandbox.js.map +1 -1
- package/dist/server.js +10 -1
- package/dist/server.js.map +1 -1
- package/dist/vendor/spec-core/markdown/links.d.ts +2 -2
- package/dist/vendor/spec-core/markdown/links.js +92 -26
- package/dist/vendor/spec-core/markdown/links.js.map +1 -1
- package/dist/vendor/spec-core/markdown/scan.js +1 -1
- package/dist/vendor/spec-core/markdown/scan.js.map +1 -1
- package/dist/vendor/spec-core/markdown/tables.js +3 -0
- package/dist/vendor/spec-core/markdown/tables.js.map +1 -1
- package/dist/vendor/spec-core/pattern/automaton.d.ts +15 -2
- package/dist/vendor/spec-core/pattern/automaton.js +21 -2
- package/dist/vendor/spec-core/pattern/automaton.js.map +1 -1
- package/dist/vendor/spec-core/pattern/charset.d.ts +5 -1
- package/dist/vendor/spec-core/pattern/charset.js +8 -1
- package/dist/vendor/spec-core/pattern/charset.js.map +1 -1
- package/dist/vendor/spec-core/pattern/glob.d.ts +14 -3
- package/dist/vendor/spec-core/pattern/glob.js +55 -16
- package/dist/vendor/spec-core/pattern/glob.js.map +1 -1
- package/dist/vendor/spec-core/text/lines.js +10 -0
- package/dist/vendor/spec-core/text/lines.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAA8B,MAAM,kBAAkB,CAAC;AACxI,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,eAAe,EACf,aAAa,EACb,eAAe,EACf,SAAS,EACT,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,eAAe,EACf,WAAW,GAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,GAAG,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/E,MAAM,SAAS,GAAG,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC;IACnE,MAAM,IAAI,GAAG,QAAQ,CA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2EAA2E;QAC3E,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAK,QAAQ,CAAC,CAAC,CAAiB,CAAC,GAAG,IAAI,IAAI;YAAE,CAAC,IAAI,CAAC,CAAC;QAC/E,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["/**\n * A structural Markdown scanner.\n *\n * Deliberately not a CommonMark parser: nothing here renders. What it must get\n * exactly right is what is code, what is a comment, and what is neither,\n * because every reader downstream asks that question first. A heading inside\n * a fenced block is not a section, a template hint inside `<!-- -->` is not\n * content, and a link in a code sample is not a reference.\n *\n * The scan works on offsets. One pass over the lines finds front matter, code\n * blocks and raw-text HTML, and inside everything else it finds code spans and\n * comments in a single sweep from left to right, as CommonMark does: whichever\n * of the two opens first wins, so `` `<!--` `` is code that mentions a comment,\n * and a backtick inside a comment is a character. Three masks are built from\n * the result, and headings, list items, links and tables are read from them.\n *\n * Every pass is linear in the text. No search runs to the end of the document\n * once per opener: a code span looks for its closer only to the end of its\n * paragraph and remembers what it saw there, and a comment with no `-->`\n * after it tells every later one that there is none.\n *\n * Loops here that stop at a line's end compare against it, and the character\n * there is the line's terminator, which none of them acts on. A bound moved\n * to read one character further changes no answer; mutation testing reports\n * such mutants as surviving, and they are equivalent. So is a search for `-->`\n * compared as `close <= 0` rather than `close < 0`: it starts past `<!--`.\n */\n\nimport { createLineIndex, inRanges, maskRanges, mergeRanges, splitLines, stripBom, type LineIndex, type Range } from '../text/index.js';\nimport { frontMatterCloses, frontMatterKind } from './frontmatter.js';\nimport { findAtxHeadings, findHeadings } from './headings.js';\nimport type { Layout } from './layout.js';\nimport { findLinks } from './links.js';\nimport { findListItems } from './lists.js';\nimport {\n atxLevel,\n fenceCloses,\n fenceOpen,\n hasRawTextClose,\n isRawTextOpen,\n isThematicBreak,\n leadIndex,\n listMarker,\n measureIndent,\n opensComment,\n rawTextTag,\n setextUnderline,\n stripQuotes,\n type FenceOpen,\n type ListMarker,\n} from './syntax.js';\nimport { findTables } from './tables.js';\nimport type { Block, BlockKind, FrontMatterBlock, HtmlComment, MarkdownScan, MaskKind, Masks, ScannedLine, UnclosedFrontMatter } from './types.js';\n\nconst BACKTICK = 0x60;\nconst BACKSLASH = 0x5c;\n\n/** Scans a Markdown document. Pure, and linear in the length of the text. */\nexport function scanMarkdown(source: string): MarkdownScan {\n const text = stripBom(source);\n const index = createLineIndex(text);\n const { frontMatter, unclosedFrontMatter } = readFrontMatterBlock(text, index);\n const bodyStart = frontMatter === null ? 0 : frontMatter.bodyStart;\n const core = scanCore(text, index, frontMatter === null ? 0 : frontMatter.closeLine);\n\n // Without front matter this range is empty, and merging drops it.\n const front: Range[] = [{ start: 0, end: bodyStart }];\n const ranges: Record<MaskKind, Range[]> = {\n structure: mergeRanges([...front, ...core.blocks, ...core.spans, ...core.comments]),\n prose: mergeRanges([...front, ...core.comments]),\n directives: mergeRanges([...front, ...core.blocks, ...core.spans]),\n };\n // Headings are read from the structure and prose masks, and every caller\n // reads headings, so those two are made now. The rest is made the first\n // time it is read: most callers read one or two of links, list items and\n // the directives mask, and making all of them for every document was most\n // of what a spec-guard query spent (ADR-0004).\n const structure = maskRanges(text, ranges.structure);\n const prose = maskRanges(text, ranges.prose);\n const directives = once(() => maskRanges(text, ranges.directives));\n const masks: Masks = {\n structure,\n prose,\n get directives() {\n return directives();\n },\n };\n\n const layout: Layout = {\n text,\n index,\n lines: core.lines,\n blocks: core.blocks,\n comments: core.comments,\n structure,\n prose,\n covered: core.covered,\n continues: core.continues,\n };\n const atx = findAtxHeadings(layout);\n const tables = findTables(layout, atx);\n const headings = findHeadings(layout, atx, tables);\n const listItems = once(() => findListItems(layout, headings));\n const links = once(() => findLinks(layout));\n\n return {\n text,\n bom: source.length - text.length,\n index,\n lines: core.lines,\n frontMatter,\n unclosedFrontMatter,\n bodyStart,\n blocks: core.blocks,\n codeSpans: core.spans,\n comments: core.comments,\n masks,\n headings,\n get listItems() {\n return listItems();\n },\n get links() {\n return links();\n },\n tables,\n isMasked: (offset, mask = 'structure') => inRanges(ranges[mask], offset),\n };\n}\n\n/**\n * The lines of the text or of one of its masks, without terminators, as\n * `splitLines` gives them: a final terminator leaves a last, empty line.\n * Every view has the same number of lines, each the same length.\n */\nexport function linesOf(scan: MarkdownScan, view: MaskKind | 'text' = 'text'): string[] {\n return splitLines(view === 'text' ? scan.text : scan.masks[view]);\n}\n\ninterface Front {\n readonly frontMatter: FrontMatterBlock | null;\n readonly unclosedFrontMatter: UnclosedFrontMatter | null;\n}\n\nconst NO_FRONT: Front = { frontMatter: null, unclosedFrontMatter: null };\n\n/**\n * YAML between `---` lines, closed by `---` or `...`, or TOML between `+++`\n * lines. The opening line is the document's first, exactly. An opening line\n * that is never closed opens nothing: it is a thematic break, and is reported\n * as unclosed front matter.\n */\nfunction readFrontMatterBlock(text: string, index: LineIndex): Front {\n const kind = frontMatterKind(index.lineText(1));\n if (kind === null) return NO_FRONT;\n for (let line = 2; line <= index.lineCount; line += 1) {\n if (!frontMatterCloses(index.lineText(line), kind)) continue;\n const start = index.lineStart(2);\n const end = index.lineStart(line);\n const bodyStart = line < index.lineCount ? index.lineStart(line + 1) : text.length;\n return { frontMatter: { kind, raw: text.slice(start, end), start, end, bodyStart, closeLine: line }, unclosedFrontMatter: null };\n }\n return { frontMatter: null, unclosedFrontMatter: { kind, line: 1, start: 0, end: index.lineEnd(1) } };\n}\n\n/** `make`, run the first time its value is asked for; the same value after. */\nfunction once<T>(make: () => T): () => T {\n let made: { readonly value: T } | null = null;\n return () => {\n made ??= { value: make() };\n return made.value;\n };\n}\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\ninterface Core {\n readonly lines: ScannedLine[];\n readonly blocks: Block[];\n readonly spans: Range[];\n readonly comments: HtmlComment[];\n readonly covered: ReadonlySet<number>;\n readonly continues: ReadonlySet<number>;\n}\n\n/** What each body line is on its own, before anything around it is known. */\ninterface Shape {\n readonly contentStart: number;\n readonly depth: number;\n readonly indent: number;\n readonly blank: boolean;\n /** An ATX heading, which is a paragraph of one line. */\n readonly atx: boolean;\n /** Opens a block that ends a paragraph above it. */\n readonly interrupts: boolean;\n}\n\n/**\n * The block pass, with the inline sweep for code spans and comments run\n * inside it line by line.\n *\n * The two cannot be separate passes. Whether a line opens a fence depends on\n * whether it lies inside a comment, and whether a comment opens depends on\n * whether its `<!--` lies inside a code span.\n */\nfunction scanCore(text: string, index: LineIndex, frontLines: number): Core {\n const count = index.lineCount;\n const lines: Mutable<ScannedLine>[] = [];\n const blocks: Mutable<Block>[] = [];\n const spans: Range[] = [];\n const comments: HtmlComment[] = [];\n const covered = new Set<number>();\n\n for (let i = 0; i < frontLines; i += 1) {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n lines.push(record(i, start, end, start, text.slice(start, end), 0, { frontMatter: true, code: false, html: false }));\n }\n\n // One shape too many, for a line past the last, would never be read.\n const shapes: Shape[] = [];\n for (let i = frontLines; i < count; i += 1) {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n const q = stripQuotes(text, start, Number.POSITIVE_INFINITY);\n const content = text.slice(q.contentStart, end);\n const indent = measureIndent(content);\n const blank = leadIndex(content) === content.length;\n const atx = atxLevel(content) > 0;\n const previous = shapes[shapes.length - 1];\n const interrupts =\n atx ||\n isThematicBreak(content) ||\n setextUnderline(content) !== null ||\n opensComment(content) ||\n listMarker(content) !== null ||\n fenceOpen(content) !== null ||\n isRawTextOpen(content) ||\n (previous !== undefined && q.depth > previous.depth);\n shapes.push({ contentStart: q.contentStart, depth: q.depth, indent, blank, atx, interrupts });\n }\n const shapeOf = (i: number): Shape => shapes[i - frontLines] as Shape;\n\n // A line continues the paragraph above it when it is not blank, opens\n // nothing of its own, and the line above is not a one-line heading. After a\n // blank line there is no paragraph to continue, and no search asks. Each\n // body line's paragraph ends at `stops`, walked from the bottom up.\n const continues = new Set<number>();\n const stops = new Map<number, number>();\n for (let i = count - 1; i >= frontLines; i -= 1) {\n const shape = shapeOf(i);\n const above = shapes[i - frontLines - 1];\n if (above !== undefined && !above.atx && !shape.blank && !shape.interrupts) continues.add(i + 1);\n stops.set(i, continues.has(i + 2) ? (stops.get(i + 1) as number) : index.lineEnd(i + 1));\n }\n\n /* ------------------------------------------------------------ inline sweep */\n\n // Where the last failed search for a closing backtick run stopped, and the\n // last run of each length it passed. Openers come in order, so a later one\n // before that stop lies inside the stretch searched, and closes only if a\n // run of its length lies after it there, which is a lookup.\n let seen: { readonly end: number; readonly last: ReadonlyMap<number, number> } | null = null;\n\n /** Where the span opened by a run ending at `from` closes, if it does. */\n const closeRun = (from: number, length: number, line: number): number | undefined => {\n // A run of a length the search never saw - one an escape split in two -\n // has no closer either. Reading its absence as any number below `from`\n // gives that answer, and one that is not below it gives it by searching.\n // No run starts at `from`, which follows one, and an opener at `seen.end`\n // finds nothing either way: the comparisons are equivalent at equality.\n if (seen !== null && from < seen.end && (seen.last.get(length) ?? -1) < from) return undefined;\n const stop = stops.get(line) as number;\n const last = new Map<number, number>();\n // A run ends at `from`, so `from` is past 0 and holds no backtick. A\n // search that stopped at `from` itself would record a run of length\n // zero, which no opener asks for, and `at > 0` tests what `at >= 0` does.\n let at = text.indexOf('`', from);\n while (at >= 0 && at < stop) {\n const run = at;\n while (at < stop && text.charCodeAt(at) === BACKTICK) at += 1;\n if (at - run === length) return at;\n last.set(at - run, run);\n at = text.indexOf('`', at);\n }\n seen = { end: stop, last };\n return undefined;\n };\n\n // Once one `<!--` has no `-->` after it, no later one has either.\n let closable = true;\n\n /** Where the comment opened at `at` closes, if it does. */\n const commentEnd = (at: number): number | undefined => {\n // CommonMark 0.31: `<!-->` and `<!--->` are whole, empty comments.\n if (text.startsWith('<!-->', at)) return at + 5;\n if (text.startsWith('<!--->', at)) return at + 6;\n if (!closable) return undefined;\n const close = text.indexOf('-->', at + 4);\n closable = close !== -1;\n return closable ? close + 3 : undefined;\n };\n\n const pushComment = (start: number, end: number, closed: boolean): void => {\n comments.push({\n start,\n end,\n // An empty comment's `-->` overlaps its `<!--`, and the slice is empty.\n inner: text.slice(start + 4, closed ? end - 3 : end),\n innerStart: start + 4,\n line: index.positionAt(start).line,\n closed,\n });\n };\n /**\n * Sweeps one line from `from`, returning where the next line's sweep may\n * begin: past a span or comment that runs onto a later line, or the line's\n * end. `lead` is the offset at which a `<!--` would open the line, or the\n * end of the line when none can: a sweep never stops there.\n */\n const sweep = (from: number, end: number, line: number, lead: number): number => {\n let at = from;\n while (at < end) {\n const ch = text.charCodeAt(at);\n if (ch === BACKSLASH) {\n // An escaped backtick opens no span, and an escaped `<` no comment.\n at += 2;\n } else if (ch === BACKTICK) {\n let run = at + 1;\n while (run < end && text.charCodeAt(run) === BACKTICK) run += 1;\n const close = closeRun(run, run - at, line);\n if (close === undefined) {\n at = run;\n } else {\n spans.push({ start: at, end: close });\n at = close;\n }\n } else if (text.startsWith('<!--', at)) {\n const close = commentEnd(at);\n if (close !== undefined) {\n pushComment(at, close, true);\n at = close;\n } else if (at === lead) {\n // CommonMark's HTML block: a comment opening a line runs to its\n // `-->`, and one never closed runs to the end of the document.\n pushComment(at, text.length, false);\n return text.length;\n } else {\n at += 4;\n }\n } else {\n at += 1;\n }\n }\n return at;\n };\n\n /* ------------------------------------------------------------- block pass */\n\n interface Open {\n readonly block: Mutable<Block>;\n readonly depth: number;\n }\n let fence: (Open & { readonly open: FenceOpen }) | null = null;\n let raw: Open | null = null;\n let indented: Mutable<Block> | null = null;\n let previousBlank = true;\n // The content column of each list item open around the line, innermost last.\n // Each loop that pops it tests its length first, which says what is meant;\n // without the test it stops all the same, `undefined > indent` being false.\n const items: number[] = [];\n let pos = 0;\n\n const openBlock = (kind: BlockKind, i: number, info: string, tag: string | null): Mutable<Block> => {\n const block = { kind, start: index.lineStart(i + 1), end: index.lineEnd(i + 1), line: i + 1, endLine: i + 1, info, tag, closed: kind === 'indented' };\n blocks.push(block);\n return block;\n };\n const extend = (block: Mutable<Block>, i: number): void => {\n block.end = index.lineEnd(i + 1);\n block.endLine = i + 1;\n };\n // Blank lines after an indented block were marked as code in case more\n // code followed; the block ends at its last code line.\n const endIndented = (block: Mutable<Block>, next: number): void => {\n for (let i = block.endLine; i < next; i += 1) (lines[i] as Mutable<ScannedLine>).code = false;\n };\n\n /** Classifies one line and sweeps it; the caller records whether it was blank. */\n const scanLine = (i: number): void => {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n const shape = shapeOf(i);\n const content = text.slice(shape.contentStart, end);\n const push = (kind: Kinds): void => {\n lines.push(record(i, start, end, shape.contentStart, content, shape.depth, kind));\n };\n\n if (pos > start) {\n // Inside a comment or span opened above: nothing opens a block here.\n covered.add(i + 1);\n push(NONE);\n pos = sweep(pos, end, i, end);\n return;\n }\n\n const container = fence ?? raw;\n if (container !== null) {\n // A fenced block or raw-text block ends with its block quote.\n const q = stripQuotes(text, start, container.depth);\n if (q.depth === container.depth) {\n const inside = text.slice(q.contentStart, end);\n lines.push(record(i, start, end, q.contentStart, inside, q.depth, fence === null ? HTML : CODE));\n extend(container.block, i);\n if (fence !== null ? fenceCloses(inside, fence.open) : hasRawTextClose(inside)) {\n container.block.closed = true;\n fence = null;\n raw = null;\n }\n return;\n }\n fence = null;\n raw = null;\n }\n\n // After a blank line, a line left of an item's content is outside it.\n if (!shape.blank && previousBlank) {\n while (items.length > 0 && (items[items.length - 1] as number) > shape.indent) items.pop();\n }\n // Indented code: four columns past the item the line is in, or past the\n // margin outside a list, and never interrupting a paragraph. Four columns\n // inside an item are its text, not code.\n const margin = items[items.length - 1] ?? 0;\n const deep = shape.indent >= margin + 4;\n if (!shape.blank && deep && (previousBlank || indented !== null)) {\n if (indented === null) indented = openBlock('indented', i, '', null);\n else extend(indented, i);\n push(CODE);\n return;\n }\n if (shape.blank) {\n push(indented === null ? NONE : CODE);\n return;\n }\n if (indented !== null) {\n endIndented(indented, i);\n indented = null;\n }\n\n // A fence as deep as indented code continues a paragraph instead.\n const open = deep ? null : fenceOpen(content);\n if (open !== null) {\n fence = { block: openBlock('fenced', i, open.info, null), depth: shape.depth, open };\n push(CODE);\n return;\n }\n const tag = rawTextTag(content);\n if (tag !== null) {\n const block = openBlock('html', i, '', tag);\n push(HTML);\n if (hasRawTextClose(content)) block.closed = true;\n else raw = { block, depth: shape.depth };\n return;\n }\n\n push(NONE);\n const marker = listMarker(content);\n if (marker !== null) {\n // A marker left of an item's content starts a sibling or an outer item.\n while (items.length > 0 && (items[items.length - 1] as number) > shape.indent) items.pop();\n items.push(itemColumn(shape.indent, marker));\n }\n // A heading ends a list whatever its indentation.\n if (shape.atx) items.length = 0;\n const lead = shape.indent <= 3 ? shape.contentStart + leadIndex(content) : end;\n pos = sweep(shape.contentStart, end, i, lead);\n };\n\n for (let i = frontLines; i < count; i += 1) {\n scanLine(i);\n // Whether the line was blank to look at, whatever it was classified as:\n // indented code starts only after one.\n previousBlank = shapeOf(i).blank;\n }\n if (indented !== null) endIndented(indented, count);\n\n markCommentLines(lines, comments);\n return { lines, blocks, spans, comments, covered, continues };\n}\n\n/**\n * The column an item's text starts at: past its marker and the one to four\n * spaces after it. With none, or five or more, the text starts one column\n * past the marker, and anything further is indented code. At one space both\n * arms give one, so `spaces > 1` would read the same as `spaces >= 1`.\n */\nfunction itemColumn(indent: number, marker: ListMarker): number {\n const spaces = marker.width - marker.marker.length;\n return indent + marker.marker.length + (spaces >= 1 && spaces <= 4 ? spaces : 1);\n}\n\ntype Kinds = Pick<ScannedLine, 'frontMatter' | 'code' | 'html'>;\nconst NONE: Kinds = { frontMatter: false, code: false, html: false };\nconst CODE: Kinds = { frontMatter: false, code: true, html: false };\nconst HTML: Kinds = { frontMatter: false, code: false, html: true };\n\nfunction record(\n i: number,\n start: number,\n end: number,\n contentStart: number,\n content: string,\n quoteDepth: number,\n kinds: Kinds,\n): Mutable<ScannedLine> {\n return {\n line: i + 1,\n start,\n end,\n contentStart,\n content,\n indent: measureIndent(content),\n blank: leadIndex(content) === content.length,\n quoteDepth,\n ...kinds,\n comment: false,\n };\n}\n\n/** Marks each line whose first non-blank character lies inside a comment. */\nfunction markCommentLines(lines: readonly Mutable<ScannedLine>[], comments: readonly HtmlComment[]): void {\n let c = 0;\n for (const line of lines) {\n if (line.blank) continue;\n const lead = line.contentStart + leadIndex(line.content);\n // No comment ends exactly at a line's first non-blank character: a\n // comment ends in `>`, so one that ends before it ends on an earlier line.\n while (c < comments.length && (comments[c] as HtmlComment).end <= lead) c += 1;\n const comment = comments[c];\n line.comment = comment !== undefined && comment.start <= lead;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAA8B,MAAM,kBAAkB,CAAC;AACxI,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,eAAe,EACf,aAAa,EACb,eAAe,EACf,SAAS,EACT,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,eAAe,EACf,WAAW,GAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,6EAA6E;AAC7E,MAAM,UAAU,YAAY,C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QAC5C,UAAU;QACV,GAAG,KAAK;QACR,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC;AAED,6EAA6E;AAC7E,SAAS,gBAAgB,CAAC,KAAsC,EAAE,QAAgC;IAChG,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,KAAK;YAAE,SAAS;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,mEAAmE;QACnE,2EAA2E;QAC3E,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAK,QAAQ,CAAC,CAAC,CAAiB,CAAC,GAAG,IAAI,IAAI;YAAE,CAAC,IAAI,CAAC,CAAC;QAC/E,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["/**\n * A structural Markdown scanner.\n *\n * Deliberately not a CommonMark parser: nothing here renders. What it must get\n * exactly right is what is code, what is a comment, and what is neither,\n * because every reader downstream asks that question first. A heading inside\n * a fenced block is not a section, a template hint inside `<!-- -->` is not\n * content, and a link in a code sample is not a reference.\n *\n * The scan works on offsets. One pass over the lines finds front matter, code\n * blocks and raw-text HTML, and inside everything else it finds code spans and\n * comments in a single sweep from left to right, as CommonMark does: whichever\n * of the two opens first wins, so `` `<!--` `` is code that mentions a comment,\n * and a backtick inside a comment is a character. Three masks are built from\n * the result, and headings, list items, links and tables are read from them.\n *\n * Every pass is linear in the text. No search runs to the end of the document\n * once per opener: a code span looks for its closer only to the end of its\n * paragraph and remembers what it saw there, and a comment with no `-->`\n * after it tells every later one that there is none.\n *\n * Loops here that stop at a line's end compare against it, and the character\n * there is the line's terminator, which none of them acts on. A bound moved\n * to read one character further changes no answer; mutation testing reports\n * such mutants as surviving, and they are equivalent. So is a search for `-->`\n * compared as `close <= 0` rather than `close < 0`: it starts past `<!--`.\n */\n\nimport { createLineIndex, inRanges, maskRanges, mergeRanges, splitLines, stripBom, type LineIndex, type Range } from '../text/index.js';\nimport { frontMatterCloses, frontMatterKind } from './frontmatter.js';\nimport { findAtxHeadings, findHeadings } from './headings.js';\nimport type { Layout } from './layout.js';\nimport { findLinks } from './links.js';\nimport { findListItems } from './lists.js';\nimport {\n atxLevel,\n fenceCloses,\n fenceOpen,\n hasRawTextClose,\n isRawTextOpen,\n isThematicBreak,\n leadIndex,\n listMarker,\n measureIndent,\n opensComment,\n rawTextTag,\n setextUnderline,\n stripQuotes,\n type FenceOpen,\n type ListMarker,\n} from './syntax.js';\nimport { findTables } from './tables.js';\nimport type { Block, BlockKind, FrontMatterBlock, HtmlComment, MarkdownScan, MaskKind, Masks, ScannedLine, UnclosedFrontMatter } from './types.js';\n\nconst BACKTICK = 0x60;\nconst BACKSLASH = 0x5c;\n\n/** Scans a Markdown document. Pure, and linear in the length of the text. */\nexport function scanMarkdown(source: string): MarkdownScan {\n const text = stripBom(source);\n const index = createLineIndex(text);\n const { frontMatter, unclosedFrontMatter } = readFrontMatterBlock(text, index);\n const bodyStart = frontMatter === null ? 0 : frontMatter.bodyStart;\n const core = scanCore(text, index, frontMatter === null ? 0 : frontMatter.closeLine);\n\n // Without front matter this range is empty, and merging drops it.\n const front: Range[] = [{ start: 0, end: bodyStart }];\n const ranges: Record<MaskKind, Range[]> = {\n structure: mergeRanges([...front, ...core.blocks, ...core.spans, ...core.comments]),\n prose: mergeRanges([...front, ...core.comments]),\n directives: mergeRanges([...front, ...core.blocks, ...core.spans]),\n };\n // Headings are read from the structure and prose masks, and every caller\n // reads headings, so those two are made now. The rest is made the first\n // time it is read: most callers read one or two of links, list items and\n // the directives mask, and making all of them for every document was most\n // of what a spec-guard query spent (ADR-0004).\n const structure = maskRanges(text, ranges.structure);\n const prose = maskRanges(text, ranges.prose);\n const directives = once(() => maskRanges(text, ranges.directives));\n const masks: Masks = {\n structure,\n prose,\n get directives() {\n return directives();\n },\n };\n\n const layout: Layout = {\n text,\n index,\n lines: core.lines,\n blocks: core.blocks,\n comments: core.comments,\n structure,\n prose,\n covered: core.covered,\n continues: core.continues,\n };\n const atx = findAtxHeadings(layout);\n const tables = findTables(layout, atx);\n const headings = findHeadings(layout, atx, tables);\n const listItems = once(() => findListItems(layout, headings));\n const links = once(() => findLinks(layout, headings));\n\n return {\n text,\n bom: source.length - text.length,\n index,\n lines: core.lines,\n frontMatter,\n unclosedFrontMatter,\n bodyStart,\n blocks: core.blocks,\n codeSpans: core.spans,\n comments: core.comments,\n masks,\n headings,\n get listItems() {\n return listItems();\n },\n get links() {\n return links();\n },\n tables,\n isMasked: (offset, mask = 'structure') => inRanges(ranges[mask], offset),\n };\n}\n\n/**\n * The lines of the text or of one of its masks, without terminators, as\n * `splitLines` gives them: a final terminator leaves a last, empty line.\n * Every view has the same number of lines, each the same length.\n */\nexport function linesOf(scan: MarkdownScan, view: MaskKind | 'text' = 'text'): string[] {\n return splitLines(view === 'text' ? scan.text : scan.masks[view]);\n}\n\ninterface Front {\n readonly frontMatter: FrontMatterBlock | null;\n readonly unclosedFrontMatter: UnclosedFrontMatter | null;\n}\n\nconst NO_FRONT: Front = { frontMatter: null, unclosedFrontMatter: null };\n\n/**\n * YAML between `---` lines, closed by `---` or `...`, or TOML between `+++`\n * lines. The opening line is the document's first, exactly. An opening line\n * that is never closed opens nothing: it is a thematic break, and is reported\n * as unclosed front matter.\n */\nfunction readFrontMatterBlock(text: string, index: LineIndex): Front {\n const kind = frontMatterKind(index.lineText(1));\n if (kind === null) return NO_FRONT;\n for (let line = 2; line <= index.lineCount; line += 1) {\n if (!frontMatterCloses(index.lineText(line), kind)) continue;\n const start = index.lineStart(2);\n const end = index.lineStart(line);\n const bodyStart = line < index.lineCount ? index.lineStart(line + 1) : text.length;\n return { frontMatter: { kind, raw: text.slice(start, end), start, end, bodyStart, closeLine: line }, unclosedFrontMatter: null };\n }\n return { frontMatter: null, unclosedFrontMatter: { kind, line: 1, start: 0, end: index.lineEnd(1) } };\n}\n\n/** `make`, run the first time its value is asked for; the same value after. */\nfunction once<T>(make: () => T): () => T {\n let made: { readonly value: T } | null = null;\n return () => {\n made ??= { value: make() };\n return made.value;\n };\n}\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\ninterface Core {\n readonly lines: ScannedLine[];\n readonly blocks: Block[];\n readonly spans: Range[];\n readonly comments: HtmlComment[];\n readonly covered: ReadonlySet<number>;\n readonly continues: ReadonlySet<number>;\n}\n\n/** What each body line is on its own, before anything around it is known. */\ninterface Shape {\n readonly contentStart: number;\n readonly depth: number;\n readonly indent: number;\n readonly blank: boolean;\n /** An ATX heading, which is a paragraph of one line. */\n readonly atx: boolean;\n /** Opens a block that ends a paragraph above it. */\n readonly interrupts: boolean;\n}\n\n/**\n * The block pass, with the inline sweep for code spans and comments run\n * inside it line by line.\n *\n * The two cannot be separate passes. Whether a line opens a fence depends on\n * whether it lies inside a comment, and whether a comment opens depends on\n * whether its `<!--` lies inside a code span.\n */\nfunction scanCore(text: string, index: LineIndex, frontLines: number): Core {\n const count = index.lineCount;\n const lines: Mutable<ScannedLine>[] = [];\n const blocks: Mutable<Block>[] = [];\n const spans: Range[] = [];\n const comments: HtmlComment[] = [];\n const covered = new Set<number>();\n\n for (let i = 0; i < frontLines; i += 1) {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n lines.push(record(i, start, end, start, text.slice(start, end), 0, { frontMatter: true, code: false, html: false }));\n }\n\n // One shape too many, for a line past the last, would never be read.\n const shapes: Shape[] = [];\n for (let i = frontLines; i < count; i += 1) {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n const q = stripQuotes(text, start, Number.POSITIVE_INFINITY);\n const content = text.slice(q.contentStart, end);\n const indent = measureIndent(content);\n const blank = leadIndex(content) === content.length;\n const atx = atxLevel(content) > 0;\n const previous = shapes[shapes.length - 1];\n const interrupts =\n atx ||\n isThematicBreak(content) ||\n setextUnderline(content) !== null ||\n opensComment(content) ||\n listMarker(content) !== null ||\n fenceOpen(content) !== null ||\n isRawTextOpen(content) ||\n (previous !== undefined && q.depth > previous.depth);\n shapes.push({ contentStart: q.contentStart, depth: q.depth, indent, blank, atx, interrupts });\n }\n const shapeOf = (i: number): Shape => shapes[i - frontLines] as Shape;\n\n // A line continues the paragraph above it when it is not blank, opens\n // nothing of its own, and the line above is not a one-line heading. After a\n // blank line there is no paragraph to continue, and no search asks. Each\n // body line's paragraph ends at `stops`, walked from the bottom up.\n const continues = new Set<number>();\n const stops = new Map<number, number>();\n for (let i = count - 1; i >= frontLines; i -= 1) {\n const shape = shapeOf(i);\n const above = shapes[i - frontLines - 1];\n if (above !== undefined && !above.atx && !shape.blank && !shape.interrupts) continues.add(i + 1);\n stops.set(i, continues.has(i + 2) ? (stops.get(i + 1) as number) : index.lineEnd(i + 1));\n }\n\n /* ------------------------------------------------------------ inline sweep */\n\n // Where the last failed search for a closing backtick run stopped, and the\n // last run of each length it passed. Openers come in order, so a later one\n // before that stop lies inside the stretch searched, and closes only if a\n // run of its length lies after it there, which is a lookup.\n let seen: { readonly end: number; readonly last: ReadonlyMap<number, number> } | null = null;\n\n /** Where the span opened by a run ending at `from` closes, if it does. */\n const closeRun = (from: number, length: number, line: number): number | undefined => {\n // A run of a length the search never saw - one an escape split in two -\n // has no closer either. Reading its absence as any number below `from`\n // gives that answer, and one that is not below it gives it by searching.\n // No run starts at `from`, which follows one, and an opener at `seen.end`\n // finds nothing either way: the comparisons are equivalent at equality.\n if (seen !== null && from < seen.end && (seen.last.get(length) ?? -1) < from) return undefined;\n const stop = stops.get(line) as number;\n const last = new Map<number, number>();\n // A run ends at `from`, so `from` is past 0 and holds no backtick. A\n // search that stopped at `from` itself would record a run of length\n // zero, which no opener asks for, and `at > 0` tests what `at >= 0` does.\n let at = text.indexOf('`', from);\n while (at >= 0 && at < stop) {\n const run = at;\n while (at < stop && text.charCodeAt(at) === BACKTICK) at += 1;\n if (at - run === length) return at;\n last.set(at - run, run);\n at = text.indexOf('`', at);\n }\n seen = { end: stop, last };\n return undefined;\n };\n\n // Once one `<!--` has no `-->` after it, no later one has either.\n let closable = true;\n\n /** Where the comment opened at `at` closes, if it does. */\n const commentEnd = (at: number): number | undefined => {\n // CommonMark 0.31: `<!-->` and `<!--->` are whole, empty comments.\n if (text.startsWith('<!-->', at)) return at + 5;\n if (text.startsWith('<!--->', at)) return at + 6;\n if (!closable) return undefined;\n const close = text.indexOf('-->', at + 4);\n closable = close !== -1;\n return closable ? close + 3 : undefined;\n };\n\n const pushComment = (start: number, end: number, closed: boolean): void => {\n comments.push({\n start,\n end,\n // An empty comment's `-->` overlaps its `<!--`, and the slice is empty.\n inner: text.slice(start + 4, closed ? end - 3 : end),\n innerStart: start + 4,\n line: index.positionAt(start).line,\n closed,\n });\n };\n /**\n * Sweeps one line from `from`, returning where the next line's sweep may\n * begin: past a span or comment that runs onto a later line, or the line's\n * end. `lead` is the offset at which a `<!--` would open the line, or the\n * end of the line when none can: a sweep never stops there.\n */\n const sweep = (from: number, end: number, line: number, lead: number): number => {\n let at = from;\n while (at < end) {\n const ch = text.charCodeAt(at);\n if (ch === BACKSLASH) {\n // An escaped backtick opens no span, and an escaped `<` no comment.\n at += 2;\n } else if (ch === BACKTICK) {\n let run = at + 1;\n while (run < end && text.charCodeAt(run) === BACKTICK) run += 1;\n const close = closeRun(run, run - at, line);\n if (close === undefined) {\n at = run;\n } else {\n spans.push({ start: at, end: close });\n at = close;\n }\n } else if (text.startsWith('<!--', at)) {\n const close = commentEnd(at);\n if (close !== undefined) {\n pushComment(at, close, true);\n at = close;\n } else if (at === lead) {\n // CommonMark's HTML block: a comment opening a line runs to its\n // `-->`, and one never closed runs to the end of the document.\n pushComment(at, text.length, false);\n return text.length;\n } else {\n at += 4;\n }\n } else {\n at += 1;\n }\n }\n return at;\n };\n\n /* ------------------------------------------------------------- block pass */\n\n interface Open {\n readonly block: Mutable<Block>;\n readonly depth: number;\n }\n let fence: (Open & { readonly open: FenceOpen }) | null = null;\n let raw: Open | null = null;\n let indented: Mutable<Block> | null = null;\n let previousBlank = true;\n // The content column of each list item open around the line, innermost last.\n // Each loop that pops it tests its length first, which says what is meant;\n // without the test it stops all the same, `undefined > indent` being false.\n const items: number[] = [];\n let pos = 0;\n\n const openBlock = (kind: BlockKind, i: number, info: string, tag: string | null): Mutable<Block> => {\n const block = { kind, start: index.lineStart(i + 1), end: index.lineEnd(i + 1), line: i + 1, endLine: i + 1, info, tag, closed: kind === 'indented' };\n blocks.push(block);\n return block;\n };\n const extend = (block: Mutable<Block>, i: number): void => {\n block.end = index.lineEnd(i + 1);\n block.endLine = i + 1;\n };\n // Blank lines after an indented block were marked as code in case more\n // code followed; the block ends at its last code line.\n const endIndented = (block: Mutable<Block>, next: number): void => {\n for (let i = block.endLine; i < next; i += 1) (lines[i] as Mutable<ScannedLine>).code = false;\n };\n\n /** Classifies one line and sweeps it; the caller records whether it was blank. */\n const scanLine = (i: number): void => {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n const shape = shapeOf(i);\n const content = text.slice(shape.contentStart, end);\n const push = (kind: Kinds): void => {\n lines.push(record(i, start, end, shape.contentStart, content, shape.depth, kind));\n };\n\n if (pos > start) {\n // Inside a comment or span opened above: nothing opens a block here.\n covered.add(i + 1);\n push(NONE);\n pos = sweep(pos, end, i, end);\n return;\n }\n\n const container = fence ?? raw;\n if (container !== null) {\n // A fenced block or raw-text block ends with its block quote.\n const q = stripQuotes(text, start, container.depth);\n if (q.depth === container.depth) {\n const inside = text.slice(q.contentStart, end);\n lines.push(record(i, start, end, q.contentStart, inside, q.depth, fence === null ? HTML : CODE));\n extend(container.block, i);\n if (fence !== null ? fenceCloses(inside, fence.open) : hasRawTextClose(inside)) {\n container.block.closed = true;\n fence = null;\n raw = null;\n }\n return;\n }\n fence = null;\n raw = null;\n }\n\n // After a blank line, a line left of an item's content is outside it.\n if (!shape.blank && previousBlank) {\n while (items.length > 0 && (items[items.length - 1] as number) > shape.indent) items.pop();\n }\n // Indented code: four columns past the item the line is in, or past the\n // margin outside a list, and never interrupting a paragraph. Four columns\n // inside an item are its text, not code.\n const margin = items[items.length - 1] ?? 0;\n const deep = shape.indent >= margin + 4;\n if (!shape.blank && deep && (previousBlank || indented !== null)) {\n if (indented === null) indented = openBlock('indented', i, '', null);\n else extend(indented, i);\n push(CODE);\n return;\n }\n if (shape.blank) {\n push(indented === null ? NONE : CODE);\n return;\n }\n if (indented !== null) {\n endIndented(indented, i);\n indented = null;\n }\n\n // A fence as deep as indented code continues a paragraph instead.\n const open = deep ? null : fenceOpen(content);\n if (open !== null) {\n fence = { block: openBlock('fenced', i, open.info, null), depth: shape.depth, open };\n push(CODE);\n return;\n }\n const tag = rawTextTag(content);\n if (tag !== null) {\n const block = openBlock('html', i, '', tag);\n push(HTML);\n if (hasRawTextClose(content)) block.closed = true;\n else raw = { block, depth: shape.depth };\n return;\n }\n\n push(NONE);\n const marker = listMarker(content);\n if (marker !== null) {\n // A marker left of an item's content starts a sibling or an outer item.\n while (items.length > 0 && (items[items.length - 1] as number) > shape.indent) items.pop();\n items.push(itemColumn(shape.indent, marker));\n }\n // A heading ends a list whatever its indentation.\n if (shape.atx) items.length = 0;\n const lead = shape.indent <= 3 ? shape.contentStart + leadIndex(content) : end;\n pos = sweep(shape.contentStart, end, i, lead);\n };\n\n for (let i = frontLines; i < count; i += 1) {\n scanLine(i);\n // Whether the line was blank to look at, whatever it was classified as:\n // indented code starts only after one.\n previousBlank = shapeOf(i).blank;\n }\n if (indented !== null) endIndented(indented, count);\n\n markCommentLines(lines, comments);\n return { lines, blocks, spans, comments, covered, continues };\n}\n\n/**\n * The column an item's text starts at: past its marker and the one to four\n * spaces after it. With none, or five or more, the text starts one column\n * past the marker, and anything further is indented code. At one space both\n * arms give one, so `spaces > 1` would read the same as `spaces >= 1`.\n */\nfunction itemColumn(indent: number, marker: ListMarker): number {\n const spaces = marker.width - marker.marker.length;\n return indent + marker.marker.length + (spaces >= 1 && spaces <= 4 ? spaces : 1);\n}\n\ntype Kinds = Pick<ScannedLine, 'frontMatter' | 'code' | 'html'>;\nconst NONE: Kinds = { frontMatter: false, code: false, html: false };\nconst CODE: Kinds = { frontMatter: false, code: true, html: false };\nconst HTML: Kinds = { frontMatter: false, code: false, html: true };\n\nfunction record(\n i: number,\n start: number,\n end: number,\n contentStart: number,\n content: string,\n quoteDepth: number,\n kinds: Kinds,\n): Mutable<ScannedLine> {\n return {\n line: i + 1,\n start,\n end,\n contentStart,\n content,\n indent: measureIndent(content),\n blank: leadIndex(content) === content.length,\n quoteDepth,\n ...kinds,\n comment: false,\n };\n}\n\n/** Marks each line whose first non-blank character lies inside a comment. */\nfunction markCommentLines(lines: readonly Mutable<ScannedLine>[], comments: readonly HtmlComment[]): void {\n let c = 0;\n for (const line of lines) {\n if (line.blank) continue;\n const lead = line.contentStart + leadIndex(line.content);\n // No comment ends exactly at a line's first non-blank character: a\n // comment ends in `>`, so one that ends before it ends on an earlier line.\n while (c < comments.length && (comments[c] as HtmlComment).end <= lead) c += 1;\n const comment = comments[c];\n line.comment = comment !== undefined && comment.start <= lead;\n }\n}\n"]}
|
|
@@ -29,6 +29,9 @@ export function findTables(layout, atx) {
|
|
|
29
29
|
return layout.covered.has(line.line) || heading.has(line.line) ? null : line;
|
|
30
30
|
};
|
|
31
31
|
const out = [];
|
|
32
|
+
// A header needs a line under it. `row` answers null for a line past the
|
|
33
|
+
// last, so a bound that lets `i` reach one or two further finds the same
|
|
34
|
+
// tables.
|
|
32
35
|
for (let i = 0; i + 1 < lines.length; i += 1) {
|
|
33
36
|
const header = row(i);
|
|
34
37
|
const delimiter = row(i + 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/tables.ts"],"names":[],"mappings":"AAAA;;;;;;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IAC7F,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,IAAI,CAAC,IAAY,EAAE,KAAa,EAAE,GAAW;IACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;IACpD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;AAC1F,CAAC","sourcesContent":["/**\n * GFM pipe tables, with an offset for every cell.\n *\n * Cell offsets are the point: a register kept as a table needs findings that\n * name the cell declaring a relation, not the row and not the file. Rows are\n * split on the structure mask, so a pipe inside a code span or a comment\n * cannot invent a column, and the text of each cell comes from the original.\n *\n * Reading one line past the last, or one character past a line's end, finds\n * no row and no pipe, so mutants that move those bounds are equivalent.\n */\n\nimport { isMarkdown, leadOffset, type Layout } from './layout.js';\nimport type { Heading, ScannedLine, Table, TableCell, TableRow } from './types.js';\n\nconst PIPE = 124;\nconst BACKSLASH = 92;\nconst DELIMITER_CELL = /^:?-+:?$/;\n\n/**\n * A header line, a delimiter row with as many cells, and the rows under them\n * up to a line that is blank, holds no pipe, or is not Markdown.\n */\nexport function findTables(layout: Layout, atx: readonly Pick<Heading, 'line'>[]): Table[] {\n const { lines } = layout;\n const heading = new Set(atx.map((h) => h.line));\n // A line starting in a comment is not a row, and neither is one that\n // continues a code span or comment from the line above.\n const row = (i: number): ScannedLine | null => {\n const line = lines[i];\n if (line === undefined || !isMarkdown(line) || line.blank || line.comment) return null;\n return layout.covered.has(line.line) || heading.has(line.line) ? null : line;\n };\n\n const out: Table[] = [];\n for (let i = 0; i + 1 < lines.length; i += 1) {\n const header = row(i);\n const delimiter = row(i + 1);\n if (header === null || delimiter === null) continue;\n const headers = splitRow(layout, header);\n if (headers.length === 0) continue;\n const marks = splitRow(layout, delimiter);\n if (marks.length !== headers.length || !marks.every((cell) => DELIMITER_CELL.test(cell.text))) continue;\n\n const rows: TableRow[] = [];\n let last = delimiter;\n for (let line = row(i + 2); line !== null; line = row(line.line)) {\n const cells = splitRow(layout, line);\n if (cells.length === 0) break;\n rows.push({ cells, start: line.contentStart, end: line.end, line: line.line });\n last = line;\n }\n out.push({ start: header.contentStart, end: last.end, line: header.line, endLine: last.line, headers, rows });\n i = last.line - 1;\n }\n return out;\n}\n\n/** Splits a row into cells, keeping each cell's offsets. A row without a pipe has none. */\nfunction splitRow(layout: Layout, line: ScannedLine): TableCell[] {\n const { text, structure } = layout;\n const bounds: number[] = [];\n for (let at = line.contentStart; at < line.end; at += 1) {\n // A pipe escaped with a backslash is content, not a column edge.\n if (structure.charCodeAt(at) === PIPE && text.charCodeAt(at - 1) !== BACKSLASH) bounds.push(at);\n }\n if (bounds.length === 0) return [];\n\n const cells: TableCell[] = [];\n // A pipe opening the row is a border, not the edge of an empty first cell.\n let cursor = bounds[0] === leadOffset(line) ? (bounds.shift() as number) + 1 : line.contentStart;\n for (const bound of bounds) {\n cells.push(cell(text, cursor, bound));\n cursor = bound + 1;\n }\n // What follows the last pipe is a cell unless the row ended with a border.\n if (text.slice(cursor, line.end).trim().length > 0) cells.push(cell(text, cursor, line.end));\n return cells;\n}\n\nfunction cell(text: string, start: number, end: number): TableCell {\n const raw = text.slice(start, end);\n const leading = raw.length - raw.trimStart().length;\n const trimmed = raw.trim();\n return { text: trimmed, start: start + leading, end: start + leading + trimmed.length };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAGl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AAED,SAAS,IAAI,CAAC,IAAY,EAAE,KAAa,EAAE,GAAW;IACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC;IACpD,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;AAC1F,CAAC","sourcesContent":["/**\n * GFM pipe tables, with an offset for every cell.\n *\n * Cell offsets are the point: a register kept as a table needs findings that\n * name the cell declaring a relation, not the row and not the file. Rows are\n * split on the structure mask, so a pipe inside a code span or a comment\n * cannot invent a column, and the text of each cell comes from the original.\n *\n * Reading one line past the last, or one character past a line's end, finds\n * no row and no pipe, so mutants that move those bounds are equivalent.\n */\n\nimport { isMarkdown, leadOffset, type Layout } from './layout.js';\nimport type { Heading, ScannedLine, Table, TableCell, TableRow } from './types.js';\n\nconst PIPE = 124;\nconst BACKSLASH = 92;\nconst DELIMITER_CELL = /^:?-+:?$/;\n\n/**\n * A header line, a delimiter row with as many cells, and the rows under them\n * up to a line that is blank, holds no pipe, or is not Markdown.\n */\nexport function findTables(layout: Layout, atx: readonly Pick<Heading, 'line'>[]): Table[] {\n const { lines } = layout;\n const heading = new Set(atx.map((h) => h.line));\n // A line starting in a comment is not a row, and neither is one that\n // continues a code span or comment from the line above.\n const row = (i: number): ScannedLine | null => {\n const line = lines[i];\n if (line === undefined || !isMarkdown(line) || line.blank || line.comment) return null;\n return layout.covered.has(line.line) || heading.has(line.line) ? null : line;\n };\n\n const out: Table[] = [];\n // A header needs a line under it. `row` answers null for a line past the\n // last, so a bound that lets `i` reach one or two further finds the same\n // tables.\n for (let i = 0; i + 1 < lines.length; i += 1) {\n const header = row(i);\n const delimiter = row(i + 1);\n if (header === null || delimiter === null) continue;\n const headers = splitRow(layout, header);\n if (headers.length === 0) continue;\n const marks = splitRow(layout, delimiter);\n if (marks.length !== headers.length || !marks.every((cell) => DELIMITER_CELL.test(cell.text))) continue;\n\n const rows: TableRow[] = [];\n let last = delimiter;\n for (let line = row(i + 2); line !== null; line = row(line.line)) {\n const cells = splitRow(layout, line);\n if (cells.length === 0) break;\n rows.push({ cells, start: line.contentStart, end: line.end, line: line.line });\n last = line;\n }\n out.push({ start: header.contentStart, end: last.end, line: header.line, endLine: last.line, headers, rows });\n i = last.line - 1;\n }\n return out;\n}\n\n/** Splits a row into cells, keeping each cell's offsets. A row without a pipe has none. */\nfunction splitRow(layout: Layout, line: ScannedLine): TableCell[] {\n const { text, structure } = layout;\n const bounds: number[] = [];\n for (let at = line.contentStart; at < line.end; at += 1) {\n // A pipe escaped with a backslash is content, not a column edge.\n if (structure.charCodeAt(at) === PIPE && text.charCodeAt(at - 1) !== BACKSLASH) bounds.push(at);\n }\n if (bounds.length === 0) return [];\n\n const cells: TableCell[] = [];\n // A pipe opening the row is a border, not the edge of an empty first cell.\n let cursor = bounds[0] === leadOffset(line) ? (bounds.shift() as number) + 1 : line.contentStart;\n for (const bound of bounds) {\n cells.push(cell(text, cursor, bound));\n cursor = bound + 1;\n }\n // What follows the last pipe is a cell unless the row ended with a border.\n if (text.slice(cursor, line.end).trim().length > 0) cells.push(cell(text, cursor, line.end));\n return cells;\n}\n\nfunction cell(text: string, start: number, end: number): TableCell {\n const raw = text.slice(start, end);\n const leading = raw.length - raw.trimStart().length;\n const trimmed = raw.trim();\n return { text: trimmed, start: start + leading, end: start + leading + trimmed.length };\n}\n"]}
|
|
@@ -46,10 +46,22 @@ interface Hole {
|
|
|
46
46
|
* matched slowly.
|
|
47
47
|
*/
|
|
48
48
|
export declare const MAX_STATES = 65536;
|
|
49
|
+
/**
|
|
50
|
+
* Thrown by the builder past {@link MAX_STATES}. `parseGlob` answers it as a
|
|
51
|
+
* refusal and `compileGlob` as a `GlobError`, so no function the pattern
|
|
52
|
+
* module exports lets it out; it stays exported for callers written when
|
|
53
|
+
* `parseGlob` did.
|
|
54
|
+
*/
|
|
49
55
|
export declare class AutomatonTooLarge extends Error {
|
|
50
56
|
constructor();
|
|
51
57
|
}
|
|
52
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Thompson's construction, one fragment at a time.
|
|
60
|
+
*
|
|
61
|
+
* An arrow written as -1 is a hole that `patch` aims before `finish` returns,
|
|
62
|
+
* or one nothing follows: a CHAR's second and both of a MATCH's. What it
|
|
63
|
+
* starts as is never read, so any other start gives the same automaton.
|
|
64
|
+
*/
|
|
53
65
|
export declare class Builder {
|
|
54
66
|
private readonly kinds;
|
|
55
67
|
private readonly first;
|
|
@@ -78,7 +90,8 @@ export declare class Builder {
|
|
|
78
90
|
* A reusable matcher over one automaton.
|
|
79
91
|
*
|
|
80
92
|
* Holds its buffers between subjects; it is not reentrant, and nothing needs
|
|
81
|
-
* it to be - matching calls out to nothing.
|
|
93
|
+
* it to be - matching calls out to nothing. `test` empties each buffer before
|
|
94
|
+
* it reads one, so what a buffer starts with is never read.
|
|
82
95
|
*/
|
|
83
96
|
export declare class Matcher {
|
|
84
97
|
private readonly automaton;
|
|
@@ -29,13 +29,25 @@ const MATCH = 3;
|
|
|
29
29
|
* matched slowly.
|
|
30
30
|
*/
|
|
31
31
|
export const MAX_STATES = 65_536;
|
|
32
|
+
/**
|
|
33
|
+
* Thrown by the builder past {@link MAX_STATES}. `parseGlob` answers it as a
|
|
34
|
+
* refusal and `compileGlob` as a `GlobError`, so no function the pattern
|
|
35
|
+
* module exports lets it out; it stays exported for callers written when
|
|
36
|
+
* `parseGlob` did.
|
|
37
|
+
*/
|
|
32
38
|
export class AutomatonTooLarge extends Error {
|
|
33
39
|
constructor() {
|
|
34
40
|
super(`the pattern compiles to more than ${MAX_STATES} states`);
|
|
35
41
|
this.name = 'AutomatonTooLarge';
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Thompson's construction, one fragment at a time.
|
|
46
|
+
*
|
|
47
|
+
* An arrow written as -1 is a hole that `patch` aims before `finish` returns,
|
|
48
|
+
* or one nothing follows: a CHAR's second and both of a MATCH's. What it
|
|
49
|
+
* starts as is never read, so any other start gives the same automaton.
|
|
50
|
+
*/
|
|
39
51
|
export class Builder {
|
|
40
52
|
kinds = [];
|
|
41
53
|
first = [];
|
|
@@ -70,6 +82,10 @@ export class Builder {
|
|
|
70
82
|
}
|
|
71
83
|
/** Each fragment after the one before it. */
|
|
72
84
|
sequence(parts) {
|
|
85
|
+
// A glob never asks for an empty sequence, nor below for an empty
|
|
86
|
+
// alternation: a segment holds a token, a pattern an alternative. The two
|
|
87
|
+
// guards change no answer the module gives; they meet a misuse where it
|
|
88
|
+
// happens rather than in whatever reads the fragment next.
|
|
73
89
|
if (parts.length === 0)
|
|
74
90
|
return this.empty();
|
|
75
91
|
let current = parts[0];
|
|
@@ -151,7 +167,8 @@ function close(automaton, stack, visited, stamp, into) {
|
|
|
151
167
|
* A reusable matcher over one automaton.
|
|
152
168
|
*
|
|
153
169
|
* Holds its buffers between subjects; it is not reentrant, and nothing needs
|
|
154
|
-
* it to be - matching calls out to nothing.
|
|
170
|
+
* it to be - matching calls out to nothing. `test` empties each buffer before
|
|
171
|
+
* it reads one, so what a buffer starts with is never read.
|
|
155
172
|
*/
|
|
156
173
|
export class Matcher {
|
|
157
174
|
automaton;
|
|
@@ -187,6 +204,8 @@ export class Matcher {
|
|
|
187
204
|
this.stack.push(automaton.first[state]);
|
|
188
205
|
close(automaton, this.stack, this.visited, this.stamp, this.next);
|
|
189
206
|
}
|
|
207
|
+
// With no live state the rest of the subject changes nothing, and the
|
|
208
|
+
// answer is false either way; this only stops early.
|
|
190
209
|
if (this.next.length === 0)
|
|
191
210
|
return false;
|
|
192
211
|
const spent = this.live;
|
|
@@ -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zC,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YACpD,IAAI,QAAQ,KAAK,OAAO;gBAAE,SAAS;YACnC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAE,OAAO,CAAC,CAAC,CAAe,CAAC,IAAI,CAAC,KAAK,CAAY,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;gBACzG,SAAS;YACX,CAAC;YACD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAc,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YAC7F,KAAK,MAAM,QAAQ,IAAI,UAAU;gBAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,KAAK,CAAC,KAA4B,EAAE,KAAa;IACxD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,KAAK,EAAG,KAAK,CAAC,CAAC,CAAgB,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,GAAI,KAAK,CAAC,CAAC,CAAgB,CAAC,MAAM,EAAE,CAAC;QAC9F,MAAM,CAAC,IAAI,CAAE,KAAK,CAAC,CAAC,CAAgB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/**\n * Non-deterministic finite automata over code points: built by Thompson's\n * construction, run by keeping a set of live states, and searched for a\n * shortest string several of them accept and several others refuse.\n *\n * Why an automaton rather than a `RegExp`: a glob such as `*-*-*-*-*-*x`\n * handed to a backtracking engine tries every way of dividing a long name\n * between its stars, and one spec-* tool measured 28 seconds for one path. A\n * set of live states visits each state at most once per character, so a match\n * costs at most the pattern's size times the path's length, whatever the\n * pattern says.\n *\n * Why the same automaton for the witness: whether two scopes can name the same\n * file, and whether one lies wholly inside another, are questions about the\n * languages the patterns accept. Asked of the automata that do the matching,\n * the answers cannot drift from what matching does.\n */\n\nimport { accepts, acceptsIgnoringCase, boundaryPoints, DOT, SLASH, type CharSet } from './charset.js';\n\nconst CHAR = 0;\nconst SPLIT = 1;\nconst JUMP = 2;\nconst MATCH = 3;\n\n/** A compiled automaton. Immutable once built, and safe to share. */\nexport interface Automaton {\n readonly kinds: Uint8Array;\n /** A CHAR's next state, a SPLIT's first branch, a JUMP's target. */\n readonly first: Int32Array;\n /** A SPLIT's second branch. */\n readonly second: Int32Array;\n /** A CHAR's set; unused for the others. */\n readonly sets: readonly (CharSet | null)[];\n readonly start: number;\n readonly caseSensitive: boolean;\n}\n\n/** A piece of an automaton under construction: where it starts, and the arrows still unaimed. */\nexport interface Fragment {\n readonly start: number;\n readonly holes: readonly Hole[];\n}\n\ninterface Hole {\n readonly state: number;\n readonly slot: 1 | 2;\n}\n\n/**\n * Ceiling on the size of one automaton.\n *\n * Brace alternatives are compiled side by side, so a pattern's size is the\n * sum of its alternatives'. Far above anything a scope list says; it exists\n * so that a pathological pattern is refused while compiling rather than\n * matched slowly.\n */\nexport const MAX_STATES = 65_536;\n\nexport class AutomatonTooLarge extends Error {\n constructor() {\n super(`the pattern compiles to more than ${MAX_STATES} states`);\n this.name = 'AutomatonTooLarge';\n }\n}\n\n/** Thompson's construction, one fragment at a time. */\nexport class Builder {\n private readonly kinds: number[] = [];\n private readonly first: number[] = [];\n private readonly second: number[] = [];\n private readonly sets: (CharSet | null)[] = [];\n\n private add(kind: number, set: CharSet | null, first: number, second: number): number {\n if (this.kinds.length >= MAX_STATES) throw new AutomatonTooLarge();\n this.kinds.push(kind);\n this.first.push(first);\n this.second.push(second);\n this.sets.push(set);\n return this.kinds.length - 1;\n }\n\n private patch(holes: readonly Hole[], target: number): void {\n for (const hole of holes) {\n if (hole.slot === 1) this.first[hole.state] = target;\n else this.second[hole.state] = target;\n }\n }\n\n /** One character from a set. */\n char(set: CharSet): Fragment {\n const state = this.add(CHAR, set, -1, -1);\n return { start: state, holes: [{ state, slot: 1 }] };\n }\n\n /** The empty string. */\n empty(): Fragment {\n const state = this.add(JUMP, null, -1, -1);\n return { start: state, holes: [{ state, slot: 1 }] };\n }\n\n /** Each fragment after the one before it. */\n sequence(parts: readonly Fragment[]): Fragment {\n if (parts.length === 0) return this.empty();\n let current = parts[0] as Fragment;\n for (let i = 1; i < parts.length; i += 1) {\n const next = parts[i] as Fragment;\n this.patch(current.holes, next.start);\n current = { start: current.start, holes: next.holes };\n }\n return current;\n }\n\n /** Any one of the fragments. */\n either(options: readonly Fragment[]): Fragment {\n if (options.length === 0) throw new Error('an alternation needs at least one option');\n let current = options[options.length - 1] as Fragment;\n for (let i = options.length - 2; i >= 0; i -= 1) {\n const option = options[i] as Fragment;\n const split = this.add(SPLIT, null, option.start, current.start);\n current = { start: split, holes: [...option.holes, ...current.holes] };\n }\n return current;\n }\n\n /** Zero or more of a fragment. */\n star(body: Fragment): Fragment {\n const split = this.add(SPLIT, null, body.start, -1);\n this.patch(body.holes, split);\n return { start: split, holes: [{ state: split, slot: 2 }] };\n }\n\n /** One or more of a fragment. */\n plus(body: Fragment): Fragment {\n const split = this.add(SPLIT, null, body.start, -1);\n this.patch(body.holes, split);\n return { start: body.start, holes: [{ state: split, slot: 2 }] };\n }\n\n /** Zero or one of a fragment. */\n optional(body: Fragment): Fragment {\n const empty = this.empty();\n return this.either([body, empty]);\n }\n\n /** Closes the automaton: every unaimed arrow reaches acceptance. */\n finish(body: Fragment, caseSensitive: boolean): Automaton {\n const match = this.add(MATCH, null, -1, -1);\n this.patch(body.holes, match);\n return {\n kinds: Uint8Array.from(this.kinds),\n first: Int32Array.from(this.first),\n second: Int32Array.from(this.second),\n sets: [...this.sets],\n start: body.start,\n caseSensitive,\n };\n }\n}\n\n/**\n * Follows every empty arrow out of the states on a stack, appending each\n * CHAR or MATCH state reached to `into`. `visited[state] === stamp` marks a\n * state already taken this round, which is what bounds the work.\n */\nfunction close(\n automaton: Automaton,\n stack: number[],\n visited: Int32Array,\n stamp: number,\n into: number[],\n): void {\n const { kinds, first, second } = automaton;\n while (stack.length > 0) {\n const state = stack.pop() as number;\n if (visited[state] === stamp) continue;\n visited[state] = stamp;\n switch (kinds[state]) {\n case SPLIT:\n stack.push(second[state] as number, first[state] as number);\n break;\n case JUMP:\n stack.push(first[state] as number);\n break;\n default:\n into.push(state);\n }\n }\n}\n\n/**\n * A reusable matcher over one automaton.\n *\n * Holds its buffers between subjects; it is not reentrant, and nothing needs\n * it to be - matching calls out to nothing.\n */\nexport class Matcher {\n private readonly automaton: Automaton;\n private readonly visited: Int32Array;\n private stamp = 0;\n private readonly stack: number[] = [];\n private live: number[] = [];\n private next: number[] = [];\n\n constructor(automaton: Automaton) {\n this.automaton = automaton;\n this.visited = new Int32Array(automaton.kinds.length).fill(-1);\n }\n\n /** Whether the automaton accepts the whole of a subject. */\n test(subject: string): boolean {\n const { automaton } = this;\n const accept = automaton.caseSensitive ? accepts : acceptsIgnoringCase;\n this.live.length = 0;\n this.stack.length = 0;\n this.stack.push(automaton.start);\n this.stamp += 1;\n close(automaton, this.stack, this.visited, this.stamp, this.live);\n\n for (let i = 0; i < subject.length; i += 1) {\n const point = subject.codePointAt(i) as number;\n if (point > 0xffff) i += 1;\n this.next.length = 0;\n this.stamp += 1;\n for (const state of this.live) {\n if (automaton.kinds[state] !== CHAR) continue;\n if (!accept(automaton.sets[state] as CharSet, point)) continue;\n this.stack.push(automaton.first[state] as number);\n close(automaton, this.stack, this.visited, this.stamp, this.next);\n }\n if (this.next.length === 0) return false;\n const spent = this.live;\n this.live = this.next;\n this.next = spent;\n }\n return this.live.some((state) => automaton.kinds[state] === MATCH);\n }\n}\n\n/** The answer to a witness search. */\nexport type Witness =\n | { readonly kind: 'found'; readonly path: string }\n | { readonly kind: 'none' }\n /** The search met its budget before deciding. Rare, and never a guess either way. */\n | { readonly kind: 'undecided' };\n\n/**\n * How many distinct search states a witness search may visit. The search is\n * polynomial in the sizes of the automata it must satisfy and, for the ones\n * it must avoid, bounded by the subsets of their states it reaches; scope\n * patterns reach a handful. The bound turns a pathological input into an\n * `undecided` rather than a hang.\n */\nexport const WITNESS_BUDGET = 200_000;\n\n/**\n * Path validity as a four-state machine: at the start of a segment, inside a\n * segment reading `.` or `..` so far, or inside a segment that is a name. A\n * witness must end inside a name, and a `/` is only legal after one, so no\n * witness has an empty segment, a `.` or `..` segment, or a slash at either\n * end - which a pattern such as `a/*\\/b` would otherwise produce as `a//b`.\n * NUL is refused outright: no filesystem and no git tree holds a path with one.\n */\nconst SEGMENT_START = 0;\nconst ONE_DOT = 1;\nconst TWO_DOTS = 2;\nconst IN_NAME = 3;\nconst INVALID = -1;\nconst NUL = 0;\n\nfunction stepValidity(state: number, point: number): number {\n if (point === NUL) return INVALID;\n if (point === SLASH) return state === IN_NAME ? SEGMENT_START : INVALID;\n if (point === DOT) return state === SEGMENT_START ? ONE_DOT : state === ONE_DOT ? TWO_DOTS : IN_NAME;\n return IN_NAME;\n}\n\ninterface SearchNode {\n /** One live CHAR/MATCH state per automaton that must accept. */\n readonly positive: readonly number[];\n /** Every live state, sorted, per automaton that must refuse. */\n readonly negative: readonly (readonly number[])[];\n readonly validity: number;\n readonly parent: number;\n readonly point: number;\n}\n\nfunction closureOf(automaton: Automaton, seeds: readonly number[]): number[] {\n const visited = new Int32Array(automaton.kinds.length).fill(-1);\n const out: number[] = [];\n close(automaton, [...seeds], visited, 0, out);\n return out;\n}\n\nfunction stepSet(automaton: Automaton, states: readonly number[], point: number): number[] {\n const seeds: number[] = [];\n for (const state of states) {\n if (automaton.kinds[state] === CHAR && accepts(automaton.sets[state] as CharSet, point)) {\n seeds.push(automaton.first[state] as number);\n }\n }\n return closureOf(automaton, seeds).sort((a, b) => a - b);\n}\n\n/** Every way of choosing one element from each list. */\nfunction combinations(lists: readonly (readonly number[])[]): number[][] {\n let out: number[][] = [[]];\n for (const list of lists) {\n const grown: number[][] = [];\n for (const prefix of out) for (const state of list) grown.push([...prefix, state]);\n out = grown;\n }\n return out;\n}\n\nfunction isMatch(automaton: Automaton, state: number): boolean {\n return automaton.kinds[state] === MATCH;\n}\n\n/**\n * A shortest path every automaton in `include` accepts and none in `exclude`\n * does, spelled with readable characters where there is a choice.\n *\n * Breadth-first over the product of one live state per included automaton\n * (existential: some run of each must accept) and the whole live set per\n * excluded one (universal: no run of it may). Characters are tried at the\n * boundary points of every set in play, which meets every combination of\n * answers those sets can give, so the search is exact: `none` means no path\n * exists, not that none was found. The first path reached is a shortest one.\n *\n * Case-sensitive automata only. Every scope comparison in the family is\n * case-sensitive, and folding case exactly would need every set's closure\n * under case mapping.\n */\nexport function findWitness(\n include: readonly Automaton[],\n exclude: readonly Automaton[] = [],\n budget: number = WITNESS_BUDGET,\n): Witness {\n if (include.length === 0) throw new Error('a witness search needs at least one automaton to satisfy');\n for (const automaton of [...include, ...exclude]) {\n if (!automaton.caseSensitive) throw new Error('a witness search is defined for case-sensitive patterns only');\n }\n\n const startPositive = include.map((automaton) => closureOf(automaton, [automaton.start]));\n const startNegative = exclude.map((automaton) => closureOf(automaton, [automaton.start]).sort((a, b) => a - b));\n\n const nodes: SearchNode[] = [];\n const seen = new Set<string>();\n const key = (positive: readonly number[], negative: readonly (readonly number[])[], validity: number): string =>\n `${positive.join(',')}|${validity}|${negative.map((set) => set.join(',')).join('|')}`;\n\n const enqueue = (\n positive: readonly number[],\n negative: readonly (readonly number[])[],\n validity: number,\n parent: number,\n point: number,\n ): void => {\n const id = key(positive, negative, validity);\n if (seen.has(id)) return;\n seen.add(id);\n nodes.push({ positive, negative, validity, parent, point });\n };\n\n for (const positive of combinations(startPositive)) enqueue(positive, startNegative, SEGMENT_START, -1, 0);\n\n for (let cursor = 0; cursor < nodes.length; cursor += 1) {\n if (cursor >= budget) return { kind: 'undecided' };\n const node = nodes[cursor] as SearchNode;\n\n const accepted = node.positive.every((state, i) => isMatch(include[i] as Automaton, state));\n const refused = node.negative.every((set, i) => !set.some((state) => isMatch(exclude[i] as Automaton, state)));\n if (accepted && refused && node.validity === IN_NAME) return { kind: 'found', path: spell(nodes, cursor) };\n\n // A MATCH state reads nothing more: an included automaton sitting on one\n // can only accept here, so no longer path extends this node.\n if (node.positive.some((state, i) => (include[i] as Automaton).kinds[state] !== CHAR)) continue;\n\n const sets: CharSet[] = [];\n node.positive.forEach((state, i) => sets.push((include[i] as Automaton).sets[state] as CharSet));\n node.negative.forEach((set, i) => {\n const automaton = exclude[i] as Automaton;\n for (const state of set) if (automaton.kinds[state] === CHAR) sets.push(automaton.sets[state] as CharSet);\n });\n\n // Where each included automaton goes next does not depend on the\n // character, only whether it may go; what the excluded ones reach does.\n const successors = combinations(\n node.positive.map((state, i) => closureOf(include[i] as Automaton, [(include[i] as Automaton).first[state] as number])),\n );\n for (const point of boundaryPoints(sets)) {\n const validity = stepValidity(node.validity, point);\n if (validity === INVALID) continue;\n if (!node.positive.every((state, i) => accepts((include[i] as Automaton).sets[state] as CharSet, point))) {\n continue;\n }\n const negative = node.negative.map((set, i) => stepSet(exclude[i] as Automaton, set, point));\n for (const positive of successors) enqueue(positive, negative, validity, cursor, point);\n }\n }\n return { kind: 'none' };\n}\n\nfunction spell(nodes: readonly SearchNode[], index: number): string {\n const points: number[] = [];\n for (let i = index; (nodes[i] as SearchNode).parent >= 0; i = (nodes[i] as SearchNode).parent) {\n points.push((nodes[i] as SearchNode).point);\n }\n return String.fromCodePoint(...points.reverse());\n}\n"]}
|
|
1
|
+
{"version":3,"file":"automaton.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/automaton.ts"],"names":[],"mappings":"A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YACzC,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;YACpD,IAAI,QAAQ,KAAK,OAAO;gBAAE,SAAS;YACnC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAE,OAAO,CAAC,CAAC,CAAe,CAAC,IAAI,CAAC,KAAK,CAAY,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;gBACzG,SAAS;YACX,CAAC;YACD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAc,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YAC7F,KAAK,MAAM,QAAQ,IAAI,UAAU;gBAAE,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC1B,CAAC;AAED,SAAS,KAAK,CAAC,KAA4B,EAAE,KAAa;IACxD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,KAAK,EAAG,KAAK,CAAC,CAAC,CAAgB,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,GAAI,KAAK,CAAC,CAAC,CAAgB,CAAC,MAAM,EAAE,CAAC;QAC9F,MAAM,CAAC,IAAI,CAAE,KAAK,CAAC,CAAC,CAAgB,CAAC,KAAK,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,MAAM,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;AACnD,CAAC","sourcesContent":["/**\n * Non-deterministic finite automata over code points: built by Thompson's\n * construction, run by keeping a set of live states, and searched for a\n * shortest string several of them accept and several others refuse.\n *\n * Why an automaton rather than a `RegExp`: a glob such as `*-*-*-*-*-*x`\n * handed to a backtracking engine tries every way of dividing a long name\n * between its stars, and one spec-* tool measured 28 seconds for one path. A\n * set of live states visits each state at most once per character, so a match\n * costs at most the pattern's size times the path's length, whatever the\n * pattern says.\n *\n * Why the same automaton for the witness: whether two scopes can name the same\n * file, and whether one lies wholly inside another, are questions about the\n * languages the patterns accept. Asked of the automata that do the matching,\n * the answers cannot drift from what matching does.\n */\n\nimport { accepts, acceptsIgnoringCase, boundaryPoints, DOT, SLASH, type CharSet } from './charset.js';\n\nconst CHAR = 0;\nconst SPLIT = 1;\nconst JUMP = 2;\nconst MATCH = 3;\n\n/** A compiled automaton. Immutable once built, and safe to share. */\nexport interface Automaton {\n readonly kinds: Uint8Array;\n /** A CHAR's next state, a SPLIT's first branch, a JUMP's target. */\n readonly first: Int32Array;\n /** A SPLIT's second branch. */\n readonly second: Int32Array;\n /** A CHAR's set; unused for the others. */\n readonly sets: readonly (CharSet | null)[];\n readonly start: number;\n readonly caseSensitive: boolean;\n}\n\n/** A piece of an automaton under construction: where it starts, and the arrows still unaimed. */\nexport interface Fragment {\n readonly start: number;\n readonly holes: readonly Hole[];\n}\n\ninterface Hole {\n readonly state: number;\n readonly slot: 1 | 2;\n}\n\n/**\n * Ceiling on the size of one automaton.\n *\n * Brace alternatives are compiled side by side, so a pattern's size is the\n * sum of its alternatives'. Far above anything a scope list says; it exists\n * so that a pathological pattern is refused while compiling rather than\n * matched slowly.\n */\nexport const MAX_STATES = 65_536;\n\n/**\n * Thrown by the builder past {@link MAX_STATES}. `parseGlob` answers it as a\n * refusal and `compileGlob` as a `GlobError`, so no function the pattern\n * module exports lets it out; it stays exported for callers written when\n * `parseGlob` did.\n */\nexport class AutomatonTooLarge extends Error {\n constructor() {\n super(`the pattern compiles to more than ${MAX_STATES} states`);\n this.name = 'AutomatonTooLarge';\n }\n}\n\n/**\n * Thompson's construction, one fragment at a time.\n *\n * An arrow written as -1 is a hole that `patch` aims before `finish` returns,\n * or one nothing follows: a CHAR's second and both of a MATCH's. What it\n * starts as is never read, so any other start gives the same automaton.\n */\nexport class Builder {\n private readonly kinds: number[] = [];\n private readonly first: number[] = [];\n private readonly second: number[] = [];\n private readonly sets: (CharSet | null)[] = [];\n\n private add(kind: number, set: CharSet | null, first: number, second: number): number {\n if (this.kinds.length >= MAX_STATES) throw new AutomatonTooLarge();\n this.kinds.push(kind);\n this.first.push(first);\n this.second.push(second);\n this.sets.push(set);\n return this.kinds.length - 1;\n }\n\n private patch(holes: readonly Hole[], target: number): void {\n for (const hole of holes) {\n if (hole.slot === 1) this.first[hole.state] = target;\n else this.second[hole.state] = target;\n }\n }\n\n /** One character from a set. */\n char(set: CharSet): Fragment {\n const state = this.add(CHAR, set, -1, -1);\n return { start: state, holes: [{ state, slot: 1 }] };\n }\n\n /** The empty string. */\n empty(): Fragment {\n const state = this.add(JUMP, null, -1, -1);\n return { start: state, holes: [{ state, slot: 1 }] };\n }\n\n /** Each fragment after the one before it. */\n sequence(parts: readonly Fragment[]): Fragment {\n // A glob never asks for an empty sequence, nor below for an empty\n // alternation: a segment holds a token, a pattern an alternative. The two\n // guards change no answer the module gives; they meet a misuse where it\n // happens rather than in whatever reads the fragment next.\n if (parts.length === 0) return this.empty();\n let current = parts[0] as Fragment;\n for (let i = 1; i < parts.length; i += 1) {\n const next = parts[i] as Fragment;\n this.patch(current.holes, next.start);\n current = { start: current.start, holes: next.holes };\n }\n return current;\n }\n\n /** Any one of the fragments. */\n either(options: readonly Fragment[]): Fragment {\n if (options.length === 0) throw new Error('an alternation needs at least one option');\n let current = options[options.length - 1] as Fragment;\n for (let i = options.length - 2; i >= 0; i -= 1) {\n const option = options[i] as Fragment;\n const split = this.add(SPLIT, null, option.start, current.start);\n current = { start: split, holes: [...option.holes, ...current.holes] };\n }\n return current;\n }\n\n /** Zero or more of a fragment. */\n star(body: Fragment): Fragment {\n const split = this.add(SPLIT, null, body.start, -1);\n this.patch(body.holes, split);\n return { start: split, holes: [{ state: split, slot: 2 }] };\n }\n\n /** One or more of a fragment. */\n plus(body: Fragment): Fragment {\n const split = this.add(SPLIT, null, body.start, -1);\n this.patch(body.holes, split);\n return { start: body.start, holes: [{ state: split, slot: 2 }] };\n }\n\n /** Zero or one of a fragment. */\n optional(body: Fragment): Fragment {\n const empty = this.empty();\n return this.either([body, empty]);\n }\n\n /** Closes the automaton: every unaimed arrow reaches acceptance. */\n finish(body: Fragment, caseSensitive: boolean): Automaton {\n const match = this.add(MATCH, null, -1, -1);\n this.patch(body.holes, match);\n return {\n kinds: Uint8Array.from(this.kinds),\n first: Int32Array.from(this.first),\n second: Int32Array.from(this.second),\n sets: [...this.sets],\n start: body.start,\n caseSensitive,\n };\n }\n}\n\n/**\n * Follows every empty arrow out of the states on a stack, appending each\n * CHAR or MATCH state reached to `into`. `visited[state] === stamp` marks a\n * state already taken this round, which is what bounds the work.\n */\nfunction close(\n automaton: Automaton,\n stack: number[],\n visited: Int32Array,\n stamp: number,\n into: number[],\n): void {\n const { kinds, first, second } = automaton;\n while (stack.length > 0) {\n const state = stack.pop() as number;\n if (visited[state] === stamp) continue;\n visited[state] = stamp;\n switch (kinds[state]) {\n case SPLIT:\n stack.push(second[state] as number, first[state] as number);\n break;\n case JUMP:\n stack.push(first[state] as number);\n break;\n default:\n into.push(state);\n }\n }\n}\n\n/**\n * A reusable matcher over one automaton.\n *\n * Holds its buffers between subjects; it is not reentrant, and nothing needs\n * it to be - matching calls out to nothing. `test` empties each buffer before\n * it reads one, so what a buffer starts with is never read.\n */\nexport class Matcher {\n private readonly automaton: Automaton;\n private readonly visited: Int32Array;\n private stamp = 0;\n private readonly stack: number[] = [];\n private live: number[] = [];\n private next: number[] = [];\n\n constructor(automaton: Automaton) {\n this.automaton = automaton;\n this.visited = new Int32Array(automaton.kinds.length).fill(-1);\n }\n\n /** Whether the automaton accepts the whole of a subject. */\n test(subject: string): boolean {\n const { automaton } = this;\n const accept = automaton.caseSensitive ? accepts : acceptsIgnoringCase;\n this.live.length = 0;\n this.stack.length = 0;\n this.stack.push(automaton.start);\n this.stamp += 1;\n close(automaton, this.stack, this.visited, this.stamp, this.live);\n\n for (let i = 0; i < subject.length; i += 1) {\n const point = subject.codePointAt(i) as number;\n if (point > 0xffff) i += 1;\n this.next.length = 0;\n this.stamp += 1;\n for (const state of this.live) {\n if (automaton.kinds[state] !== CHAR) continue;\n if (!accept(automaton.sets[state] as CharSet, point)) continue;\n this.stack.push(automaton.first[state] as number);\n close(automaton, this.stack, this.visited, this.stamp, this.next);\n }\n // With no live state the rest of the subject changes nothing, and the\n // answer is false either way; this only stops early.\n if (this.next.length === 0) return false;\n const spent = this.live;\n this.live = this.next;\n this.next = spent;\n }\n return this.live.some((state) => automaton.kinds[state] === MATCH);\n }\n}\n\n/** The answer to a witness search. */\nexport type Witness =\n | { readonly kind: 'found'; readonly path: string }\n | { readonly kind: 'none' }\n /** The search met its budget before deciding. Rare, and never a guess either way. */\n | { readonly kind: 'undecided' };\n\n/**\n * How many distinct search states a witness search may visit. The search is\n * polynomial in the sizes of the automata it must satisfy and, for the ones\n * it must avoid, bounded by the subsets of their states it reaches; scope\n * patterns reach a handful. The bound turns a pathological input into an\n * `undecided` rather than a hang.\n */\nexport const WITNESS_BUDGET = 200_000;\n\n/**\n * Path validity as a four-state machine: at the start of a segment, inside a\n * segment reading `.` or `..` so far, or inside a segment that is a name. A\n * witness must end inside a name, and a `/` is only legal after one, so no\n * witness has an empty segment, a `.` or `..` segment, or a slash at either\n * end - which a pattern such as `a/*\\/b` would otherwise produce as `a//b`.\n * NUL is refused outright: no filesystem and no git tree holds a path with one.\n */\nconst SEGMENT_START = 0;\nconst ONE_DOT = 1;\nconst TWO_DOTS = 2;\nconst IN_NAME = 3;\nconst INVALID = -1;\nconst NUL = 0;\n\nfunction stepValidity(state: number, point: number): number {\n if (point === NUL) return INVALID;\n if (point === SLASH) return state === IN_NAME ? SEGMENT_START : INVALID;\n if (point === DOT) return state === SEGMENT_START ? ONE_DOT : state === ONE_DOT ? TWO_DOTS : IN_NAME;\n return IN_NAME;\n}\n\ninterface SearchNode {\n /** One live CHAR/MATCH state per automaton that must accept. */\n readonly positive: readonly number[];\n /** Every live state, sorted, per automaton that must refuse. */\n readonly negative: readonly (readonly number[])[];\n readonly validity: number;\n readonly parent: number;\n readonly point: number;\n}\n\nfunction closureOf(automaton: Automaton, seeds: readonly number[]): number[] {\n const visited = new Int32Array(automaton.kinds.length).fill(-1);\n const out: number[] = [];\n close(automaton, [...seeds], visited, 0, out);\n return out;\n}\n\nfunction stepSet(automaton: Automaton, states: readonly number[], point: number): number[] {\n const seeds: number[] = [];\n for (const state of states) {\n if (automaton.kinds[state] === CHAR && accepts(automaton.sets[state] as CharSet, point)) {\n seeds.push(automaton.first[state] as number);\n }\n }\n return closureOf(automaton, seeds).sort((a, b) => a - b);\n}\n\n/** Every way of choosing one element from each list. */\nfunction combinations(lists: readonly (readonly number[])[]): number[][] {\n let out: number[][] = [[]];\n for (const list of lists) {\n const grown: number[][] = [];\n for (const prefix of out) for (const state of list) grown.push([...prefix, state]);\n out = grown;\n }\n return out;\n}\n\nfunction isMatch(automaton: Automaton, state: number): boolean {\n return automaton.kinds[state] === MATCH;\n}\n\n/**\n * A shortest path every automaton in `include` accepts and none in `exclude`\n * does, spelled with readable characters where there is a choice.\n *\n * Breadth-first over the product of one live state per included automaton\n * (existential: some run of each must accept) and the whole live set per\n * excluded one (universal: no run of it may). Characters are tried at the\n * boundary points of every set in play, which meets every combination of\n * answers those sets can give, so the search is exact: `none` means no path\n * exists, not that none was found. The first path reached is a shortest one.\n *\n * Case-sensitive automata only. Every scope comparison in the family is\n * case-sensitive, and folding case exactly would need every set's closure\n * under case mapping.\n */\nexport function findWitness(\n include: readonly Automaton[],\n exclude: readonly Automaton[] = [],\n budget: number = WITNESS_BUDGET,\n): Witness {\n if (include.length === 0) throw new Error('a witness search needs at least one automaton to satisfy');\n for (const automaton of [...include, ...exclude]) {\n if (!automaton.caseSensitive) throw new Error('a witness search is defined for case-sensitive patterns only');\n }\n\n const startPositive = include.map((automaton) => closureOf(automaton, [automaton.start]));\n const startNegative = exclude.map((automaton) => closureOf(automaton, [automaton.start]).sort((a, b) => a - b));\n\n const nodes: SearchNode[] = [];\n const seen = new Set<string>();\n const key = (positive: readonly number[], negative: readonly (readonly number[])[], validity: number): string =>\n `${positive.join(',')}|${validity}|${negative.map((set) => set.join(',')).join('|')}`;\n\n const enqueue = (\n positive: readonly number[],\n negative: readonly (readonly number[])[],\n validity: number,\n parent: number,\n point: number,\n ): void => {\n const id = key(positive, negative, validity);\n if (seen.has(id)) return;\n seen.add(id);\n nodes.push({ positive, negative, validity, parent, point });\n };\n\n for (const positive of combinations(startPositive)) enqueue(positive, startNegative, SEGMENT_START, -1, 0);\n\n for (let cursor = 0; cursor < nodes.length; cursor += 1) {\n if (cursor >= budget) return { kind: 'undecided' };\n const node = nodes[cursor] as SearchNode;\n\n const accepted = node.positive.every((state, i) => isMatch(include[i] as Automaton, state));\n const refused = node.negative.every((set, i) => !set.some((state) => isMatch(exclude[i] as Automaton, state)));\n if (accepted && refused && node.validity === IN_NAME) return { kind: 'found', path: spell(nodes, cursor) };\n\n // A MATCH state reads nothing more: an included automaton sitting on one\n // can only accept here, so no longer path extends this node.\n if (node.positive.some((state, i) => (include[i] as Automaton).kinds[state] !== CHAR)) continue;\n\n const sets: CharSet[] = [];\n node.positive.forEach((state, i) => sets.push((include[i] as Automaton).sets[state] as CharSet));\n node.negative.forEach((set, i) => {\n const automaton = exclude[i] as Automaton;\n for (const state of set) if (automaton.kinds[state] === CHAR) sets.push(automaton.sets[state] as CharSet);\n });\n\n // Where each included automaton goes next does not depend on the\n // character, only whether it may go; what the excluded ones reach does.\n const successors = combinations(\n node.positive.map((state, i) => closureOf(include[i] as Automaton, [(include[i] as Automaton).first[state] as number])),\n );\n for (const point of boundaryPoints(sets)) {\n const validity = stepValidity(node.validity, point);\n if (validity === INVALID) continue;\n if (!node.positive.every((state, i) => accepts((include[i] as Automaton).sets[state] as CharSet, point))) {\n continue;\n }\n const negative = node.negative.map((set, i) => stepSet(exclude[i] as Automaton, set, point));\n for (const positive of successors) enqueue(positive, negative, validity, cursor, point);\n }\n }\n return { kind: 'none' };\n}\n\nfunction spell(nodes: readonly SearchNode[], index: number): string {\n const points: number[] = [];\n for (let i = index; (nodes[i] as SearchNode).parent >= 0; i = (nodes[i] as SearchNode).parent) {\n points.push((nodes[i] as SearchNode).point);\n }\n return String.fromCodePoint(...points.reverse());\n}\n"]}
|
|
@@ -21,7 +21,11 @@ export interface CharSet {
|
|
|
21
21
|
export declare const SLASH = 47;
|
|
22
22
|
export declare const DOT = 46;
|
|
23
23
|
export declare const MAX_CODE_POINT = 1114111;
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The separator, and nothing else. `separator` is what `accepts` asks; the
|
|
26
|
+
* range is read only for the points a witness search tries, and `/` and `0`,
|
|
27
|
+
* the point after it, are tried whatever the sets hold.
|
|
28
|
+
*/
|
|
25
29
|
export declare const SEPARATOR: CharSet;
|
|
26
30
|
/** Any character but the separator: `?`, and the body of `*`. */
|
|
27
31
|
export declare const ANY: CharSet;
|
|
@@ -13,11 +13,18 @@
|
|
|
13
13
|
export const SLASH = 0x2f;
|
|
14
14
|
export const DOT = 0x2e;
|
|
15
15
|
export const MAX_CODE_POINT = 0x10ffff;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* The separator, and nothing else. `separator` is what `accepts` asks; the
|
|
18
|
+
* range is read only for the points a witness search tries, and `/` and `0`,
|
|
19
|
+
* the point after it, are tried whatever the sets hold.
|
|
20
|
+
*/
|
|
17
21
|
export const SEPARATOR = { negated: false, ranges: [[SLASH, SLASH]], separator: true };
|
|
18
22
|
/** Any character but the separator: `?`, and the body of `*`. */
|
|
19
23
|
export const ANY = { negated: true, ranges: [], separator: false };
|
|
20
24
|
export function literalSet(point) {
|
|
25
|
+
// A glob's literals are read from inside one segment, so none is `/` and
|
|
26
|
+
// `separator` is false for every one compiled; it is computed so the set
|
|
27
|
+
// holds true for any point it is given.
|
|
21
28
|
return { negated: false, ranges: [[point, point]], separator: point === SLASH };
|
|
22
29
|
}
|
|
23
30
|
export function classSet(ranges, negated) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"charset.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/charset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC;AAC1B,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC;AACxB,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEvC
|
|
1
|
+
{"version":3,"file":"charset.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/pattern/charset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAYH,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC;AAC1B,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC;AACxB,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAY,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAEhG,iEAAiE;AACjE,MAAM,CAAC,MAAM,GAAG,GAAY,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAE5E,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,yEAAyE;IACzE,yEAAyE;IACzE,wCAAwC;IACxC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,KAAK,K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C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,IAAI,IAAI,GAAG,cAAc;gBAAE,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,SAAS;QAC9B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChB,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Sets of characters a glob position accepts, over Unicode code points.\n *\n * A glob matches a path one character at a time, and a character is a code\n * point: `?` matches `é` whether it is stored as one UTF-16 unit or not, and an\n * emoji as one. That is what a person counting characters in a file name\n * expects, and it is the same on every host.\n *\n * No set but the separator's accepts `/`. A path is matched a segment at a\n * time, and a `*` or a `[!a]` that swallowed a slash would let one segment of\n * a pattern match two of a path.\n */\n\n/** An inclusive range of code points. */\nexport type CodeRange = readonly [number, number];\n\nexport interface CharSet {\n readonly negated: boolean;\n readonly ranges: readonly CodeRange[];\n /** True only for the path separator itself. */\n readonly separator: boolean;\n}\n\nexport const SLASH = 0x2f;\nexport const DOT = 0x2e;\nexport const MAX_CODE_POINT = 0x10ffff;\n\n/**\n * The separator, and nothing else. `separator` is what `accepts` asks; the\n * range is read only for the points a witness search tries, and `/` and `0`,\n * the point after it, are tried whatever the sets hold.\n */\nexport const SEPARATOR: CharSet = { negated: false, ranges: [[SLASH, SLASH]], separator: true };\n\n/** Any character but the separator: `?`, and the body of `*`. */\nexport const ANY: CharSet = { negated: true, ranges: [], separator: false };\n\nexport function literalSet(point: number): CharSet {\n // A glob's literals are read from inside one segment, so none is `/` and\n // `separator` is false for every one compiled; it is computed so the set\n // holds true for any point it is given.\n return { negated: false, ranges: [[point, point]], separator: point === SLASH };\n}\n\nexport function classSet(ranges: readonly CodeRange[], negated: boolean): CharSet {\n return { negated, ranges, separator: false };\n}\n\nfunction within(ranges: readonly CodeRange[], point: number): boolean {\n for (let i = 0; i < ranges.length; i += 1) {\n const range = ranges[i] as CodeRange;\n if (point >= range[0] && point <= range[1]) return true;\n }\n return false;\n}\n\n/** Whether a set accepts a code point as written. */\nexport function accepts(set: CharSet, point: number): boolean {\n if (point === SLASH) return set.separator;\n return within(set.ranges, point) !== set.negated;\n}\n\n/**\n * The code points a code point is the same letter as, ignoring case: itself,\n * and its lower- and upper-case forms where each is a single code point.\n *\n * Simple case mapping, which is what `toLowerCase` and `toUpperCase` give one\n * character at a time. It is locale-free, so two hosts agree; `ß` has no single\n * upper-case code point and so matches only itself.\n */\nexport function caseVariants(point: number): readonly number[] {\n if (point < 0x80) {\n if (point >= 0x41 && point <= 0x5a) return [point, point + 32];\n if (point >= 0x61 && point <= 0x7a) return [point, point - 32];\n return [point];\n }\n const char = String.fromCodePoint(point);\n const out = [point];\n for (const variant of [char.toLowerCase(), char.toUpperCase()]) {\n const code = variant.codePointAt(0) as number;\n if (variant.length === String.fromCodePoint(code).length && !out.includes(code)) out.push(code);\n }\n return out;\n}\n\n/**\n * Whether a set accepts a code point with case ignored: whether it accepts\n * the point or one of its case variants. A negated set is negated over the\n * same question, so `[!a]` refuses `A` as well as `a`.\n */\nexport function acceptsIgnoringCase(set: CharSet, point: number): boolean {\n if (point === SLASH) return set.separator;\n const variants = caseVariants(point);\n let inside = false;\n for (let i = 0; i < variants.length && !inside; i += 1) inside = within(set.ranges, variants[i] as number);\n return inside !== set.negated;\n}\n\n/**\n * Characters a witness is spelled with when any of them will do, in order of\n * preference. A witness is read by a person deciding whether two scopes really\n * overlap, and `src/x.ts` reads better than `src/\\u0000.ts`.\n */\nconst READABLE = [0x78, 0x61, 0x62, 0x30, 0x5f, 0x2d, 0x7e, 0x21, DOT, SLASH] as const;\n\n/**\n * Every code point at which the answer \"which of these sets accept it\" can\n * change, readable ones first.\n *\n * Each set accepts a union of intervals, so the sets' memberships are constant\n * between consecutive interval ends. The start of each interval and the point\n * after its end therefore meet every distinct combination of answers, and\n * trying them all decides every question a witness search can ask of one\n * character. The separator and the dot are always included: path validity\n * turns on them.\n */\nexport function boundaryPoints(sets: readonly CharSet[]): number[] {\n // 1, not 0: no path holds a NUL, so the least character worth trying is the next.\n const points: number[] = [...READABLE, 1];\n for (const set of sets) {\n for (const [low, high] of set.ranges) {\n points.push(low);\n if (high < MAX_CODE_POINT) points.push(high + 1);\n }\n }\n const seen = new Set<number>();\n const out: number[] = [];\n for (const point of points) {\n if (seen.has(point)) continue;\n seen.add(point);\n out.push(point);\n }\n return out;\n}\n"]}
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
* tools read it three ways, and the quiet reading narrowed their scope. The
|
|
27
27
|
* refusal writes the two patterns it may have meant from the one written.
|
|
28
28
|
* - `*`, `?` and classes never match `/`, and `*` matches a leading dot.
|
|
29
|
+
* - Braces expand first, and each alternative reads as it would written on
|
|
30
|
+
* its own: `{src/,lib}` is `src/` or `lib`, and a trailing `/` means the
|
|
31
|
+
* directory's contents - in an exclusion, the directory and its contents.
|
|
29
32
|
* - Case is the caller's decision, stated every time. A result must not
|
|
30
33
|
* depend on the host it ran on.
|
|
31
34
|
* - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,
|
|
@@ -46,7 +49,8 @@ export interface GlobOptions {
|
|
|
46
49
|
* `path` dialect only: how a pattern with no glob syntax is read - as a
|
|
47
50
|
* file, as a directory and everything beneath it, or as either. A function
|
|
48
51
|
* is asked per literal path, for a caller that knows the tree. `either` when
|
|
49
|
-
* unset. A trailing
|
|
52
|
+
* unset. A trailing `/`, on the pattern or on one of its brace alternatives,
|
|
53
|
+
* always means a directory's contents, and is never asked about.
|
|
50
54
|
*/
|
|
51
55
|
readonly literal?: LiteralReading | ((path: string) => LiteralReading) | undefined;
|
|
52
56
|
/**
|
|
@@ -85,9 +89,16 @@ export declare class GlobError extends Error {
|
|
|
85
89
|
export declare const MAX_ALTERNATIVES = 256;
|
|
86
90
|
/** Whether a string uses glob syntax at all. */
|
|
87
91
|
export declare function isGlobSyntax(source: string): boolean;
|
|
88
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Parses and compiles a glob, or says why it cannot: malformed, or too large
|
|
94
|
+
* to compile, past {@link MAX_ALTERNATIVES} alternatives or `MAX_STATES`
|
|
95
|
+
* states. It throws only what a `literal` function throws.
|
|
96
|
+
*/
|
|
89
97
|
export declare function parseGlob(source: string, options: GlobOptions): GlobParse;
|
|
90
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Parses and compiles a glob, throwing {@link GlobError} for every reason
|
|
100
|
+
* {@link parseGlob} gives, and what a `literal` function throws.
|
|
101
|
+
*/
|
|
91
102
|
export declare function compileGlob(source: string, options: GlobOptions): Glob;
|
|
92
103
|
/**
|
|
93
104
|
* A shortest path every glob in `include` matches and no glob in `exclude`
|