@descent-vtt/spec-graph 0.14.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/glob.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"glob.js","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EACL,WAAW,IAAI,iBAAiB,EAChC,SAAS,EACT,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,GAKX,MAAM,qCAAqC,CAAC;AAE7C,kEAAkE;AAClE,MAAM,CAAC,MAAM,2BAA2B,GAAsB,MAAM,CAAC,MAAM,CAAC;IAC1E,MAAM;IACN,KAAK;IACL,MAAM;IACN,QAAQ;IACR,OAAO;IACP,OAAO;IACP,QAAQ;IACR,OAAO;IACP,cAAc;IACd,kBAAkB;IAClB,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;IACL,QAAQ;IACR,UAAU;IACV,aAAa;CACd,CAAC,CAAC;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAsB7C;;;;;;;GAOG;AACH,MAAM,IAAI,GAAsB,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AAEpH,kFAAkF;AAClF,MAAM,UAAU,MAAM,CAAC,OAAe;IACpC,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,OAAO,IAAI,MAAM,CAAC,I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AAc,CAAC,QAAQ,CAAC;QAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvD,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/**\n * Pattern matching and directory walking.\n *\n * The patterns are the `path` dialect every spec-* tool reads, from spec-core:\n * `**`, `*`, `?`, `{a,b}`, `[abc]` and `[!a-z]`, matched against whole\n * repository-relative POSIX paths by an automaton that cannot backtrack, with\n * case respected on every host (ADR-0022). What stays here is spec-graph's own:\n * how a list with `!` entries in it reads, which directories a walk never\n * enters, and how a reference target - which is not a path - is matched.\n */\n\nimport type { Dirent } from 'node:fs';\nimport { readdir, realpath, stat } from 'node:fs/promises';\n\nimport { isAbsolutePath, joinPosix, toPosix } from './paths.js';\nimport {\n compileGlob as compileFamilyGlob,\n GlobError,\n isGlobSyntax,\n parseGlob,\n parseGlobList,\n rebaseGlob,\n type Glob,\n type GlobList,\n type GlobOptions as FamilyGlobOptions,\n type RegexMatcher,\n} from './vendor/spec-core/pattern/index.js';\n\n/** Directories skipped unless a pattern explicitly names them. */\nexport const DEFAULT_IGNORED_DIRECTORIES: readonly string[] = Object.freeze([\n '.git',\n '.hg',\n '.svn',\n '.cache',\n '.next',\n '.nuxt',\n '.turbo',\n '.venv',\n 'node_modules',\n 'bower_components',\n 'vendor',\n 'dist',\n 'build',\n 'out',\n 'target',\n 'coverage',\n '__pycache__',\n]);\n\n/** Files larger than this are skipped: a specification is not a binary. */\nexport const MAX_FILE_SIZE = 4 * 1024 * 1024;\n\nexport interface WalkedFile {\n /** Repository-relative POSIX path. */\n readonly path: string;\n /** Absolute host path, for reading. */\n readonly absolute: string;\n readonly size: number;\n}\n\nexport interface WalkOptions {\n readonly root: string;\n readonly patterns: readonly string[];\n readonly ignore?: readonly string[] | undefined;\n readonly maxFileSize?: number | undefined;\n /**\n * Follow links. Off by default: a link can lead out of the repository. A\n * link back into a directory the walk is inside is never followed.\n */\n readonly followSymlinks?: boolean | undefined;\n}\n\n/**\n * How a path pattern is read everywhere in spec-graph.\n *\n * A literal names a file or a directory and everything beneath it, which is\n * what `--ignore docs/drafts` has always meant. A `\\` is a separator, because a\n * pattern typed on a Windows shell arrives with them and spec-graph has always\n * read them that way; it cannot also be an escape.\n */\nconst PATH: FamilyGlobOptions = { dialect: 'path', caseSensitive: true, literal: 'either', backslash: 'separator' };\n\n/** True when the string contains glob syntax rather than being a literal path. */\nexport function isGlob(pattern: string): boolean {\n return isGlobSyntax(pattern);\n}\n\n/**\n * Compiles a glob to an anchored regular expression, in the dialect spec-graph\n * read before it adopted spec-core's.\n *\n * @deprecated Nothing matches with this. It stays for callers who want a\n * `RegExp`, and as the record of the old reading that `tests/glob.test.ts`\n * holds every difference against, each one named in ADR-0022. It no longer\n * folds case on Windows alone: an answer must not depend on the host.\n */\nexport function globToRegExp(pattern: string): RegExp {\n return new RegExp(`^${globSource(pattern)}$`);\n}\n\nexport interface GlobOptions {\n /** Fold case. Off unless asked for, on every host. */\n readonly ignoreCase?: boolean | undefined;\n}\n\n/**\n * Compiles one glob to a matcher over whole repository-relative paths.\n *\n * A pattern with no glob syntax names that path and nothing beneath it; a bare\n * directory meaning its contents is a reading of {@link createGlobMatcher}'s.\n * Throws a `GlobError` that names the glob as it was written.\n *\n * Matching is linear in the path whatever the pattern. It was not always: a\n * glob's stars are not nested, but each is a `[^/]*` to `RegExp`, and a subject\n * that fails is divided between them every way there is - `*-*-*-x` took two\n * minutes over a 10,000-character reference target (ADR-0017).\n */\nexport function compileGlob(pattern: string, options: GlobOptions = {}): RegexMatcher {\n // `literal: 'file'` is the dialect's reading of any value but `directory`\n // and `either`, so a mutant that blanks it reads the same. It is spelled out\n // because what an unknown value means is spec-core's to change.\n const glob = compileFamilyGlob(pattern, { ...PATH, literal: 'file', caseSensitive: options.ignoreCase !== true });\n return { test: (path) => glob.match(path), size: glob.automaton.kinds.length };\n}\n\n/** The expression a glob stood for before 0.9.0, before anchors and flags. */\nfunction globSource(pattern: string): string {\n let source = '';\n let i = 0;\n const braces: number[] = [];\n\n while (i < pattern.length) {\n const ch = pattern[i] as string;\n\n if (ch === '*') {\n const doubled = pattern[i + 1] === '*';\n if (doubled) {\n const slashAfter = pattern[i + 2] === '/';\n // `a/**/b` must also match `a/b`, so the separator is folded in.\n source += slashAfter ? '(?:.*/)?' : '.*';\n i += slashAfter ? 3 : 2;\n } else {\n source += '[^/]*';\n i += 1;\n }\n continue;\n }\n\n if (ch === '?') {\n source += '[^/]';\n i += 1;\n continue;\n }\n\n if (ch === '[') {\n const close = pattern.indexOf(']', i + 1);\n if (close === -1) {\n source += '\\\\[';\n i += 1;\n continue;\n }\n const body = pattern.slice(i + 1, close);\n source += `[${body.startsWith('!') ? `^${escapeClass(body.slice(1))}` : escapeClass(body)}]`;\n i = close + 1;\n continue;\n }\n\n if (ch === '{') {\n braces.push(source.length);\n source += '(?:';\n i += 1;\n continue;\n }\n if (ch === '}' && braces.length > 0) {\n braces.pop();\n source += ')';\n i += 1;\n continue;\n }\n if (ch === ',' && braces.length > 0) {\n source += '|';\n i += 1;\n continue;\n }\n\n source += ch.replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&');\n i += 1;\n }\n\n // Otherwise reported as an unmatched parenthesis, in a glob that has none.\n if (braces.length > 0) throw new Error(`invalid glob \"${pattern}\": unclosed \"{\"`);\n return source;\n}\n\nfunction escapeClass(body: string): string {\n return body.replace(/[\\\\^\\]]/g, '\\\\$&');\n}\n\nexport interface GlobMatcher {\n (path: string): boolean;\n}\n\n/** Compiles a list of path patterns, or throws naming the one that is not a glob. */\nfunction pathList(patterns: readonly string[]): GlobList {\n const parsed = parseGlobList(patterns, PATH);\n if (!parsed.ok) throw new Error(`invalid glob ${parsed.error}`);\n return parsed.list;\n}\n\n/**\n * Builds a matcher from include patterns, honouring `!` negations.\n *\n * Later patterns win, so `docs/**\\/*.md` followed by `!docs/drafts/**` reads the\n * way a `.gitignore` does. A pattern with no glob syntax in it names a file, or\n * a directory and everything beneath it; `docs/` names only what is beneath.\n */\nexport function createGlobMatcher(patterns: readonly string[]): GlobMatcher {\n const list = pathList(patterns);\n return (path: string): boolean => list.match(path);\n}\n\n/**\n * A list entry typed in `directory`, below the root, rewritten to read from the\n * root, or refused naming the entry as it was typed (ADR-0018).\n *\n * Each brace alternative is rebased as that text written alone would be, so\n * `{/docs,x}` typed in `sub` is `{/docs,sub/x}`: a leading `/` roots it\n * wherever it was typed. A leading `..` climbs out of `directory`, and one past\n * the root is refused, as is a directory whose name a pattern would read as\n * syntax.\n */\nexport function rebasePattern(entry: string, directory: string): string {\n const rebased = rebaseGlob(entry, directory, PATH);\n if (!rebased.ok) throw new GlobError(entry, rebased.error);\n return rebased.pattern;\n}\n\n/**\n * Each dot in a reference pattern that may begin a segment, which is escaped:\n * a `.` or `..` segment then reads as the name it is, one or two dots, where\n * the dialect would drop the one and refuse the other.\n *\n * Braces expand before segments are read, so a dot written beside a brace or a\n * comma may begin a segment of an alternative: `docs/{.,x}` is `docs/.` or\n * `docs/x`, `.{/gone.md,x}` is `./gone.md` or `.x`, and `{docs/,x/}.` ends in a\n * segment `.` either way. An escaped dot is the same character as a dot in a\n * name, so escaping one that begins `.x`, or the braces leave inside a name as\n * in `a{.,b}`, reads the same, and nothing needs to tell those apart:\n * escaping each whole `.` or `..` segment instead reads each of 43,069\n * generated patterns the same, refusals included (ADR-0022).\n */\nconst SEGMENT_DOT = /(?<=^|[/{,}])\\./g;\n\n/**\n * How a reference target is matched. Every option is spelled out, though the\n * dialect reads `{}` the same way today: its defaults are spec-core's to\n * change, and this reading is spec-graph's to keep. A mutant that drops one,\n * or all of them, is equivalent until then.\n */\nconst TARGET: FamilyGlobOptions = { dialect: 'path', caseSensitive: false, literal: 'file' };\n\n/**\n * A refusal of a reference pattern in the words it was typed in.\n *\n * The dialect writes its advice for a `**` inside a name from the text it was\n * given, and that text held a `\\` before each dot {@link SEGMENT_DOT} escaped:\n * `../notes/**.md` was told `\\.\\./notes/**\\/*.md`. Given the pattern again with\n * a character it does not hold in place of each of those dots, the dialect\n * refuses it for the same reason, since both are one literal character and\n * neither is a direction, and each stand-in is read back as the dot it was.\n * Counting down from U+E000 would find a stand-in as well, among the\n * surrogates, so that mutant is equivalent.\n */\nfunction asTyped(typed: string, reason: string): string {\n let point = 0xe000;\n while (typed.includes(String.fromCodePoint(point))) point += 1;\n const stand = String.fromCodePoint(point);\n const again = parseGlob(typed.replace(SEGMENT_DOT, stand), TARGET);\n // Stand-ins and escaped dots compile or fail alike, so `again` never\n // compiles here, and a mutant that reads it as compiled is equivalent.\n return again.ok ? reason : again.error.replaceAll(stand, '.');\n}\n\n/**\n * Builds a predicate over reference *targets*, not paths.\n *\n * Separate from {@link createGlobMatcher} on purpose. That one is\n * path-oriented: a bare name there is a directory and everything under it. A\n * reference target has no such structure - `trap 55` is a name, not a location\n * - so a bare pattern matches it literally and nothing else.\n *\n * Case is ignored, on every platform, because a citation's spelling is the\n * author's and not the filesystem's. The fold is simple case mapping, one code\n * point at a time and without a locale, so every host gives the same answer:\n * U+00B5 (micro sign) and U+03BC (mu) stay two targets, as they have been since\n * a Windows-only `i` flag made them one there (ADR-0017).\n *\n * A target is text a document holds rather than a path on this host, and two\n * things follow. A `\\` escapes the character after it: there is no Windows\n * separator to allow for. And a `.` or `..` segment is text, in a brace\n * alternative as anywhere else: in a path the dialect drops the one and\n * refuses the other as climbing out of the root, but `../../notes/gone.md` is\n * a link somebody wrote and may want left alone. A pattern that is refused is\n * named, and advised, as it was typed.\n */\nexport function createReferenceFilter(patterns: readonly string[]): (target: string) => boolean {\n // A blank pattern reaches the dialect, which refuses it, as every pattern\n // spec-graph reads is refused when it names nothing. It used to be dropped,\n // so an unset variable in `--ignore-ref \"$TAGS\"` went unnoticed.\n const globs: Glob[] = patterns.map((pattern) => {\n const typed = pattern.trim();\n const parsed = parseGlob(typed.replace(SEGMENT_DOT, '\\\\.'), TARGET);\n if (!parsed.ok) throw new GlobError(pattern, asTyped(typed, parsed.error));\n return parsed.glob;\n });\n return (target: string): boolean => {\n const value = target.trim();\n return globs.some((glob) => glob.match(value));\n };\n}\n\n/**\n * The literal directory a pattern's matches all sit under, or `''` for the root.\n *\n * `{docs,specs}/**` has two, and this is the directory they share; the walk\n * itself starts at each.\n */\nexport function globBase(pattern: string): string {\n const { glob } = pathList([pattern]).entries[0] as { readonly glob: Glob };\n const bases = glob.bases.map((base) => base.split('/'));\n const shared = bases[0] as string[];\n let length = shared.length;\n for (const base of bases) {\n let same = 0;\n // `<=` would read one past the end, where both sides are undefined and\n // equal, and slice the same prefix: an equivalent mutant, left untested.\n while (same < length && base[same] === shared[same]) same += 1;\n length = same;\n }\n return shared.slice(0, length).join('/');\n}\n\n/**\n * Whether a base names directories the walk from the root would reach, each\n * with exactly that spelling and none a link it would not follow.\n *\n * A walk starts where a pattern's literal prefix points rather than at the\n * root, and on a filesystem that ignores case, `readdir('Docs')` lists `docs`.\n * Every file under it would come back spelled `Docs/...` - a node id, a\n * baseline key - and `Docs/**` would find it on Windows and macOS and nothing\n * on Linux. Asking each parent for the name gives git's answer on every host. A\n * base with an empty segment is rooted at `/`, which is never inside the root.\n *\n * Reading a directory by its path follows every link in the path, so\n * `docs/linked/*.md` was read through the link `docs/linked`, which the walk\n * from the root passes over. Asking each parent for the entry says which it\n * is, and a base beyond a link is left as silently as the walk leaves the link.\n *\n * Where links are followed, the answer is the real path of each directory\n * above the base, the root included, for the walk to tell a cycle by; a base\n * beyond a link back into one of them is one the walk from the root never\n * reaches, and is left the same way. Where they are not, it is empty and never\n * read, so a mutant that fills it anyway is equivalent. `null` is a base the\n * walk does not start at.\n */\nasync function reachable(root: string, base: string, followSymlinks: boolean | undefined): Promise<Set<string> | null> {\n const above = new Set<string>();\n if (base.length === 0) return above;\n let directory = root;\n for (const segment of base.split('/')) {\n let entries: Dirent[];\n try {\n entries = await readdir(directory, { withFileTypes: true });\n } catch {\n // Answering a set here would change nothing a test can see: the walk\n // would then read a directory beneath this one, fail the same way, and\n // find nothing.\n return null;\n }\n const entry = entries.find((candidate) => candidate.name === segment);\n if (entry === undefined || (entry.isSymbolicLink() && !followSymlinks)) return null;\n if (followSymlinks) {\n // The directory was just listed, so asking for its real path fails only\n // where it went in between, and the walk would find nothing there: a\n // mutant that answers otherwise is equivalent.\n const real = await realpath(directory).catch(() => null);\n if (real === null || above.has(real)) return null;\n above.add(real);\n }\n directory = `${directory}/${segment}`;\n }\n return above;\n}\n\n/**\n * Walks the tree and returns every file matching the patterns.\n *\n * Directories are pruned as early as possible: a repository with a 2 GB\n * `node_modules` should cost nothing to scan.\n */\nexport async function walkFiles(options: WalkOptions): Promise<WalkedFile[]> {\n const root = toPosix(options.root).replace(/\\/+$/, '');\n const patterns = pathList(options.patterns);\n const maxSize = options.maxFileSize ?? MAX_FILE_SIZE;\n\n // Ignores come in two shapes and both are documented. A bare name prunes any\n // directory called that, at any depth, the way a `.gitignore` line does.\n // Anything carrying a separator or glob syntax is matched against the\n // repository-relative path, which is what `--ignore \"docs/drafts/**\"` means -\n // and treating that as a directory name silently excluded nothing at all.\n // A mutant that defaults this to `['Stryker was here']` prunes directories of\n // that name, which no repository has: equivalent, and left untested.\n const ignores = options.ignore ?? [];\n // The empty pattern is no directory's name, so it goes to the dialect, which\n // refuses it as it refuses an empty include: a pattern that names nothing is\n // a typo or an unset variable, and was an ignore that ignored nothing. So\n // does a blank one, which was read as a directory called \" \".\n const plainName = (pattern: string): boolean =>\n pattern.trim().length > 0 && !isGlob(pattern) && !pattern.includes('/') && !pattern.startsWith('!');\n // A `!` before a name gives the name back, as a `.gitignore` line does, and\n // the last bare entry to name a directory decides whether it is pruned. It\n // was read as a directory called `!docs`, so `--ignore docs --ignore \"!docs\"`\n // pruned `docs` and said nothing. The default list is a list of names too,\n // and gives way to one: `--ignore \"!vendor\"` reads every `vendor`. A `!` alone\n // or before another is no name, and goes to the dialect, which refuses both.\n const bare = (pattern: string): boolean => plainName(pattern) || (pattern.startsWith('!') && plainName(pattern.slice(1)));\n const named = new Map<string, boolean>();\n for (const pattern of ignores.filter(bare)) {\n const negated = pattern.startsWith('!');\n named.set(negated ? pattern.slice(1) : pattern, !negated);\n }\n const skippedByDefault = new Set(DEFAULT_IGNORED_DIRECTORIES);\n const ignoreList = pathList(ignores.filter((pattern) => !bare(pattern)));\n const excluded = (path: string): boolean => ignoreList.match(path);\n\n // Only walk the directories the patterns can possibly reach: each pattern's\n // literal prefix, one per brace alternative. A negated pattern adds none: it\n // takes files back, and starting a walk at its prefix would enter what the\n // walk skips - `!node_modules/**/*.txt` beside `**/*.md` would read every\n // Markdown file in `node_modules`. No positive pattern at all walks nothing,\n // which is the answer.\n const bases = new Set<string>();\n // The paths a positive pattern names outright: `docs/vendor`, or each literal\n // a brace expands to. Such a name may be a file, so its walk starts in the\n // directory above, which pruned `vendor` on its way in: `docs/vendor` found\n // nothing where `docs/vendor/` read the directory. The default list gives way\n // to the directory a pattern names as it gives way to one a pattern starts\n // inside. A negated name adds none, for the reason it adds no base.\n const literals = new Set<string>();\n for (const entry of patterns.entries) {\n if (entry.negated) continue;\n for (const base of entry.glob.bases) bases.add(base);\n // The dialect is what knows a literal when it reads one, so each pattern\n // is compiled a second time to be told of them. That glob is thrown away:\n // the reading answered here decides nothing, and a mutant that changes it\n // is equivalent.\n parseGlob(entry.glob.source, {\n ...PATH,\n literal: (path) => {\n literals.add(path);\n return 'either';\n },\n });\n }\n // Every base is walked, even one inside another, because the outer walk\n // prunes `vendor` and the rest of the default list on its way down, and a\n // pattern that starts inside one of those is read from there. Dropping the\n // inner base as already covered meant `docs/**/*.md` beside\n // `docs/vendor/specs/*.md` found less than the second pattern alone. An\n // `--ignore` is not overruled that way: it is the user's. A walk that starts\n // at a base never passed through the directories above it, so each of them,\n // and the base, is asked what the walk from the root would have asked on its\n // way down. A bare name prunes at any depth - `--ignore adr` still takes out\n // `adr/`, which the default `adr/**/*.md` starts inside - and a path takes\n // out what it matches, so under `--ignore \"docs/*\"` `docs/drafts/**/*.md`\n // finds what `docs/**/*.md` finds, which is nothing there. The root is not\n // asked, as the walk from it never asks: `*` matches the empty path, and\n // `**/*.md` under `--ignore \"*\" --ignore \"!{docs,specs}\"` would read nothing\n // where it reads those two.\n const startable = (base: string): boolean => {\n if (base.length === 0) return true;\n const segments = base.split('/');\n return !segments.some((segment, i) => named.get(segment) === true || excluded(segments.slice(0, i + 1).join('/')));\n };\n // Whether the walk leaves a directory it meets, asked of a followed link to\n // one as well: a link called `node_modules`, which pnpm writes, or one an\n // `--ignore` names, is the directory it leads to under that name and path,\n // and was entered whatever they were. Pruning a whole subtree is an\n // optimisation; a pattern that only matches the files inside it is still\n // honoured when they are filtered. A bare `--ignore` name prunes a directory\n // a pattern names as well: only the default list gives way, to a pattern and\n // to a `!` before its name.\n const pruned = (name: string, path: string): boolean =>\n (named.get(name) ?? (skippedByDefault.has(name) && !literals.has(path))) || excluded(path);\n const out = new Map<string, WalkedFile>();\n // Where two walks overlap, whichever reaches a directory first reads it and\n // the other stops there. Reading it twice would find the same files under\n // the same keys, so the two mutants that drop this are equivalent.\n const visited = new Set<string>();\n // Where links are followed, the real path of each directory from the root to\n // the one being read. A link whose real path is among them leads back into a\n // directory the walk is inside, and following it read the same files again\n // under a longer path each time round, until the host refused the path: on\n // Windows, 64 copies of each. It is passed over as silently as a link is\n // when links are not followed. A link to anywhere else is followed, one to a\n // directory the walk has already read beside this one included, since only\n // a directory on the way here can make a cycle. The walks run one at a time,\n // so one set serves them all. Only a followed link can make a cycle, so with\n // links not followed no real path is asked for, and a mutant that asks finds\n // none: equivalent.\n let inside = new Set<string>();\n\n const walk = async (relative: string): Promise<void> => {\n const absolute = relative.length === 0 ? root : `${root}/${relative}`;\n if (visited.has(absolute)) return;\n visited.add(absolute);\n if (!options.followSymlinks) return read(relative, absolute);\n // A directory with no real path is one that cannot be listed either, so\n // a mutant that reads it rather than returning reads nothing more.\n const real = await realpath(absolute).catch(() => null);\n if (real === null || inside.has(real)) return;\n inside.add(real);\n await read(relative, absolute);\n inside.delete(real);\n };\n\n const read = async (relative: string, absolute: string): Promise<void> => {\n let entries;\n try {\n entries = await readdir(absolute, { withFileTypes: true });\n } catch {\n // An unreadable directory is not a reason to fail the whole run.\n return;\n }\n\n for (const entry of entries) {\n const child = relative.length === 0 ? entry.name : `${relative}/${entry.name}`;\n\n if (entry.isDirectory()) {\n if (!pruned(entry.name, child)) await walk(child);\n continue;\n }\n\n if (entry.isSymbolicLink()) {\n if (!options.followSymlinks) continue;\n try {\n const info = await stat(`${root}/${child}`);\n if (info.isDirectory()) {\n if (!pruned(entry.name, child)) await walk(child);\n continue;\n }\n if (!patterns.match(child) || excluded(child) || info.size > maxSize) continue;\n out.set(child, { path: child, absolute: `${root}/${child}`, size: info.size });\n } catch {\n // A link to nothing has nothing to read.\n }\n continue;\n }\n\n if (!entry.isFile()) continue;\n if (!patterns.match(child) || excluded(child)) continue;\n\n try {\n const info = await stat(`${root}/${child}`);\n if (info.size > maxSize) continue;\n out.set(child, { path: child, absolute: `${root}/${child}`, size: info.size });\n } catch {\n // Gone between the listing and the look: there is nothing to read.\n }\n }\n };\n\n for (const base of bases) {\n const above = startable(base) ? await reachable(root, base, options.followSymlinks) : null;\n if (above === null) continue;\n inside = above;\n await walk(base);\n }\n\n // No two paths are equal, since they are the keys of `out`, so the order\n // needs only `<`, and `<=` would read the same.\n return [...out.values()].sort((a, b) => (a.path < b.path ? -1 : 1));\n}\n\n/**\n * Resolves a repository-relative path against the root, in POSIX form.\n *\n * An absolute path already names one place, and joining it under the root names\n * another: `--baseline /tmp/b.json` read `<root>/tmp/b.json`, found nothing\n * there, and accepted nothing without saying so.\n */\nexport function underRoot(root: string, relative: string): string {\n if (isAbsolutePath(relative)) return toPosix(relative);\n return joinPosix(toPosix(root), relative);\n}\n"]}
1
+ {"version":3,"file":"glob.js","sourceRoot":"","sources":["../src/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE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C,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,IAAI,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YACjF,CAAC;YAAC,MAAM,CAAC;gBACP,mEAAmE;YACrE,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3F,IAAI,KAAK,KAAK,IAAI;YAAE,SAAS;QAC7B,MAAM,GAAG,KAAK,CAAC;QACf,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,yEAAyE;IACzE,gDAAgD;IAChD,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,QAAgB;IACtD,IAAI,cAAc,CAAC,QAAQ,CAAC;QAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvD,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/**\n * Pattern matching and directory walking.\n *\n * The patterns are the `path` dialect every spec-* tool reads, from spec-core:\n * `**`, `*`, `?`, `{a,b}`, `[abc]` and `[!a-z]`, matched against whole\n * repository-relative POSIX paths by an automaton that cannot backtrack, with\n * case respected on every host (ADR-0022). What stays here is spec-graph's own:\n * how a list with `!` entries in it reads, which directories a walk never\n * enters, and how a reference target - which is not a path - is matched.\n */\n\nimport type { Dirent } from 'node:fs';\nimport { readdir, realpath, stat } from 'node:fs/promises';\n\nimport { isAbsolutePath, joinPosix, toPosix } from './paths.js';\nimport {\n compileGlob as compileFamilyGlob,\n GlobError,\n isGlobSyntax,\n parseGlob,\n parseGlobList,\n rebaseGlob,\n type Glob,\n type GlobList,\n type GlobOptions as FamilyGlobOptions,\n type RegexMatcher,\n} from './vendor/spec-core/pattern/index.js';\n\n/** Directories skipped unless a pattern explicitly names them. */\nexport const DEFAULT_IGNORED_DIRECTORIES: readonly string[] = Object.freeze([\n '.git',\n '.hg',\n '.svn',\n '.cache',\n '.next',\n '.nuxt',\n '.turbo',\n '.venv',\n 'node_modules',\n 'bower_components',\n 'vendor',\n 'dist',\n 'build',\n 'out',\n 'target',\n 'coverage',\n '__pycache__',\n]);\n\n/** Files larger than this are skipped: a specification is not a binary. */\nexport const MAX_FILE_SIZE = 4 * 1024 * 1024;\n\nexport interface WalkedFile {\n /** Repository-relative POSIX path. */\n readonly path: string;\n /** Absolute host path, for reading. */\n readonly absolute: string;\n readonly size: number;\n}\n\nexport interface WalkOptions {\n readonly root: string;\n readonly patterns: readonly string[];\n readonly ignore?: readonly string[] | undefined;\n readonly maxFileSize?: number | undefined;\n /**\n * Follow links. Off by default: a link can lead out of the repository. A\n * link back into a directory the walk is inside is never followed.\n */\n readonly followSymlinks?: boolean | undefined;\n}\n\n/**\n * How a path pattern is read everywhere in spec-graph.\n *\n * A literal names a file or a directory and everything beneath it, which is\n * what `--ignore docs/drafts` has always meant. A `\\` is a separator, because a\n * pattern typed on a Windows shell arrives with them and spec-graph has always\n * read them that way; it cannot also be an escape.\n */\nconst PATH: FamilyGlobOptions = { dialect: 'path', caseSensitive: true, literal: 'either', backslash: 'separator' };\n\n/** True when the string contains glob syntax rather than being a literal path. */\nexport function isGlob(pattern: string): boolean {\n return isGlobSyntax(pattern);\n}\n\n/**\n * Compiles a glob to an anchored regular expression, in the dialect spec-graph\n * read before it adopted spec-core's.\n *\n * @deprecated Nothing matches with this. It stays for callers who want a\n * `RegExp`, and as the record of the old reading that `tests/glob.test.ts`\n * holds every difference against, each one named in ADR-0022. It no longer\n * folds case on Windows alone: an answer must not depend on the host.\n */\nexport function globToRegExp(pattern: string): RegExp {\n return new RegExp(`^${globSource(pattern)}$`);\n}\n\nexport interface GlobOptions {\n /** Fold case. Off unless asked for, on every host. */\n readonly ignoreCase?: boolean | undefined;\n}\n\n/**\n * Compiles one glob to a matcher over whole repository-relative paths.\n *\n * A pattern with no glob syntax names that path and nothing beneath it; a bare\n * directory meaning its contents is a reading of {@link createGlobMatcher}'s.\n * Throws a `GlobError` that names the glob as it was written.\n *\n * Matching is linear in the path whatever the pattern. It was not always: a\n * glob's stars are not nested, but each is a `[^/]*` to `RegExp`, and a subject\n * that fails is divided between them every way there is - `*-*-*-x` took two\n * minutes over a 10,000-character reference target (ADR-0017).\n */\nexport function compileGlob(pattern: string, options: GlobOptions = {}): RegexMatcher {\n // `literal: 'file'` is the dialect's reading of any value but `directory`\n // and `either`, so a mutant that blanks it reads the same. It is spelled out\n // because what an unknown value means is spec-core's to change.\n const glob = compileFamilyGlob(pattern, { ...PATH, literal: 'file', caseSensitive: options.ignoreCase !== true });\n return { test: (path) => glob.match(path), size: glob.automaton.kinds.length };\n}\n\n/** The expression a glob stood for before 0.9.0, before anchors and flags. */\nfunction globSource(pattern: string): string {\n let source = '';\n let i = 0;\n const braces: number[] = [];\n\n while (i < pattern.length) {\n const ch = pattern[i] as string;\n\n if (ch === '*') {\n const doubled = pattern[i + 1] === '*';\n if (doubled) {\n const slashAfter = pattern[i + 2] === '/';\n // `a/**/b` must also match `a/b`, so the separator is folded in.\n source += slashAfter ? '(?:.*/)?' : '.*';\n i += slashAfter ? 3 : 2;\n } else {\n source += '[^/]*';\n i += 1;\n }\n continue;\n }\n\n if (ch === '?') {\n source += '[^/]';\n i += 1;\n continue;\n }\n\n if (ch === '[') {\n const close = pattern.indexOf(']', i + 1);\n if (close === -1) {\n source += '\\\\[';\n i += 1;\n continue;\n }\n const body = pattern.slice(i + 1, close);\n source += `[${body.startsWith('!') ? `^${escapeClass(body.slice(1))}` : escapeClass(body)}]`;\n i = close + 1;\n continue;\n }\n\n if (ch === '{') {\n braces.push(source.length);\n source += '(?:';\n i += 1;\n continue;\n }\n if (ch === '}' && braces.length > 0) {\n braces.pop();\n source += ')';\n i += 1;\n continue;\n }\n if (ch === ',' && braces.length > 0) {\n source += '|';\n i += 1;\n continue;\n }\n\n source += ch.replace(/[.+^${}()|[\\]\\\\]/g, '\\\\$&');\n i += 1;\n }\n\n // Otherwise reported as an unmatched parenthesis, in a glob that has none.\n if (braces.length > 0) throw new Error(`invalid glob \"${pattern}\": unclosed \"{\"`);\n return source;\n}\n\nfunction escapeClass(body: string): string {\n return body.replace(/[\\\\^\\]]/g, '\\\\$&');\n}\n\nexport interface GlobMatcher {\n (path: string): boolean;\n}\n\n/** Compiles a list of path patterns, or throws naming the one that is not a glob. */\nfunction pathList(patterns: readonly string[]): GlobList {\n const parsed = parseGlobList(patterns, PATH);\n if (!parsed.ok) throw new Error(`invalid glob ${parsed.error}`);\n return parsed.list;\n}\n\n/**\n * Builds a matcher from include patterns, honouring `!` negations.\n *\n * Later patterns win, so `docs/**\\/*.md` followed by `!docs/drafts/**` reads the\n * way a `.gitignore` does. A pattern with no glob syntax in it names a file, or\n * a directory and everything beneath it; `docs/` names only what is beneath.\n */\nexport function createGlobMatcher(patterns: readonly string[]): GlobMatcher {\n const list = pathList(patterns);\n return (path: string): boolean => list.match(path);\n}\n\n/**\n * A list entry typed in `directory`, below the root, rewritten to read from the\n * root, or refused naming the entry as it was typed (ADR-0018).\n *\n * Each brace alternative is rebased as that text written alone would be, so\n * `{/docs,x}` typed in `sub` is `{/docs,sub/x}`: a leading `/` roots it\n * wherever it was typed. A leading `..` climbs out of `directory`, and one past\n * the root is refused, as is a directory whose name a pattern would read as\n * syntax.\n */\nexport function rebasePattern(entry: string, directory: string): string {\n const rebased = rebaseGlob(entry, directory, PATH);\n if (!rebased.ok) throw new GlobError(entry, rebased.error);\n return rebased.pattern;\n}\n\n/**\n * Each dot in a reference pattern that may begin a segment, which is escaped:\n * a `.` or `..` segment then reads as the name it is, one or two dots, where\n * the dialect would drop the one and refuse the other.\n *\n * Braces expand before segments are read, so a dot written beside a brace or a\n * comma may begin a segment of an alternative: `docs/{.,x}` is `docs/.` or\n * `docs/x`, `.{/gone.md,x}` is `./gone.md` or `.x`, and `{docs/,x/}.` ends in a\n * segment `.` either way. An escaped dot is the same character as a dot in a\n * name, so escaping one that begins `.x`, or the braces leave inside a name as\n * in `a{.,b}`, reads the same, and nothing needs to tell those apart:\n * escaping each whole `.` or `..` segment instead reads each of 43,069\n * generated patterns the same, refusals included (ADR-0022).\n */\nconst SEGMENT_DOT = /(?<=^|[/{,}])\\./g;\n\n/**\n * How a reference target is matched. Every option is spelled out, though the\n * dialect reads `{}` the same way today: its defaults are spec-core's to\n * change, and this reading is spec-graph's to keep. A mutant that drops one,\n * or all of them, is equivalent until then.\n */\nconst TARGET: FamilyGlobOptions = { dialect: 'path', caseSensitive: false, literal: 'file' };\n\n/**\n * A refusal of a reference pattern in the words it was typed in.\n *\n * The dialect writes its advice for a `**` inside a name from the text it was\n * given, and that text held a `\\` before each dot {@link SEGMENT_DOT} escaped:\n * `../notes/**.md` was told `\\.\\./notes/**\\/*.md`. Given the pattern again with\n * a character it does not hold in place of each of those dots, the dialect\n * refuses it for the same reason, since both are one literal character and\n * neither is a direction, and each stand-in is read back as the dot it was.\n * Counting down from U+E000 would find a stand-in as well, among the\n * surrogates, so that mutant is equivalent.\n */\nfunction asTyped(typed: string, reason: string): string {\n let point = 0xe000;\n while (typed.includes(String.fromCodePoint(point))) point += 1;\n const stand = String.fromCodePoint(point);\n const again = parseGlob(typed.replace(SEGMENT_DOT, stand), TARGET);\n // Stand-ins and escaped dots compile or fail alike, so `again` never\n // compiles here, and a mutant that reads it as compiled is equivalent.\n return again.ok ? reason : again.error.replaceAll(stand, '.');\n}\n\n/**\n * Builds a predicate over reference *targets*, not paths.\n *\n * Separate from {@link createGlobMatcher} on purpose. That one is\n * path-oriented: a bare name there is a directory and everything under it. A\n * reference target has no such structure - `trap 55` is a name, not a location\n * - so a bare pattern matches it literally and nothing else.\n *\n * Case is ignored, on every platform, because a citation's spelling is the\n * author's and not the filesystem's. The fold is simple case mapping, one code\n * point at a time and without a locale, so every host gives the same answer:\n * U+00B5 (micro sign) and U+03BC (mu) stay two targets, as they have been since\n * a Windows-only `i` flag made them one there (ADR-0017).\n *\n * A target is text a document holds rather than a path on this host, and two\n * things follow. A `\\` escapes the character after it: there is no Windows\n * separator to allow for. And a `.` or `..` segment is text, in a brace\n * alternative as anywhere else: in a path the dialect drops the one and\n * refuses the other as climbing out of the root, but `../../notes/gone.md` is\n * a link somebody wrote and may want left alone. A pattern that is refused is\n * named, and advised, as it was typed.\n */\nexport function createReferenceFilter(patterns: readonly string[]): (target: string) => boolean {\n // A blank pattern reaches the dialect, which refuses it, as every pattern\n // spec-graph reads is refused when it names nothing. It used to be dropped,\n // so an unset variable in `--ignore-ref \"$TAGS\"` went unnoticed.\n const globs: Glob[] = patterns.map((pattern) => {\n const typed = pattern.trim();\n const parsed = parseGlob(typed.replace(SEGMENT_DOT, '\\\\.'), TARGET);\n if (!parsed.ok) throw new GlobError(pattern, asTyped(typed, parsed.error));\n return parsed.glob;\n });\n return (target: string): boolean => {\n const value = target.trim();\n return globs.some((glob) => glob.match(value));\n };\n}\n\n/**\n * The literal directory a pattern's matches all sit under, or `''` for the root.\n *\n * `{docs,specs}/**` has two, and this is the directory they share; the walk\n * itself starts at each.\n */\nexport function globBase(pattern: string): string {\n const { glob } = pathList([pattern]).entries[0]!;\n const bases = glob.bases.map((base) => base.split('/'));\n const shared = bases[0] as string[];\n let length = shared.length;\n for (const base of bases) {\n let same = 0;\n // `<=` would read one past the end, where both sides are undefined and\n // equal, and slice the same prefix: an equivalent mutant, left untested.\n while (same < length && base[same] === shared[same]) same += 1;\n length = same;\n }\n return shared.slice(0, length).join('/');\n}\n\n/**\n * Whether a base names directories the walk from the root would reach, each\n * with exactly that spelling and none a link it would not follow.\n *\n * A walk starts where a pattern's literal prefix points rather than at the\n * root, and on a filesystem that ignores case, `readdir('Docs')` lists `docs`.\n * Every file under it would come back spelled `Docs/...` - a node id, a\n * baseline key - and `Docs/**` would find it on Windows and macOS and nothing\n * on Linux. Asking each parent for the name gives git's answer on every host. A\n * base with an empty segment is rooted at `/`, which is never inside the root.\n *\n * Reading a directory by its path follows every link in the path, so\n * `docs/linked/*.md` was read through the link `docs/linked`, which the walk\n * from the root passes over. Asking each parent for the entry says which it\n * is, and a base beyond a link is left as silently as the walk leaves the link.\n *\n * Where links are followed, the answer is the real path of each directory\n * above the base, the root included, for the walk to tell a cycle by; a base\n * beyond a link back into one of them is one the walk from the root never\n * reaches, and is left the same way. Where they are not, it is empty and never\n * read, so a mutant that fills it anyway is equivalent. `null` is a base the\n * walk does not start at.\n */\nasync function reachable(root: string, base: string, followSymlinks: boolean | undefined): Promise<Set<string> | null> {\n const above = new Set<string>();\n if (base.length === 0) return above;\n let directory = root;\n for (const segment of base.split('/')) {\n let entries: Dirent[];\n try {\n entries = await readdir(directory, { withFileTypes: true });\n } catch {\n // Answering a set here would change nothing a test can see: the walk\n // would then read a directory beneath this one, fail the same way, and\n // find nothing.\n return null;\n }\n const entry = entries.find((candidate) => candidate.name === segment);\n if (entry === undefined || (entry.isSymbolicLink() && !followSymlinks)) return null;\n if (followSymlinks) {\n // The directory was just listed, so asking for its real path fails only\n // where it went in between, and the walk would find nothing there: a\n // mutant that answers otherwise is equivalent.\n const real = await realpath(directory).catch(() => null);\n if (real === null || above.has(real)) return null;\n above.add(real);\n }\n directory = `${directory}/${segment}`;\n }\n return above;\n}\n\n/**\n * Walks the tree and returns every file matching the patterns.\n *\n * Directories are pruned as early as possible: a repository with a 2 GB\n * `node_modules` should cost nothing to scan.\n */\nexport async function walkFiles(options: WalkOptions): Promise<WalkedFile[]> {\n const root = toPosix(options.root).replace(/\\/+$/, '');\n const patterns = pathList(options.patterns);\n const maxSize = options.maxFileSize ?? MAX_FILE_SIZE;\n\n // Ignores come in two shapes and both are documented. A bare name prunes any\n // directory called that, at any depth, the way a `.gitignore` line does.\n // Anything carrying a separator or glob syntax is matched against the\n // repository-relative path, which is what `--ignore \"docs/drafts/**\"` means -\n // and treating that as a directory name silently excluded nothing at all.\n // A mutant that defaults this to `['Stryker was here']` prunes directories of\n // that name, which no repository has: equivalent, and left untested.\n const ignores = options.ignore ?? [];\n // The empty pattern is no directory's name, so it goes to the dialect, which\n // refuses it as it refuses an empty include: a pattern that names nothing is\n // a typo or an unset variable, and was an ignore that ignored nothing. So\n // does a blank one, which was read as a directory called \" \".\n const plainName = (pattern: string): boolean =>\n pattern.trim().length > 0 && !isGlob(pattern) && !pattern.includes('/') && !pattern.startsWith('!');\n // A `!` before a name gives the name back, as a `.gitignore` line does, and\n // the last bare entry to name a directory decides whether it is pruned. It\n // was read as a directory called `!docs`, so `--ignore docs --ignore \"!docs\"`\n // pruned `docs` and said nothing. The default list is a list of names too,\n // and gives way to one: `--ignore \"!vendor\"` reads every `vendor`. A `!` alone\n // or before another is no name, and goes to the dialect, which refuses both.\n const bare = (pattern: string): boolean => plainName(pattern) || (pattern.startsWith('!') && plainName(pattern.slice(1)));\n const named = new Map<string, boolean>();\n for (const pattern of ignores.filter(bare)) {\n const negated = pattern.startsWith('!');\n named.set(negated ? pattern.slice(1) : pattern, !negated);\n }\n const skippedByDefault = new Set(DEFAULT_IGNORED_DIRECTORIES);\n const ignoreList = pathList(ignores.filter((pattern) => !bare(pattern)));\n const excluded = (path: string): boolean => ignoreList.match(path);\n\n // Only walk the directories the patterns can possibly reach: each pattern's\n // literal prefix, one per brace alternative. A negated pattern adds none: it\n // takes files back, and starting a walk at its prefix would enter what the\n // walk skips - `!node_modules/**/*.txt` beside `**/*.md` would read every\n // Markdown file in `node_modules`. No positive pattern at all walks nothing,\n // which is the answer.\n const bases = new Set<string>();\n // The paths a positive pattern names outright: `docs/vendor`, or each literal\n // a brace expands to. Such a name may be a file, so its walk starts in the\n // directory above, which pruned `vendor` on its way in: `docs/vendor` found\n // nothing where `docs/vendor/` read the directory. The default list gives way\n // to the directory a pattern names as it gives way to one a pattern starts\n // inside. A negated name adds none, for the reason it adds no base.\n const literals = new Set<string>();\n for (const entry of patterns.entries) {\n if (entry.negated) continue;\n for (const base of entry.glob.bases) bases.add(base);\n // The dialect is what knows a literal when it reads one, so each pattern\n // is compiled a second time to be told of them. That glob is thrown away:\n // the reading answered here decides nothing, and a mutant that changes it\n // is equivalent.\n parseGlob(entry.glob.source, {\n ...PATH,\n literal: (path) => {\n literals.add(path);\n return 'either';\n },\n });\n }\n // Every base is walked, even one inside another, because the outer walk\n // prunes `vendor` and the rest of the default list on its way down, and a\n // pattern that starts inside one of those is read from there. Dropping the\n // inner base as already covered meant `docs/**/*.md` beside\n // `docs/vendor/specs/*.md` found less than the second pattern alone. An\n // `--ignore` is not overruled that way: it is the user's. A walk that starts\n // at a base never passed through the directories above it, so each of them,\n // and the base, is asked what the walk from the root would have asked on its\n // way down. A bare name prunes at any depth - `--ignore adr` still takes out\n // `adr/`, which the default `adr/**/*.md` starts inside - and a path takes\n // out what it matches, so under `--ignore \"docs/*\"` `docs/drafts/**/*.md`\n // finds what `docs/**/*.md` finds, which is nothing there. The root is not\n // asked, as the walk from it never asks: `*` matches the empty path, and\n // `**/*.md` under `--ignore \"*\" --ignore \"!{docs,specs}\"` would read nothing\n // where it reads those two.\n const startable = (base: string): boolean => {\n if (base.length === 0) return true;\n const segments = base.split('/');\n return !segments.some((segment, i) => named.get(segment) === true || excluded(segments.slice(0, i + 1).join('/')));\n };\n // Whether the walk leaves a directory it meets, asked of a followed link to\n // one as well: a link called `node_modules`, which pnpm writes, or one an\n // `--ignore` names, is the directory it leads to under that name and path,\n // and was entered whatever they were. Pruning a whole subtree is an\n // optimisation; a pattern that only matches the files inside it is still\n // honoured when they are filtered. A bare `--ignore` name prunes a directory\n // a pattern names as well: only the default list gives way, to a pattern and\n // to a `!` before its name.\n const pruned = (name: string, path: string): boolean =>\n (named.get(name) ?? (skippedByDefault.has(name) && !literals.has(path))) || excluded(path);\n const out = new Map<string, WalkedFile>();\n // Where two walks overlap, whichever reaches a directory first reads it and\n // the other stops there. Reading it twice would find the same files under\n // the same keys, so the two mutants that drop this are equivalent.\n const visited = new Set<string>();\n // Where links are followed, the real path of each directory from the root to\n // the one being read. A link whose real path is among them leads back into a\n // directory the walk is inside, and following it read the same files again\n // under a longer path each time round, until the host refused the path: on\n // Windows, 64 copies of each. It is passed over as silently as a link is\n // when links are not followed. A link to anywhere else is followed, one to a\n // directory the walk has already read beside this one included, since only\n // a directory on the way here can make a cycle. The walks run one at a time,\n // so one set serves them all. Only a followed link can make a cycle, so with\n // links not followed no real path is asked for, and a mutant that asks finds\n // none: equivalent.\n let inside = new Set<string>();\n\n const walk = async (relative: string): Promise<void> => {\n const absolute = relative.length === 0 ? root : `${root}/${relative}`;\n if (visited.has(absolute)) return;\n visited.add(absolute);\n if (!options.followSymlinks) return read(relative, absolute);\n // A directory with no real path is one that cannot be listed either, so\n // a mutant that reads it rather than returning reads nothing more.\n const real = await realpath(absolute).catch(() => null);\n if (real === null || inside.has(real)) return;\n inside.add(real);\n await read(relative, absolute);\n inside.delete(real);\n };\n\n const read = async (relative: string, absolute: string): Promise<void> => {\n let entries;\n try {\n entries = await readdir(absolute, { withFileTypes: true });\n } catch {\n // An unreadable directory is not a reason to fail the whole run.\n return;\n }\n\n for (const entry of entries) {\n const child = relative.length === 0 ? entry.name : `${relative}/${entry.name}`;\n\n if (entry.isDirectory()) {\n if (!pruned(entry.name, child)) await walk(child);\n continue;\n }\n\n if (entry.isSymbolicLink()) {\n if (!options.followSymlinks) continue;\n try {\n const info = await stat(`${root}/${child}`);\n if (info.isDirectory()) {\n if (!pruned(entry.name, child)) await walk(child);\n continue;\n }\n if (!patterns.match(child) || excluded(child) || info.size > maxSize) continue;\n out.set(child, { path: child, absolute: `${root}/${child}`, size: info.size });\n } catch {\n // A link to nothing has nothing to read.\n }\n continue;\n }\n\n if (!entry.isFile()) continue;\n if (!patterns.match(child) || excluded(child)) continue;\n\n try {\n const info = await stat(`${root}/${child}`);\n if (info.size > maxSize) continue;\n out.set(child, { path: child, absolute: `${root}/${child}`, size: info.size });\n } catch {\n // Gone between the listing and the look: there is nothing to read.\n }\n }\n };\n\n for (const base of bases) {\n const above = startable(base) ? await reachable(root, base, options.followSymlinks) : null;\n if (above === null) continue;\n inside = above;\n await walk(base);\n }\n\n // No two paths are equal, since they are the keys of `out`, so the order\n // needs only `<`, and `<=` would read the same.\n return [...out.values()].sort((a, b) => (a.path < b.path ? -1 : 1));\n}\n\n/**\n * Resolves a repository-relative path against the root, in POSIX form.\n *\n * An absolute path already names one place, and joining it under the root names\n * another: `--baseline /tmp/b.json` read `<root>/tmp/b.json`, found nothing\n * there, and accepted nothing without saying so.\n */\nexport function underRoot(root: string, relative: string): string {\n if (isAbsolutePath(relative)) return toPosix(relative);\n return joinPosix(toPosix(root), relative);\n}\n"]}
package/dist/graph.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"graph.js","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuCzC,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,KAG1B;IACC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,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,GAAwB,MAAM,CAAC,MAAM,CAC/D,MAAM,CAAC,IAAI,CAAC,WAAW,CAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,mBAAmB,CAAC,CACjG,CAAC;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAwB,MAAM,CAAC,MAAM,CACjE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CACzF,CAAC","sourcesContent":["/**\n * The specification graph.\n *\n * An immutable, fully indexed view over the resolved corpus. Construction pays\n * for adjacency in both directions once so that every rule, query and report is\n * a lookup rather than a scan - the difference between a linter that runs on\n * every save and one that gets moved to a nightly job and then ignored.\n *\n * The algorithms here are the ones the rules genuinely need and no more:\n * adjacency, reachability, and Tarjan's strongly connected components for\n * finding circular delegations.\n */\n\nimport type { DocumentNode, Edge, EdgeKind, ItemNode, SpecNode } from './types.js';\nimport { EDGE_TRAITS } from './types.js';\n\nexport interface SpecGraph {\n readonly nodes: ReadonlyMap<string, SpecNode>;\n readonly edges: readonly Edge[];\n readonly documents: readonly DocumentNode[];\n readonly items: readonly ItemNode[];\n\n node(id: string): SpecNode | undefined;\n document(id: string): DocumentNode | undefined;\n /** The document a node belongs to: itself, or the item's owner. */\n owningDocument(id: string): DocumentNode | undefined;\n itemsOf(documentId: string): readonly ItemNode[];\n\n /** Edges leaving `id`, optionally filtered by kind. */\n out(id: string, kinds?: readonly EdgeKind[]): readonly Edge[];\n /** Edges entering `id`, optionally filtered by kind. */\n in(id: string, kinds?: readonly EdgeKind[]): readonly Edge[];\n\n /**\n * Every node reachable from `id` over the given edge kinds, with the shortest\n * path to each. `id` itself is included only when a cycle returns to it.\n */\n reach(id: string, kinds: readonly EdgeKind[]): ReadonlyMap<string, readonly Edge[]>;\n\n /**\n * Strongly connected components with more than one member, over the given\n * edge kinds, and each node with an edge to itself as a component of one.\n * Each is a real cycle.\n *\n * With `byDocument`, relations are projected onto the documents that own\n * their endpoints before the search. That is what catches two documents\n * ping-ponging one obligation: the delegation runs item -> document in each\n * direction, so there is no cycle among the raw nodes even though the two\n * documents are plainly passing the same question back and forth.\n */\n cycles(kinds: readonly EdgeKind[], options?: { byDocument?: boolean }): readonly (readonly string[])[];\n}\n\n/** Builds the graph. Edges naming an unknown node are dropped, not stored. */\nexport function buildGraph(input: {\n readonly nodes: ReadonlyMap<string, SpecNode>;\n readonly edges: readonly Edge[];\n}): SpecGraph {\n const nodes = input.nodes;\n const edges = input.edges.filter((edge) => nodes.has(edge.from) && nodes.has(edge.to));\n\n const outgoing = new Map<string, Edge[]>();\n const incoming = new Map<string, Edge[]>();\n for (const edge of edges) {\n push(outgoing, edge.from, edge);\n push(incoming, edge.to, edge);\n }\n\n const documents: DocumentNode[] = [];\n const items: ItemNode[] = [];\n const itemsByDocument = new Map<string, ItemNode[]>();\n for (const node of nodes.values()) {\n if (node.kind === 'document') documents.push(node);\n else {\n items.push(node);\n push(itemsByDocument, node.document, node);\n }\n }\n\n const filter = (list: readonly Edge[] | undefined, kinds?: readonly EdgeKind[]): readonly Edge[] => {\n if (!list) return EMPTY_EDGES;\n if (!kinds || kinds.length === 0) return list;\n return list.filter((edge) => kinds.includes(edge.kind));\n };\n\n const graph: SpecGraph = {\n nodes,\n edges,\n documents,\n items,\n\n node: (id) => nodes.get(id),\n document: (id) => {\n const found = nodes.get(id);\n return found?.kind === 'document' ? found : undefined;\n },\n owningDocument: (id) => {\n const found = nodes.get(id);\n if (!found) return undefined;\n if (found.kind === 'document') return found;\n // An item's document is a document, or is missing from a graph built\n // from some documents and not others - never an item. So the check only\n // narrows the type, and its mutant is equivalent.\n const owner = nodes.get(found.document);\n return owner?.kind === 'document' ? owner : undefined;\n },\n itemsOf: (documentId) => itemsByDocument.get(documentId) ?? EMPTY_ITEMS,\n\n out: (id, kinds) => filter(outgoing.get(id), kinds),\n in: (id, kinds) => filter(incoming.get(id), kinds),\n\n reach(id, kinds) {\n const paths = new Map<string, readonly Edge[]>();\n const queue: string[] = [id];\n const pathTo = new Map<string, readonly Edge[]>([[id, EMPTY_EDGES]]);\n\n while (queue.length > 0) {\n const current = queue.shift() as string;\n const prefix = pathTo.get(current) as readonly Edge[];\n for (const edge of filter(outgoing.get(current), kinds)) {\n if (pathTo.has(edge.to) && edge.to !== id) continue;\n const path = [...prefix, edge];\n if (edge.to === id) {\n // A cycle back to the origin: record it, but do not re-expand.\n if (!paths.has(id)) paths.set(id, path);\n continue;\n }\n pathTo.set(edge.to, path);\n paths.set(edge.to, path);\n queue.push(edge.to);\n }\n }\n return paths;\n },\n\n cycles(kinds, options) {\n const relevant = (id: string): Edge[] => [...filter(outgoing.get(id), kinds)];\n if (!options?.byDocument) {\n return tarjan([...nodes.keys()], (id) => relevant(id).map((edge) => edge.to));\n }\n const ownerOf = (id: string): string => graph.owningDocument(id)?.id ?? id;\n const projected = new Map<string, Set<string>>();\n for (const node of nodes.values()) {\n for (const edge of relevant(node.id)) {\n const from = ownerOf(edge.from);\n const to = ownerOf(edge.to);\n // A relation that stays inside one document is a self-reference, not\n // a cycle, and has a rule of its own.\n if (from === to) continue;\n const set = projected.get(from) ?? new Set<string>();\n set.add(to);\n projected.set(from, set);\n }\n }\n return tarjan(\n documents.map((document) => document.id),\n (id) => [...(projected.get(id) ?? [])],\n );\n },\n };\n\n return graph;\n}\n\nconst EMPTY_EDGES: readonly Edge[] = Object.freeze([]);\nconst EMPTY_ITEMS: readonly ItemNode[] = Object.freeze([]);\n\nfunction push<T>(map: Map<string, T[]>, key: string, value: T): void {\n const list = map.get(key);\n if (list) list.push(value);\n else map.set(key, [value]);\n}\n\n/* -------------------------------------------------------------------------- */\n/* Cycles */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Tarjan's strongly connected components, iterative.\n *\n * Iterative rather than recursive because a monorepo's reference graph can be\n * deep enough to blow the call stack, and a linter that crashes on the largest\n * repository in the company is a linter nobody trusts on the small ones either.\n *\n * Takes a successor function so the same search serves both the raw graph and\n * the document-level projection.\n */\nfunction tarjan(ids: readonly string[], successors: (id: string) => string[]): string[][] {\n const indexOf = new Map<string, number>();\n const lowLink = new Map<string, number>();\n const onStack = new Set<string>();\n // A component is popped down to its own root and no further, so nothing\n // beneath the first root pushed is ever popped: a stack that starts with\n // something in it is an equivalent mutant.\n const stack: string[] = [];\n const components: string[][] = [];\n let counter = 0;\n\n for (const root of ids) {\n if (indexOf.has(root)) continue;\n\n const work: { id: string; next: number; children: string[] }[] = [\n { id: root, next: 0, children: successors(root) },\n ];\n indexOf.set(root, counter);\n lowLink.set(root, counter);\n counter += 1;\n stack.push(root);\n onStack.add(root);\n\n while (work.length > 0) {\n const frame = work[work.length - 1] as { id: string; next: number; children: string[] };\n // `<=` reads one child past the end: `undefined`, a node with no\n // successors that is settled on its own at once and is in no cycle. That\n // mutant is equivalent.\n if (frame.next < frame.children.length) {\n const child = frame.children[frame.next] as string;\n frame.next += 1;\n if (!indexOf.has(child)) {\n indexOf.set(child, counter);\n lowLink.set(child, counter);\n counter += 1;\n stack.push(child);\n onStack.add(child);\n work.push({ id: child, next: 0, children: successors(child) });\n } else if (onStack.has(child)) {\n lowLink.set(frame.id, Math.min(lowLink.get(frame.id) as number, indexOf.get(child) as number));\n }\n continue;\n }\n\n work.pop();\n const parent = work[work.length - 1];\n if (parent) {\n lowLink.set(parent.id, Math.min(lowLink.get(parent.id) as number, lowLink.get(frame.id) as number));\n }\n\n if (lowLink.get(frame.id) === indexOf.get(frame.id)) {\n const component: string[] = [];\n for (;;) {\n const popped = stack.pop() as string;\n onStack.delete(popped);\n component.push(popped);\n if (popped === frame.id) break;\n }\n if (component.length > 1) components.push(component.reverse());\n else if (successors(frame.id).includes(frame.id)) components.push(component);\n }\n }\n }\n\n return components;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Derived predicates */\n/* -------------------------------------------------------------------------- */\n\n/** Edge kinds that move an obligation from one document to another. */\nexport const OBLIGATION_EDGES: readonly EdgeKind[] = Object.freeze(\n (Object.keys(EDGE_TRAITS) as EdgeKind[]).filter((kind) => EDGE_TRAITS[kind].transfersObligation),\n);\n\n/** Edge kinds whose source depends on what the target says. */\nexport const LOAD_BEARING_EDGES: readonly EdgeKind[] = Object.freeze(\n (Object.keys(EDGE_TRAITS) as EdgeKind[]).filter((kind) => EDGE_TRAITS[kind].loadBearing),\n);\n"]}
1
+ {"version":3,"file":"graph.js","sourceRoot":"","sources":["../src/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAuCzC,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,KAG1B;IACC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAEvF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC3C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,MAAM,eAAe,GAAG,IAAI,GAAG,EAAsB,CAAC;IACtD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE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AC,EAAE,CAAC;gBACpD,MAAM,SAAS,GAAa,EAAE,CAAC;gBAC/B,SAAS,CAAC;oBACR,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,EAAY,CAAC;oBACrC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBACvB,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACvB,IAAI,MAAM,KAAK,KAAK,CAAC,EAAE;wBAAE,MAAM;gBACjC,CAAC;gBACD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;oBAAE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC;qBAC1D,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBAAE,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC/E,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAEhF,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAAwB,MAAM,CAAC,MAAM,CAC/D,MAAM,CAAC,IAAI,CAAC,WAAW,CAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,mBAAmB,CAAC,CACjG,CAAC;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAwB,MAAM,CAAC,MAAM,CACjE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAgB,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CACzF,CAAC","sourcesContent":["/**\n * The specification graph.\n *\n * An immutable, fully indexed view over the resolved corpus. Construction pays\n * for adjacency in both directions once so that every rule, query and report is\n * a lookup rather than a scan - the difference between a linter that runs on\n * every save and one that gets moved to a nightly job and then ignored.\n *\n * The algorithms here are the ones the rules genuinely need and no more:\n * adjacency, reachability, and Tarjan's strongly connected components for\n * finding circular delegations.\n */\n\nimport type { DocumentNode, Edge, EdgeKind, ItemNode, SpecNode } from './types.js';\nimport { EDGE_TRAITS } from './types.js';\n\nexport interface SpecGraph {\n readonly nodes: ReadonlyMap<string, SpecNode>;\n readonly edges: readonly Edge[];\n readonly documents: readonly DocumentNode[];\n readonly items: readonly ItemNode[];\n\n node(id: string): SpecNode | undefined;\n document(id: string): DocumentNode | undefined;\n /** The document a node belongs to: itself, or the item's owner. */\n owningDocument(id: string): DocumentNode | undefined;\n itemsOf(documentId: string): readonly ItemNode[];\n\n /** Edges leaving `id`, optionally filtered by kind. */\n out(id: string, kinds?: readonly EdgeKind[]): readonly Edge[];\n /** Edges entering `id`, optionally filtered by kind. */\n in(id: string, kinds?: readonly EdgeKind[]): readonly Edge[];\n\n /**\n * Every node reachable from `id` over the given edge kinds, with the shortest\n * path to each. `id` itself is included only when a cycle returns to it.\n */\n reach(id: string, kinds: readonly EdgeKind[]): ReadonlyMap<string, readonly Edge[]>;\n\n /**\n * Strongly connected components with more than one member, over the given\n * edge kinds, and each node with an edge to itself as a component of one.\n * Each is a real cycle.\n *\n * With `byDocument`, relations are projected onto the documents that own\n * their endpoints before the search. That is what catches two documents\n * ping-ponging one obligation: the delegation runs item -> document in each\n * direction, so there is no cycle among the raw nodes even though the two\n * documents are plainly passing the same question back and forth.\n */\n cycles(kinds: readonly EdgeKind[], options?: { byDocument?: boolean }): readonly (readonly string[])[];\n}\n\n/** Builds the graph. Edges naming an unknown node are dropped, not stored. */\nexport function buildGraph(input: {\n readonly nodes: ReadonlyMap<string, SpecNode>;\n readonly edges: readonly Edge[];\n}): SpecGraph {\n const nodes = input.nodes;\n const edges = input.edges.filter((edge) => nodes.has(edge.from) && nodes.has(edge.to));\n\n const outgoing = new Map<string, Edge[]>();\n const incoming = new Map<string, Edge[]>();\n for (const edge of edges) {\n push(outgoing, edge.from, edge);\n push(incoming, edge.to, edge);\n }\n\n const documents: DocumentNode[] = [];\n const items: ItemNode[] = [];\n const itemsByDocument = new Map<string, ItemNode[]>();\n for (const node of nodes.values()) {\n if (node.kind === 'document') documents.push(node);\n else {\n items.push(node);\n push(itemsByDocument, node.document, node);\n }\n }\n\n const filter = (list: readonly Edge[] | undefined, kinds?: readonly EdgeKind[]): readonly Edge[] => {\n if (!list) return EMPTY_EDGES;\n if (!kinds || kinds.length === 0) return list;\n return list.filter((edge) => kinds.includes(edge.kind));\n };\n\n const graph: SpecGraph = {\n nodes,\n edges,\n documents,\n items,\n\n node: (id) => nodes.get(id),\n document: (id) => {\n const found = nodes.get(id);\n return found?.kind === 'document' ? found : undefined;\n },\n owningDocument: (id) => {\n const found = nodes.get(id);\n if (!found) return undefined;\n if (found.kind === 'document') return found;\n // An item's document is a document, or is missing from a graph built\n // from some documents and not others - never an item. So the check only\n // narrows the type, and its mutant is equivalent.\n const owner = nodes.get(found.document);\n return owner?.kind === 'document' ? owner : undefined;\n },\n itemsOf: (documentId) => itemsByDocument.get(documentId) ?? EMPTY_ITEMS,\n\n out: (id, kinds) => filter(outgoing.get(id), kinds),\n in: (id, kinds) => filter(incoming.get(id), kinds),\n\n reach(id, kinds) {\n const paths = new Map<string, readonly Edge[]>();\n const queue: string[] = [id];\n const pathTo = new Map<string, readonly Edge[]>([[id, EMPTY_EDGES]]);\n\n while (queue.length > 0) {\n const current = queue.shift() as string;\n const prefix = pathTo.get(current) as readonly Edge[];\n for (const edge of filter(outgoing.get(current), kinds)) {\n if (pathTo.has(edge.to) && edge.to !== id) continue;\n const path = [...prefix, edge];\n if (edge.to === id) {\n // A cycle back to the origin: record it, but do not re-expand.\n if (!paths.has(id)) paths.set(id, path);\n continue;\n }\n pathTo.set(edge.to, path);\n paths.set(edge.to, path);\n queue.push(edge.to);\n }\n }\n return paths;\n },\n\n cycles(kinds, options) {\n const relevant = (id: string): Edge[] => [...filter(outgoing.get(id), kinds)];\n if (!options?.byDocument) {\n return tarjan([...nodes.keys()], (id) => relevant(id).map((edge) => edge.to));\n }\n const ownerOf = (id: string): string => graph.owningDocument(id)?.id ?? id;\n const projected = new Map<string, Set<string>>();\n for (const node of nodes.values()) {\n for (const edge of relevant(node.id)) {\n const from = ownerOf(edge.from);\n const to = ownerOf(edge.to);\n // A relation that stays inside one document is a self-reference, not\n // a cycle, and has a rule of its own.\n if (from === to) continue;\n const set = projected.get(from) ?? new Set<string>();\n set.add(to);\n projected.set(from, set);\n }\n }\n return tarjan(\n documents.map((document) => document.id),\n (id) => [...(projected.get(id) ?? [])],\n );\n },\n };\n\n return graph;\n}\n\nconst EMPTY_EDGES: readonly Edge[] = Object.freeze([]);\nconst EMPTY_ITEMS: readonly ItemNode[] = Object.freeze([]);\n\nfunction push<T>(map: Map<string, T[]>, key: string, value: T): void {\n const list = map.get(key);\n if (list) list.push(value);\n else map.set(key, [value]);\n}\n\n/* -------------------------------------------------------------------------- */\n/* Cycles */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Tarjan's strongly connected components, iterative.\n *\n * Iterative rather than recursive because a monorepo's reference graph can be\n * deep enough to blow the call stack, and a linter that crashes on the largest\n * repository in the company is a linter nobody trusts on the small ones either.\n *\n * Takes a successor function so the same search serves both the raw graph and\n * the document-level projection.\n */\nfunction tarjan(ids: readonly string[], successors: (id: string) => string[]): string[][] {\n const indexOf = new Map<string, number>();\n const lowLink = new Map<string, number>();\n const onStack = new Set<string>();\n // A component is popped down to its own root and no further, so nothing\n // beneath the first root pushed is ever popped: a stack that starts with\n // something in it is an equivalent mutant.\n const stack: string[] = [];\n const components: string[][] = [];\n let counter = 0;\n\n for (const root of ids) {\n if (indexOf.has(root)) continue;\n\n const work: { id: string; next: number; children: string[] }[] = [\n { id: root, next: 0, children: successors(root) },\n ];\n indexOf.set(root, counter);\n lowLink.set(root, counter);\n counter += 1;\n stack.push(root);\n onStack.add(root);\n\n while (work.length > 0) {\n const frame = work[work.length - 1]!;\n // `<=` reads one child past the end: `undefined`, a node with no\n // successors that is settled on its own at once and is in no cycle. That\n // mutant is equivalent.\n if (frame.next < frame.children.length) {\n const child = frame.children[frame.next] as string;\n frame.next += 1;\n if (!indexOf.has(child)) {\n indexOf.set(child, counter);\n lowLink.set(child, counter);\n counter += 1;\n stack.push(child);\n onStack.add(child);\n work.push({ id: child, next: 0, children: successors(child) });\n } else if (onStack.has(child)) {\n lowLink.set(frame.id, Math.min(lowLink.get(frame.id) as number, indexOf.get(child) as number));\n }\n continue;\n }\n\n work.pop();\n const parent = work[work.length - 1];\n if (parent) {\n lowLink.set(parent.id, Math.min(lowLink.get(parent.id) as number, lowLink.get(frame.id) as number));\n }\n\n if (lowLink.get(frame.id) === indexOf.get(frame.id)) {\n const component: string[] = [];\n for (;;) {\n const popped = stack.pop() as string;\n onStack.delete(popped);\n component.push(popped);\n if (popped === frame.id) break;\n }\n if (component.length > 1) components.push(component.reverse());\n else if (successors(frame.id).includes(frame.id)) components.push(component);\n }\n }\n }\n\n return components;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Derived predicates */\n/* -------------------------------------------------------------------------- */\n\n/** Edge kinds that move an obligation from one document to another. */\nexport const OBLIGATION_EDGES: readonly EdgeKind[] = Object.freeze(\n (Object.keys(EDGE_TRAITS) as EdgeKind[]).filter((kind) => EDGE_TRAITS[kind].transfersObligation),\n);\n\n/** Edge kinds whose source depends on what the target says. */\nexport const LOAD_BEARING_EDGES: readonly EdgeKind[] = Object.freeze(\n (Object.keys(EDGE_TRAITS) as EdgeKind[]).filter((kind) => EDGE_TRAITS[kind].loadBearing),\n);\n"]}
package/dist/sections.js CHANGED
@@ -64,8 +64,15 @@ const RELATION_COLUMNS = new Map([
64
64
  ['see also', { kind: 'relates-to', inverted: false }],
65
65
  ['references', { kind: 'references', inverted: false }],
66
66
  ]);
67
- /** Cell values that mean "nothing here". */
68
67
  const MARKDOWN_LINK = /!?\[([^\]]*)\]\(([^)]*)\)/g;
