@descent-vtt/spec-harness 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +85 -0
  4. package/README.md +273 -24
  5. package/dist/audit.d.ts +71 -1
  6. package/dist/audit.js +140 -17
  7. package/dist/audit.js.map +1 -1
  8. package/dist/branch.d.ts +13 -0
  9. package/dist/branch.js +19 -0
  10. package/dist/branch.js.map +1 -1
  11. package/dist/cli.d.ts +1 -1
  12. package/dist/cli.js +51 -13
  13. package/dist/cli.js.map +1 -1
  14. package/dist/commands.js +11 -4
  15. package/dist/commands.js.map +1 -1
  16. package/dist/config.js +3 -1
  17. package/dist/config.js.map +1 -1
  18. package/dist/configure.d.ts +50 -3
  19. package/dist/configure.js +78 -5
  20. package/dist/configure.js.map +1 -1
  21. package/dist/context.d.ts +10 -5
  22. package/dist/context.js +54 -19
  23. package/dist/context.js.map +1 -1
  24. package/dist/document.d.ts +2 -1
  25. package/dist/document.js.map +1 -1
  26. package/dist/formats.d.ts +31 -0
  27. package/dist/formats.js +127 -0
  28. package/dist/formats.js.map +1 -0
  29. package/dist/git.d.ts +6 -0
  30. package/dist/git.js +8 -0
  31. package/dist/git.js.map +1 -1
  32. package/dist/guard.d.ts +8 -0
  33. package/dist/guard.js +19 -1
  34. package/dist/guard.js.map +1 -1
  35. package/dist/host.d.ts +14 -0
  36. package/dist/host.js +50 -0
  37. package/dist/host.js.map +1 -0
  38. package/dist/index.d.ts +4 -2
  39. package/dist/index.js +2 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/manifests.d.ts +8 -1
  42. package/dist/manifests.js +16 -6
  43. package/dist/manifests.js.map +1 -1
  44. package/dist/premises.d.ts +3 -0
  45. package/dist/premises.js +43 -13
  46. package/dist/premises.js.map +1 -1
  47. package/dist/reader.js +10 -2
  48. package/dist/reader.js.map +1 -1
  49. package/dist/round.d.ts +8 -0
  50. package/dist/round.js +73 -22
  51. package/dist/round.js.map +1 -1
  52. package/dist/server.js +9 -3
  53. package/dist/server.js.map +1 -1
  54. package/dist/setup.d.ts +10 -0
  55. package/dist/setup.js +68 -32
  56. package/dist/setup.js.map +1 -1
  57. package/dist/signers.d.ts +43 -0
  58. package/dist/signers.js +105 -0
  59. package/dist/signers.js.map +1 -0
  60. package/dist/types.d.ts +7 -0
  61. package/dist/types.js.map +1 -1
  62. package/dist/vendor/spec-core/markdown/frontmatter.d.ts +11 -1
  63. package/dist/vendor/spec-core/markdown/frontmatter.js +20 -3
  64. package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -1
  65. package/dist/vendor/spec-core/pattern/glob.d.ts +85 -0
  66. package/dist/vendor/spec-core/pattern/glob.js +207 -17
  67. package/dist/vendor/spec-core/pattern/glob.js.map +1 -1
  68. package/dist/vendor/spec-core/pattern/index.d.ts +2 -2
  69. package/dist/vendor/spec-core/pattern/index.js +1 -1
  70. package/dist/vendor/spec-core/pattern/index.js.map +1 -1
  71. package/dist/vendor/spec-core/text/index.d.ts +1 -0
  72. package/dist/vendor/spec-core/text/index.js +1 -0
  73. package/dist/vendor/spec-core/text/index.js.map +1 -1
  74. package/dist/vendor/spec-core/text/width.d.ts +30 -0
  75. package/dist/vendor/spec-core/text/width.js +113 -0
  76. package/dist/vendor/spec-core/text/width.js.map +1 -0
  77. package/dist/versions.d.ts +27 -1
  78. package/dist/versions.js +23 -1
  79. package/dist/versions.js.map +1 -1
  80. package/dist/workspace.d.ts +6 -1
  81. package/dist/workspace.js +17 -6
  82. package/dist/workspace.js.map +1 -1
  83. package/package.json +1 -1
  84. package/skills/close-round/SKILL.md +4 -1