68
+ /**
69
+ * Cell values that mean "nothing here".
70
+ *
71
+ * Underscores reach this only out of a link in a relation cell, whose
72
+ * destination or label is kept whole: a template's blank such as
73
+ * `[to be decided](___)`. Everywhere else a cell is flattened first, which
74
+ * takes them out as emphasis.
75
+ */
69
76
  const EMPTY_CELL = /^(?:-+|—|–|n\/?a|none|nil|tbd|\.|_+)$/i;
70
77
  /** `## ADR-0007: Sharding` - an identifier at the very start of a heading. */
71
78
  const HEADING_ID = /^\s*([A-Za-z]{1,15}[\s._-]?\d{1,6})\b/;
@@ -1 +1 @@
1
- {"version":3,"file":"sections.js","sourceRoot":"","sources":["../src/sections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,IAAI,EAAkB,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,cAAc,EACd,aAAa,GAOd,MAAM,eAAe,CAAC;AA+CvB,qDAAqD;AACrD,MAAM,UAAU,GAAG,uFAAuF,CAAC;AAE3G,iDAAiD;AACjD,MAAM,cAAc,GAAG,0CAA0C,CAAC;AAElE,gDAAgD;AAChD,MAAM,aAAa,GAAG,6DAA6D,CAAC;AAEpF;;;;;;;;;;GAUG;AACH,MAAM,gBAAgB,GAA+D,IAAI,GAAG,CAAC;IAC3F,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACvD,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACvD,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACzD,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,CAA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["/**\n * Specification regions: the part of a file that one specification occupies.\n *\n * `spec-graph` began by assuming one specification per file, because that is\n * how MADR, KEPs and Rust RFCs are laid out. Plenty of organisations do not\n * work that way. A register, a whitepaper or a living architecture document\n * holds dozens of decisions in one file, each with its own identifier, its own\n * status and its own dependencies - and to an engine that binds a document to a\n * file, every one of them is invisible.\n *\n * The fix is small once stated: **a specification is a region of a file, not a\n * file.** A file yields at least one region - itself - and may yield more.\n * Everything downstream is unchanged, because a region produces exactly the\n * same `DocumentNode` a whole file produced.\n *\n * What this module decides is where those regions begin and end, and it is\n * deliberately hard to convince. A heading has to carry an identifier *and* the\n * section has to declare a status before it counts. One signal is not enough:\n * `## Q3 2026 Roadmap` parses as family `Q`, number 3, and `## v1.2.0` in a\n * changelog parses as family `v`, number 1. Neither is a specification, and\n * neither declares a status.\n */\n\nimport { attr, type Directive } from './directives.js';\nimport { HAS_LETTER_OR_DIGIT, isExternal, parsePrefixedRef } from './identity.js';\nimport { isStatusHeading } from './lifecycle.js';\nimport {\n isMarkdownLine,\n isOnlyComment,\n type Heading,\n type Range,\n type ScannedDocument,\n type Table,\n type TableCell,\n type TableRow,\n} from './markdown.js';\nimport type { EdgeKind } from './types.js';\n\n/** A status as written, and where it was written. */\nexport interface RegionStatus {\n readonly text: string;\n readonly start: number;\n readonly end: number;\n}\n\n/** A relation read from a table column rather than from prose. */\nexport interface TableRelation {\n readonly kind: EdgeKind;\n readonly inverted: boolean;\n readonly target: string;\n readonly start: number;\n readonly end: number;\n /** The column header that gave it its meaning, for the diagnostic. */\n readonly column: string;\n}\n\nexport interface SpecificationRegion {\n /** The heading that opens the region, or `null` for the file or a table row. */\n readonly heading: Heading | null;\n /** The table row that is the region, when it is one. */\n readonly row: TableRow | null;\n /** Offset the region starts at. */\n readonly start: number;\n /** Offset just past the region. */\n readonly end: number;\n /** Identifier read from the heading or the identifier column. */\n readonly declaredId: string | null;\n readonly title: string | null;\n readonly status: RegionStatus | null;\n /** A `@spec-node` directive inside the region, when there is one. */\n readonly directive: Directive | null;\n /** Relations declared by column, empty for a heading region. */\n readonly relations: readonly TableRelation[];\n /**\n * Cells whose content is already accounted for as a typed relation.\n *\n * Prose scanning skips these, so a link in a `Depends on` column produces one\n * typed edge rather than a typed edge and a neutral citation beside it.\n */\n readonly claimed: readonly Range[];\n}\n\n/** Column headers that name the row's identifier. */\nconst ID_COLUMNS = /^(?:id|ids|ref|reference|key|no|number|#|adr|rfc|kep|oi|decision|spec|specification)$/;\n\n/** Column headers that name the row's status. */\nconst STATUS_COLUMNS = /^(?:status|state|stage|lifecycle|phase)$/;\n\n/** Column headers that name the row's title. */\nconst TITLE_COLUMNS = /^(?:title|name|summary|description|subject|decision|topic)$/;\n\n/**\n * Column headers that declare a relation.\n *\n * Written the way a header is written - \"Depends on\", \"Superseded by\" - rather\n * than the way a front-matter key is, because that is what an author types at\n * the top of a column.\n *\n * A map, because a header is whatever an author typed and an object answers to\n * more names than it was given: a column headed `Constructor` was a relation\n * of no kind, and every cell in it an edge to wherever it pointed.\n */\nconst RELATION_COLUMNS: ReadonlyMap<string, { kind: EdgeKind; inverted: boolean }> = new Map([\n ['depends on', { kind: 'depends-on', inverted: false }],\n ['depends-on', { kind: 'depends-on', inverted: false }],\n ['dependencies', { kind: 'depends-on', inverted: false }],\n ['requires', { kind: 'depends-on', inverted: false }],\n ['supersedes', { kind: 'supersedes', inverted: false }],\n ['replaces', { kind: 'supersedes', inverted: false }],\n ['superseded by', { kind: 'supersedes', inverted: true }],\n ['replaced by', { kind: 'supersedes', inverted: true }],\n ['blocked by', { kind: 'blocked-by', inverted: false }],\n ['blocked on', { kind: 'blocked-by', inverted: false }],\n ['blocks', { kind: 'blocked-by', inverted: true }],\n ['amends', { kind: 'amends', inverted: false }],\n ['extends', { kind: 'amends', inverted: false }],\n ['assumes', { kind: 'assumes', inverted: false }],\n ['delegates to', { kind: 'delegates-to', inverted: false }],\n ['delegated to', { kind: 'delegates-to', inverted: false }],\n ['tracked in', { kind: 'delegates-to', inverted: false }],\n ['related', { kind: 'relates-to', inverted: false }],\n ['related to', { kind: 'relates-to', inverted: false }],\n ['see also', { kind: 'relates-to', inverted: false }],\n ['references', { kind: 'references', inverted: false }],\n]);\n\n/** Cell values that mean \"nothing here\". */\nconst MARKDOWN_LINK = /!?\\[([^\\]]*)\\]\\(([^)]*)\\)/g;\nconst EMPTY_CELL = /^(?:-+|—|–|n\\/?a|none|nil|tbd|\\.|_+)$/i;\n\n/** `## ADR-0007: Sharding` - an identifier at the very start of a heading. */\nconst HEADING_ID = /^\\s*([A-Za-z]{1,15}[\\s._-]?\\d{1,6})\\b/;\n\n/** `**Status:** Accepted`, `Status: Accepted`, `*Status* : Accepted`. */\nconst INLINE_STATUS = /^[ \\t>]*[*_]{0,2}\\s*status\\s*[*_]{0,2}\\s*:\\s*(.+?)\\s*$/im;\n\n/**\n * Finds every specification in a file.\n *\n * The first entry is always the file itself, so a caller that ignores the rest\n * behaves exactly as it did before regions existed.\n */\nexport function findSpecificationRegions(\n scanned: ScannedDocument,\n directives: readonly Directive[],\n /** The file's own identifier, so its title heading is not read as a sub-region. */\n fileId: string,\n): SpecificationRegion[] {\n // The file's own relations come from its front matter and prose, never from\n // here, and it claims no cell: nothing reads either list off this region.\n const whole: SpecificationRegion = {\n heading: null,\n row: null,\n start: scanned.bodyStart,\n end: scanned.text.length,\n declaredId: null,\n title: null,\n status: null,\n directive: null,\n relations: [],\n claimed: [],\n };\n\n const regions: SpecificationRegion[] = [];\n const folded = fold(fileId);\n const fileRef = parsePrefixedRef(fileId);\n\n for (let i = 0; i < scanned.headings.length; i += 1) {\n const heading = scanned.headings[i] as Heading;\n const declaredId = HEADING_ID.exec(heading.text)?.[1];\n if (declaredId === undefined) continue;\n // The file's own title heading names the file, not a region inside it.\n if (fold(declaredId) === folded) continue;\n // Padding is not part of an identity anywhere else - `ADR-40`, `ADR-040`\n // and `ADR-0040` all resolve to one document - so a heading that spells the\n // number differently from the file name is still that file's own title.\n // Comparing the text alone made `# ADR-040` inside `0040-enforce.md` a\n // region within the file it names: one decision, two nodes, and a citation\n // arriving at whichever spelling it happened to use.\n // `HEADING_ID` captures only what `PREFIXED_ID` parses, so `ref` is never\n // null here; the check is for the type.\n const ref = parsePrefixedRef(declaredId);\n if (ref !== null && fileRef !== null && ref.family === fileRef.family && ref.number === fileRef.number) continue;\n\n const end = regionEnd(scanned, i);\n const directive = directiveIn(directives, heading.end, end);\n const status = readRegionStatus(scanned, heading.end, end);\n\n // Two independent signals are required. An identifier alone matches\n // `## Q3 2026 Roadmap` and `## v1.2.0`; a status alone matches every\n // ordinary `## Status` section in a normal ADR.\n if (status === null && directive === null) continue;\n\n // A directive's id wins, but only if it is a name. One that is not - the\n // lone backslash `id=\\\"ADR-9\\\"` parses to, written inside a string - would\n // be discarded when the region is identified, and a region with nothing\n // to go by falls back to the file's own name: the file then contained\n // itself, and the section vanished. The heading's id is the one to keep.\n const directiveId = directive ? attr(directive, 'id')?.value : undefined;\n\n regions.push({\n heading,\n row: null,\n start: heading.start,\n end,\n declaredId: directiveId !== undefined && HAS_LETTER_OR_DIGIT.test(directiveId) ? directiveId : declaredId,\n title: heading.text,\n status,\n directive,\n relations: [],\n // Prose inside a section is prose: a heading region claims no cell.\n claimed: [],\n });\n }\n\n return [whole, ...regions, ...findTableRegions(scanned)];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Registers kept as tables */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Reads a table whose columns describe specifications.\n *\n * A table qualifies when it has an identifier column *and* either a status\n * column or at least one relation column. Two signals again, for the same\n * reason: a table of identifiers and prose is a citation list, and promoting\n * every row of it to a specification would invent a register nobody wrote.\n */\nexport function findTableRegions(scanned: ScannedDocument): SpecificationRegion[] {\n const out: SpecificationRegion[] = [];\n\n for (const table of scanned.tables) {\n const schema = readSchema(table);\n if (schema === null) continue;\n\n for (const row of table.rows) {\n const idCell = row.cells[schema.id];\n if (!idCell) continue;\n const id = flatten(idCell.text);\n // A row is named by its id cell or not at all. An empty one, a\n // placeholder, or punctuation alone - `?` for a row nobody has numbered\n // yet - names nothing, and a region with no name fell back to the file's:\n // the register then contained itself, and the row vanished.\n if (!HAS_LETTER_OR_DIGIT.test(id) || EMPTY_CELL.test(id)) continue;\n\n // `row.cells[null]` is undefined too, so the null checks on the optional\n // columns are for the type; and `statusText` is read only beside a cell.\n const statusCell = schema.status === null ? undefined : row.cells[schema.status];\n const statusText = statusCell ? flatten(statusCell.text) : '';\n const status: RegionStatus | null =\n statusCell && statusText.length > 0 && !EMPTY_CELL.test(statusText)\n ? { text: statusText, start: statusCell.start, end: statusCell.end }\n : null;\n\n const titleCell = schema.title === null ? undefined : row.cells[schema.title];\n const title = titleCell ? flatten(titleCell.text) : null;\n\n const relations: TableRelation[] = [];\n // The status cell is left to prose, as a status line under a heading is:\n // `Superseded by ADR-0002` there names the row's successor, and claimed\n // it named nothing at all.\n const claimed: Range[] = [{ start: idCell.start, end: idCell.end }];\n\n for (const [column, relation] of schema.relations) {\n const cell = row.cells[column];\n if (!cell) continue;\n claimed.push({ start: cell.start, end: cell.end });\n for (const target of splitTargets(cell)) {\n relations.push({\n kind: relation.kind,\n inverted: relation.inverted,\n target: target.text,\n start: target.start,\n end: target.end,\n column: (table.headers[column] as TableCell).text,\n });\n }\n }\n\n out.push({\n heading: null,\n row,\n start: row.start,\n end: row.end,\n declaredId: id,\n title: title !== null && title.length > 0 ? title : null,\n status,\n directive: null,\n relations,\n claimed,\n });\n }\n }\n\n return out;\n}\n\n/**\n * Whether spec-graph reads a table as a register: an identifier column, and a\n * status column or a relation column beside it. Such a table's status column\n * describes its rows, never the document holding it.\n */\nexport function isRegisterTable(table: Table): boolean {\n return readSchema(table) !== null;\n}\n\ninterface TableSchema {\n readonly id: number;\n readonly status: number | null;\n readonly title: number | null;\n readonly relations: readonly (readonly [number, { kind: EdgeKind; inverted: boolean }])[];\n}\n\nfunction readSchema(table: Table): TableSchema | null {\n let id: number | null = null;\n let status: number | null = null;\n let title: number | null = null;\n const relations: [number, { kind: EdgeKind; inverted: boolean }][] = [];\n\n table.headers.forEach((header, column) => {\n const name = normaliseHeader(header.text);\n if (id === null && ID_COLUMNS.test(name)) {\n id = column;\n return;\n }\n if (status === null && STATUS_COLUMNS.test(name)) {\n status = column;\n return;\n }\n const relation = RELATION_COLUMNS.get(name);\n if (relation) {\n relations.push([column, relation]);\n return;\n }\n if (title === null && TITLE_COLUMNS.test(name)) title = column;\n });\n\n // Without an id column every row would be skipped for want of an id cell;\n // this says so before reading any of them.\n if (id === null) return null;\n if (status === null && relations.length === 0) return null;\n return { id, status, title, relations };\n}\n\nfunction normaliseHeader(text: string): string {\n return flatten(text)\n .toLowerCase()\n .replace(/[^a-z0-9/#\\s-]/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/** Splits a cell into the identifiers it lists, keeping each one's offset. */\nfunction splitTargets(cell: TableCell): { text: string; start: number; end: number }[] {\n const out: { text: string; start: number; end: number }[] = [];\n // Every target is reported at the cell's span. A cell is short, and an offset\n // recovered back through a flattening is an offset that can drift.\n const push = (raw: string): void => {\n const target = raw.trim();\n if (target.length === 0 || EMPTY_CELL.test(target)) return;\n out.push({ text: target, start: cell.start, end: cell.end });\n };\n const prose = (segment: string): void => {\n for (const piece of flatten(segment).split(/\\s*(?:[,;]|\\band\\b)\\s*/i)) push(piece);\n };\n\n // Links are taken out whole rather than flattened with everything else: a\n // path would otherwise be cut in half by its own slash, and its underscores\n // stripped as emphasis.\n // `matchAll` scans a copy of the pattern. `prose` calls `flatten`, which\n // drives the shared one, and one /g regex advanced from inside its own scan\n // resets its cursor and never terminates.\n let last = 0;\n for (const match of cell.text.matchAll(MARKDOWN_LINK)) {\n prose(cell.text.slice(last, match.index));\n // Both groups always take part in a match, so the `?? ''` below and in the\n // label are for the type.\n const destination = (match[2] ?? '').trim();\n // A link states where its target lives; its label states only what the\n // target is called (ADR-0008). In a column the author has already typed,\n // the destination is the claim - `[see](adr/0050.md)` is a dependency on\n // that file, not on the word \"see\". An external or in-page destination\n // names no document here, so the label is what is left to try.\n const local = destination.length > 0 && !destination.startsWith('#') && !isExternal(destination);\n push(local ? destination : (match[1] ?? ''));\n last = match.index + match[0].length;\n }\n prose(cell.text.slice(last));\n return out;\n}\n\n/** Reduces a cell to its text: link labels rather than link syntax. */\nfunction flatten(text: string): string {\n return text\n .replace(MARKDOWN_LINK, '$1')\n .replace(/\\[\\[(?:[^\\]|]*\\|)?([^\\]]*)\\]\\]/g, '$1')\n .replace(/[`*_~]/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/** Where a heading's section ends: the next heading at the same level or above. */\nfunction regionEnd(scanned: ScannedDocument, index: number): number {\n const heading = scanned.headings[index] as Heading;\n for (let i = index + 1; i < scanned.headings.length; i += 1) {\n const next = scanned.headings[i] as Heading;\n if (next.level <= heading.level) return next.start;\n }\n return scanned.text.length;\n}\n\n/**\n * Reads a status declared inside a region.\n *\n * Two forms, both common: a labelled line (`**Status:** Accepted`) and a\n * sub-heading (`### Status` with the value beneath it). Only the region is\n * searched, so one decision in a register cannot inherit its neighbour's.\n */\nexport function readRegionStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n const labelled = readLabelledStatus(scanned, start, end);\n if (labelled) return labelled;\n return readHeadedStatus(scanned, start, end);\n}\n\nfunction readLabelledStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n for (const line of scanned.lines) {\n if (line.contentStart < start) continue;\n if (line.contentStart >= end) break;\n // A template's commented-out `Status: proposed | accepted` is a hint to\n // whoever fills it in, not a status the region declares, and one in code or\n // a <pre> block is an example.\n if (!isMarkdownLine(line) || line.blank || line.comment) continue;\n const match = INLINE_STATUS.exec(line.content);\n if (!match) continue;\n // `**Status:** Accepted` closes its emphasis *after* the colon, so the\n // closing marker lands in the captured value. Strip it rather than let it\n // reach the report as part of the status a reader is shown.\n const value = (match[1] as string).replace(/^[*_\\s]+/, '').replace(/[*_\\s]+$/, '');\n if (value.length === 0) continue;\n const offset = line.contentStart + line.content.lastIndexOf(value);\n return { text: value, start: offset, end: offset + value.length };\n }\n return null;\n}\n\nfunction readHeadedStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n // The upper bound decides nothing on its own: under a heading at or past\n // `end` there is no line before `end`, and the loop below stops there.\n const heading = scanned.headings.find((h) => h.start >= start && h.start < end && isStatusHeading(h.text));\n if (!heading) return null;\n\n for (const line of scanned.lines) {\n if (line.line <= heading.line) continue;\n if (line.contentStart >= end) break;\n if (line.blank || isOnlyComment(scanned, line)) continue;\n if (!isMarkdownLine(line)) return null;\n if (opensHeading(scanned, line.line)) return null;\n const trimmed = line.content.trim();\n // A bullet list under Status is a status history; the first entry is current.\n const cleaned = trimmed.replace(/^[-*+]\\s+/, '');\n const offset = line.contentStart + line.content.indexOf(trimmed) + (trimmed.length - cleaned.length);\n return { text: cleaned, start: offset, end: offset + cleaned.length };\n }\n return null;\n}\n\n/**\n * Whether a heading begins on this line, which ends a status section's search\n * for its value.\n *\n * Asked of the scanner rather than of the line's first character, because a\n * setext heading's text line starts with no `#`: under `### Status` it read as\n * the status, and a register took the next decision's title for its own.\n */\nexport function opensHeading(scanned: ScannedDocument, line: number): boolean {\n return scanned.headings.some((heading) => heading.line === line);\n}\n\n/**\n * The last `@spec-node` directive inside a region: the one written last, which\n * is the one a reader sees as the final word.\n *\n * Directives arrive in the order they were written, so each candidate starts\n * after the one before it and the comparison below only restates that. And\n * `start` is where a heading's line ends, a comment written on it included,\n * so no directive begins exactly there and `<` against `<=` decides nothing.\n */\nfunction directiveIn(directives: readonly Directive[], start: number, end: number): Directive | null {\n let found: Directive | null = null;\n for (const directive of directives) {\n if (directive.name !== 'spec-node') continue;\n if (directive.start < start || directive.end > end) continue;\n if (found === null || directive.start > found.start) found = directive;\n }\n return found;\n}\n\n/**\n * Case- and separator-insensitive comparison, matching reference folding.\n *\n * Applied to both sides of one comparison, so which case it folds to does not\n * matter; the separators take every space with them, so the trim does not\n * either; and `+` only saves work.\n */\nfunction fold(value: string): string {\n return value.trim().toLowerCase().replace(/[\\s._-]+/g, '');\n}\n\n/** The region containing an offset, innermost first. `null` when only the file does. */\nexport function regionAt(regions: readonly SpecificationRegion[], offset: number): SpecificationRegion | null {\n let best: SpecificationRegion | null = null;\n for (const region of regions) {\n // The whole-file region owns nothing in particular; it is the fallback.\n if (region.heading === null && region.row === null) continue;\n if (offset < region.start || offset >= region.end) continue;\n // No two regions of one file open at the same offset, so `>` and `>=`\n // agree here.\n if (best === null || region.start > best.start) best = region;\n }\n return best;\n}\n"]}
1
+ {"version":3,"file":"sections.js","sourceRoot":"","sources":["../src/sections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,IAAI,EAAkB,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,cAAc,EACd,aAAa,GAOd,MAAM,eAAe,CAAC;AA+CvB,qDAAqD;AACrD,MAAM,UAAU,GAAG,uFAAuF,CAAC;AAE3G,iDAAiD;AACjD,MAAM,cAAc,GAAG,0CAA0C,CAAC;AAElE,gDAAgD;AAChD,MAAM,aAAa,GAAG,6DAA6D,CAAC;AAEpF;;;;;;;;;;GAUG;AACH,MAAM,gBAAgB,GAA+D,IAAI,GAAG,CAAC;IAC3F,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACvD,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACvD,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACzD,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,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cesContent":["/**\n * Specification regions: the part of a file that one specification occupies.\n *\n * `spec-graph` began by assuming one specification per file, because that is\n * how MADR, KEPs and Rust RFCs are laid out. Plenty of organisations do not\n * work that way. A register, a whitepaper or a living architecture document\n * holds dozens of decisions in one file, each with its own identifier, its own\n * status and its own dependencies - and to an engine that binds a document to a\n * file, every one of them is invisible.\n *\n * The fix is small once stated: **a specification is a region of a file, not a\n * file.** A file yields at least one region - itself - and may yield more.\n * Everything downstream is unchanged, because a region produces exactly the\n * same `DocumentNode` a whole file produced.\n *\n * What this module decides is where those regions begin and end, and it is\n * deliberately hard to convince. A heading has to carry an identifier *and* the\n * section has to declare a status before it counts. One signal is not enough:\n * `## Q3 2026 Roadmap` parses as family `Q`, number 3, and `## v1.2.0` in a\n * changelog parses as family `v`, number 1. Neither is a specification, and\n * neither declares a status.\n */\n\nimport { attr, type Directive } from './directives.js';\nimport { HAS_LETTER_OR_DIGIT, isExternal, parsePrefixedRef } from './identity.js';\nimport { isStatusHeading } from './lifecycle.js';\nimport {\n isMarkdownLine,\n isOnlyComment,\n type Heading,\n type Range,\n type ScannedDocument,\n type Table,\n type TableCell,\n type TableRow,\n} from './markdown.js';\nimport type { EdgeKind } from './types.js';\n\n/** A status as written, and where it was written. */\nexport interface RegionStatus {\n readonly text: string;\n readonly start: number;\n readonly end: number;\n}\n\n/** A relation read from a table column rather than from prose. */\nexport interface TableRelation {\n readonly kind: EdgeKind;\n readonly inverted: boolean;\n readonly target: string;\n readonly start: number;\n readonly end: number;\n /** The column header that gave it its meaning, for the diagnostic. */\n readonly column: string;\n}\n\nexport interface SpecificationRegion {\n /** The heading that opens the region, or `null` for the file or a table row. */\n readonly heading: Heading | null;\n /** The table row that is the region, when it is one. */\n readonly row: TableRow | null;\n /** Offset the region starts at. */\n readonly start: number;\n /** Offset just past the region. */\n readonly end: number;\n /** Identifier read from the heading or the identifier column. */\n readonly declaredId: string | null;\n readonly title: string | null;\n readonly status: RegionStatus | null;\n /** A `@spec-node` directive inside the region, when there is one. */\n readonly directive: Directive | null;\n /** Relations declared by column, empty for a heading region. */\n readonly relations: readonly TableRelation[];\n /**\n * Cells whose content is already accounted for as a typed relation.\n *\n * Prose scanning skips these, so a link in a `Depends on` column produces one\n * typed edge rather than a typed edge and a neutral citation beside it.\n */\n readonly claimed: readonly Range[];\n}\n\n/** Column headers that name the row's identifier. */\nconst ID_COLUMNS = /^(?:id|ids|ref|reference|key|no|number|#|adr|rfc|kep|oi|decision|spec|specification)$/;\n\n/** Column headers that name the row's status. */\nconst STATUS_COLUMNS = /^(?:status|state|stage|lifecycle|phase)$/;\n\n/** Column headers that name the row's title. */\nconst TITLE_COLUMNS = /^(?:title|name|summary|description|subject|decision|topic)$/;\n\n/**\n * Column headers that declare a relation.\n *\n * Written the way a header is written - \"Depends on\", \"Superseded by\" - rather\n * than the way a front-matter key is, because that is what an author types at\n * the top of a column.\n *\n * A map, because a header is whatever an author typed and an object answers to\n * more names than it was given: a column headed `Constructor` was a relation\n * of no kind, and every cell in it an edge to wherever it pointed.\n */\nconst RELATION_COLUMNS: ReadonlyMap<string, { kind: EdgeKind; inverted: boolean }> = new Map([\n ['depends on', { kind: 'depends-on', inverted: false }],\n ['depends-on', { kind: 'depends-on', inverted: false }],\n ['dependencies', { kind: 'depends-on', inverted: false }],\n ['requires', { kind: 'depends-on', inverted: false }],\n ['supersedes', { kind: 'supersedes', inverted: false }],\n ['replaces', { kind: 'supersedes', inverted: false }],\n ['superseded by', { kind: 'supersedes', inverted: true }],\n ['replaced by', { kind: 'supersedes', inverted: true }],\n ['blocked by', { kind: 'blocked-by', inverted: false }],\n ['blocked on', { kind: 'blocked-by', inverted: false }],\n ['blocks', { kind: 'blocked-by', inverted: true }],\n ['amends', { kind: 'amends', inverted: false }],\n ['extends', { kind: 'amends', inverted: false }],\n ['assumes', { kind: 'assumes', inverted: false }],\n ['delegates to', { kind: 'delegates-to', inverted: false }],\n ['delegated to', { kind: 'delegates-to', inverted: false }],\n ['tracked in', { kind: 'delegates-to', inverted: false }],\n ['related', { kind: 'relates-to', inverted: false }],\n ['related to', { kind: 'relates-to', inverted: false }],\n ['see also', { kind: 'relates-to', inverted: false }],\n ['references', { kind: 'references', inverted: false }],\n]);\n\nconst MARKDOWN_LINK = /!?\\[([^\\]]*)\\]\\(([^)]*)\\)/g;\n/**\n * Cell values that mean \"nothing here\".\n *\n * Underscores reach this only out of a link in a relation cell, whose\n * destination or label is kept whole: a template's blank such as\n * `[to be decided](___)`. Everywhere else a cell is flattened first, which\n * takes them out as emphasis.\n */\nconst EMPTY_CELL = /^(?:-+|—|–|n\\/?a|none|nil|tbd|\\.|_+)$/i;\n\n/** `## ADR-0007: Sharding` - an identifier at the very start of a heading. */\nconst HEADING_ID = /^\\s*([A-Za-z]{1,15}[\\s._-]?\\d{1,6})\\b/;\n\n/** `**Status:** Accepted`, `Status: Accepted`, `*Status* : Accepted`. */\nconst INLINE_STATUS = /^[ \\t>]*[*_]{0,2}\\s*status\\s*[*_]{0,2}\\s*:\\s*(.+?)\\s*$/im;\n\n/**\n * Finds every specification in a file.\n *\n * The first entry is always the file itself, so a caller that ignores the rest\n * behaves exactly as it did before regions existed.\n */\nexport function findSpecificationRegions(\n scanned: ScannedDocument,\n directives: readonly Directive[],\n /** The file's own identifier, so its title heading is not read as a sub-region. */\n fileId: string,\n): SpecificationRegion[] {\n // The file's own relations come from its front matter and prose, never from\n // here, and it claims no cell: nothing reads either list off this region.\n const whole: SpecificationRegion = {\n heading: null,\n row: null,\n start: scanned.bodyStart,\n end: scanned.text.length,\n declaredId: null,\n title: null,\n status: null,\n directive: null,\n relations: [],\n claimed: [],\n };\n\n const regions: SpecificationRegion[] = [];\n const folded = fold(fileId);\n const fileRef = parsePrefixedRef(fileId);\n\n for (let i = 0; i < scanned.headings.length; i += 1) {\n const heading = scanned.headings[i] as Heading;\n const declaredId = HEADING_ID.exec(heading.text)?.[1];\n if (declaredId === undefined) continue;\n // The file's own title heading names the file, not a region inside it.\n if (fold(declaredId) === folded) continue;\n // Padding is not part of an identity anywhere else - `ADR-40`, `ADR-040`\n // and `ADR-0040` all resolve to one document - so a heading that spells the\n // number differently from the file name is still that file's own title.\n // Comparing the text alone made `# ADR-040` inside `0040-enforce.md` a\n // region within the file it names: one decision, two nodes, and a citation\n // arriving at whichever spelling it happened to use.\n // `HEADING_ID` captures only what `PREFIXED_ID` parses, so `ref` is never\n // null here; the check is for the type.\n const ref = parsePrefixedRef(declaredId);\n if (ref !== null && fileRef !== null && ref.family === fileRef.family && ref.number === fileRef.number) continue;\n\n const end = regionEnd(scanned, i);\n const directive = directiveIn(directives, heading.end, end);\n const status = readRegionStatus(scanned, heading.end, end);\n\n // Two independent signals are required. An identifier alone matches\n // `## Q3 2026 Roadmap` and `## v1.2.0`; a status alone matches every\n // ordinary `## Status` section in a normal ADR.\n if (status === null && directive === null) continue;\n\n // A directive's id wins, but only if it is a name. One that is not - the\n // lone backslash `id=\\\"ADR-9\\\"` parses to, written inside a string - would\n // be discarded when the region is identified, and a region with nothing\n // to go by falls back to the file's own name: the file then contained\n // itself, and the section vanished. The heading's id is the one to keep.\n const directiveId = directive ? attr(directive, 'id')?.value : undefined;\n\n regions.push({\n heading,\n row: null,\n start: heading.start,\n end,\n declaredId: directiveId !== undefined && HAS_LETTER_OR_DIGIT.test(directiveId) ? directiveId : declaredId,\n title: heading.text,\n status,\n directive,\n relations: [],\n // Prose inside a section is prose: a heading region claims no cell.\n claimed: [],\n });\n }\n\n return [whole, ...regions, ...findTableRegions(scanned)];\n}\n\n/* -------------------------------------------------------------------------- */\n/* Registers kept as tables */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Reads a table whose columns describe specifications.\n *\n * A table qualifies when it has an identifier column *and* either a status\n * column or at least one relation column. Two signals again, for the same\n * reason: a table of identifiers and prose is a citation list, and promoting\n * every row of it to a specification would invent a register nobody wrote.\n */\nexport function findTableRegions(scanned: ScannedDocument): SpecificationRegion[] {\n const out: SpecificationRegion[] = [];\n\n for (const table of scanned.tables) {\n const schema = readSchema(table);\n if (schema === null) continue;\n\n for (const row of table.rows) {\n const idCell = row.cells[schema.id];\n if (!idCell) continue;\n const id = flatten(idCell.text);\n // A row is named by its id cell or not at all. An empty one, a\n // placeholder, or punctuation alone - `?` for a row nobody has numbered\n // yet - names nothing, and a region with no name fell back to the file's:\n // the register then contained itself, and the row vanished.\n if (!HAS_LETTER_OR_DIGIT.test(id) || EMPTY_CELL.test(id)) continue;\n\n // `row.cells[null]` is undefined too, so the null checks on the optional\n // columns are for the type; and `statusText` is read only beside a cell.\n const statusCell = schema.status === null ? undefined : row.cells[schema.status];\n const statusText = statusCell ? flatten(statusCell.text) : '';\n const status: RegionStatus | null =\n statusCell && statusText.length > 0 && !EMPTY_CELL.test(statusText)\n ? { text: statusText, start: statusCell.start, end: statusCell.end }\n : null;\n\n const titleCell = schema.title === null ? undefined : row.cells[schema.title];\n const title = titleCell ? flatten(titleCell.text) : null;\n\n const relations: TableRelation[] = [];\n // The status cell is left to prose, as a status line under a heading is:\n // `Superseded by ADR-0002` there names the row's successor, and claimed\n // it named nothing at all.\n const claimed: Range[] = [{ start: idCell.start, end: idCell.end }];\n\n for (const [column, relation] of schema.relations) {\n const cell = row.cells[column];\n if (!cell) continue;\n claimed.push({ start: cell.start, end: cell.end });\n for (const target of splitTargets(cell)) {\n relations.push({\n kind: relation.kind,\n inverted: relation.inverted,\n target: target.text,\n start: target.start,\n end: target.end,\n column: (table.headers[column] as TableCell).text,\n });\n }\n }\n\n out.push({\n heading: null,\n row,\n start: row.start,\n end: row.end,\n declaredId: id,\n title: title !== null && title.length > 0 ? title : null,\n status,\n directive: null,\n relations,\n claimed,\n });\n }\n }\n\n return out;\n}\n\n/**\n * Whether spec-graph reads a table as a register: an identifier column, and a\n * status column or a relation column beside it. Such a table's status column\n * describes its rows, never the document holding it.\n */\nexport function isRegisterTable(table: Table): boolean {\n return readSchema(table) !== null;\n}\n\ninterface TableSchema {\n readonly id: number;\n readonly status: number | null;\n readonly title: number | null;\n readonly relations: readonly (readonly [number, { kind: EdgeKind; inverted: boolean }])[];\n}\n\nfunction readSchema(table: Table): TableSchema | null {\n let id: number | null = null;\n let status: number | null = null;\n let title: number | null = null;\n const relations: [number, { kind: EdgeKind; inverted: boolean }][] = [];\n\n table.headers.forEach((header, column) => {\n const name = normaliseHeader(header.text);\n if (id === null && ID_COLUMNS.test(name)) {\n id = column;\n return;\n }\n if (status === null && STATUS_COLUMNS.test(name)) {\n status = column;\n return;\n }\n const relation = RELATION_COLUMNS.get(name);\n if (relation) {\n relations.push([column, relation]);\n return;\n }\n if (title === null && TITLE_COLUMNS.test(name)) title = column;\n });\n\n // Without an id column every row would be skipped for want of an id cell;\n // this says so before reading any of them.\n if (id === null) return null;\n if (status === null && relations.length === 0) return null;\n return { id, status, title, relations };\n}\n\nfunction normaliseHeader(text: string): string {\n return flatten(text)\n .toLowerCase()\n .replace(/[^a-z0-9/#\\s-]/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/** Splits a cell into the identifiers it lists, keeping each one's offset. */\nfunction splitTargets(cell: TableCell): { text: string; start: number; end: number }[] {\n const out: { text: string; start: number; end: number }[] = [];\n // Every target is reported at the cell's span. A cell is short, and an offset\n // recovered back through a flattening is an offset that can drift.\n const push = (raw: string): void => {\n const target = raw.trim();\n if (target.length === 0 || EMPTY_CELL.test(target)) return;\n out.push({ text: target, start: cell.start, end: cell.end });\n };\n const prose = (segment: string): void => {\n for (const piece of flatten(segment).split(/\\s*(?:[,;]|\\band\\b)\\s*/i)) push(piece);\n };\n\n // Links are taken out whole rather than flattened with everything else: a\n // path would otherwise be cut in half by its own slash, and its underscores\n // stripped as emphasis.\n // `matchAll` scans a copy of the pattern. `prose` calls `flatten`, which\n // drives the shared one, and one /g regex advanced from inside its own scan\n // resets its cursor and never terminates.\n let last = 0;\n for (const match of cell.text.matchAll(MARKDOWN_LINK)) {\n prose(cell.text.slice(last, match.index));\n // Both groups always take part in a match, so the `?? ''` below and in the\n // label are for the type.\n const destination = (match[2] ?? '').trim();\n // A link states where its target lives; its label states only what the\n // target is called (ADR-0008). In a column the author has already typed,\n // the destination is the claim - `[see](adr/0050.md)` is a dependency on\n // that file, not on the word \"see\". An external or in-page destination\n // names no document here, so the label is what is left to try.\n const local = destination.length > 0 && !destination.startsWith('#') && !isExternal(destination);\n push(local ? destination : (match[1] ?? ''));\n last = match.index + match[0].length;\n }\n prose(cell.text.slice(last));\n return out;\n}\n\n/** Reduces a cell to its text: link labels rather than link syntax. */\nfunction flatten(text: string): string {\n return text\n .replace(MARKDOWN_LINK, '$1')\n .replace(/\\[\\[(?:[^\\]|]*\\|)?([^\\]]*)\\]\\]/g, '$1')\n .replace(/[`*_~]/g, '')\n .replace(/\\s+/g, ' ')\n .trim();\n}\n\n/** Where a heading's section ends: the next heading at the same level or above. */\nfunction regionEnd(scanned: ScannedDocument, index: number): number {\n const heading = scanned.headings[index] as Heading;\n for (let i = index + 1; i < scanned.headings.length; i += 1) {\n const next = scanned.headings[i] as Heading;\n if (next.level <= heading.level) return next.start;\n }\n return scanned.text.length;\n}\n\n/**\n * Reads a status declared inside a region.\n *\n * Two forms, both common: a labelled line (`**Status:** Accepted`) and a\n * sub-heading (`### Status` with the value beneath it). Only the region is\n * searched, so one decision in a register cannot inherit its neighbour's.\n */\nexport function readRegionStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n const labelled = readLabelledStatus(scanned, start, end);\n if (labelled) return labelled;\n return readHeadedStatus(scanned, start, end);\n}\n\nfunction readLabelledStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n for (const line of scanned.lines) {\n if (line.contentStart < start) continue;\n if (line.contentStart >= end) break;\n // A template's commented-out `Status: proposed | accepted` is a hint to\n // whoever fills it in, not a status the region declares, and one in code or\n // a <pre> block is an example.\n if (!isMarkdownLine(line) || line.blank || line.comment) continue;\n const match = INLINE_STATUS.exec(line.content);\n if (!match) continue;\n // `**Status:** Accepted` closes its emphasis *after* the colon, so the\n // closing marker lands in the captured value. Strip it rather than let it\n // reach the report as part of the status a reader is shown.\n const value = (match[1] as string).replace(/^[*_\\s]+/, '').replace(/[*_\\s]+$/, '');\n if (value.length === 0) continue;\n const offset = line.contentStart + line.content.lastIndexOf(value);\n return { text: value, start: offset, end: offset + value.length };\n }\n return null;\n}\n\nfunction readHeadedStatus(scanned: ScannedDocument, start: number, end: number): RegionStatus | null {\n // The upper bound decides nothing on its own: under a heading at or past\n // `end` there is no line before `end`, and the loop below stops there.\n const heading = scanned.headings.find((h) => h.start >= start && h.start < end && isStatusHeading(h.text));\n if (!heading) return null;\n\n for (const line of scanned.lines) {\n if (line.line <= heading.line) continue;\n if (line.contentStart >= end) break;\n if (line.blank || isOnlyComment(scanned, line)) continue;\n if (!isMarkdownLine(line)) return null;\n if (opensHeading(scanned, line.line)) return null;\n const trimmed = line.content.trim();\n // A bullet list under Status is a status history; the first entry is current.\n const cleaned = trimmed.replace(/^[-*+]\\s+/, '');\n const offset = line.contentStart + line.content.indexOf(trimmed) + (trimmed.length - cleaned.length);\n return { text: cleaned, start: offset, end: offset + cleaned.length };\n }\n return null;\n}\n\n/**\n * Whether a heading begins on this line, which ends a status section's search\n * for its value.\n *\n * Asked of the scanner rather than of the line's first character, because a\n * setext heading's text line starts with no `#`: under `### Status` it read as\n * the status, and a register took the next decision's title for its own.\n */\nexport function opensHeading(scanned: ScannedDocument, line: number): boolean {\n return scanned.headings.some((heading) => heading.line === line);\n}\n\n/**\n * The last `@spec-node` directive inside a region: the one written last, which\n * is the one a reader sees as the final word.\n *\n * Directives arrive in the order they were written, so each candidate starts\n * after the one before it and the comparison below only restates that. And\n * `start` is where a heading's line ends, a comment written on it included,\n * so no directive begins exactly there and `<` against `<=` decides nothing.\n */\nfunction directiveIn(directives: readonly Directive[], start: number, end: number): Directive | null {\n let found: Directive | null = null;\n for (const directive of directives) {\n if (directive.name !== 'spec-node') continue;\n if (directive.start < start || directive.end > end) continue;\n if (found === null || directive.start > found.start) found = directive;\n }\n return found;\n}\n\n/**\n * Case- and separator-insensitive comparison, matching reference folding.\n *\n * Applied to both sides of one comparison, so which case it folds to does not\n * matter; the separators take every space with them, so the trim does not\n * either; and `+` only saves work.\n */\nfunction fold(value: string): string {\n return value.trim().toLowerCase().replace(/[\\s._-]+/g, '');\n}\n\n/** The region containing an offset, innermost first. `null` when only the file does. */\nexport function regionAt(regions: readonly SpecificationRegion[], offset: number): SpecificationRegion | null {\n let best: SpecificationRegion | null = null;\n for (const region of regions) {\n // The whole-file region owns nothing in particular; it is the fallback.\n if (region.heading === null && region.row === null) continue;\n if (offset < region.start || offset >= region.end) continue;\n // No two regions of one file open at the same offset, so `>` and `>=`\n // agree here.\n if (best === null || region.start > best.start) best = region;\n }\n return best;\n}\n"]}
package/dist/select.js CHANGED
@@ -162,9 +162,10 @@ class Parser {
162
162
  return out;
163
163
  }
164
164
  // The anchor decides nothing, since a starred class matches the empty
165
- // string where the search starts; it says where the value begins.
166
- const match = /^[^\]\s]*/.exec(this.source.slice(this.position));
167
- const value = (match?.[0] ?? '');
165
+ // string where the search starts; it says where the value begins. For the
166
+ // same reason the search never misses, and there is nothing to fall back
167
+ // from.
168
+ const value = /^[^\]\s]*/.exec(this.source.slice(this.position))[0];
168
169
  this.position += value.length;
169
170
  return value;
170
171
  }