@@ -1 +1 @@
1
- {"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO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,QAAQ,EAAE;QAC7B,CAAC,CAAC,GAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAY,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAW,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;IAClJ,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,WAAW,CAAC,KAAwB,EAAE,WAA+B,EAAE,GAAW;IAChG,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAC1C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["/**\n * A reader and editor for the front matter the spec-* tools use: a flat bag\n * of YAML scalars and lists, and optionally one level of nested mapping.\n *\n * Supported: `key: value` lines; plain, single-quoted and double-quoted\n * scalars; inline `[a, b]` sequences; block `- item` sequences; `#` comments.\n * Plain scalars follow the YAML 1.2 core schema, so `yes` is a word and `035`\n * keeps its leading zero for whoever reads it as text. With `nested`, a key\n * whose value is an indented block of keys is read as `parent.child` entries.\n *\n * Anything richer - deeper nesting, block scalars, anchors, tags, a value\n * continued onto the next line - is recognised and reported as unsupported\n * rather than guessed at. A YAML library would parse more, but it would not\n * give back the line and the offset of every value, and a report has to point\n * at the value it is about, and an edit has to leave every other line of the\n * file as it was.\n */\n\nimport { lineStarts, splitLines, stripBom } from '../text/index.js';\nimport { leadIndex } from './syntax.js';\nimport type { FrontMatterKind } from './types.js';\n\nexport interface YamlScalar {\n readonly text: string;\n readonly quoted: boolean;\n}\n\nexport type YamlValue =\n | { readonly kind: 'scalar'; readonly scalar: YamlScalar }\n | { readonly kind: 'list'; readonly items: readonly YamlScalar[] }\n | { readonly kind: 'unsupported'; readonly reason: string };\n\nexport interface FrontMatterEntry {\n /** The key as written; a nested key is its parent's and its own, joined by a dot. */\n readonly key: string;\n /** The key compared: {@link keyName} of `key`, so `depends-on` is `dependsOn`. */\n readonly name: string;\n /** The parent key as written, for a nested key; `null` at the top level. */\n readonly parent: string | null;\n /** 0-based line of the key. */\n readonly line: number;\n /** 0-based line after the entry's last line. */\n readonly end: number;\n /** Offset of the key in the text read. */\n readonly keyStart: number;\n /**\n * Offsets of the value as written: a quoted scalar with its quotes, an\n * inline list with its brackets, a block list from its first item's text to\n * its last item's. An empty value is the empty range just past the colon.\n */\n readonly valueStart: number;\n readonly valueEnd: number;\n readonly value: YamlValue;\n}\n\nexport interface FrontMatterProblem {\n /** 0-based line. */\n readonly line: number;\n readonly message: string;\n}\n\nexport interface FrontMatter {\n readonly kind: FrontMatterKind;\n /** 0-based line of the closing delimiter, or -1 when the block is never closed. */\n readonly close: number;\n readonly entries: readonly FrontMatterEntry[];\n readonly problems: readonly FrontMatterProblem[];\n}\n\nexport interface ReadOptions {\n /**\n * Read one level of nested mapping as `parent.child` entries, instead of\n * reporting the parent's value as unsupported.\n */\n readonly nested?: boolean;\n}\n\nconst YAML_OPEN = /^---[ \\t]*$/;\nconst YAML_CLOSE = /^(?:---|\\.\\.\\.)[ \\t]*$/;\nconst TOML_FENCE = /^\\+\\+\\+[ \\t]*$/;\n\n/** The kind of front matter a document's first line opens, or `null` when it opens none. */\nexport function frontMatterKind(firstLine: string): FrontMatterKind | null {\n if (YAML_OPEN.test(firstLine)) return 'yaml';\n return TOML_FENCE.test(firstLine) ? 'toml' : null;\n}\n\n/** Whether a line closes front matter of a kind: `---` or `...` for YAML, `+++` for TOML. */\nexport function frontMatterCloses(line: string, kind: FrontMatterKind): boolean {\n return (kind === 'yaml' ? YAML_CLOSE : TOML_FENCE).test(line);\n}\n\nconst KEY = /^([A-Za-z_][\\w.-]*)[ \\t]*:(?:[ \\t]+(.*))?$/;\nconst SEQUENCE_ITEM = /^([ \\t]*)-(?:[ \\t]+(.*))?$/;\nconst BLANK_OR_COMMENT = /^[ \\t]*(?:#.*)?$/;\n\nexport function keyName(key: string): string {\n return key.toLowerCase().replace(/[-_]/g, '');\n}\n\n/**\n * Reads the front matter at the top of a text, or `null` when there is none.\n *\n * A leading byte-order mark is not part of the text read: offsets count from\n * the character after it, as a scan's do.\n */\nexport function readFrontMatter(source: string, options: ReadOptions = {}): FrontMatter | null {\n const text = stripBom(source);\n const lines = splitLines(text);\n const kind = frontMatterKind(lines[0] as string);\n if (kind === null) return null;\n const close = lines.findIndex((line, i) => i > 0 && frontMatterCloses(line, kind));\n if (close === -1) {\n return { kind, close, entries: [], problems: [{ line: 0, message: 'the front matter opened on line 1 is never closed' }] };\n }\n if (kind === 'toml') {\n return { kind, close, entries: [], problems: [{ line: 0, message: 'TOML front matter is not read; write YAML between \"---\" lines' }] };\n }\n\n const reader: Reader = {\n lines,\n starts: lineStarts(text),\n nested: options.nested === true,\n entries: [],\n problems: [],\n seen: new Map(),\n };\n let i = 1;\n while (i < close) {\n const line = lines[i] as string;\n if (BLANK_OR_COMMENT.test(line)) {\n i += 1;\n continue;\n }\n const match = KEY.exec(line);\n if (match === null) {\n reader.problems.push({\n line: i,\n message: /^\\s/.test(line) ? 'an indented line belongs to no key' : 'not a \"key: value\" line',\n });\n i += 1;\n continue;\n }\n // The closing delimiter belongs to no value, so the block stops there.\n let end = i + 1;\n while (belongsToBlock(lines[end] as string)) end += 1;\n end = trimBlock(lines, end);\n readEntry(reader, { key: match[1] as string, parent: null, line: i, column: 0, inline: match[2] ?? '', end });\n i = end;\n }\n return { kind, close, entries: reader.entries, problems: reader.problems };\n}\n\ninterface Reader {\n readonly lines: readonly string[];\n readonly starts: readonly number[];\n readonly nested: boolean;\n readonly entries: FrontMatterEntry[];\n readonly problems: FrontMatterProblem[];\n readonly seen: Map<string, number>;\n}\n\ninterface KeyLine {\n /** The key as written on its line, without a parent. */\n readonly key: string;\n readonly parent: string | null;\n readonly line: number;\n /** Column of the key. */\n readonly column: number;\n /** What follows the colon and its whitespace, as written. */\n readonly inline: string;\n /** 0-based line after the key's value. */\n readonly end: number;\n}\n\n/** A line under a top-level key is part of its value when it is indented or starts a sequence item. */\nfunction belongsToBlock(line: string): boolean {\n return /^[ \\t]/.test(line) || /^-(?:[ \\t]|$)/.test(line) || line.trim() === '';\n}\n\n/**\n * Takes trailing blank and comment lines off a value's block: they belong to\n * no key. The key's own line is neither, so the walk stops there at the latest.\n */\nfunction trimBlock(lines: readonly string[], end: number): number {\n let at = end;\n while (BLANK_OR_COMMENT.test(lines[at - 1] as string)) at -= 1;\n return at;\n}\n\nfunction note(reader: Reader, key: string, line: number): string {\n const name = keyName(key);\n const previous = reader.seen.get(name);\n if (previous === undefined) reader.seen.set(name, line);\n else reader.problems.push({ line, message: `\"${key}\" is declared twice (first on line ${previous + 1})` });\n return name;\n}\n\nfunction readEntry(reader: Reader, at: KeyLine): void {\n const { lines, starts } = reader;\n const text = lines[at.line] as string;\n const lineStart = starts[at.line] as number;\n const key = at.parent === null ? at.key : `${at.parent}.${at.key}`;\n // A key holds no colon and nothing before it does, so the first is its own.\n const colon = lineStart + text.indexOf(':') + 1;\n // What follows the colon starts after its whitespace; what ends it is\n // trimmed by whichever reader takes it.\n const inline = stripLeadingComment(at.inline);\n\n let read: Read;\n if (inline.length > 0) {\n const valueStart = lineStart + text.length - at.inline.length;\n const continued = contentLines(lines, at.line + 1, at.end).length > 0;\n const parsed = continued\n ? rough(unsupported('the value continues on the next line; keep it on one line, or quote it'), inline)\n : readInline(inline);\n read = { value: parsed.value, valueStart, valueEnd: valueStart + parsed.length };\n } else {\n const content = contentLines(lines, at.line + 1, at.end);\n const first = content[0];\n if (first !== undefined && at.parent === null && reader.nested && KEY.test((lines[first] as string).trim())) {\n note(reader, at.key, at.line);\n readChildren(reader, at.key, at.line + 1, at.end);\n return;\n }\n read = readBlock(reader, content, colon, at.parent === null);\n }\n\n reader.entries.push({\n key,\n name: note(reader, key, at.line),\n parent: at.parent,\n line: at.line,\n end: at.end,\n keyStart: lineStart + at.column,\n ...read,\n });\n}\n\n/** One level of keys under a parent, all at the indentation of the first. */\nfunction readChildren(reader: Reader, parent: string, from: number, end: number): void {\n const { lines } = reader;\n const first = lines[contentLines(lines, from, end)[0] as number] as string;\n const lead = first.slice(0, leadIndex(first));\n let i = from;\n while (i < end) {\n const line = lines[i] as string;\n if (BLANK_OR_COMMENT.test(line)) {\n i += 1;\n continue;\n }\n // A line deeper than the keys is always taken by the key above it, so only\n // one at their indentation or shallower reaches here.\n const match = line.startsWith(lead) ? KEY.exec(line.slice(lead.length)) : null;\n if (match === null) {\n reader.problems.push({ line: i, message: 'not a \"key: value\" line at the indentation of the keys before it' });\n i += 1;\n continue;\n }\n // Past the parent's value, a line belongs to a child only when it is blank\n // or a comment, and those are trimmed off again.\n let childEnd = i + 1;\n while (belongsToChild(lines[childEnd] as string, lead)) childEnd += 1;\n childEnd = trimBlock(lines, childEnd);\n readEntry(reader, { key: match[1] as string, parent, line: i, column: lead.length, inline: match[2] ?? '', end: childEnd });\n i = childEnd;\n }\n}\n\n/** A line under a nested key is part of its value when it is deeper, or a sequence item at the key's indentation. */\nfunction belongsToChild(line: string, lead: string): boolean {\n if (line.trim() === '') return true;\n if (!line.startsWith(lead)) return false;\n return /^(?:[ \\t]|-(?:[ \\t]|$))/.test(line.slice(lead.length));\n}\n\ninterface Read {\n readonly value: YamlValue;\n readonly valueStart: number;\n readonly valueEnd: number;\n}\n\n/** Indices of the lines in a range that are neither blank nor a comment. */\nfunction contentLines(lines: readonly string[], from: number, end: number): number[] {\n const out: number[] = [];\n for (let i = from; i < end; i += 1) if (!BLANK_OR_COMMENT.test(lines[i] as string)) out.push(i);\n return out;\n}\n\n/** A value written on the lines under its key. */\nfunction readBlock(reader: Reader, content: readonly number[], colon: number, topLevel: boolean): Read {\n const { lines, starts } = reader;\n const first = content[0];\n if (first === undefined) return { value: { kind: 'scalar', scalar: { text: '', quoted: false } }, valueStart: colon, valueEnd: colon };\n\n // An unsupported block is reported over all of its content lines.\n const firstText = lines[first] as string;\n const last = content[content.length - 1] as number;\n const whole = (value: YamlValue): Read => ({\n value,\n valueStart: (starts[first] as number) + leadIndex(firstText),\n valueEnd: (starts[last] as number) + (lines[last] as string).trimEnd().length,\n });\n\n const head = SEQUENCE_ITEM.exec(firstText);\n if (head === null) {\n // Quoting a list would make it a string, so a list gets its own advice.\n if (firstText.trim().startsWith('[')) return whole(unsupported('an inline list starts on the line after its key; write it after the colon'));\n if (!KEY.test(firstText.trim())) return whole(unsupported('the value continues on the next line; keep it on one line, or quote it'));\n return whole(\n unsupported(topLevel ? 'nested mappings are not supported; flatten the key' : 'only one level of nesting is read; flatten the key'),\n );\n }\n const indent = (head[1] as string).length;\n const items: YamlScalar[] = [];\n const spans: [number, number][] = [];\n for (const index of content) {\n const line = lines[index] as string;\n const item = SEQUENCE_ITEM.exec(line);\n if (item === null || (item[1] as string).length !== indent) {\n return whole(unsupported('a list item is continued or nested; keep each item on one line'));\n }\n // The item's text starts after its whitespace, as a key's value does.\n const written = item[2] ?? '';\n const text = stripLeadingComment(written);\n if (text.length === 0) return whole(unsupported('a list item is empty'));\n const parsed = readInline(text);\n if (parsed.value.kind !== 'scalar') {\n return whole(parsed.value.kind === 'list' ? unsupported('nested lists are not supported') : parsed.value);\n }\n const start = (starts[index] as number) + line.length - written.length;\n spans.push([start, start + parsed.length]);\n items.push(parsed.value.scalar);\n }\n return { value: { kind: 'list', items }, valueStart: (spans[0] as [number, number])[0], valueEnd: (spans[spans.length - 1] as [number, number])[1] };\n}\n\nfunction stripLeadingComment(text: string): string {\n return text.startsWith('#') ? '' : text;\n}\n\nfunction unsupported(reason: string): YamlValue {\n return { kind: 'unsupported', reason };\n}\n\ninterface Parsed {\n readonly value: YamlValue;\n /** Characters of the text the value spans. */\n readonly length: number;\n}\n\n/** An unsupported value spans its text up to any comment. */\nfunction rough(value: YamlValue, text: string): Parsed {\n return { value, length: stripTrailingComment(text).length };\n}\n\n/** Parses a value written on the key's own line. `text` is trimmed and non-empty. */\nexport function parseInline(text: string): YamlValue {\n return readInline(text).value;\n}\n\n/** `text` starts with the value; whitespace after it is allowed. */\nfunction readInline(text: string): Parsed {\n const head = text.charAt(0);\n if (head === '\"' || head === \"'\") {\n const quoted = head === '\"' ? readDoubleQuoted(text) : readSingleQuoted(text);\n if (typeof quoted === 'string') return rough(unsupported(quoted), text);\n return trailingIsComment(text.slice(quoted.next))\n ? { value: { kind: 'scalar', scalar: { text: quoted.text, quoted: true } }, length: quoted.next }\n : rough(unsupported('text follows a closing quote'), text);\n }\n if (head === '[') return parseFlowSequence(text);\n if (head === '{') return rough(unsupported('inline mappings are not supported'), text);\n if (head === '|' || head === '>') return rough(unsupported('block scalars are not supported; keep the value on one line'), text);\n if (head === '&' || head === '*' || head === '!') return rough(unsupported('anchors, aliases and tags are not supported'), text);\n if (head === '@' || head === '`') return rough(unsupported(`a plain value cannot start with \"${head}\"; quote it`), text);\n const plain = stripTrailingComment(text);\n if (/:(?:\\s|$)/.test(plain)) return rough(unsupported('a plain value cannot contain \": \"; quote it'), text);\n if (/^-(?:\\s|$)/.test(plain)) return rough(unsupported('a list must start on the line after its key'), text);\n return { value: { kind: 'scalar', scalar: { text: plain, quoted: false } }, length: plain.length };\n}\n\n/** A comment starts at a `#` after whitespace; a `#` inside a word is text. */\nfunction stripTrailingComment(text: string): string {\n return (text.split(/\\s#/, 1)[0] as string).trim();\n}\n\n/** Nothing after a closing quote or bracket, or whitespace and then a comment. */\nfunction trailingIsComment(rest: string): boolean {\n return /^(?:\\s+(?:#.*)?)?$/.test(rest);\n}\n\ninterface Quoted {\n readonly text: string;\n /** Index just past the closing quote. */\n readonly next: number;\n}\n\nconst ESCAPES: Readonly<Record<string, string>> = {\n '\"': '\"',\n '\\\\': '\\\\',\n '/': '/',\n '0': '\\u0000',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t',\n};\n\nconst HEX_ESCAPE_LENGTH: Readonly<Record<string, number>> = { x: 2, u: 4, U: 8 };\n\n/** Reads a double-quoted scalar starting at index 0, or returns why it cannot. */\nfunction readDoubleQuoted(text: string): Quoted | string {\n let out = '';\n for (let i = 1; ; i += 1) {\n const ch = text.charAt(i);\n if (ch === '') return 'a double-quoted value is never closed';\n if (ch === '\"') return { text: out, next: i + 1 };\n if (ch !== '\\\\') {\n out += ch;\n continue;\n }\n const code = text.charAt(i + 1);\n const simple = ESCAPES[code];\n if (simple !== undefined) {\n out += simple;\n i += 1;\n continue;\n }\n // An escape this reader does not know has no digits to read, and no\n // digits are not a number.\n const width = HEX_ESCAPE_LENGTH[code] ?? 0;\n const hex = text.slice(i + 2, i + 2 + width);\n if (hex.length !== width || !/^[0-9A-Fa-f]+$/.test(hex)) return `\"\\\\${code}\" is not an escape this reader knows`;\n const point = Number.parseInt(hex, 16);\n if (point > 0x10ffff) return `\"\\\\${code}${hex}\" is not a character`;\n out += String.fromCodePoint(point);\n i += 1 + width;\n }\n}\n\nfunction readSingleQuoted(text: string): Quoted | string {\n let out = '';\n for (let i = 1; ; i += 1) {\n const ch = text.charAt(i);\n if (ch === '') return 'a single-quoted value is never closed';\n if (ch !== \"'\") {\n out += ch;\n continue;\n }\n if (text.charAt(i + 1) !== \"'\") return { text: out, next: i + 1 };\n out += \"'\";\n i += 1;\n }\n}\n\n/** The first index at or after `from` that is not whitespace. */\nfunction skipSpace(text: string, from: number): number {\n let i = from;\n while (/\\s/.test(text.charAt(i))) i += 1;\n return i;\n}\n\nfunction parseFlowSequence(text: string): Parsed {\n const items: YamlScalar[] = [];\n const fail = (reason: string): Parsed => rough(unsupported(reason), text);\n let i = 1;\n for (;;) {\n i = skipSpace(text, i);\n const ch = text.charAt(i);\n if (ch === '') return fail('an inline list is never closed; keep it on one line');\n if (ch === ']') {\n return trailingIsComment(text.slice(i + 1))\n ? { value: { kind: 'list', items }, length: i + 1 }\n : fail('text follows the end of an inline list');\n }\n if (ch === '[' || ch === '{') return fail('nested lists and mappings are not supported');\n if (ch === ',') return fail('an inline list has an empty item');\n if (ch === '\"' || ch === \"'\") {\n const rest = text.slice(i);\n const quoted = ch === '\"' ? readDoubleQuoted(rest) : readSingleQuoted(rest);\n if (typeof quoted === 'string') return fail(quoted);\n items.push({ text: quoted.text, quoted: true });\n i += quoted.next;\n } else {\n let j = i;\n // One step past the end reads nothing and slices nothing more, so the\n // bound could be one further and still stop the walk.\n while (j < text.length && text.charAt(j) !== ',' && text.charAt(j) !== ']') j += 1;\n const plain = text.slice(i, j).trim();\n if (/[[{]/.test(plain) || /:(?:\\s|$)/.test(plain) || plain.includes(' #')) {\n return fail(`\"${plain}\" needs quoting inside an inline list`);\n }\n items.push({ text: plain, quoted: false });\n i = j;\n }\n i = skipSpace(text, i);\n // After a comma the next pass reads an item or, legally in YAML, the\n // bracket; at the end of the text it says the list is never closed.\n const next = text.charAt(i);\n if (next === ',') i += 1;\n else if (next !== ']' && next !== '') return fail('inline list items must be separated by commas');\n }\n}\n\n/** Null in the YAML 1.2 core schema: empty, `~` or `null` in any of its three spellings. */\nexport function isNull(scalar: YamlScalar): boolean {\n return !scalar.quoted && ['', '~', 'null', 'Null', 'NULL'].includes(scalar.text);\n}\n\n/** Renders a string as a scalar that reads back as the same string. */\nexport function renderScalar(value: string): string {\n const reserved = /^(?:true|false|null|yes|no|on|off|~)$/i.test(value);\n const plain = /^[A-Za-z][A-Za-z0-9 ._/+-]*$/.test(value) && !value.endsWith(' ');\n return plain && !reserved ? value : JSON.stringify(value);\n}\n\nexport function findEntry(frontMatter: FrontMatter | null, key: string): FrontMatterEntry | undefined {\n const name = keyName(key);\n return frontMatter?.entries.find((entry) => entry.name === name);\n}\n\n/**\n * Sets one key, leaving every other line as it was.\n *\n * `lines` are the lines of the text the front matter was read from, as\n * `splitLines` gives them. An existing entry keeps the spelling and the\n * indentation of its key; a new one goes last, at the top level. A text with\n * no front matter gains a block.\n */\nexport function setEntry(lines: readonly string[], frontMatter: FrontMatter | null, key: string, rendered: string): string[] {\n if (frontMatter === null) return ['---', `${key}: ${rendered}`, '---', ...lines];\n if (frontMatter.close === -1) throw new Error('cannot edit front matter that is never closed');\n if (frontMatter.kind === 'toml') throw new Error('cannot edit TOML front matter');\n const entry = findEntry(frontMatter, key);\n if (entry === undefined) {\n return [...lines.slice(0, frontMatter.close), `${key}: ${rendered}`, ...lines.slice(frontMatter.close)];\n }\n const written =\n entry.parent === null\n ? `${entry.key}: ${rendered}`\n : `${(lines[entry.line] as string).slice(0, leadIndex(lines[entry.line] as string))}${entry.key.slice(entry.parent.length + 1)}: ${rendered}`;\n return [...lines.slice(0, entry.line), written, ...lines.slice(entry.end)];\n}\n\n/** Removes one key and its value lines; a key that is absent changes nothing. */\nexport function removeEntry(lines: readonly string[], frontMatter: FrontMatter | null, key: string): string[] {\n const entry = findEntry(frontMatter, key);\n if (entry === undefined) return [...lines];\n return [...lines.slice(0, entry.line), ...lines.slice(entry.end)];\n}\n"]}
1
+ {"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA0DxC,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,UAAU,GAAG,wBAAwB,CAAC;AAC5C,MAAM,UAAU,GAAG,gBAAgB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AK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;IAClJ,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7E,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,WAAW,CAAC,KAAwB,EAAE,WAA+B,EAAE,GAAW;IAChG,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAC1C,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["/**\n * A reader and editor for the front matter the spec-* tools use: a flat bag\n * of YAML scalars and lists, and optionally one level of nested mapping.\n *\n * Supported: `key: value` lines; plain, single-quoted and double-quoted\n * scalars; inline `[a, b]` sequences; block `- item` sequences; `#` comments.\n * Plain scalars follow the YAML 1.2 core schema, so `yes` is a word and `035`\n * keeps its leading zero for whoever reads it as text. With `nested`, a key\n * whose value is an indented block of keys is read as `parent.child` entries.\n *\n * Anything richer - deeper nesting, block scalars, anchors, tags, a value\n * continued onto the next line - is recognised and reported as unsupported\n * rather than guessed at. A YAML library would parse more, but it would not\n * give back the line and the offset of every value, and a report has to point\n * at the value it is about, and an edit has to leave every other line of the\n * file as it was.\n */\n\nimport { lineStarts, splitLines, stripBom } from '../text/index.js';\nimport { leadIndex } from './syntax.js';\nimport type { FrontMatterKind } from './types.js';\n\nexport interface YamlScalar {\n readonly text: string;\n readonly quoted: boolean;\n}\n\nexport type YamlValue =\n | { readonly kind: 'scalar'; readonly scalar: YamlScalar }\n | { readonly kind: 'list'; readonly items: readonly YamlScalar[] }\n | { readonly kind: 'unsupported'; readonly reason: string };\n\nexport interface FrontMatterEntry {\n /** The key as written; a nested key is its parent's and its own, joined by a dot. */\n readonly key: string;\n /** The key compared: {@link keyName} of `key`, so `depends-on` is `dependsOn`. */\n readonly name: string;\n /** The parent key as written, for a nested key; `null` at the top level. */\n readonly parent: string | null;\n /** 0-based line of the key. */\n readonly line: number;\n /** 0-based line after the entry's last line. */\n readonly end: number;\n /** Offset of the key in the text read. */\n readonly keyStart: number;\n /**\n * Offsets of the value as written: a quoted scalar with its quotes, an\n * inline list with its brackets, a block list from its first item's text to\n * its last item's. An empty value is the empty range just past the colon.\n */\n readonly valueStart: number;\n readonly valueEnd: number;\n readonly value: YamlValue;\n}\n\nexport interface FrontMatterProblem {\n /** 0-based line. */\n readonly line: number;\n readonly message: string;\n}\n\nexport interface FrontMatter {\n readonly kind: FrontMatterKind;\n /** 0-based line of the closing delimiter, or -1 when the block is never closed. */\n readonly close: number;\n readonly entries: readonly FrontMatterEntry[];\n readonly problems: readonly FrontMatterProblem[];\n}\n\nexport interface ReadOptions {\n /**\n * Read one level of nested mapping as `parent.child` entries, instead of\n * reporting the parent's value as unsupported.\n */\n readonly nested?: boolean;\n}\n\nconst YAML_OPEN = /^---[ \\t]*$/;\nconst YAML_CLOSE = /^(?:---|\\.\\.\\.)[ \\t]*$/;\nconst TOML_FENCE = /^\\+\\+\\+[ \\t]*$/;\n\n/** The kind of front matter a document's first line opens, or `null` when it opens none. */\nexport function frontMatterKind(firstLine: string): FrontMatterKind | null {\n if (YAML_OPEN.test(firstLine)) return 'yaml';\n return TOML_FENCE.test(firstLine) ? 'toml' : null;\n}\n\n/** Whether a line closes front matter of a kind: `---` or `...` for YAML, `+++` for TOML. */\nexport function frontMatterCloses(line: string, kind: FrontMatterKind): boolean {\n return (kind === 'yaml' ? YAML_CLOSE : TOML_FENCE).test(line);\n}\n\n/**\n * A key and what follows its colon. A key is a word of any script, as a YAML\n * plain key may be: a letter or `_` first, then letters, marks, digits and\n * `_.-`, so `狀態` and `状态` are keys as `status` is. Nothing else is one: a\n * digit or a mark first, a space, punctuation, and a full-width colon, which\n * YAML does not read as one.\n */\nconst KEY = /^([\\p{L}_][\\p{L}\\p{M}\\p{N}_.-]*)[ \\t]*:(?:[ \\t]+(.*))?$/u;\nconst SEQUENCE_ITEM = /^([ \\t]*)-(?:[ \\t]+(.*))?$/;\nconst BLANK_OR_COMMENT = /^[ \\t]*(?:#.*)?$/;\n\nexport function keyName(key: string): string {\n return key.toLowerCase().replace(/[-_]/g, '');\n}\n\n/**\n * Reads the front matter at the top of a text, or `null` when there is none.\n *\n * A leading byte-order mark is not part of the text read: offsets count from\n * the character after it, as a scan's do.\n */\nexport function readFrontMatter(source: string, options: ReadOptions = {}): FrontMatter | null {\n const text = stripBom(source);\n const lines = splitLines(text);\n const kind = frontMatterKind(lines[0] as string);\n if (kind === null) return null;\n const close = lines.findIndex((line, i) => i > 0 && frontMatterCloses(line, kind));\n if (close === -1) {\n return { kind, close, entries: [], problems: [{ line: 0, message: 'the front matter opened on line 1 is never closed' }] };\n }\n if (kind === 'toml') {\n return { kind, close, entries: [], problems: [{ line: 0, message: 'TOML front matter is not read; write YAML between \"---\" lines' }] };\n }\n\n const reader: Reader = {\n lines,\n starts: lineStarts(text),\n nested: options.nested === true,\n entries: [],\n problems: [],\n seen: new Map(),\n };\n let i = 1;\n while (i < close) {\n const line = lines[i] as string;\n if (BLANK_OR_COMMENT.test(line)) {\n i += 1;\n continue;\n }\n const match = KEY.exec(line);\n if (match === null) {\n reader.problems.push({\n line: i,\n message: /^\\s/.test(line) ? 'an indented line belongs to no key' : 'not a \"key: value\" line',\n });\n i += 1;\n continue;\n }\n // The closing delimiter belongs to no value, so the block stops there.\n let end = i + 1;\n while (belongsToBlock(lines[end] as string)) end += 1;\n end = trimBlock(lines, end);\n readEntry(reader, { key: match[1] as string, parent: null, line: i, column: 0, inline: match[2] ?? '', end });\n i = end;\n }\n return { kind, close, entries: reader.entries, problems: reader.problems };\n}\n\ninterface Reader {\n readonly lines: readonly string[];\n readonly starts: readonly number[];\n readonly nested: boolean;\n readonly entries: FrontMatterEntry[];\n readonly problems: FrontMatterProblem[];\n readonly seen: Map<string, number>;\n}\n\ninterface KeyLine {\n /** The key as written on its line, without a parent. */\n readonly key: string;\n readonly parent: string | null;\n readonly line: number;\n /** Column of the key. */\n readonly column: number;\n /** What follows the colon and its whitespace, as written. */\n readonly inline: string;\n /** 0-based line after the key's value. */\n readonly end: number;\n}\n\n/** A line under a top-level key is part of its value when it is indented or starts a sequence item. */\nfunction belongsToBlock(line: string): boolean {\n return /^[ \\t]/.test(line) || /^-(?:[ \\t]|$)/.test(line) || line.trim() === '';\n}\n\n/**\n * Takes trailing blank and comment lines off a value's block: they belong to\n * no key. The key's own line is neither, so the walk stops there at the latest.\n */\nfunction trimBlock(lines: readonly string[], end: number): number {\n let at = end;\n while (BLANK_OR_COMMENT.test(lines[at - 1] as string)) at -= 1;\n return at;\n}\n\nfunction note(reader: Reader, key: string, line: number): string {\n const name = keyName(key);\n const previous = reader.seen.get(name);\n if (previous === undefined) reader.seen.set(name, line);\n else reader.problems.push({ line, message: `\"${key}\" is declared twice (first on line ${previous + 1})` });\n return name;\n}\n\nfunction readEntry(reader: Reader, at: KeyLine): void {\n const { lines, starts } = reader;\n const text = lines[at.line] as string;\n const lineStart = starts[at.line] as number;\n const key = at.parent === null ? at.key : `${at.parent}.${at.key}`;\n // A key holds no colon and nothing before it does, so the first is its own.\n const colon = lineStart + text.indexOf(':') + 1;\n // What follows the colon starts after its whitespace; what ends it is\n // trimmed by whichever reader takes it.\n const inline = stripLeadingComment(at.inline);\n\n let read: Read;\n if (inline.length > 0) {\n const valueStart = lineStart + text.length - at.inline.length;\n const continued = contentLines(lines, at.line + 1, at.end).length > 0;\n const parsed = continued\n ? rough(unsupported('the value continues on the next line; keep it on one line, or quote it'), inline)\n : readInline(inline);\n read = { value: parsed.value, valueStart, valueEnd: valueStart + parsed.length };\n } else {\n const content = contentLines(lines, at.line + 1, at.end);\n const first = content[0];\n if (first !== undefined && at.parent === null && reader.nested && KEY.test((lines[first] as string).trim())) {\n note(reader, at.key, at.line);\n readChildren(reader, at.key, at.line + 1, at.end);\n return;\n }\n read = readBlock(reader, content, colon, at.parent === null);\n }\n\n reader.entries.push({\n key,\n name: note(reader, key, at.line),\n parent: at.parent,\n line: at.line,\n end: at.end,\n keyStart: lineStart + at.column,\n ...read,\n });\n}\n\n/** One level of keys under a parent, all at the indentation of the first. */\nfunction readChildren(reader: Reader, parent: string, from: number, end: number): void {\n const { lines } = reader;\n const first = lines[contentLines(lines, from, end)[0] as number] as string;\n const lead = first.slice(0, leadIndex(first));\n let i = from;\n while (i < end) {\n const line = lines[i] as string;\n if (BLANK_OR_COMMENT.test(line)) {\n i += 1;\n continue;\n }\n // A line deeper than the keys is always taken by the key above it, so only\n // one at their indentation or shallower reaches here.\n const match = line.startsWith(lead) ? KEY.exec(line.slice(lead.length)) : null;\n if (match === null) {\n reader.problems.push({ line: i, message: 'not a \"key: value\" line at the indentation of the keys before it' });\n i += 1;\n continue;\n }\n // Past the parent's value, a line belongs to a child only when it is blank\n // or a comment, and those are trimmed off again.\n let childEnd = i + 1;\n while (belongsToChild(lines[childEnd] as string, lead)) childEnd += 1;\n childEnd = trimBlock(lines, childEnd);\n readEntry(reader, { key: match[1] as string, parent, line: i, column: lead.length, inline: match[2] ?? '', end: childEnd });\n i = childEnd;\n }\n}\n\n/** A line under a nested key is part of its value when it is deeper, or a sequence item at the key's indentation. */\nfunction belongsToChild(line: string, lead: string): boolean {\n if (line.trim() === '') return true;\n if (!line.startsWith(lead)) return false;\n return /^(?:[ \\t]|-(?:[ \\t]|$))/.test(line.slice(lead.length));\n}\n\ninterface Read {\n readonly value: YamlValue;\n readonly valueStart: number;\n readonly valueEnd: number;\n}\n\n/** Indices of the lines in a range that are neither blank nor a comment. */\nfunction contentLines(lines: readonly string[], from: number, end: number): number[] {\n const out: number[] = [];\n for (let i = from; i < end; i += 1) if (!BLANK_OR_COMMENT.test(lines[i] as string)) out.push(i);\n return out;\n}\n\n/** A value written on the lines under its key. */\nfunction readBlock(reader: Reader, content: readonly number[], colon: number, topLevel: boolean): Read {\n const { lines, starts } = reader;\n const first = content[0];\n if (first === undefined) return { value: { kind: 'scalar', scalar: { text: '', quoted: false } }, valueStart: colon, valueEnd: colon };\n\n // An unsupported block is reported over all of its content lines.\n const firstText = lines[first] as string;\n const last = content[content.length - 1] as number;\n const whole = (value: YamlValue): Read => ({\n value,\n valueStart: (starts[first] as number) + leadIndex(firstText),\n valueEnd: (starts[last] as number) + (lines[last] as string).trimEnd().length,\n });\n\n const head = SEQUENCE_ITEM.exec(firstText);\n if (head === null) {\n // Quoting a list would make it a string, so a list gets its own advice.\n if (firstText.trim().startsWith('[')) return whole(unsupported('an inline list starts on the line after its key; write it after the colon'));\n if (!KEY.test(firstText.trim())) return whole(unsupported('the value continues on the next line; keep it on one line, or quote it'));\n return whole(\n unsupported(topLevel ? 'nested mappings are not supported; flatten the key' : 'only one level of nesting is read; flatten the key'),\n );\n }\n const indent = (head[1] as string).length;\n const items: YamlScalar[] = [];\n const spans: [number, number][] = [];\n for (const index of content) {\n const line = lines[index] as string;\n const item = SEQUENCE_ITEM.exec(line);\n if (item === null || (item[1] as string).length !== indent) {\n return whole(unsupported('a list item is continued or nested; keep each item on one line'));\n }\n // The item's text starts after its whitespace, as a key's value does.\n const written = item[2] ?? '';\n const text = stripLeadingComment(written);\n if (text.length === 0) return whole(unsupported('a list item is empty'));\n const parsed = readInline(text);\n if (parsed.value.kind !== 'scalar') {\n return whole(parsed.value.kind === 'list' ? unsupported('nested lists are not supported') : parsed.value);\n }\n const start = (starts[index] as number) + line.length - written.length;\n spans.push([start, start + parsed.length]);\n items.push(parsed.value.scalar);\n }\n return { value: { kind: 'list', items }, valueStart: (spans[0] as [number, number])[0], valueEnd: (spans[spans.length - 1] as [number, number])[1] };\n}\n\nfunction stripLeadingComment(text: string): string {\n return text.startsWith('#') ? '' : text;\n}\n\nfunction unsupported(reason: string): YamlValue {\n return { kind: 'unsupported', reason };\n}\n\ninterface Parsed {\n readonly value: YamlValue;\n /** Characters of the text the value spans. */\n readonly length: number;\n}\n\n/** An unsupported value spans its text up to any comment. */\nfunction rough(value: YamlValue, text: string): Parsed {\n return { value, length: stripTrailingComment(text).length };\n}\n\n/** Parses a value written on the key's own line. `text` is trimmed and non-empty. */\nexport function parseInline(text: string): YamlValue {\n return readInline(text).value;\n}\n\n/** `text` starts with the value; whitespace after it is allowed. */\nfunction readInline(text: string): Parsed {\n const head = text.charAt(0);\n if (head === '\"' || head === \"'\") {\n const quoted = head === '\"' ? readDoubleQuoted(text) : readSingleQuoted(text);\n if (typeof quoted === 'string') return rough(unsupported(quoted), text);\n return trailingIsComment(text.slice(quoted.next))\n ? { value: { kind: 'scalar', scalar: { text: quoted.text, quoted: true } }, length: quoted.next }\n : rough(unsupported('text follows a closing quote'), text);\n }\n if (head === '[') return parseFlowSequence(text);\n if (head === '{') return rough(unsupported('inline mappings are not supported'), text);\n if (head === '|' || head === '>') return rough(unsupported('block scalars are not supported; keep the value on one line'), text);\n if (head === '&' || head === '*' || head === '!') return rough(unsupported('anchors, aliases and tags are not supported'), text);\n if (head === '@' || head === '`') return rough(unsupported(`a plain value cannot start with \"${head}\"; quote it`), text);\n const plain = stripTrailingComment(text);\n if (/:(?:\\s|$)/.test(plain)) return rough(unsupported('a plain value cannot contain \": \"; quote it'), text);\n if (/^-(?:\\s|$)/.test(plain)) return rough(unsupported('a list must start on the line after its key'), text);\n return { value: { kind: 'scalar', scalar: { text: plain, quoted: false } }, length: plain.length };\n}\n\n/** A comment starts at a `#` after whitespace; a `#` inside a word is text. */\nfunction stripTrailingComment(text: string): string {\n return (text.split(/\\s#/, 1)[0] as string).trim();\n}\n\n/** Nothing after a closing quote or bracket, or whitespace and then a comment. */\nfunction trailingIsComment(rest: string): boolean {\n return /^(?:\\s+(?:#.*)?)?$/.test(rest);\n}\n\ninterface Quoted {\n readonly text: string;\n /** Index just past the closing quote. */\n readonly next: number;\n}\n\nconst ESCAPES: Readonly<Record<string, string>> = {\n '\"': '\"',\n '\\\\': '\\\\',\n '/': '/',\n '0': '\\u0000',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t',\n};\n\nconst HEX_ESCAPE_LENGTH: Readonly<Record<string, number>> = { x: 2, u: 4, U: 8 };\n\n/** Reads a double-quoted scalar starting at index 0, or returns why it cannot. */\nfunction readDoubleQuoted(text: string): Quoted | string {\n let out = '';\n for (let i = 1; ; i += 1) {\n const ch = text.charAt(i);\n if (ch === '') return 'a double-quoted value is never closed';\n if (ch === '\"') return { text: out, next: i + 1 };\n if (ch !== '\\\\') {\n out += ch;\n continue;\n }\n const code = text.charAt(i + 1);\n const simple = ESCAPES[code];\n if (simple !== undefined) {\n out += simple;\n i += 1;\n continue;\n }\n // An escape this reader does not know has no digits to read, and no\n // digits are not a number.\n const width = HEX_ESCAPE_LENGTH[code] ?? 0;\n const hex = text.slice(i + 2, i + 2 + width);\n if (hex.length !== width || !/^[0-9A-Fa-f]+$/.test(hex)) return `\"\\\\${code}\" is not an escape this reader knows`;\n const point = Number.parseInt(hex, 16);\n if (point > 0x10ffff) return `\"\\\\${code}${hex}\" is not a character`;\n out += String.fromCodePoint(point);\n i += 1 + width;\n }\n}\n\nfunction readSingleQuoted(text: string): Quoted | string {\n let out = '';\n for (let i = 1; ; i += 1) {\n const ch = text.charAt(i);\n if (ch === '') return 'a single-quoted value is never closed';\n if (ch !== \"'\") {\n out += ch;\n continue;\n }\n if (text.charAt(i + 1) !== \"'\") return { text: out, next: i + 1 };\n out += \"'\";\n i += 1;\n }\n}\n\n/** The first index at or after `from` that is not whitespace. */\nfunction skipSpace(text: string, from: number): number {\n let i = from;\n while (/\\s/.test(text.charAt(i))) i += 1;\n return i;\n}\n\nfunction parseFlowSequence(text: string): Parsed {\n const items: YamlScalar[] = [];\n const fail = (reason: string): Parsed => rough(unsupported(reason), text);\n let i = 1;\n for (;;) {\n i = skipSpace(text, i);\n const ch = text.charAt(i);\n if (ch === '') return fail('an inline list is never closed; keep it on one line');\n if (ch === ']') {\n return trailingIsComment(text.slice(i + 1))\n ? { value: { kind: 'list', items }, length: i + 1 }\n : fail('text follows the end of an inline list');\n }\n if (ch === '[' || ch === '{') return fail('nested lists and mappings are not supported');\n if (ch === ',') return fail('an inline list has an empty item');\n if (ch === '\"' || ch === \"'\") {\n const rest = text.slice(i);\n const quoted = ch === '\"' ? readDoubleQuoted(rest) : readSingleQuoted(rest);\n if (typeof quoted === 'string') return fail(quoted);\n items.push({ text: quoted.text, quoted: true });\n i += quoted.next;\n } else {\n let j = i;\n // One step past the end reads nothing and slices nothing more, so the\n // bound could be one further and still stop the walk.\n while (j < text.length && text.charAt(j) !== ',' && text.charAt(j) !== ']') j += 1;\n const plain = text.slice(i, j).trim();\n if (/[[{]/.test(plain) || /:(?:\\s|$)/.test(plain) || plain.includes(' #')) {\n return fail(`\"${plain}\" needs quoting inside an inline list`);\n }\n items.push({ text: plain, quoted: false });\n i = j;\n }\n i = skipSpace(text, i);\n // After a comma the next pass reads an item or, legally in YAML, the\n // bracket; at the end of the text it says the list is never closed.\n const next = text.charAt(i);\n if (next === ',') i += 1;\n else if (next !== ']' && next !== '') return fail('inline list items must be separated by commas');\n }\n}\n\n/** Null in the YAML 1.2 core schema: empty, `~` or `null` in any of its three spellings. */\nexport function isNull(scalar: YamlScalar): boolean {\n return !scalar.quoted && ['', '~', 'null', 'Null', 'NULL'].includes(scalar.text);\n}\n\n/**\n * Renders a string as a scalar that reads back as the same string.\n *\n * Plain only as a YAML plain scalar that reads back as itself: a letter\n * first, of any script, then letters, marks, digits, spaces and `._/+-` - so\n * a status of `封存` or `已接受` is written as it is typed - with no space at\n * the end, and none of `true`, `false`, `null`, `yes`, `no`, `on`, `off` or\n * `~` in any case, which YAML 1.2 or 1.1 reads as a boolean or a null.\n * Anything else is quoted: an indicator, `: ` or ` #`, a number, a space at\n * either end, a full-width space or punctuation.\n */\nexport function renderScalar(value: string): string {\n const reserved = /^(?:true|false|null|yes|no|on|off|~)$/i.test(value);\n const plain = /^\\p{L}[\\p{L}\\p{M}\\p{N} ._/+-]*$/u.test(value) && !value.endsWith(' ');\n return plain && !reserved ? value : JSON.stringify(value);\n}\n\nexport function findEntry(frontMatter: FrontMatter | null, key: string): FrontMatterEntry | undefined {\n const name = keyName(key);\n return frontMatter?.entries.find((entry) => entry.name === name);\n}\n\n/**\n * Sets one key, leaving every other line as it was.\n *\n * `lines` are the lines of the text the front matter was read from, as\n * `splitLines` gives them. An existing entry keeps the spelling and the\n * indentation of its key; a new one goes last, at the top level. A text with\n * no front matter gains a block.\n */\nexport function setEntry(lines: readonly string[], frontMatter: FrontMatter | null, key: string, rendered: string): string[] {\n if (frontMatter === null) return ['---', `${key}: ${rendered}`, '---', ...lines];\n if (frontMatter.close === -1) throw new Error('cannot edit front matter that is never closed');\n if (frontMatter.kind === 'toml') throw new Error('cannot edit TOML front matter');\n const entry = findEntry(frontMatter, key);\n if (entry === undefined) {\n return [...lines.slice(0, frontMatter.close), `${key}: ${rendered}`, ...lines.slice(frontMatter.close)];\n }\n const written =\n entry.parent === null\n ? `${entry.key}: ${rendered}`\n : `${(lines[entry.line] as string).slice(0, leadIndex(lines[entry.line] as string))}${entry.key.slice(entry.parent.length + 1)}: ${rendered}`;\n return [...lines.slice(0, entry.line), written, ...lines.slice(entry.end)];\n}\n\n/** Removes one key and its value lines; a key that is absent changes nothing. */\nexport function removeEntry(lines: readonly string[], frontMatter: FrontMatter | null, key: string): string[] {\n const entry = findEntry(frontMatter, key);\n if (entry === undefined) return [...lines];\n return [...lines.slice(0, entry.line), ...lines.slice(entry.end)];\n}\n"]}
@@ -32,6 +32,8 @@
32
32
  * `{/docs,lib}` is `/docs` or `lib`, the leading `/` rooting or anchoring
33
33
  * that alternative as it would the pattern. One that names no path,
34
34
  * `{./,lib}` or `{,lib}`, is refused, as `./` and the empty pattern are.
35
+ * - A leading `./` is the current directory, and goes with the slashes after
36
+ * it, as POSIX reads them: `.//docs` is `docs`, and never `/docs`.
35
37
  * - Case is the caller's decision, stated every time. A result must not
36
38
  * depend on the host it ran on.
37
39
  * - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,
@@ -134,3 +136,86 @@ export type GlobListParse = {
134
136
  * deciding the paths it matches, a leading `!` taking them back out.
135
137
  */
136
138
  export declare function parseGlobList(patterns: readonly string[], options: GlobOptions): GlobListParse;
139
+ /** One text a pattern's braces give, as every dialect reads its start. */
140
+ export interface GlobAlternative {
141
+ /**
142
+ * Led by a `/`, the pattern's or its own with no `./` of the pattern's
143
+ * before it: rooted at the filesystem's root in the `path` and `ripgrep`
144
+ * dialects, and anchored at the repository root in `gitignore`.
145
+ */
146
+ readonly rooted: boolean;
147
+ /**
148
+ * The text without the `./` and the slashes it starts with, the pattern's
149
+ * included, and with each `}` and `,` no group took written as a class of
150
+ * that one character, so that it reads the same inside braces again. Alone,
151
+ * it reads the same behind a `/` when rooted and behind a `./` when not,
152
+ * which keeps a `!` it starts with a character. A trailing `/` stays: what
153
+ * it means is the dialect's.
154
+ */
155
+ readonly text: string;
156
+ }
157
+ export type GlobAlternatives = {
158
+ readonly ok: true;
159
+ /** Led by a `/` of its own, before any `./`, which roots every alternative. */
160
+ readonly rooted: boolean;
161
+ /** In the order the braces give them. */
162
+ readonly alternatives: readonly GlobAlternative[];
163
+ } | {
164
+ readonly ok: false;
165
+ readonly error: string;
166
+ };
167
+ /**
168
+ * The alternatives a pattern's braces give, each read at its start as
169
+ * {@link parseGlob} reads it, for a tool that reads a pattern's alternatives
170
+ * one by one - to anchor a rooted one, to hand each to another engine - and
171
+ * would otherwise expand braces and read a leading `./` and `/` again itself.
172
+ *
173
+ * Braces expand first, and an alternative is rooted by a leading `/` on the
174
+ * pattern, or on the text the braces give when no `./` of the pattern's stands
175
+ * before it: `{/docs,x}` is `docs` rooted and `x`; `./{/docs,x}` and
176
+ * `{.//docs,x}` are `docs` and `x`, neither rooted; `a/{/b,c}` is `a//b` and
177
+ * `a/c`. A `!` after a `./` is a character, as it is to `parseGlob`: `./!a` is
178
+ * the name `!a`.
179
+ *
180
+ * A reading, not a verdict: refused are only what `parseGlob` refuses before
181
+ * it reads an alternative, in its words, and braces that do not expand. An
182
+ * alternative `parseGlob` refuses - `{/,x}` gives `/` - is given as read.
183
+ */
184
+ export declare function globAlternatives(source: string, options?: Pick<GlobOptions, 'backslash'>): GlobAlternatives;
185
+ export type GlobRebase = {
186
+ readonly ok: true;
187
+ readonly pattern: string;
188
+ } | {
189
+ readonly ok: false;
190
+ readonly error: string;
191
+ };
192
+ /**
193
+ * A list entry typed in a directory below the root, rewritten to read from
194
+ * the root as the `path` dialect reads it: for a tool run in a subdirectory
195
+ * that matches whole paths from the root, where what is typed means what it
196
+ * names from where it was typed.
197
+ *
198
+ * `directory` is where the entry was typed, a path under the root; at the
199
+ * root itself, `''`, there is nothing to rewrite. The entry is read as
200
+ * {@link parseGlobList} reads one: a leading `!` stays in front, and what
201
+ * follows is the pattern. Braces expand first, and each alternative is
202
+ * rebased as that text written alone would be:
203
+ *
204
+ * - one with a leading `/` is rooted at the filesystem's root, which no
205
+ * directory moves, and is kept: `/docs` is `/docs` typed anywhere;
206
+ * - any other gets the directory in front, a leading `..` climbing out of
207
+ * it: `docs/*.md` typed in `sub` is `sub/docs/*.md`, and `../*.md` typed in
208
+ * `docs/deep` is `docs/*.md`.
209
+ *
210
+ * When every alternative is rebased alike, the braces stay as written, `{a,b}`
211
+ * typed in `sub` being `sub/{a,b}`; when they are not, each is written out:
212
+ * `{/docs,x}` is `{/docs,sub/x}`.
213
+ *
214
+ * Refused, with the reason: what {@link parseGlob} refuses before it reads an
215
+ * alternative, in its words; braces that do not expand; a `..` that climbs
216
+ * above the root; a directory no pattern can name; and alternatives written
217
+ * out that hold a `,` or a `}`, which would read as braces. Anything else a
218
+ * rebased pattern holds is for `parseGlob` to refuse, as it would the same
219
+ * pattern typed at the root.
220
+ */
221
+ export declare function rebaseGlob(entry: string, directory: string, options?: Pick<GlobOptions, 'backslash'>): GlobRebase;
@@ -32,6 +32,8 @@
32
32
  * `{/docs,lib}` is `/docs` or `lib`, the leading `/` rooting or anchoring
33
33
  * that alternative as it would the pattern. One that names no path,
34
34
  * `{./,lib}` or `{,lib}`, is refused, as `./` and the empty pattern are.
35
+ * - A leading `./` is the current directory, and goes with the slashes after
36
+ * it, as POSIX reads them: `.//docs` is `docs`, and never `/docs`.
35
37
  * - Case is the caller's decision, stated every time. A result must not
36
38
  * depend on the host it ran on.
37
39
  * - A malformed pattern is an error, never a literal. An unclosed `[` or `{`,
@@ -75,18 +77,28 @@ export function compileGlob(source, options) {
75
77
  throw new GlobError(source, result);
76
78
  return result;
77
79
  }
78
- function build(source, options) {
79
- const escapes = options.backslash !== 'separator';
80
- let pattern = source.trim();
81
- if (!escapes)
82
- pattern = pattern.replace(/\\/g, '/');
83
- const written = pattern;
80
+ /**
81
+ * A pattern as every dialect takes it - trimmed, and each `\` a separator
82
+ * when the caller asks - or the reason it is refused before anything in it is
83
+ * read.
84
+ */
85
+ function prepare(source, escapes) {
86
+ const trimmed = source.trim();
87
+ const pattern = escapes ? trimmed : trimmed.replace(/\\/g, '/');
84
88
  if (pattern.length === 0)
85
89
  return 'the pattern is empty';
86
90
  if (pattern.startsWith('!'))
87
91
  return 'a negated pattern is a list entry, not a glob; narrow the positive pattern';
88
92
  if (/(?:^|[^\\])[?*+@!]\([^)]*\|/.test(pattern))
89
93
  return EXTGLOB;
94
+ return { pattern };
95
+ }
96
+ function build(source, options) {
97
+ const escapes = options.backslash !== 'separator';
98
+ const prepared = prepare(source, escapes);
99
+ if (typeof prepared === 'string')
100
+ return prepared;
101
+ const { pattern } = prepared;
90
102
  // The pattern's own leading slash is taken off before the braces expand, so
91
103
  // that the root itself, and a text the braces give, are refused in the
92
104
  // words they always were: `/{./,a}` is told `./`.
@@ -108,14 +120,15 @@ function build(source, options) {
108
120
  // before anything else is decided: `{/docs,x}` is `/docs` or `x`. Left to
109
121
  // `parseAlternative`, the slash would be an empty segment, dropped, and
110
122
  // `/docs` would read as `docs`. A slash after a segment, as in
111
- // `a/{/b,c}`, starts no text, and is the empty segment of `a//b`.
123
+ // `a/{/b,c}`, starts no text, and is the empty segment of `a//b`; one
124
+ // after the pattern's `./` roots nothing either.
112
125
  const alone = unrooted(text);
113
126
  const parsed = parseAlternative(trailingSlash(alone.text, options.dialect), escapes);
114
127
  if (parsed === GLOBSTAR_IN_NAME)
115
- return `${GLOBSTAR_IN_NAME}: ${globstarAdvice(written)}`;
128
+ return `${GLOBSTAR_IN_NAME}: ${globstarAdvice(pattern)}`;
116
129
  if (typeof parsed === 'string')
117
130
  return parsed;
118
- alternatives.push({ ...parsed, rooted: whole.rooted || alone.rooted });
131
+ alternatives.push({ ...parsed, rooted: rootedIn(whole, alone) });
119
132
  }
120
133
  const builder = new Builder();
121
134
  const fragments = [];
@@ -261,17 +274,30 @@ function classEnd(pattern, open, escapes) {
261
274
  /* ---------------------------------------------------------------- segments */
262
275
  /**
263
276
  * A pattern, or a text its braces give, without the `./` and the slashes it
264
- * starts with, and whether a slash led it once the `./` was gone. What a
265
- * leading slash means is the dialect's: it roots a pattern at the
266
- * filesystem's root in `path` and `ripgrep`, and only anchors it at the
267
- * repository root in `gitignore`, as git reads one. `.//docs` is led by one,
268
- * as `/docs` is.
277
+ * starts with; whether a slash led it, which roots it; and whether a `./`
278
+ * did, which leaves every slash after it rootless. What a leading slash means
279
+ * is the dialect's: it roots a pattern at the filesystem's root in `path` and
280
+ * `ripgrep`, and only anchors it at the repository root in `gitignore`, as
281
+ * git reads one.
282
+ *
283
+ * The slashes after a `./` go with it, as POSIX reads `.//docs` as `./docs`:
284
+ * the current directory, then `docs`. Left behind, they would lead what is
285
+ * left and root it, and `.//docs` would be `/docs`. A slash the braces give
286
+ * after a pattern's `./` is one of them, so `./{/docs,x}`, which is
287
+ * `.//docs` or `./x`, roots neither.
269
288
  */
270
289
  function unrooted(text) {
271
290
  let rest = text;
272
291
  while (rest.startsWith('./'))
273
- rest = rest.slice(2);
274
- return { text: rest.replace(/^\/+/, ''), rooted: rest.startsWith('/') };
292
+ rest = rest.slice(2).replace(/^\/+/, '');
293
+ return { text: rest.replace(/^\/+/, ''), rooted: rest.startsWith('/'), dotted: rest !== text };
294
+ }
295
+ /**
296
+ * Whether a text the braces give is rooted: by the pattern's own leading
297
+ * slash, or by its own when the pattern's `./` does not stand before it.
298
+ */
299
+ function rootedIn(whole, alone) {
300
+ return whole.rooted || (alone.rooted && !whole.dotted);
275
301
  }
276
302
  /** Whether a pattern's text names no path: nothing in it but `/` and `.` segments. */
277
303
  function namesNoPath(text) {
@@ -314,7 +340,7 @@ function parseAlternative(text, escapes) {
314
340
  if (part === '' || part === '.')
315
341
  continue;
316
342
  if (part === '..')
317
- return 'a pattern cannot climb out of its root with ".."';
343
+ return CLIMBS_OUT;
318
344
  if (part === '**') {
319
345
  if (segments[segments.length - 1]?.kind !== 'globstar')
320
346
  segments.push({ kind: 'globstar' });
@@ -327,6 +353,7 @@ function parseAlternative(text, escapes) {
327
353
  }
328
354
  return { segments, slashed: raw.filter((part) => part !== '' && part !== '.').length > 1 };
329
355
  }
356
+ const CLIMBS_OUT = 'a pattern cannot climb out of its root with ".."';
330
357
  const EXTGLOB = 'extended globs such as "+(a|b)" are not supported: write alternatives as "{a,b}", and a literal parenthesis as "[(]"';
331
358
  const GLOBSTAR_IN_NAME = '"**" means any number of directories only as a whole segment';
332
359
  /**
@@ -609,4 +636,167 @@ export function parseGlobList(patterns, options) {
609
636
  },
610
637
  };
611
638
  }
639
+ /**
640
+ * The alternatives a pattern's braces give, each read at its start as
641
+ * {@link parseGlob} reads it, for a tool that reads a pattern's alternatives
642
+ * one by one - to anchor a rooted one, to hand each to another engine - and
643
+ * would otherwise expand braces and read a leading `./` and `/` again itself.
644
+ *
645
+ * Braces expand first, and an alternative is rooted by a leading `/` on the
646
+ * pattern, or on the text the braces give when no `./` of the pattern's stands
647
+ * before it: `{/docs,x}` is `docs` rooted and `x`; `./{/docs,x}` and
648
+ * `{.//docs,x}` are `docs` and `x`, neither rooted; `a/{/b,c}` is `a//b` and
649
+ * `a/c`. A `!` after a `./` is a character, as it is to `parseGlob`: `./!a` is
650
+ * the name `!a`.
651
+ *
652
+ * A reading, not a verdict: refused are only what `parseGlob` refuses before
653
+ * it reads an alternative, in its words, and braces that do not expand. An
654
+ * alternative `parseGlob` refuses - `{/,x}` gives `/` - is given as read.
655
+ */
656
+ export function globAlternatives(source, options = {}) {
657
+ const escapes = options.backslash !== 'separator';
658
+ const prepared = prepare(source, escapes);
659
+ if (typeof prepared === 'string')
660
+ return { ok: false, error: prepared };
661
+ const whole = unrooted(prepared.pattern);
662
+ const texts = expandBraces(whole.text, escapes);
663
+ if (typeof texts === 'string')
664
+ return { ok: false, error: texts };
665
+ return {
666
+ ok: true,
667
+ rooted: whole.rooted,
668
+ alternatives: texts.map((text) => {
669
+ const alone = unrooted(text);
670
+ // Past its root, a text may start with a `./` of its own, as `/./docs`
671
+ // does, and names the same without it.
672
+ return { rooted: rootedIn(whole, alone), text: asCharacters(unrooted(alone.text).text) };
673
+ }),
674
+ };
675
+ }
676
+ /**
677
+ * A text the braces gave, with each `}` and `,` no group took written as the
678
+ * class of that one character: once the braces have expanded, that is every
679
+ * one outside a class and not escaped. Escapes and classes are copied as
680
+ * written. A `\` is always an escape here, since one read as a separator was
681
+ * a `/` before the braces expanded. A step past the end reads `''`, which
682
+ * adds nothing, so the bound could be one further.
683
+ */
684
+ function asCharacters(text) {
685
+ let out = '';
686
+ for (let i = 0; i < text.length; i += 1) {
687
+ const ch = text.charAt(i);
688
+ let next = i + 1;
689
+ if (ch === '\\')
690
+ next = i + 2;
691
+ else if (ch === '[')
692
+ next = Math.max(next, classEnd(text, i, true) + 1);
693
+ out += ch === '}' || ch === ',' ? `[${ch}]` : text.slice(i, next);
694
+ i = next - 1;
695
+ }
696
+ return out;
697
+ }
698
+ /**
699
+ * A list entry typed in a directory below the root, rewritten to read from
700
+ * the root as the `path` dialect reads it: for a tool run in a subdirectory
701
+ * that matches whole paths from the root, where what is typed means what it
702
+ * names from where it was typed.
703
+ *
704
+ * `directory` is where the entry was typed, a path under the root; at the
705
+ * root itself, `''`, there is nothing to rewrite. The entry is read as
706
+ * {@link parseGlobList} reads one: a leading `!` stays in front, and what
707
+ * follows is the pattern. Braces expand first, and each alternative is
708
+ * rebased as that text written alone would be:
709
+ *
710
+ * - one with a leading `/` is rooted at the filesystem's root, which no
711
+ * directory moves, and is kept: `/docs` is `/docs` typed anywhere;
712
+ * - any other gets the directory in front, a leading `..` climbing out of
713
+ * it: `docs/*.md` typed in `sub` is `sub/docs/*.md`, and `../*.md` typed in
714
+ * `docs/deep` is `docs/*.md`.
715
+ *
716
+ * When every alternative is rebased alike, the braces stay as written, `{a,b}`
717
+ * typed in `sub` being `sub/{a,b}`; when they are not, each is written out:
718
+ * `{/docs,x}` is `{/docs,sub/x}`.
719
+ *
720
+ * Refused, with the reason: what {@link parseGlob} refuses before it reads an
721
+ * alternative, in its words; braces that do not expand; a `..` that climbs
722
+ * above the root; a directory no pattern can name; and alternatives written
723
+ * out that hold a `,` or a `}`, which would read as braces. Anything else a
724
+ * rebased pattern holds is for `parseGlob` to refuse, as it would the same
725
+ * pattern typed at the root.
726
+ */
727
+ export function rebaseGlob(entry, directory, options = {}) {
728
+ if (directory === '')
729
+ return { ok: true, pattern: entry };
730
+ const directories = directory.split('/');
731
+ if (directories.some((name) => name === '' || name === '.' || name === '..')) {
732
+ throw new Error(`"${directory}" is not a directory under the root`);
733
+ }
734
+ const escapes = options.backslash !== 'separator';
735
+ const trimmed = entry.trim();
736
+ const negation = trimmed.startsWith('!') ? '!' : '';
737
+ const prepared = prepare(trimmed.slice(negation.length), escapes);
738
+ if (typeof prepared === 'string')
739
+ return { ok: false, error: prepared };
740
+ const { pattern } = prepared;
741
+ const whole = unrooted(pattern);
742
+ if (whole.rooted)
743
+ return { ok: true, pattern: negation + pattern };
744
+ const texts = expandBraces(whole.text, escapes);
745
+ if (typeof texts === 'string')
746
+ return { ok: false, error: texts };
747
+ const pieces = [];
748
+ const depths = new Set();
749
+ let rooted = false;
750
+ for (const text of texts) {
751
+ // Rooted as `build` roots it, the pattern's own slash having been read.
752
+ if (rootedIn(whole, unrooted(text))) {
753
+ rooted = true;
754
+ pieces.push(text);
755
+ continue;
756
+ }
757
+ const moved = climb(text, directories);
758
+ if (moved === null)
759
+ return { ok: false, error: CLIMBS_OUT };
760
+ depths.add(moved.directories.length);
761
+ pieces.push(spell(moved));
762
+ }
763
+ if (depths.size === 0)
764
+ return { ok: true, pattern: negation + pattern };
765
+ if (/^[!\s]|[*?[{\\]/.test(directory)) {
766
+ return {
767
+ ok: false,
768
+ error: `the directory "${directory}" cannot be named in a pattern: a "*", "?", "[", "{" or "\\" in it, or a "!" or a space it starts with, would be read as syntax`,
769
+ };
770
+ }
771
+ // Every text the braces give starts with the pattern's own leading `..`
772
+ // segments, and one of them has just climbed without leaving the root.
773
+ const lead = climb(whole.text, directories);
774
+ if (!rooted && depths.size === 1 && depths.has(lead.directories.length))
775
+ return { ok: true, pattern: negation + spell(lead) };
776
+ const split = pieces.find((piece) => /[,}]/.test(piece));
777
+ if (split !== undefined) {
778
+ return { ok: false, error: `the braces cannot be rebased one alternative at a time: "${split}" holds a "," or a "}"` };
779
+ }
780
+ return { ok: true, pattern: `${negation}{${pieces.join(',')}}` };
781
+ }
782
+ /** A relative text's leading `..` segments taken off the directories it was typed in, or `null` past the root. */
783
+ function climb(text, directories) {
784
+ let kept = directories.length;
785
+ let rest = unrooted(text).text;
786
+ while (rest === '..' || rest.startsWith('../')) {
787
+ if (kept === 0)
788
+ return null;
789
+ kept -= 1;
790
+ rest = unrooted(rest.slice(3)).text;
791
+ }
792
+ return { directories: directories.slice(0, kept), rest };
793
+ }
794
+ /**
795
+ * A rebased relative text. At the root itself it is read from there behind a
796
+ * `./`, which keeps a slash the braces give after it from rooting it, and
797
+ * leaves the root refused as `./` is.
798
+ */
799
+ function spell(moved) {
800
+ return moved.directories.length > 0 ? `${moved.directories.join('/')}/${moved.rest}` : `./${moved.rest}`;
801
+ }
612
802
  //# sourceMappingURL=glob.js.map