@pithyjs/vite-plugin 0.2.0-beta.11 → 0.2.0-beta.13
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/aotCodegen/generateDomFactory.d.ts +1 -1
- package/dist/aotCodegen/generateDomFactory.d.ts.map +1 -1
- package/dist/aotCodegen/generateDomFactory.js +10 -1
- package/dist/aotCodegen/generateDomFactory.js.map +1 -1
- package/dist/babelPlugin/extractUsedIdentifiers.d.ts.map +1 -1
- package/dist/babelPlugin/extractUsedIdentifiers.js +2 -0
- package/dist/babelPlugin/extractUsedIdentifiers.js.map +1 -1
- package/dist/designSystemPlugin/channelVars.d.ts.map +1 -1
- package/dist/designSystemPlugin/channelVars.js +1 -2
- package/dist/designSystemPlugin/channelVars.js.map +1 -1
- package/dist/routerPlugin/manifest.d.ts.map +1 -1
- package/dist/routerPlugin/manifest.js +54 -107
- package/dist/routerPlugin/manifest.js.map +1 -1
- package/dist/routerPlugin/plugin.d.ts.map +1 -1
- package/dist/routerPlugin/plugin.js +4 -1
- package/dist/routerPlugin/plugin.js.map +1 -1
- package/dist/routerPlugin/scanner.d.ts +17 -2
- package/dist/routerPlugin/scanner.d.ts.map +1 -1
- package/dist/routerPlugin/scanner.js +107 -30
- package/dist/routerPlugin/scanner.js.map +1 -1
- package/dist/ssrPlugin/plugin.d.ts.map +1 -1
- package/dist/ssrPlugin/plugin.js +42 -19
- package/dist/ssrPlugin/plugin.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelVars.js","sourceRoot":"","sources":["../../src/designSystemPlugin/channelVars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,E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C,EAAE,CAAC;IAEP,OAAO;QACL,IAAI,EAAE,CAAC,OAAe,EAAE,MAAqB,EAAE,EAAE,CAC/C,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC;YACrB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;YACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,EAAE,IAAI;QACZ,MAAM,EACJ,GAAG,IAAI,CAAC,IAAI,sBAAsB,KAAK,CAAC,IAAI,CAAC,YAAY,UAAU;YACnE,YAAY;QACd,IAAI;KACL,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.vite-plugin-design-system.channel-vars\",\n \"title\": \"Colour Channel Variable Usage Gate\",\n \"category\": \"plugin\",\n \"description\": \"Scans stylesheets for var(--color-*-rgb|-l|-c|-h) so the static palette emits only the channel variables something can read.\",\n \"since\": \"0.1.0\",\n \"stability\": \"experimental\",\n \"risk\": \"high\",\n \"testing\": {\n \"unit\": { \"required\": true, \"covered\": true, \"file\": \"design-system-channel-vars.test.ts\" },\n \"integration\": { \"required\": true, \"covered\": true, \"file\": \"design-system-channel-vars.test.ts\" },\n \"e2e\": { \"required\": false, \"covered\": false }\n }\n}\n*/\n\nimport fg from 'fast-glob';\nimport { readFileSync, readdirSync, statSync } from 'fs';\nimport { dirname, extname, isAbsolute, join, resolve } from 'path';\nimport {\n CHANNEL_SUFFIXES,\n type ChannelSuffix,\n} from '@pithyjs/design-system/palette';\n\nconst CHANNEL_SUFFIX_COUNT = CHANNEL_SUFFIXES.length;\n\n/**\n * The suffix alternation, BUILT from `CHANNEL_SUFFIXES` rather than retyped.\n * Hard-coding it meant adding a suffix silently created a variable no regex\n * could detect — and pushed `CHANNEL_SUFFIX_COUNT` past what the wildcards can\n * ever hold, so the all-suffixes escape below could never fire again.\n * Longest-first so `rgb` is not shadowed by a prefix of itself.\n */\nconst SUFFIX_ALT = [...CHANNEL_SUFFIXES]\n .sort((a, b) => b.length - a.length)\n .join('|');\n\n/**\n * `var(--color-<anything>-<channel>)` as written in a stylesheet.\n *\n * Deliberately not anchored to a token list: state variants, future tokens and\n * a custom prefix all have to match, and a name that matches nothing real only\n * pins open a variable that was going to ship anyway.\n *\n * `var` is spelled case-insensitively by hand rather than with the `i` flag,\n * which would also loosen the suffix alternation — custom property NAMES are\n * case-sensitive, and `--color-x-RGB` is a property nothing here ever emits.\n */\nconst CHANNEL_REF_RE = new RegExp(\n String.raw`[Vv][Aa][Rr]\\(\\s*(--[A-Za-z0-9_-]*-(?:${SUFFIX_ALT}))\\b`,\n 'g'\n);\n\n/**\n * A `var()` whose custom property name is BUILT — SCSS `#{}` or JS `${}` — and\n * still ends in a channel suffix, e.g. `rgb(var(--color-#{$token}-rgb))` in\n * `@pithyjs/design-system`'s generated `u-*` utilities.\n *\n * Which tokens such a loop covers is unknowable from the text, so a hit pins\n * open every variable with that suffix.\n *\n * KNOWN BLIND SPOTS, all of which leave the gate active rather than degrading\n * it — use `channelVarSafelist`, and see BACKLOG #83 for why deciding at purge\n * time removes the whole class:\n * - the whole name held in a variable: `$p: --color-primary-rgb;` then\n * `var(#{$p})`. This is established house style in the design system's own\n * mixins, so it is the likeliest of these to appear;\n * - assembly other than `+`: `[a, b].join('')`, `a.concat(b)`;\n * - an interpolation containing `}` before the suffix, e.g. a helper called\n * with an inline object literal — `{0,500}` stops at the first `}`;\n * - a name whose SUFFIX is itself interpolated.\n *\n * A name ending in the interpolation (`var(--color-#{$scheme})`) is not matched\n * because it is a base-token reference — but note that is only true when the\n * interpolation does not itself carry the suffix.\n */\n// `{0,500}` rather than `*`: unbounded, it rescanned to EOF from\n// every `var(--X${` with no closing brace, which is quadratic in file size\n// (20KB 16ms, 40KB 61ms, 80KB 248ms, 160KB 971ms). Reachable because package\n// roots are deliberately scanned without the build-output ignores, so a\n// dependency's minified dist is read whole. Bounding is what removes the\n// quadratic term; newlines must stay IN the class, or a Prettier-wrapped\n// interpolation stops matching and unpins its whole family.\n//\n// The TRAILING fragment needed the same treatment and did not get it: it\n// excluded whitespace, so a second interpolation containing a space — a SCSS\n// map lookup, a ternary, anything Prettier wrapped — matched nothing. This is\n// load-bearing: all 142 surviving channel declarations rest on this regex\n// matching `_color-utilities.scss`.\nconst DYNAMIC_CHANNEL_REF_RE = new RegExp(\n String.raw`[Vv][Aa][Rr]\\(\\s*(?:--)?[A-Za-z0-9_-]*(?:#\\{[^}]{0,500}\\}|\\$\\{[^}]{0,500}\\})[^;]{0,200}?-(${SUFFIX_ALT})\\b`,\n 'g'\n);\n\n/**\n * A channel name assembled by string concatenation rather than interpolation\n * — `'var(--color-' + token + '-rgb)'`. The opening fragment ends mid-name, so\n * neither regex above can see it; this one keys on the dangling prefix.\n */\n// Anchored to `--color`, and it must SEE a channel suffix as the LAST segment\n// of the trailing fragment. Three things were wrong before:\n// - anchoring alone pinned every suffix for a base-token concat\n// (`'var(--color-' + scheme + ')'`), tripping the all-suffixes escape and\n// switching the gate off build-wide;\n// - the trailing fragment must CLOSE the var() call: without the `)`,\n// `'var(--color-' + t + ')' + 'chip-l'` matched on an unrelated adjacent\n// string and switched the gate off build-wide;\n// - `['\"`]-(?:rgb|l|c|h)\\b` required the suffix immediately after the quote,\n// so `'-hover-rgb)'` and `'-focus-l)'` — real state-variant channel\n// variables — were missed, while `'-l-delta)'` matched on `\\b` and was a\n// false positive;\n// - `[^;\\n]` forbade newlines, so the shape stopped matching the moment\n// Prettier wrapped it — the identical bug fixed for the sibling detector,\n// never applied here.\n// A concat whose SUFFIX is itself dynamic still matches nothing; that is what\n// `channelVarSafelist` is for, as is a palette built with a custom `prefix`.\nconst CONCAT_CHANNEL_REF_RE = new RegExp(\n String.raw`[Vv][Aa][Rr]\\(\\s*['\"\\`]?--color[A-Za-z0-9_-]*-['\"\\`]\\s*\\+[^;]{0,200}['\"\\`][A-Za-z0-9_-]*?-(?:${SUFFIX_ALT})\\)`,\n 'g'\n);\n\n/**\n * File types that can carry a `var()` in a PithyJS app.\n *\n * This repo has none of `tsx`/`jsx`/`vue`/`svelte`/`astro`/`sass`/`less`, but\n * the plugin is PUBLISHED and its default `include` advertises `src/**\\/*.tsx`\n * — so `tsx` stays. A file this list omits is never opened, which drops the\n * variables it reads with `degraded: false`: the one direction that is a bug.\n * The rest are left out because nothing advertises them.\n */\nconst SCAN_EXTENSIONS = [\n 'css',\n 'scss',\n 'ts',\n 'tsx',\n 'mts',\n 'cts',\n 'js',\n 'jsx',\n 'mjs',\n 'cjs',\n 'pithy',\n 'html',\n // `iconsPlugin/optimize.ts` deliberately preserves `<style>` in SVGs.\n 'svg',\n // The sibling `packages/ssr/src/build/collect-css.ts` matches both and\n // inlines them into every exported page, so a reference in one reaches a\n // static page while this scan could not see it.\n 'sass',\n 'less',\n];\n\n/** Extensions as a lookup, for the dev watcher's per-file relevance check. */\nconst SCAN_EXTENSION_SET = new Set(SCAN_EXTENSIONS.map(e => `.${e}`));\n\n/**\n * Never scanned, in any root. Unambiguous test markers only: a file named\n * `*.test.*` ships no CSS anywhere, whereas a DIRECTORY called `tests` may be a\n * route (`src/routes/tests/+page.scss`), which is why it is not listed here.\n */\nconst ALWAYS_IGNORED = [\n '**/node_modules/**',\n '**/.git/**',\n '**/coverage/**',\n '**/__tests__/**',\n '**/*.test.*',\n '**/*.spec.*',\n];\n\n/**\n * Additionally ignored in a DEPENDENCY root: a library's nested `tests`\n * directories are certainly tests, and they quote channel names as fixtures.\n */\nconst PACKAGE_IGNORED = [...ALWAYS_IGNORED, '**/tests/**'];\n\n/**\n * Additionally ignored under the Vite root — an app's own build output, and its\n * the build output directories below. `tests` is deliberately NOT here: a\n * directory called `tests` may be a route, and this repo has one.\n *\n * All anchored to the root: unanchored, `**\\/build/**` would skip\n * `src/routes/build/+page.scss` on a site that has a `/build` page.\n *\n * NOT applied to package roots: a published `@pithyjs/ui-kit` ships its\n * component SCSS inside `dist`, and skipping it there would drop a variable\n * that really is read, which is the one direction this module must never fail.\n */\nconst BUILD_OUTPUT_IGNORED = [\n 'dist/**',\n 'out/**',\n 'build/**',\n '.vite/**',\n '.output/**',\n];\n\n/**\n * Channel variables composed at runtime from a string, which no scan can see.\n *\n * `ShadowManager.resolveTintColor()` reads `--color-${color}-rgb` through\n * `getComputedStyle` for the three brand tints, so a brand-tinted shadow in an\n * app that never calls `initTheme()` would otherwise read an undefined token.\n */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"DEFAULT_CHANNEL_VAR_SAFELIST\",\"stability\":\"experimental\",\"signature\":\"readonly string[]\"} */\nexport const DEFAULT_CHANNEL_VAR_SAFELIST: readonly string[] = [\n '--color-primary-rgb',\n '--color-secondary-rgb',\n '--color-tertiary-rgb',\n];\n\n/**\n * Index of the unescaped quote closing the one at `start`.\n *\n * A template literal legitimately spans lines, and this repo writes CSS that\n * way (`colors/generate-utilities.ts`). Stopping at the newline left the scan\n * INSIDE the literal, where a `/*` in prose pairs with a later `*\\/` and eats\n * the live references between — the same loss as an unhandled line comment.\n * `'`/`\"` still stop at the newline so an apostrophe in prose cannot open a\n * span that swallows the rest of the file.\n */\nfunction closingQuote(text: string, start: number): number {\n const q = text[start];\n const multiline = q === '`';\n for (let i = start + 1; i < text.length; i++) {\n const c = text[i];\n if (c === '\\\\') i++;\n else if (c === '\\n' && !multiline) return -1;\n else if (c === q) return i;\n }\n return -1;\n}\n\n/**\n * Remove comments before scanning, so a documented example does not read as\n * usage — `_colors.scss` shows `var(--color-primary-l)` in a docblock.\n *\n * Quoted spans are stepped over, so `content: \"/*\"` cannot pair with a later\n * close and swallow the live references between them. A quote with no partner\n * on its own line is ordinary text, so prose (\"don't\") never opens a span, and\n * an unterminated `/*` leaves the rest of the file intact.\n *\n * A comment opener must sit where a comment can START — after input start,\n * whitespace, or one of `;{}` `,` (and `(` for `/*`). Keying on which single\n * character precedes it was tried twice and failed twice: requiring whitespace\n * let `;//` and `}//` through, and excluding only `:`/`(` let the `/` in a\n * base64 blob, an unquoted `href=//cdn/x` and `\\/\\/` inside a regex literal\n * open one. A positive position test rejects all of those, because `src/*.scss`,\n * `AA//BB` and `[^/*]` have an identifier character in front.\n *\n * Every ambiguity here resolves toward NOT stripping: an unstripped docblock\n * over-keeps a variable, a mis-stripped span drops a live one.\n */\n/**\n * End of a `url(` span, honouring quotes and nesting.\n *\n * `indexOf(')')` closed on a `)` INSIDE the quoted URL — `url(\"x),/*y\")` — so\n * the scanner resumed inside URL text, where a `/*` then opened a real block\n * comment. Reachable in an unencoded inline SVG data URI, or any path with\n * parentheses. Seventh position of this class, in the span added to close it.\n */\nfunction closingUrlParen(text: string, from: number): number {\n let depth = 1;\n let quote = '';\n for (let i = from; i < text.length; i++) {\n const c = text[i];\n if (c === '\\\\') {\n i++;\n continue;\n }\n if (quote) {\n if (c === quote) quote = '';\n continue;\n }\n if (c === '\"' || c === \"'\") quote = c;\n else if (c === '(') depth++;\n else if (c === ')' && --depth === 0) return i;\n }\n return -1;\n}\n\n/**\n * End of the regex literal opening at `at`, or -1.\n *\n * Only needed so a literal's contents cannot open a comment or a string: the\n * span is emitted VERBATIM, so any `var()` inside it is still scanned and\n * mistaking a division for a regex can never lose a reference. Without this,\n * the backtick in this module's own `/[\"'`]|.../` character class read as a\n * template-literal opener and misaligned the rest of the file.\n */\nfunction closingSlash(text: string, at: number): number {\n let inClass = false;\n for (let i = at + 1; i < text.length; i++) {\n const c = text[i];\n if (c === '\\\\') {\n i++;\n continue;\n }\n if (c === '\\n') return -1;\n if (inClass) {\n if (c === ']') inClass = false;\n } else if (c === '[') inClass = true;\n else if (c === '/') return i;\n }\n return -1;\n}\n\n/** Whether a `/` at `at` can start a regex literal rather than divide. */\nfunction opensRegex(text: string, at: number): boolean {\n let i = at - 1;\n for (; i >= 0 && /\\s/.test(text[i]); i--);\n if (i < 0) return true;\n if ('(,=:[!&|?{;+*%<>~^'.includes(text[i])) return true;\n // A KEYWORD position too. `return /[ /*]/.test(c)` was read as division, so\n // the `/*` inside the character class opened a real block comment — the\n // eighth position of this class, inside the code added to close the first six.\n const word = /[A-Za-z$_]+$/.exec(text.slice(Math.max(0, i - 11), i + 1));\n return word !== null && KEYWORDS_BEFORE_REGEX.has(word[0]);\n}\n\n/** Keywords a regex literal may follow; after an operand, `/` divides. */\nconst KEYWORDS_BEFORE_REGEX = new Set([\n 'return',\n 'typeof',\n 'case',\n 'in',\n 'of',\n 'new',\n 'delete',\n 'void',\n 'instanceof',\n 'do',\n 'else',\n 'yield',\n 'await',\n 'throw',\n]);\n\n/**\n * Which comment syntaxes a file's language actually has.\n *\n * `stripComments` had no idea what it was reading, so it applied JS/CSS rules\n * to text where `//` and `/*` are ordinary characters. Two live losses came\n * from exactly that: `:root{--cdn: //cdn.example.com}` in a minified `.css`\n * (plain CSS has NO line comment, and package roots are deliberately scanned\n * without the build-output ignores, so a dependency's minified dist is this\n * shape), and `/*` written as prose in `.html`.\n *\n * Erring toward NOT stripping is the safe direction — an unstripped docblock\n * over-keeps a variable, a mis-stripped span drops a live one — so an unknown\n * extension gets both, matching the previous behaviour, and `.html`/`.svg` get\n * neither. A `<style>` block inside them keeps its comments, which can only\n * over-keep.\n */\nfunction commentSyntax(ext: string): { line: boolean; block: boolean } {\n switch (ext.replace(/^\\./, '').toLowerCase()) {\n case 'css':\n return { line: false, block: true };\n // `.pithy` sits with them: it is `<template>` + `<script>` + plain-CSS\n // `<style>`, so prose `/*` in the template paired with the real `*/` in the\n // style block and ate the rule between — the `.css` bug this function\n // exists to fix, in the project's own format. `<script>` genuinely has\n // `//`, so disabling both over-keeps its commented-out examples; that is\n // the safe direction, and per-block handling is not worth it for 7 files.\n case 'html':\n case 'svg':\n case 'pithy':\n return { line: false, block: false };\n default:\n return { line: true, block: true };\n }\n}\n\n/**\n * Whether a comment opener at `at` is in a position a comment can start.\n *\n * `block` allows `(` as well, for `foo(/* x *\\/ y)`. `//` must not, or\n * `url(//cdn/x)` reads as a comment.\n */\nfunction opensComment(text: string, at: number, block: boolean): boolean {\n if (at === 0) return true;\n const prev = text[at - 1];\n if (/\\s/.test(prev)) return true;\n if (prev === ';' || prev === '{' || prev === '}' || prev === ',') return true;\n return block && prev === '(';\n}\n\nfunction stripComments(text: string, ext = ''): string {\n const syntax = commentSyntax(ext);\n let noCloser = false;\n const interesting = /[Uu][Rr][Ll]\\(|[\"'`]|\\/\\*|\\/\\/|\\//g;\n let out = '';\n let i = 0;\n\n for (let m = interesting.exec(text); m; m = interesting.exec(text)) {\n const at = m.index;\n out += text.slice(i, at);\n\n if (m[0].length === 4) {\n // `url(...)` is OPAQUE, like a quote or a regex literal: emitted\n // verbatim, so its contents cannot open anything. A base64 payload\n // beginning `//` (a standard BMP/ICO prefix) sat right after the `,`\n // that `opensComment` accepts, and on a minified one-line file the\n // \"comment\" then ran to EOF. This also subsumes `url(//cdn/x)` and\n // `url(img/*.png)`. Refs inside are still found, since the text stays.\n const close = closingUrlParen(text, at + 4);\n if (close === -1) {\n out += m[0];\n i = at + 4;\n } else {\n out += text.slice(at, close + 1);\n i = close + 1;\n }\n } else if (m[0] === '//') {\n if (!syntax.line || !opensComment(text, at, false)) {\n // Emit the REST OF THE LINE verbatim, not just the two characters.\n // Re-feeding the retained text let a space-preceded `/*` inside it\n // open a real block comment running to the next `*/` — the loss kept\n // coming back through the retained text while four rounds replaced the\n // predicate. Opaque spans are what the quote and regex branches do.\n const nl = text.indexOf('\\n', at);\n const stop = nl === -1 ? text.length : nl;\n out += text.slice(at, stop);\n i = stop;\n } else {\n const nl = text.indexOf('\\n', at);\n out += ' ';\n i = nl === -1 ? text.length : nl;\n }\n } else if (m[0] === '/*') {\n // Language and position FIRST: `.html`/`.svg` have no block comment, and\n // the `indexOf` below is a scan to EOF whose result they then discard.\n if (!syntax.block || noCloser || !opensComment(text, at, true)) {\n out += m[0];\n i = at + 2;\n interesting.lastIndex = i;\n continue;\n }\n const end = text.indexOf('*/', at + 2);\n if (end === -1) {\n // No `*/` after here means none after any LATER `/*` either, so stop\n // searching. Without this latch every `/*` in a file with no closer\n // rescanned to EOF — quadratic, 1.9 s on 70 KB of `/* `.\n noCloser = true;\n out += m[0];\n i = at + 2;\n interesting.lastIndex = i;\n continue;\n }\n out += ' ';\n i = end + 2;\n } else if (m[0] === '/') {\n const end = opensRegex(text, at) ? closingSlash(text, at) : -1;\n if (end === -1) {\n out += m[0];\n i = at + 1;\n } else {\n out += text.slice(at, end + 1);\n i = end + 1;\n }\n } else {\n const end = closingQuote(text, at);\n if (end === -1) {\n out += m[0];\n i = at + 1;\n } else {\n out += text.slice(at, end + 1);\n i = end + 1;\n }\n }\n interesting.lastIndex = i;\n }\n\n return out + text.slice(i);\n}\n\n/**\n * Every channel variable `text` reads.\n *\n * @param text - Stylesheet or source text.\n * @returns The fully-qualified custom property names referenced by `var()`.\n *\n * @example\n * ```typescript\n * collectChannelVarRefs('.m{background:rgb(var(--color-overlay-rgb) / 0.55)}');\n * // Set { '--color-overlay-rgb' }\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"collectChannelVarRefs\",\"stability\":\"experimental\",\"signature\":\"(text: string) => Set<string>\"} */\nexport function collectChannelVarRefs(text: string, ext = ''): Set<string> {\n const refs = new Set<string>();\n for (const match of stripComments(text, ext).matchAll(CHANNEL_REF_RE)) {\n refs.add(match[1]);\n }\n return refs;\n}\n\n/**\n * Channel suffixes `text` reads through a name it BUILDS rather than writes.\n *\n * @param text - Stylesheet or source text.\n * @returns The suffixes whose whole family must be kept; see\n * {@link DYNAMIC_CHANNEL_REF_RE} for what does and does not count.\n *\n * @example\n * ```typescript\n * collectDynamicChannelSuffixes('a{b:rgb(var(--color-#{$token}-rgb))}');\n * // Set { 'rgb' }\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"collectDynamicChannelSuffixes\",\"stability\":\"experimental\",\"signature\":\"(text: string) => Set<ChannelSuffix>\"} */\nexport function collectDynamicChannelSuffixes(\n text: string,\n ext = ''\n): Set<ChannelSuffix> {\n const suffixes = new Set<ChannelSuffix>();\n const source = stripComments(text, ext);\n for (const match of source.matchAll(DYNAMIC_CHANNEL_REF_RE)) {\n suffixes.add(match[1] as ChannelSuffix);\n }\n // A concatenated name hides its suffix in a later fragment, so which family\n // it reads is unknowable. Keep all of them.\n if (CONCAT_CHANNEL_REF_RE.test(source)) {\n CONCAT_CHANNEL_REF_RE.lastIndex = 0;\n for (const suffix of CHANNEL_SUFFIXES) suffixes.add(suffix);\n }\n return suffixes;\n}\n\n/** Whether a changed file could contain a channel reference — dev watcher. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"isChannelScanCandidate\",\"stability\":\"experimental\",\"signature\":\"(filePath: string) => boolean\"} */\nexport function isChannelScanCandidate(filePath: string): boolean {\n // Lower-cased to match the glob's `caseSensitiveMatch: false`: a `.SCSS`\n // the scan reads but the watcher ignores goes stale on every edit.\n if (!SCAN_EXTENSION_SET.has(extname(filePath).toLowerCase())) return false;\n // A file the scan always ignores cannot change the result, so rescanning on\n // it is pure cost — and saving a test file is the common case.\n const unix = filePath.replace(/\\\\/g, '/');\n return (\n // ONLY what every root ignores. Adding the build-output names here was\n // wrong in the other direction: the scan's `BUILD_OUTPUT_IGNORED` is\n // anchored to the Vite root and is deliberately NOT applied to package\n // roots, so `src/routes/build/+page.scss` and a package's `dist/*.scss`\n // are both scanned — and this check was refusing to rescan them, leaving\n // the dev sheet stale for the session. An extra rescan costs time; a\n // missed one is wrong output, so this errs toward rescanning. (The SSG\n // export's own `.html` writes still trip it — cost only, since\n // `sameChannelScan` discards the result.)\n !/(^|\\/)(node_modules|\\.git|coverage|__tests__)\\//.test(unix) &&\n !/\\.(test|spec)\\.[^/]+$/.test(unix)\n );\n}\n\n/** Outcome of a filesystem scan. `degraded` means: keep every channel variable. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelVarScan\",\"stability\":\"experimental\",\"signature\":\"interface ChannelVarScan\"} */\nexport interface ChannelVarScan {\n refs: Set<string>;\n /** Suffixes read through a built name — every variable with one is kept. */\n wildcardSuffixes: Set<ChannelSuffix>;\n degraded: boolean;\n reason?: string;\n filesScanned: number;\n}\n\n/**\n * `false` only for \"not there\". An EACCES or ELOOP means \"cannot tell\", and\n * collapsing that to `false` routed a real install to `absent` — the one\n * classification that keeps the gate ACTIVE. Those throw instead, so the\n * caller degrades.\n */\nfunction statKind(p: string): 'dir' | 'file' | 'other' | 'missing' {\n try {\n const st = statSync(p);\n return st.isDirectory() ? 'dir' : st.isFile() ? 'file' : 'other';\n } catch (err) {\n const code = (err as NodeJS.ErrnoException)?.code;\n if (code === 'ENOENT' || code === 'ENOTDIR') return 'missing';\n throw err;\n }\n}\n\nfunction isDir(p: string): boolean {\n return statKind(p) === 'dir';\n}\n\nfunction isFile(p: string): boolean {\n return statKind(p) === 'file';\n}\n\n/**\n * Where a framework package's source tree is — or why it could not be found.\n *\n * `absent` and `unresolvable` are deliberately different answers. A package\n * nobody installed cannot contribute CSS to the output, so skipping it is\n * certain. A package that may be installed but cannot be located — a partial\n * install, or a layout with no `node_modules` at all, such as Yarn PnP — may\n * have its SCSS in the bundle regardless, and that is uncertainty.\n */\ntype PackageDirLookup =\n | { kind: 'dir'; dir: string }\n | { kind: 'absent' }\n | { kind: 'unresolvable'; reason: string };\n\n/**\n * Locate a framework package's source tree so its component SCSS can be read.\n *\n * A Vite alias first (the monorepo case, pointing at `src`), then\n * {@link probePackage}. Not found resolves to `absent` only when nothing\n * declares the package; otherwise it degrades — see the body.\n */\nfunction resolvePackageDir(\n name: string,\n aliases: unknown,\n from: string\n): PackageDirLookup {\n const aliased = aliasReplacement(name, aliases);\n if (aliased) {\n if (isDir(aliased)) return { kind: 'dir', dir: aliased };\n // An alias may point at an entry FILE (`.../src/index.ts`). A path that is\n // neither is returned as-is so the scan degrades rather than silently\n // scanning its parent.\n return { kind: 'dir', dir: isFile(aliased) ? dirname(aliased) : aliased };\n }\n\n const probe = probePackage(name, from);\n if (probe.dir) return { kind: 'dir', dir: probe.dir };\n\n // `absent` means CERTAINLY not installed, and only that answer keeps the\n // gate on. Everything else degrades, which keeps every channel variable:\n // - a directory with no manifest — something IS installed, unreadable;\n // - no `node_modules` anywhere (Yarn PnP) — nothing can be ruled out;\n // - declared but not found — pnpm's isolated store, a partial install.\n // Guessing `absent` in any of those leaves the gate active and blind to the\n // package that reads these variables.\n if (probe.dirWithoutManifest) {\n return {\n kind: 'unresolvable',\n reason: `${probe.dirWithoutManifest} has no package.json`,\n };\n }\n if (!probe.sawNodeModules) {\n return {\n kind: 'unresolvable',\n reason: `no node_modules tree above ${from}`,\n };\n }\n return isDeclaredDependency(name, from)\n ? {\n kind: 'unresolvable',\n reason: `${name} is declared but was not found on disk from ${from}`,\n }\n : { kind: 'absent' };\n}\n\n/**\n * `pkg@1.2.3_peer@4.5.6` → `['pkg', [1,2,3]]`.\n *\n * The peer suffix is cut FIRST. Reading the version from the last `@` picked\n * the PEER's version instead — replayed against this repo's store, 23 of 109\n * names resolved to a non-newest copy, worst case prettier 2.8.8 over 3.5.3\n * via `_@changesets+apply-release-plan@7.1.1`.\n */\nfunction parseStoreEntry(entry: string): { pkg: string; version: number[] } {\n const base = entry.split('_')[0];\n const at = base.lastIndexOf('@');\n const pkg = at > 0 ? base.slice(0, at) : base;\n const raw = at > 0 ? base.slice(at + 1) : '';\n return {\n pkg,\n version: raw.split(/[.\\-+]/).map(n => (/^\\d+$/.test(n) ? Number(n) : -1)),\n };\n}\n\n/**\n * Orders `.pnpm` entries so the probe reads the newest copy OF THE PACKAGE it\n * is looking for. An entry can host `name` nested under a different package,\n * so entries whose own package IS `name` sort first — otherwise the comparator\n * would be ranking unrelated versions.\n */\nfunction compareStoreEntries(name: string, a: string, b: string): number {\n const want = name.replace(/\\//g, '+');\n const pa = parseStoreEntry(a);\n const pb = parseStoreEntry(b);\n const exact = (p: { pkg: string }) => (p.pkg === want ? 0 : 1);\n const byExact = exact(pa) - exact(pb);\n if (byExact !== 0) return byExact;\n for (let i = 0; i < Math.max(pa.version.length, pb.version.length); i++) {\n const d = (pb.version[i] ?? -1) - (pa.version[i] ?? -1);\n if (d !== 0) return d;\n }\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\ninterface PackageProbe {\n dir: string | null;\n dirWithoutManifest: string | null;\n sawNodeModules: boolean;\n}\n\n/**\n * Walk up looking for the package, recording what was seen on the way.\n *\n * Probes `node_modules/<name>` and pnpm's isolated store, where a transitive\n * dependency lives only at `node_modules/.pnpm/<pkg>@<ver>/node_modules/<name>`\n * with no top-level link.\n *\n * NOT `require.resolve`: `@pithyjs/ui-kit` and `@pithyjs/design-system`\n * declare `exports` with an `import` condition and no `require` one, so a CJS\n * resolver rejects both with `ERR_PACKAGE_PATH_NOT_EXPORTED` — the entry and\n * the `package.json` subpath alike. The directory is right there either way.\n */\nfunction probePackage(name: string, from: string): PackageProbe {\n const out: PackageProbe = {\n dir: null,\n dirWithoutManifest: null,\n sawNodeModules: false,\n };\n let dir = from;\n for (;;) {\n const modules = join(dir, 'node_modules');\n if (isDir(modules)) out.sawNodeModules = true;\n\n const direct = join(modules, name);\n if (isFile(join(direct, 'package.json'))) {\n out.dir = direct;\n return out;\n }\n\n // npm nests a conflicting version under its dependent, so the package can\n // live at `node_modules/<dep>/node_modules/<name>`. Missing it classified\n // a real install as `absent` — the one answer that keeps the gate on.\n for (const host of ['@pithyjs/ui-kit', '@pithyjs/design-system']) {\n if (host === name) continue;\n const nested = join(modules, host, 'node_modules', name);\n if (isFile(join(nested, 'package.json'))) {\n out.dir = nested;\n return out;\n }\n }\n if (out.dirWithoutManifest === null && isDir(direct)) {\n out.dirWithoutManifest = direct;\n }\n\n const store = join(modules, '.pnpm');\n if (isDir(store)) {\n let entries: string[] = [];\n try {\n // Sorted by VERSION, descending. The store holds one name at several\n // versions (and under other packages' entries), and `readdirSync`\n // order is filesystem dependent, so taking whichever came first made\n // the palette differ between machines on one lockfile. A plain\n // lexicographic sort then preferred `@1.0.0` over `@2.0.0` and `@12`\n // over `@22`; this is still a guess, but the newest copy is the one a\n // bundler is likeliest to have resolved.\n entries = readdirSync(store).sort((x, y) =>\n compareStoreEntries(name, x, y)\n );\n } catch {\n entries = [];\n }\n for (const entry of entries) {\n const candidate = join(store, entry, 'node_modules', name);\n if (isFile(join(candidate, 'package.json'))) {\n out.dir = candidate;\n return out;\n }\n }\n }\n\n const up = dirname(dir);\n if (up === dir) return out;\n dir = up;\n }\n}\n\n/** Whether any `package.json` above `from` lists `name` in a dependency field. */\nfunction isDeclaredDependency(name: string, from: string): boolean {\n const FIELDS = [\n 'dependencies',\n 'devDependencies',\n 'peerDependencies',\n 'optionalDependencies',\n ] as const;\n let dir = from;\n for (;;) {\n const manifest = join(dir, 'package.json');\n if (isFile(manifest)) {\n try {\n const json = JSON.parse(readFileSync(manifest, 'utf8')) as Record<\n string,\n Record<string, string> | undefined\n >;\n // A non-object dependency field cannot prove absence. `in` on an\n // array or null answers false, which routed a declared package to\n // `absent` — strictly worse than an UNPARSEABLE manifest, which\n // already fails open below.\n for (const f of FIELDS) {\n const field = json[f];\n if (field === undefined || field === null) continue;\n if (typeof field !== 'object' || Array.isArray(field)) return true;\n if (name in field) return true;\n }\n } catch {\n // An unreadable manifest cannot prove absence.\n return true;\n }\n }\n const up = dirname(dir);\n if (up === dir) return false;\n dir = up;\n }\n}\n\nfunction aliasReplacement(name: string, aliases: unknown): string | null {\n if (!Array.isArray(aliases)) return null;\n for (const entry of aliases as Array<{\n find?: string | RegExp;\n replacement?: string;\n }>) {\n if (typeof entry.replacement !== 'string') continue;\n\n if (typeof entry.find === 'string') {\n // Vite's own rule: equal, or a prefix ending at a `/` SEGMENT boundary\n // (`importee === pattern || importee.startsWith(pattern + '/')`).\n // Omitting the boundary let `{find:'@'}` — a very common config — build\n // `<src>pithyjs/ui-kit` out of `@pithyjs/ui-kit`.\n if (entry.find === name) return entry.replacement;\n if (name.startsWith(`${entry.find}/`)) {\n return entry.replacement + name.slice(entry.find.length);\n }\n\n // A SUBPATH alias (`@pithyjs/ui-kit/styles`) names a directory inside\n // the package, so peel the subpath off to get the package root. If the\n // replacement does not end with that subpath — every app here maps\n // `/styles` to `.../styles/index.scss` — the root cannot be derived, so\n // give up on this entry rather than return the subpath. Returning it\n // narrowed the scan to one directory, and which of the two happened\n // depended on the ORDER of keys in the alias object.\n if (entry.find.startsWith(`${name}/`)) {\n const sub = entry.find.slice(name.length);\n if (entry.replacement.endsWith(sub)) {\n return entry.replacement.slice(0, -sub.length);\n }\n continue;\n }\n } else if (entry.find instanceof RegExp) {\n // A LOCAL CLONE. The alias object belongs to Vite, which calls\n // `pattern.test(importee)` on it for every later import — and `test` and\n // `[Symbol.replace]` both advance `lastIndex` on a /y or /g pattern.\n // Resetting before the call was not enough: leaving it advanced AFTER\n // made the user's alias stop resolving for the rest of the build, a\n // module-resolution failure caused by a CSS plugin. Never mutate it.\n const find = new RegExp(entry.find.source, entry.find.flags);\n if (find.test(name)) {\n find.lastIndex = 0;\n // STRING replacement: `$1` is the documented Vite API, and\n // `{find: /^@pithyjs\\/(.*)$/, replacement: 'packages/$1/src'}` is the\n // canonical monorepo alias.\n return name.replace(find, entry.replacement);\n }\n }\n }\n return null;\n}\n\n/** One directory to scan, with the ignore set its kind warrants. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelScanRoot\",\"stability\":\"experimental\",\"signature\":\"interface ChannelScanRoot\"} */\nexport interface ChannelScanRoot {\n dir: string;\n ignore: string[];\n}\n\n/** Everything one build can be scanned over, and what could not be located. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelScanPlan\",\"stability\":\"experimental\",\"signature\":\"interface ChannelScanPlan\"} */\nexport interface ChannelScanPlan {\n roots: ChannelScanRoot[];\n /** Packages the bundler may still see — each one degrades the scan. */\n unresolvable: string[];\n}\n\n/** Scan roots for one build: the Vite root, the framework packages, extras. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"resolveChannelScanRoots\",\"stability\":\"experimental\",\"signature\":\"(viteRoot: string, aliases: unknown, extraRoots?: string[]) => ChannelScanPlan\"} */\nexport function resolveChannelScanRoots(\n viteRoot: string,\n aliases: unknown,\n extraRoots: string[] = []\n): ChannelScanPlan {\n // Validate rather than throw from deep inside. A string passed where an\n // array belongs used to surface as `scan threw: TypeError: …map is not a\n // function` — a config mistake reported as an internal failure, which then\n // turned the feature off. Named here, it degrades with a usable message.\n if (!Array.isArray(extraRoots)) {\n return {\n roots: [],\n unresolvable: [\n `channelVarScanRoots must be an array of paths, received ${typeof extraRoots}`,\n ],\n };\n }\n for (const entry of extraRoots) {\n if (typeof entry !== 'string' || entry === '') {\n return {\n roots: [],\n unresolvable: [\n `channelVarScanRoots entries must be non-empty strings, received ${JSON.stringify(entry)}`,\n ],\n };\n }\n }\n const roots: ChannelScanRoot[] = [\n { dir: viteRoot, ignore: [...ALWAYS_IGNORED, ...BUILD_OUTPUT_IGNORED] },\n // Resolved against the Vite root, like `include`/`exclude` — a relative\n // entry used to be evaluated against `process.cwd()`, so a monorepo-root\n // config could scan a same-named directory in the wrong tree and still\n // report `degraded: false`.\n //\n // Only the UNIVERSAL ignores. Not the dependency set, which excludes\n // `**/tests/**` while a directory called `tests` may be a route (this repo\n // has `apps/basic-app/src/routes/tests/`); and not the ROOT set, which\n // skips `dist/**`, where a published library's CSS exists\n // nowhere else — a root someone names explicitly is one they want read.\n // The dependency set is also wrong here, because it excludes\n // `**/tests/**` and a directory called `tests` may be a route.\n ...extraRoots.map(dir => ({\n dir: isAbsolute(dir) ? dir : join(viteRoot, dir),\n ignore: [...ALWAYS_IGNORED],\n })),\n ];\n const unresolvable: string[] = [];\n\n // UI Kit ships the component SCSS that consumes these variables, and the\n // design system ships the mixins; neither lives under the Vite root.\n for (const pkg of ['@pithyjs/ui-kit', '@pithyjs/design-system']) {\n const found = resolvePackageDir(pkg, aliases, viteRoot);\n if (found.kind === 'dir')\n roots.push({ dir: found.dir, ignore: PACKAGE_IGNORED });\n else if (found.kind === 'unresolvable') unresolvable.push(found.reason);\n }\n\n // Dedupe on the RESOLVED path, and keep the WIDEST ignore set for a path\n // reached twice. Exact string identity meant `channelVarScanRoots: ['.']`\n // collapsed into the Vite root and silently inherited its build-output\n // ignores — so `dist/**` went unread — while `'./'`, the same intent, stayed\n // separate and read it. An explicitly named root is one someone wants read,\n // so the narrower set must not win.\n const byPath = new Map<string, ChannelScanRoot>();\n for (const root of roots) {\n const key = resolve(root.dir);\n const prev = byPath.get(key);\n if (prev === undefined) {\n byPath.set(key, { ...root, dir: key });\n continue;\n }\n // INTERSECTION, not the shorter array. The two ignore sets are not nested:\n // `PACKAGE_IGNORED` has fewer entries than the root set but ADDS\n // `**/tests/**`, so picking it by length hid `src/routes/tests/` — the\n // exact file the root set exists to keep. Only a pattern both sets ignore\n // is safe to ignore here.\n const both = new Set(prev.ignore);\n byPath.set(key, {\n ...root,\n dir: key,\n ignore: root.ignore.filter(p => both.has(p)),\n });\n }\n return { roots: [...byPath.values()], unresolvable };\n}\n\n/**\n * Read every scannable file under `plan.roots` and union the channel variables\n * they reference.\n *\n * **Fails OPEN, and this is the module's one invariant.** A root that is\n * missing, a root a glob matched no file in, a package that will not resolve, a\n * glob that throws, a file that cannot be read — each sets `degraded`, and a\n * degraded scan makes the caller emit every channel variable. A variable\n * dropped by mistake renders a JavaScript-disabled page wrong; a variable kept\n * by mistake costs bytes. Only one of those is a bug.\n *\n * @example\n * ```typescript\n * const scan = scanChannelVarRefs(resolveChannelScanRoots(config.root, alias));\n * if (scan.degraded) console.warn(scan.reason);\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"scanChannelVarRefs\",\"stability\":\"experimental\",\"signature\":\"(plan: ChannelScanPlan) => ChannelVarScan\"} */\nexport function scanChannelVarRefs(plan: ChannelScanPlan): ChannelVarScan {\n const refs = new Set<string>();\n const wildcardSuffixes = new Set<ChannelSuffix>();\n let filesScanned = 0;\n let readFailure: string | undefined;\n\n const fail = (reason: string): ChannelVarScan => ({\n refs,\n wildcardSuffixes,\n degraded: true,\n reason,\n filesScanned,\n });\n\n if (plan.unresolvable.length > 0) {\n return fail(`unresolvable package: ${plan.unresolvable.join('; ')}`);\n }\n\n for (const { dir: root, ignore } of plan.roots) {\n // `statKind` rethrows EACCES/ELOOP so the caller can degrade — but this,\n // the first caller, was not catching, so the module threw where its own\n // invariant says it fails open. An unreadable directory is the common\n // CI/Docker shape; only an unreadable FILE was covered.\n let readable: boolean;\n try {\n readable = isDir(root);\n } catch (err) {\n return fail(`unreadable root ${root}: ${String(err)}`);\n }\n if (!readable) return fail(`unreadable root: ${root}`);\n\n let files: string[];\n try {\n // Every option here widens rather than narrows, because a file this\n // scan does not read is a variable it drops. `dot` reaches generated\n // `.generated/` trees; `caseSensitiveMatch: false` reaches `D.SCSS` on\n // the case-insensitive filesystems Vite resolves it on; symlinks are\n // followed because a linked source tree is source.\n files = fg.sync(`**/*.{${SCAN_EXTENSIONS.join(',')}}`, {\n cwd: root,\n absolute: true,\n ignore,\n followSymbolicLinks: true,\n // Bounded. `followSymbolicLinks` with no cap turns one upward link\n // into exponential path growth and a cycle into a non-terminating\n // walk — which hangs `buildStart` and the dev rescan, with no throw\n // and so no degradation signal. No real source tree is 24 deep.\n deep: 24,\n // NOT suppressed. Swallowing a per-entry EACCES/ELOOP returns a\n // PARTIAL list with no error, so every reference in the unreadable\n // subtree is dropped while `degraded` stays false — a root-owned\n // directory in a CI or Docker build ships an incomplete palette and\n // says nothing. Surfacing the throw degrades instead, which keeps\n // every variable.\n suppressErrors: false,\n dot: true,\n caseSensitiveMatch: false,\n });\n } catch (err) {\n return fail(`glob failed in ${root}: ${String(err)}`);\n }\n\n // An empty match is uncertainty, not evidence of absence: a mis-anchored\n // ignore or a tree laid out unexpectedly looks exactly like this.\n if (files.length === 0) return fail(`no scannable files under ${root}`);\n\n for (const file of files) {\n let content: string;\n try {\n content = readFileSync(file, 'utf-8');\n } catch (err) {\n // Keep reading rather than abort on the first failure, so one\n // unreadable file does not decide the whole scan. A file present at\n // glob time and gone at read time is routine — an atomic editor save,\n // an export cleaning its out dir, a dangling symlink.\n //\n // This does NOT remove the dev flap: `fail()` below still degrades the\n // whole scan, so a transient failure still swings the sheet between\n // gated and ungated between rescans. What it removes is losing the\n // refs already collected. Deciding at purge time (BACKLOG #83) is what\n // actually ends the flap.\n readFailure ??= `unreadable file ${file}: ${String(err)}`;\n continue;\n }\n filesScanned++;\n const ext = extname(file);\n for (const ref of collectChannelVarRefs(content, ext)) refs.add(ref);\n for (const s of collectDynamicChannelSuffixes(content, ext)) {\n wildcardSuffixes.add(s);\n }\n }\n }\n\n if (readFailure !== undefined) return fail(readFailure);\n return { refs, wildcardSuffixes, degraded: false, filesScanned };\n}\n\n/** Inputs to {@link createChannelVarGate}. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelVarGateInput\",\"stability\":\"experimental\",\"signature\":\"interface ChannelVarGateInput\"} */\nexport interface ChannelVarGateInput {\n /** `false` disables gating entirely — the `gateChannelVars` escape hatch. */\n enabled: boolean;\n /** Filesystem scan result; `null` means no scan ran, which keeps everything. */\n scan: ChannelVarScan | null;\n /**\n * Names read by text the plugin holds rather than reads — the generated\n * utility CSS. Defence-in-depth, and empty today: the plugin's own\n * `generator.ts` emits no channel reference at all. The design system's other\n * utility generator (`colors/generate-utilities.ts`) emits exactly this form,\n * so a future route through it is caught rather than silently unstyled.\n */\n extraRefs?: Iterable<string>;\n /** Additional names to keep, on top of {@link DEFAULT_CHANNEL_VAR_SAFELIST}. */\n safelist?: Array<string | RegExp>;\n}\n\n/** A gate ready to hand to `themeToCss`, plus why it decided what it did. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelVarGate\",\"stability\":\"experimental\",\"signature\":\"interface ChannelVarGate\"} */\nexport interface ChannelVarGate {\n /**\n * The scan failed, as opposed to the gate being switched off or correctly\n * deciding to keep everything. Only this warrants a build-time warning.\n */\n degraded?: boolean;\n keep: (varName: string, suffix: ChannelSuffix) => boolean;\n /** `false` when every channel variable ships — disabled, or failed open. */\n active: boolean;\n reason: string;\n /** Names the gate will let through, when active. */\n kept: Set<string>;\n}\n\n/**\n * Build the emission gate from everything known about this build.\n *\n * @example\n * ```typescript\n * const gate = createChannelVarGate({ enabled: true, scan, extraRefs: utilityRefs });\n * const css = themeToCss(theme, { defaultMode, keepChannelVar: gate.keep });\n * ```\n */\n/** A description of any value that cannot itself throw. */\nfunction describe(v: unknown): string {\n try {\n return typeof v === 'object' && v !== null\n ? Object.prototype.toString.call(v)\n : String(v);\n } catch {\n return typeof v;\n }\n}\n\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"createChannelVarGate\",\"stability\":\"experimental\",\"signature\":\"(input: ChannelVarGateInput) => ChannelVarGate\"} */\nexport function createChannelVarGate(\n input: ChannelVarGateInput\n): ChannelVarGate {\n const keepAll = (reason: string, degraded = false): ChannelVarGate => ({\n keep: () => true,\n active: false,\n // `active: false` conflates three things: switched off, DEGRADED, and\n // correctly decided to keep everything. Only the middle one is a problem\n // worth warning about, so it is flagged separately.\n degraded,\n reason,\n kept: new Set(),\n });\n\n if (!input.enabled) return keepAll('disabled via gateChannelVars: false');\n if (!input.scan) return keepAll('no source scan ran');\n if (input.scan.degraded)\n return keepAll(input.scan.reason ?? 'scan degraded', true);\n\n const kept = new Set<string>([\n ...DEFAULT_CHANNEL_VAR_SAFELIST,\n ...input.scan.refs,\n ...(input.extraRefs ?? []),\n ]);\n // Validate, then CLONE. `keep()` runs ~800 times per sheet and\n // `patterns.some` short-circuits, so testing the caller's own objects left\n // them at arbitrary `lastIndex` offsets — an app factoring one array into\n // both `safelist` and `channelVarSafelist` got silent cross-contamination.\n // Same rule as the two alias resolvers: never mutate what the caller owns.\n const safelist = input.safelist ?? [];\n if (!Array.isArray(safelist)) {\n return keepAll(\n `channelVarSafelist must be an array, received ${typeof safelist}`,\n true\n );\n }\n const patterns: RegExp[] = [];\n for (const entry of safelist) {\n if (typeof entry === 'string') {\n kept.add(entry);\n } else if (entry instanceof RegExp) {\n // Clone WITHOUT `g`/`y`. The clone alone protects the caller's object;\n // dropping the stateful flags is what makes `test()` correct here, since\n // `lastIndex` on a global pattern makes consecutive matches skip every\n // other name. Neither flag means anything for a boolean membership test.\n patterns.push(new RegExp(entry.source, entry.flags.replace(/[gy]/g, '')));\n } else {\n // A config mistake must not surface as a TypeError from inside `load()`,\n // which has no try/catch. Uncertainty ships everything.\n // `String(...)`, not `JSON.stringify`: the latter throws on a BigInt and\n // on a circular object, from inside the guard whose own purpose is that a\n // config mistake must not surface as an internal failure.\n return keepAll(\n `channelVarSafelist entries must be strings or RegExps, received ${describe(entry)}`,\n true\n );\n }\n }\n\n const wildcards = input.scan.wildcardSuffixes;\n if (wildcards.size === CHANNEL_SUFFIX_COUNT) {\n // `degraded: true` so this is AUDIBLE. `active: false` alone silenced both\n // signals — the warning keys on `degraded`, the banner on `active` — so a\n // single concat anywhere switched the feature off with no output at all.\n // It is not a failure, but it is a surprise worth one line.\n return keepAll(`every suffix read through a built name`, true);\n }\n\n const wildcardNote = wildcards.size\n ? `, all -${[...wildcards].join('/-')} (built names)`\n : '';\n\n return {\n keep: (varName: string, suffix: ChannelSuffix) =>\n wildcards.has(suffix) ||\n kept.has(varName) ||\n patterns.some(re => re.test(varName)),\n active: true,\n reason:\n `${kept.size} name(s) kept from ${input.scan.filesScanned} file(s)` +\n wildcardNote,\n kept,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"channelVars.js","sourceRoot":"","sources":["../../src/designSystemPlugin/channelVars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;EAeE;AAEF,OAAO,EAAE,MAAM,WAAW,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE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AAC,IAAI,CAAC,IAAI,CAAC,gBAAgB;QACrD,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,IAAI,EAAE,CAAC,OAAe,EAAE,MAAqB,EAAE,EAAE,CAC/C,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC;YACrB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;YACjB,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,EAAE,IAAI;QACZ,MAAM,EACJ,GAAG,IAAI,CAAC,IAAI,sBAAsB,KAAK,CAAC,IAAI,CAAC,YAAY,UAAU;YACnE,YAAY;QACd,IAAI;KACL,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.vite-plugin-design-system.channel-vars\",\n \"title\": \"Colour Channel Variable Usage Gate\",\n \"category\": \"plugin\",\n \"description\": \"Scans stylesheets for var(--color-*-rgb|-l|-c|-h) so the static palette emits only the channel variables something can read.\",\n \"since\": \"0.1.0\",\n \"stability\": \"experimental\",\n \"risk\": \"high\",\n \"testing\": {\n \"unit\": { \"required\": true, \"covered\": true, \"file\": \"design-system-channel-vars.test.ts\" },\n \"integration\": { \"required\": true, \"covered\": true, \"file\": \"design-system-channel-vars.test.ts\" },\n \"e2e\": { \"required\": false, \"covered\": false }\n }\n}\n*/\n\nimport fg from 'fast-glob';\nimport { readFileSync, readdirSync, statSync } from 'fs';\nimport { dirname, extname, isAbsolute, join, resolve } from 'path';\nimport {\n CHANNEL_SUFFIXES,\n type ChannelSuffix,\n} from '@pithyjs/design-system/palette';\n\nconst CHANNEL_SUFFIX_COUNT = CHANNEL_SUFFIXES.length;\n\n/**\n * The suffix alternation, BUILT from `CHANNEL_SUFFIXES` rather than retyped.\n * Hard-coding it meant adding a suffix silently created a variable no regex\n * could detect — and pushed `CHANNEL_SUFFIX_COUNT` past what the wildcards can\n * ever hold, so the all-suffixes escape below could never fire again.\n * Longest-first so `rgb` is not shadowed by a prefix of itself.\n */\nconst SUFFIX_ALT = [...CHANNEL_SUFFIXES]\n .sort((a, b) => b.length - a.length)\n .join('|');\n\n/**\n * `var(--color-<anything>-<channel>)` as written in a stylesheet.\n *\n * Deliberately not anchored to a token list: state variants, future tokens and\n * a custom prefix all have to match, and a name that matches nothing real only\n * pins open a variable that was going to ship anyway.\n *\n * `var` is spelled case-insensitively by hand rather than with the `i` flag,\n * which would also loosen the suffix alternation — custom property NAMES are\n * case-sensitive, and `--color-x-RGB` is a property nothing here ever emits.\n */\nconst CHANNEL_REF_RE = new RegExp(\n String.raw`[Vv][Aa][Rr]\\(\\s*(--[A-Za-z0-9_-]*-(?:${SUFFIX_ALT}))\\b`,\n 'g'\n);\n\n/**\n * A `var()` whose custom property name is BUILT — SCSS `#{}` or JS `${}` — and\n * still ends in a channel suffix, e.g. `rgb(var(--color-#{$token}-rgb))` in\n * `@pithyjs/design-system`'s generated `u-*` utilities.\n *\n * Which tokens such a loop covers is unknowable from the text, so a hit pins\n * open every variable with that suffix.\n *\n * KNOWN BLIND SPOTS, all of which leave the gate active rather than degrading\n * it — use `channelVarSafelist`, and see BACKLOG #83 for why deciding at purge\n * time removes the whole class:\n * - the whole name held in a variable: `$p: --color-primary-rgb;` then\n * `var(#{$p})`. This is established house style in the design system's own\n * mixins, so it is the likeliest of these to appear;\n * - assembly other than `+`: `[a, b].join('')`, `a.concat(b)`;\n * - an interpolation containing `}` before the suffix, e.g. a helper called\n * with an inline object literal — `{0,500}` stops at the first `}`;\n * - a name whose SUFFIX is itself interpolated.\n *\n * A name ending in the interpolation (`var(--color-#{$scheme})`) is not matched\n * because it is a base-token reference — but note that is only true when the\n * interpolation does not itself carry the suffix.\n */\n// `{0,500}` rather than `*`: unbounded, it rescanned to EOF from\n// every `var(--X${` with no closing brace, which is quadratic in file size\n// (20KB 16ms, 40KB 61ms, 80KB 248ms, 160KB 971ms). Reachable because package\n// roots are deliberately scanned without the build-output ignores, so a\n// dependency's minified dist is read whole. Bounding is what removes the\n// quadratic term; newlines must stay IN the class, or a Prettier-wrapped\n// interpolation stops matching and unpins its whole family.\n//\n// The TRAILING fragment needed the same treatment and did not get it: it\n// excluded whitespace, so a second interpolation containing a space — a SCSS\n// map lookup, a ternary, anything Prettier wrapped — matched nothing. This is\n// load-bearing: a built name it misses has its whole family dropped.\nconst DYNAMIC_CHANNEL_REF_RE = new RegExp(\n String.raw`[Vv][Aa][Rr]\\(\\s*(?:--)?[A-Za-z0-9_-]*(?:#\\{[^}]{0,500}\\}|\\$\\{[^}]{0,500}\\})[^;]{0,200}?-(${SUFFIX_ALT})\\b`,\n 'g'\n);\n\n/**\n * A channel name assembled by string concatenation rather than interpolation\n * — `'var(--color-' + token + '-rgb)'`. The opening fragment ends mid-name, so\n * neither regex above can see it; this one keys on the dangling prefix.\n */\n// Anchored to `--color`, and it must SEE a channel suffix as the LAST segment\n// of the trailing fragment. Three things were wrong before:\n// - anchoring alone pinned every suffix for a base-token concat\n// (`'var(--color-' + scheme + ')'`), tripping the all-suffixes escape and\n// switching the gate off build-wide;\n// - the trailing fragment must CLOSE the var() call: without the `)`,\n// `'var(--color-' + t + ')' + 'chip-l'` matched on an unrelated adjacent\n// string and switched the gate off build-wide;\n// - `['\"`]-(?:rgb|l|c|h)\\b` required the suffix immediately after the quote,\n// so `'-hover-rgb)'` and `'-focus-l)'` — real state-variant channel\n// variables — were missed, while `'-l-delta)'` matched on `\\b` and was a\n// false positive;\n// - `[^;\\n]` forbade newlines, so the shape stopped matching the moment\n// Prettier wrapped it — the identical bug fixed for the sibling detector,\n// never applied here.\n// A concat whose SUFFIX is itself dynamic still matches nothing; that is what\n// `channelVarSafelist` is for, as is a palette built with a custom `prefix`.\nconst CONCAT_CHANNEL_REF_RE = new RegExp(\n String.raw`[Vv][Aa][Rr]\\(\\s*['\"\\`]?--color[A-Za-z0-9_-]*-['\"\\`]\\s*\\+[^;]{0,200}['\"\\`][A-Za-z0-9_-]*?-(?:${SUFFIX_ALT})\\)`,\n 'g'\n);\n\n/**\n * File types that can carry a `var()` in a PithyJS app.\n *\n * This repo has none of `tsx`/`jsx`/`vue`/`svelte`/`astro`/`sass`/`less`, but\n * the plugin is PUBLISHED and its default `include` advertises `src/**\\/*.tsx`\n * — so `tsx` stays. A file this list omits is never opened, which drops the\n * variables it reads with `degraded: false`: the one direction that is a bug.\n * The rest are left out because nothing advertises them.\n */\nconst SCAN_EXTENSIONS = [\n 'css',\n 'scss',\n 'ts',\n 'tsx',\n 'mts',\n 'cts',\n 'js',\n 'jsx',\n 'mjs',\n 'cjs',\n 'pithy',\n 'html',\n // `iconsPlugin/optimize.ts` deliberately preserves `<style>` in SVGs.\n 'svg',\n // The sibling `packages/ssr/src/build/collect-css.ts` matches both and\n // inlines them into every exported page, so a reference in one reaches a\n // static page while this scan could not see it.\n 'sass',\n 'less',\n];\n\n/** Extensions as a lookup, for the dev watcher's per-file relevance check. */\nconst SCAN_EXTENSION_SET = new Set(SCAN_EXTENSIONS.map(e => `.${e}`));\n\n/**\n * Never scanned, in any root. Unambiguous test markers only: a file named\n * `*.test.*` ships no CSS anywhere, whereas a DIRECTORY called `tests` may be a\n * route (`src/routes/tests/+page.scss`), which is why it is not listed here.\n */\nconst ALWAYS_IGNORED = [\n '**/node_modules/**',\n '**/.git/**',\n '**/coverage/**',\n '**/__tests__/**',\n '**/*.test.*',\n '**/*.spec.*',\n];\n\n/**\n * Additionally ignored in a DEPENDENCY root: a library's nested `tests`\n * directories are certainly tests, and they quote channel names as fixtures.\n */\nconst PACKAGE_IGNORED = [...ALWAYS_IGNORED, '**/tests/**'];\n\n/**\n * Additionally ignored under the Vite root — an app's own build output, and its\n * the build output directories below. `tests` is deliberately NOT here: a\n * directory called `tests` may be a route, and this repo has one.\n *\n * All anchored to the root: unanchored, `**\\/build/**` would skip\n * `src/routes/build/+page.scss` on a site that has a `/build` page.\n *\n * NOT applied to package roots: a published `@pithyjs/ui-kit` ships its\n * component SCSS inside `dist`, and skipping it there would drop a variable\n * that really is read, which is the one direction this module must never fail.\n */\nconst BUILD_OUTPUT_IGNORED = [\n 'dist/**',\n 'out/**',\n 'build/**',\n '.vite/**',\n '.output/**',\n];\n\n/**\n * Channel variables composed at runtime from a string, which no scan can see.\n *\n * `ShadowManager.resolveTintColor()` reads `--color-${color}-rgb` through\n * `getComputedStyle` for the three brand tints, so a brand-tinted shadow in an\n * app that never calls `initTheme()` would otherwise read an undefined token.\n */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"DEFAULT_CHANNEL_VAR_SAFELIST\",\"stability\":\"experimental\",\"signature\":\"readonly string[]\"} */\nexport const DEFAULT_CHANNEL_VAR_SAFELIST: readonly string[] = [\n '--color-primary-rgb',\n '--color-secondary-rgb',\n '--color-tertiary-rgb',\n];\n\n/**\n * Index of the unescaped quote closing the one at `start`.\n *\n * A template literal legitimately spans lines, and this repo writes CSS that\n * way (`colors/generate-utilities.ts`). Stopping at the newline left the scan\n * INSIDE the literal, where a `/*` in prose pairs with a later `*\\/` and eats\n * the live references between — the same loss as an unhandled line comment.\n * `'`/`\"` still stop at the newline so an apostrophe in prose cannot open a\n * span that swallows the rest of the file.\n */\nfunction closingQuote(text: string, start: number): number {\n const q = text[start];\n const multiline = q === '`';\n for (let i = start + 1; i < text.length; i++) {\n const c = text[i];\n if (c === '\\\\') i++;\n else if (c === '\\n' && !multiline) return -1;\n else if (c === q) return i;\n }\n return -1;\n}\n\n/**\n * Remove comments before scanning, so a documented example does not read as\n * usage — `_colors.scss` shows `var(--color-primary-l)` in a docblock.\n *\n * Quoted spans are stepped over, so `content: \"/*\"` cannot pair with a later\n * close and swallow the live references between them. A quote with no partner\n * on its own line is ordinary text, so prose (\"don't\") never opens a span, and\n * an unterminated `/*` leaves the rest of the file intact.\n *\n * A comment opener must sit where a comment can START — after input start,\n * whitespace, or one of `;{}` `,` (and `(` for `/*`). Keying on which single\n * character precedes it was tried twice and failed twice: requiring whitespace\n * let `;//` and `}//` through, and excluding only `:`/`(` let the `/` in a\n * base64 blob, an unquoted `href=//cdn/x` and `\\/\\/` inside a regex literal\n * open one. A positive position test rejects all of those, because `src/*.scss`,\n * `AA//BB` and `[^/*]` have an identifier character in front.\n *\n * Every ambiguity here resolves toward NOT stripping: an unstripped docblock\n * over-keeps a variable, a mis-stripped span drops a live one.\n */\n/**\n * End of a `url(` span, honouring quotes and nesting.\n *\n * `indexOf(')')` closed on a `)` INSIDE the quoted URL — `url(\"x),/*y\")` — so\n * the scanner resumed inside URL text, where a `/*` then opened a real block\n * comment. Reachable in an unencoded inline SVG data URI, or any path with\n * parentheses. Seventh position of this class, in the span added to close it.\n */\nfunction closingUrlParen(text: string, from: number): number {\n let depth = 1;\n let quote = '';\n for (let i = from; i < text.length; i++) {\n const c = text[i];\n if (c === '\\\\') {\n i++;\n continue;\n }\n if (quote) {\n if (c === quote) quote = '';\n continue;\n }\n if (c === '\"' || c === \"'\") quote = c;\n else if (c === '(') depth++;\n else if (c === ')' && --depth === 0) return i;\n }\n return -1;\n}\n\n/**\n * End of the regex literal opening at `at`, or -1.\n *\n * Only needed so a literal's contents cannot open a comment or a string: the\n * span is emitted VERBATIM, so any `var()` inside it is still scanned and\n * mistaking a division for a regex can never lose a reference. Without this,\n * the backtick in this module's own `/[\"'`]|.../` character class read as a\n * template-literal opener and misaligned the rest of the file.\n */\nfunction closingSlash(text: string, at: number): number {\n let inClass = false;\n for (let i = at + 1; i < text.length; i++) {\n const c = text[i];\n if (c === '\\\\') {\n i++;\n continue;\n }\n if (c === '\\n') return -1;\n if (inClass) {\n if (c === ']') inClass = false;\n } else if (c === '[') inClass = true;\n else if (c === '/') return i;\n }\n return -1;\n}\n\n/** Whether a `/` at `at` can start a regex literal rather than divide. */\nfunction opensRegex(text: string, at: number): boolean {\n let i = at - 1;\n for (; i >= 0 && /\\s/.test(text[i]); i--);\n if (i < 0) return true;\n if ('(,=:[!&|?{;+*%<>~^'.includes(text[i])) return true;\n // A KEYWORD position too. `return /[ /*]/.test(c)` was read as division, so\n // the `/*` inside the character class opened a real block comment — the\n // eighth position of this class, inside the code added to close the first six.\n const word = /[A-Za-z$_]+$/.exec(text.slice(Math.max(0, i - 11), i + 1));\n return word !== null && KEYWORDS_BEFORE_REGEX.has(word[0]);\n}\n\n/** Keywords a regex literal may follow; after an operand, `/` divides. */\nconst KEYWORDS_BEFORE_REGEX = new Set([\n 'return',\n 'typeof',\n 'case',\n 'in',\n 'of',\n 'new',\n 'delete',\n 'void',\n 'instanceof',\n 'do',\n 'else',\n 'yield',\n 'await',\n 'throw',\n]);\n\n/**\n * Which comment syntaxes a file's language actually has.\n *\n * `stripComments` had no idea what it was reading, so it applied JS/CSS rules\n * to text where `//` and `/*` are ordinary characters. Two live losses came\n * from exactly that: `:root{--cdn: //cdn.example.com}` in a minified `.css`\n * (plain CSS has NO line comment, and package roots are deliberately scanned\n * without the build-output ignores, so a dependency's minified dist is this\n * shape), and `/*` written as prose in `.html`.\n *\n * Erring toward NOT stripping is the safe direction — an unstripped docblock\n * over-keeps a variable, a mis-stripped span drops a live one — so an unknown\n * extension gets both, matching the previous behaviour, and `.html`/`.svg` get\n * neither. A `<style>` block inside them keeps its comments, which can only\n * over-keep.\n */\nfunction commentSyntax(ext: string): { line: boolean; block: boolean } {\n switch (ext.replace(/^\\./, '').toLowerCase()) {\n case 'css':\n return { line: false, block: true };\n // `.pithy` sits with them: it is `<template>` + `<script>` + plain-CSS\n // `<style>`, so prose `/*` in the template paired with the real `*/` in the\n // style block and ate the rule between — the `.css` bug this function\n // exists to fix, in the project's own format. `<script>` genuinely has\n // `//`, so disabling both over-keeps its commented-out examples; that is\n // the safe direction, and per-block handling is not worth it for 7 files.\n case 'html':\n case 'svg':\n case 'pithy':\n return { line: false, block: false };\n default:\n return { line: true, block: true };\n }\n}\n\n/**\n * Whether a comment opener at `at` is in a position a comment can start.\n *\n * `block` allows `(` as well, for `foo(/* x *\\/ y)`. `//` must not, or\n * `url(//cdn/x)` reads as a comment.\n */\nfunction opensComment(text: string, at: number, block: boolean): boolean {\n if (at === 0) return true;\n const prev = text[at - 1];\n if (/\\s/.test(prev)) return true;\n if (prev === ';' || prev === '{' || prev === '}' || prev === ',') return true;\n return block && prev === '(';\n}\n\nfunction stripComments(text: string, ext = ''): string {\n const syntax = commentSyntax(ext);\n let noCloser = false;\n const interesting = /[Uu][Rr][Ll]\\(|[\"'`]|\\/\\*|\\/\\/|\\//g;\n let out = '';\n let i = 0;\n\n for (let m = interesting.exec(text); m; m = interesting.exec(text)) {\n const at = m.index;\n out += text.slice(i, at);\n\n if (m[0].length === 4) {\n // `url(...)` is OPAQUE, like a quote or a regex literal: emitted\n // verbatim, so its contents cannot open anything. A base64 payload\n // beginning `//` (a standard BMP/ICO prefix) sat right after the `,`\n // that `opensComment` accepts, and on a minified one-line file the\n // \"comment\" then ran to EOF. This also subsumes `url(//cdn/x)` and\n // `url(img/*.png)`. Refs inside are still found, since the text stays.\n const close = closingUrlParen(text, at + 4);\n if (close === -1) {\n out += m[0];\n i = at + 4;\n } else {\n out += text.slice(at, close + 1);\n i = close + 1;\n }\n } else if (m[0] === '//') {\n if (!syntax.line || !opensComment(text, at, false)) {\n // Emit the REST OF THE LINE verbatim, not just the two characters.\n // Re-feeding the retained text let a space-preceded `/*` inside it\n // open a real block comment running to the next `*/` — the loss kept\n // coming back through the retained text while four rounds replaced the\n // predicate. Opaque spans are what the quote and regex branches do.\n const nl = text.indexOf('\\n', at);\n const stop = nl === -1 ? text.length : nl;\n out += text.slice(at, stop);\n i = stop;\n } else {\n const nl = text.indexOf('\\n', at);\n out += ' ';\n i = nl === -1 ? text.length : nl;\n }\n } else if (m[0] === '/*') {\n // Language and position FIRST: `.html`/`.svg` have no block comment, and\n // the `indexOf` below is a scan to EOF whose result they then discard.\n if (!syntax.block || noCloser || !opensComment(text, at, true)) {\n out += m[0];\n i = at + 2;\n interesting.lastIndex = i;\n continue;\n }\n const end = text.indexOf('*/', at + 2);\n if (end === -1) {\n // No `*/` after here means none after any LATER `/*` either, so stop\n // searching. Without this latch every `/*` in a file with no closer\n // rescanned to EOF — quadratic, 1.9 s on 70 KB of `/* `.\n noCloser = true;\n out += m[0];\n i = at + 2;\n interesting.lastIndex = i;\n continue;\n }\n out += ' ';\n i = end + 2;\n } else if (m[0] === '/') {\n const end = opensRegex(text, at) ? closingSlash(text, at) : -1;\n if (end === -1) {\n out += m[0];\n i = at + 1;\n } else {\n out += text.slice(at, end + 1);\n i = end + 1;\n }\n } else {\n const end = closingQuote(text, at);\n if (end === -1) {\n out += m[0];\n i = at + 1;\n } else {\n out += text.slice(at, end + 1);\n i = end + 1;\n }\n }\n interesting.lastIndex = i;\n }\n\n return out + text.slice(i);\n}\n\n/**\n * Every channel variable `text` reads.\n *\n * @param text - Stylesheet or source text.\n * @returns The fully-qualified custom property names referenced by `var()`.\n *\n * @example\n * ```typescript\n * collectChannelVarRefs('.m{background:rgb(var(--color-overlay-rgb) / 0.55)}');\n * // Set { '--color-overlay-rgb' }\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"collectChannelVarRefs\",\"stability\":\"experimental\",\"signature\":\"(text: string) => Set<string>\"} */\nexport function collectChannelVarRefs(text: string, ext = ''): Set<string> {\n const refs = new Set<string>();\n for (const match of stripComments(text, ext).matchAll(CHANNEL_REF_RE)) {\n refs.add(match[1]);\n }\n return refs;\n}\n\n/**\n * Channel suffixes `text` reads through a name it BUILDS rather than writes.\n *\n * @param text - Stylesheet or source text.\n * @returns The suffixes whose whole family must be kept; see\n * {@link DYNAMIC_CHANNEL_REF_RE} for what does and does not count.\n *\n * @example\n * ```typescript\n * collectDynamicChannelSuffixes('a{b:rgb(var(--color-#{$token}-rgb))}');\n * // Set { 'rgb' }\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"collectDynamicChannelSuffixes\",\"stability\":\"experimental\",\"signature\":\"(text: string) => Set<ChannelSuffix>\"} */\nexport function collectDynamicChannelSuffixes(\n text: string,\n ext = ''\n): Set<ChannelSuffix> {\n const suffixes = new Set<ChannelSuffix>();\n const source = stripComments(text, ext);\n for (const match of source.matchAll(DYNAMIC_CHANNEL_REF_RE)) {\n suffixes.add(match[1] as ChannelSuffix);\n }\n // A concatenated name hides its suffix in a later fragment, so which family\n // it reads is unknowable. Keep all of them.\n if (CONCAT_CHANNEL_REF_RE.test(source)) {\n CONCAT_CHANNEL_REF_RE.lastIndex = 0;\n for (const suffix of CHANNEL_SUFFIXES) suffixes.add(suffix);\n }\n return suffixes;\n}\n\n/** Whether a changed file could contain a channel reference — dev watcher. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"isChannelScanCandidate\",\"stability\":\"experimental\",\"signature\":\"(filePath: string) => boolean\"} */\nexport function isChannelScanCandidate(filePath: string): boolean {\n // Lower-cased to match the glob's `caseSensitiveMatch: false`: a `.SCSS`\n // the scan reads but the watcher ignores goes stale on every edit.\n if (!SCAN_EXTENSION_SET.has(extname(filePath).toLowerCase())) return false;\n // A file the scan always ignores cannot change the result, so rescanning on\n // it is pure cost — and saving a test file is the common case.\n const unix = filePath.replace(/\\\\/g, '/');\n return (\n // ONLY what every root ignores. Adding the build-output names here was\n // wrong in the other direction: the scan's `BUILD_OUTPUT_IGNORED` is\n // anchored to the Vite root and is deliberately NOT applied to package\n // roots, so `src/routes/build/+page.scss` and a package's `dist/*.scss`\n // are both scanned — and this check was refusing to rescan them, leaving\n // the dev sheet stale for the session. An extra rescan costs time; a\n // missed one is wrong output, so this errs toward rescanning. (The SSG\n // export's own `.html` writes still trip it — cost only, since\n // `sameChannelScan` discards the result.)\n !/(^|\\/)(node_modules|\\.git|coverage|__tests__)\\//.test(unix) &&\n !/\\.(test|spec)\\.[^/]+$/.test(unix)\n );\n}\n\n/** Outcome of a filesystem scan. `degraded` means: keep every channel variable. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelVarScan\",\"stability\":\"experimental\",\"signature\":\"interface ChannelVarScan\"} */\nexport interface ChannelVarScan {\n refs: Set<string>;\n /** Suffixes read through a built name — every variable with one is kept. */\n wildcardSuffixes: Set<ChannelSuffix>;\n degraded: boolean;\n reason?: string;\n filesScanned: number;\n}\n\n/**\n * `false` only for \"not there\". An EACCES or ELOOP means \"cannot tell\", and\n * collapsing that to `false` routed a real install to `absent` — the one\n * classification that keeps the gate ACTIVE. Those throw instead, so the\n * caller degrades.\n */\nfunction statKind(p: string): 'dir' | 'file' | 'other' | 'missing' {\n try {\n const st = statSync(p);\n return st.isDirectory() ? 'dir' : st.isFile() ? 'file' : 'other';\n } catch (err) {\n const code = (err as NodeJS.ErrnoException)?.code;\n if (code === 'ENOENT' || code === 'ENOTDIR') return 'missing';\n throw err;\n }\n}\n\nfunction isDir(p: string): boolean {\n return statKind(p) === 'dir';\n}\n\nfunction isFile(p: string): boolean {\n return statKind(p) === 'file';\n}\n\n/**\n * Where a framework package's source tree is — or why it could not be found.\n *\n * `absent` and `unresolvable` are deliberately different answers. A package\n * nobody installed cannot contribute CSS to the output, so skipping it is\n * certain. A package that may be installed but cannot be located — a partial\n * install, or a layout with no `node_modules` at all, such as Yarn PnP — may\n * have its SCSS in the bundle regardless, and that is uncertainty.\n */\ntype PackageDirLookup =\n | { kind: 'dir'; dir: string }\n | { kind: 'absent' }\n | { kind: 'unresolvable'; reason: string };\n\n/**\n * Locate a framework package's source tree so its component SCSS can be read.\n *\n * A Vite alias first (the monorepo case, pointing at `src`), then\n * {@link probePackage}. Not found resolves to `absent` only when nothing\n * declares the package; otherwise it degrades — see the body.\n */\nfunction resolvePackageDir(\n name: string,\n aliases: unknown,\n from: string\n): PackageDirLookup {\n const aliased = aliasReplacement(name, aliases);\n if (aliased) {\n if (isDir(aliased)) return { kind: 'dir', dir: aliased };\n // An alias may point at an entry FILE (`.../src/index.ts`). A path that is\n // neither is returned as-is so the scan degrades rather than silently\n // scanning its parent.\n return { kind: 'dir', dir: isFile(aliased) ? dirname(aliased) : aliased };\n }\n\n const probe = probePackage(name, from);\n if (probe.dir) return { kind: 'dir', dir: probe.dir };\n\n // `absent` means CERTAINLY not installed, and only that answer keeps the\n // gate on. Everything else degrades, which keeps every channel variable:\n // - a directory with no manifest — something IS installed, unreadable;\n // - no `node_modules` anywhere (Yarn PnP) — nothing can be ruled out;\n // - declared but not found — pnpm's isolated store, a partial install.\n // Guessing `absent` in any of those leaves the gate active and blind to the\n // package that reads these variables.\n if (probe.dirWithoutManifest) {\n return {\n kind: 'unresolvable',\n reason: `${probe.dirWithoutManifest} has no package.json`,\n };\n }\n if (!probe.sawNodeModules) {\n return {\n kind: 'unresolvable',\n reason: `no node_modules tree above ${from}`,\n };\n }\n return isDeclaredDependency(name, from)\n ? {\n kind: 'unresolvable',\n reason: `${name} is declared but was not found on disk from ${from}`,\n }\n : { kind: 'absent' };\n}\n\n/**\n * `pkg@1.2.3_peer@4.5.6` → `['pkg', [1,2,3]]`.\n *\n * The peer suffix is cut FIRST. Reading the version from the last `@` picked\n * the PEER's version instead — replayed against this repo's store, 23 of 109\n * names resolved to a non-newest copy, worst case prettier 2.8.8 over 3.5.3\n * via `_@changesets+apply-release-plan@7.1.1`.\n */\nfunction parseStoreEntry(entry: string): { pkg: string; version: number[] } {\n const base = entry.split('_')[0];\n const at = base.lastIndexOf('@');\n const pkg = at > 0 ? base.slice(0, at) : base;\n const raw = at > 0 ? base.slice(at + 1) : '';\n return {\n pkg,\n version: raw.split(/[.\\-+]/).map(n => (/^\\d+$/.test(n) ? Number(n) : -1)),\n };\n}\n\n/**\n * Orders `.pnpm` entries so the probe reads the newest copy OF THE PACKAGE it\n * is looking for. An entry can host `name` nested under a different package,\n * so entries whose own package IS `name` sort first — otherwise the comparator\n * would be ranking unrelated versions.\n */\nfunction compareStoreEntries(name: string, a: string, b: string): number {\n const want = name.replace(/\\//g, '+');\n const pa = parseStoreEntry(a);\n const pb = parseStoreEntry(b);\n const exact = (p: { pkg: string }) => (p.pkg === want ? 0 : 1);\n const byExact = exact(pa) - exact(pb);\n if (byExact !== 0) return byExact;\n for (let i = 0; i < Math.max(pa.version.length, pb.version.length); i++) {\n const d = (pb.version[i] ?? -1) - (pa.version[i] ?? -1);\n if (d !== 0) return d;\n }\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\ninterface PackageProbe {\n dir: string | null;\n dirWithoutManifest: string | null;\n sawNodeModules: boolean;\n}\n\n/**\n * Walk up looking for the package, recording what was seen on the way.\n *\n * Probes `node_modules/<name>` and pnpm's isolated store, where a transitive\n * dependency lives only at `node_modules/.pnpm/<pkg>@<ver>/node_modules/<name>`\n * with no top-level link.\n *\n * NOT `require.resolve`: `@pithyjs/ui-kit` and `@pithyjs/design-system`\n * declare `exports` with an `import` condition and no `require` one, so a CJS\n * resolver rejects both with `ERR_PACKAGE_PATH_NOT_EXPORTED` — the entry and\n * the `package.json` subpath alike. The directory is right there either way.\n */\nfunction probePackage(name: string, from: string): PackageProbe {\n const out: PackageProbe = {\n dir: null,\n dirWithoutManifest: null,\n sawNodeModules: false,\n };\n let dir = from;\n for (;;) {\n const modules = join(dir, 'node_modules');\n if (isDir(modules)) out.sawNodeModules = true;\n\n const direct = join(modules, name);\n if (isFile(join(direct, 'package.json'))) {\n out.dir = direct;\n return out;\n }\n\n // npm nests a conflicting version under its dependent, so the package can\n // live at `node_modules/<dep>/node_modules/<name>`. Missing it classified\n // a real install as `absent` — the one answer that keeps the gate on.\n for (const host of ['@pithyjs/ui-kit', '@pithyjs/design-system']) {\n if (host === name) continue;\n const nested = join(modules, host, 'node_modules', name);\n if (isFile(join(nested, 'package.json'))) {\n out.dir = nested;\n return out;\n }\n }\n if (out.dirWithoutManifest === null && isDir(direct)) {\n out.dirWithoutManifest = direct;\n }\n\n const store = join(modules, '.pnpm');\n if (isDir(store)) {\n let entries: string[] = [];\n try {\n // Sorted by VERSION, descending. The store holds one name at several\n // versions (and under other packages' entries), and `readdirSync`\n // order is filesystem dependent, so taking whichever came first made\n // the palette differ between machines on one lockfile. A plain\n // lexicographic sort then preferred `@1.0.0` over `@2.0.0` and `@12`\n // over `@22`; this is still a guess, but the newest copy is the one a\n // bundler is likeliest to have resolved.\n entries = readdirSync(store).sort((x, y) =>\n compareStoreEntries(name, x, y)\n );\n } catch {\n entries = [];\n }\n for (const entry of entries) {\n const candidate = join(store, entry, 'node_modules', name);\n if (isFile(join(candidate, 'package.json'))) {\n out.dir = candidate;\n return out;\n }\n }\n }\n\n const up = dirname(dir);\n if (up === dir) return out;\n dir = up;\n }\n}\n\n/** Whether any `package.json` above `from` lists `name` in a dependency field. */\nfunction isDeclaredDependency(name: string, from: string): boolean {\n const FIELDS = [\n 'dependencies',\n 'devDependencies',\n 'peerDependencies',\n 'optionalDependencies',\n ] as const;\n let dir = from;\n for (;;) {\n const manifest = join(dir, 'package.json');\n if (isFile(manifest)) {\n try {\n const json = JSON.parse(readFileSync(manifest, 'utf8')) as Record<\n string,\n Record<string, string> | undefined\n >;\n // A non-object dependency field cannot prove absence. `in` on an\n // array or null answers false, which routed a declared package to\n // `absent` — strictly worse than an UNPARSEABLE manifest, which\n // already fails open below.\n for (const f of FIELDS) {\n const field = json[f];\n if (field === undefined || field === null) continue;\n if (typeof field !== 'object' || Array.isArray(field)) return true;\n if (name in field) return true;\n }\n } catch {\n // An unreadable manifest cannot prove absence.\n return true;\n }\n }\n const up = dirname(dir);\n if (up === dir) return false;\n dir = up;\n }\n}\n\nfunction aliasReplacement(name: string, aliases: unknown): string | null {\n if (!Array.isArray(aliases)) return null;\n for (const entry of aliases as Array<{\n find?: string | RegExp;\n replacement?: string;\n }>) {\n if (typeof entry.replacement !== 'string') continue;\n\n if (typeof entry.find === 'string') {\n // Vite's own rule: equal, or a prefix ending at a `/` SEGMENT boundary\n // (`importee === pattern || importee.startsWith(pattern + '/')`).\n // Omitting the boundary let `{find:'@'}` — a very common config — build\n // `<src>pithyjs/ui-kit` out of `@pithyjs/ui-kit`.\n if (entry.find === name) return entry.replacement;\n if (name.startsWith(`${entry.find}/`)) {\n return entry.replacement + name.slice(entry.find.length);\n }\n\n // A SUBPATH alias (`@pithyjs/ui-kit/styles`) names a directory inside\n // the package, so peel the subpath off to get the package root. If the\n // replacement does not end with that subpath — every app here maps\n // `/styles` to `.../styles/index.scss` — the root cannot be derived, so\n // give up on this entry rather than return the subpath. Returning it\n // narrowed the scan to one directory, and which of the two happened\n // depended on the ORDER of keys in the alias object.\n if (entry.find.startsWith(`${name}/`)) {\n const sub = entry.find.slice(name.length);\n if (entry.replacement.endsWith(sub)) {\n return entry.replacement.slice(0, -sub.length);\n }\n continue;\n }\n } else if (entry.find instanceof RegExp) {\n // A LOCAL CLONE. The alias object belongs to Vite, which calls\n // `pattern.test(importee)` on it for every later import — and `test` and\n // `[Symbol.replace]` both advance `lastIndex` on a /y or /g pattern.\n // Resetting before the call was not enough: leaving it advanced AFTER\n // made the user's alias stop resolving for the rest of the build, a\n // module-resolution failure caused by a CSS plugin. Never mutate it.\n const find = new RegExp(entry.find.source, entry.find.flags);\n if (find.test(name)) {\n find.lastIndex = 0;\n // STRING replacement: `$1` is the documented Vite API, and\n // `{find: /^@pithyjs\\/(.*)$/, replacement: 'packages/$1/src'}` is the\n // canonical monorepo alias.\n return name.replace(find, entry.replacement);\n }\n }\n }\n return null;\n}\n\n/** One directory to scan, with the ignore set its kind warrants. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelScanRoot\",\"stability\":\"experimental\",\"signature\":\"interface ChannelScanRoot\"} */\nexport interface ChannelScanRoot {\n dir: string;\n ignore: string[];\n}\n\n/** Everything one build can be scanned over, and what could not be located. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelScanPlan\",\"stability\":\"experimental\",\"signature\":\"interface ChannelScanPlan\"} */\nexport interface ChannelScanPlan {\n roots: ChannelScanRoot[];\n /** Packages the bundler may still see — each one degrades the scan. */\n unresolvable: string[];\n}\n\n/** Scan roots for one build: the Vite root, the framework packages, extras. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"resolveChannelScanRoots\",\"stability\":\"experimental\",\"signature\":\"(viteRoot: string, aliases: unknown, extraRoots?: string[]) => ChannelScanPlan\"} */\nexport function resolveChannelScanRoots(\n viteRoot: string,\n aliases: unknown,\n extraRoots: string[] = []\n): ChannelScanPlan {\n // Validate rather than throw from deep inside. A string passed where an\n // array belongs used to surface as `scan threw: TypeError: …map is not a\n // function` — a config mistake reported as an internal failure, which then\n // turned the feature off. Named here, it degrades with a usable message.\n if (!Array.isArray(extraRoots)) {\n return {\n roots: [],\n unresolvable: [\n `channelVarScanRoots must be an array of paths, received ${typeof extraRoots}`,\n ],\n };\n }\n for (const entry of extraRoots) {\n if (typeof entry !== 'string' || entry === '') {\n return {\n roots: [],\n unresolvable: [\n `channelVarScanRoots entries must be non-empty strings, received ${JSON.stringify(entry)}`,\n ],\n };\n }\n }\n const roots: ChannelScanRoot[] = [\n { dir: viteRoot, ignore: [...ALWAYS_IGNORED, ...BUILD_OUTPUT_IGNORED] },\n // Resolved against the Vite root, like `include`/`exclude` — a relative\n // entry used to be evaluated against `process.cwd()`, so a monorepo-root\n // config could scan a same-named directory in the wrong tree and still\n // report `degraded: false`.\n //\n // Only the UNIVERSAL ignores. Not the dependency set, which excludes\n // `**/tests/**` while a directory called `tests` may be a route (this repo\n // has `apps/basic-app/src/routes/tests/`); and not the ROOT set, which\n // skips `dist/**`, where a published library's CSS exists\n // nowhere else — a root someone names explicitly is one they want read.\n // The dependency set is also wrong here, because it excludes\n // `**/tests/**` and a directory called `tests` may be a route.\n ...extraRoots.map(dir => ({\n dir: isAbsolute(dir) ? dir : join(viteRoot, dir),\n ignore: [...ALWAYS_IGNORED],\n })),\n ];\n const unresolvable: string[] = [];\n\n // UI Kit ships the component SCSS that consumes these variables, and the\n // design system ships the mixins; neither lives under the Vite root.\n for (const pkg of ['@pithyjs/ui-kit', '@pithyjs/design-system']) {\n const found = resolvePackageDir(pkg, aliases, viteRoot);\n if (found.kind === 'dir')\n roots.push({ dir: found.dir, ignore: PACKAGE_IGNORED });\n else if (found.kind === 'unresolvable') unresolvable.push(found.reason);\n }\n\n // Dedupe on the RESOLVED path, and keep the WIDEST ignore set for a path\n // reached twice. Exact string identity meant `channelVarScanRoots: ['.']`\n // collapsed into the Vite root and silently inherited its build-output\n // ignores — so `dist/**` went unread — while `'./'`, the same intent, stayed\n // separate and read it. An explicitly named root is one someone wants read,\n // so the narrower set must not win.\n const byPath = new Map<string, ChannelScanRoot>();\n for (const root of roots) {\n const key = resolve(root.dir);\n const prev = byPath.get(key);\n if (prev === undefined) {\n byPath.set(key, { ...root, dir: key });\n continue;\n }\n // INTERSECTION, not the shorter array. The two ignore sets are not nested:\n // `PACKAGE_IGNORED` has fewer entries than the root set but ADDS\n // `**/tests/**`, so picking it by length hid `src/routes/tests/` — the\n // exact file the root set exists to keep. Only a pattern both sets ignore\n // is safe to ignore here.\n const both = new Set(prev.ignore);\n byPath.set(key, {\n ...root,\n dir: key,\n ignore: root.ignore.filter(p => both.has(p)),\n });\n }\n return { roots: [...byPath.values()], unresolvable };\n}\n\n/**\n * Read every scannable file under `plan.roots` and union the channel variables\n * they reference.\n *\n * **Fails OPEN, and this is the module's one invariant.** A root that is\n * missing, a root a glob matched no file in, a package that will not resolve, a\n * glob that throws, a file that cannot be read — each sets `degraded`, and a\n * degraded scan makes the caller emit every channel variable. A variable\n * dropped by mistake renders a JavaScript-disabled page wrong; a variable kept\n * by mistake costs bytes. Only one of those is a bug.\n *\n * @example\n * ```typescript\n * const scan = scanChannelVarRefs(resolveChannelScanRoots(config.root, alias));\n * if (scan.degraded) console.warn(scan.reason);\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"scanChannelVarRefs\",\"stability\":\"experimental\",\"signature\":\"(plan: ChannelScanPlan) => ChannelVarScan\"} */\nexport function scanChannelVarRefs(plan: ChannelScanPlan): ChannelVarScan {\n const refs = new Set<string>();\n const wildcardSuffixes = new Set<ChannelSuffix>();\n let filesScanned = 0;\n let readFailure: string | undefined;\n\n const fail = (reason: string): ChannelVarScan => ({\n refs,\n wildcardSuffixes,\n degraded: true,\n reason,\n filesScanned,\n });\n\n if (plan.unresolvable.length > 0) {\n return fail(`unresolvable package: ${plan.unresolvable.join('; ')}`);\n }\n\n for (const { dir: root, ignore } of plan.roots) {\n // `statKind` rethrows EACCES/ELOOP so the caller can degrade — but this,\n // the first caller, was not catching, so the module threw where its own\n // invariant says it fails open. An unreadable directory is the common\n // CI/Docker shape; only an unreadable FILE was covered.\n let readable: boolean;\n try {\n readable = isDir(root);\n } catch (err) {\n return fail(`unreadable root ${root}: ${String(err)}`);\n }\n if (!readable) return fail(`unreadable root: ${root}`);\n\n let files: string[];\n try {\n // Every option here widens rather than narrows, because a file this\n // scan does not read is a variable it drops. `dot` reaches generated\n // `.generated/` trees; `caseSensitiveMatch: false` reaches `D.SCSS` on\n // the case-insensitive filesystems Vite resolves it on; symlinks are\n // followed because a linked source tree is source.\n files = fg.sync(`**/*.{${SCAN_EXTENSIONS.join(',')}}`, {\n cwd: root,\n absolute: true,\n ignore,\n followSymbolicLinks: true,\n // Bounded. `followSymbolicLinks` with no cap turns one upward link\n // into exponential path growth and a cycle into a non-terminating\n // walk — which hangs `buildStart` and the dev rescan, with no throw\n // and so no degradation signal. No real source tree is 24 deep.\n deep: 24,\n // NOT suppressed. Swallowing a per-entry EACCES/ELOOP returns a\n // PARTIAL list with no error, so every reference in the unreadable\n // subtree is dropped while `degraded` stays false — a root-owned\n // directory in a CI or Docker build ships an incomplete palette and\n // says nothing. Surfacing the throw degrades instead, which keeps\n // every variable.\n suppressErrors: false,\n dot: true,\n caseSensitiveMatch: false,\n });\n } catch (err) {\n return fail(`glob failed in ${root}: ${String(err)}`);\n }\n\n // An empty match is uncertainty, not evidence of absence: a mis-anchored\n // ignore or a tree laid out unexpectedly looks exactly like this.\n if (files.length === 0) return fail(`no scannable files under ${root}`);\n\n for (const file of files) {\n let content: string;\n try {\n content = readFileSync(file, 'utf-8');\n } catch (err) {\n // Keep reading rather than abort on the first failure, so one\n // unreadable file does not decide the whole scan. A file present at\n // glob time and gone at read time is routine — an atomic editor save,\n // an export cleaning its out dir, a dangling symlink.\n //\n // This does NOT remove the dev flap: `fail()` below still degrades the\n // whole scan, so a transient failure still swings the sheet between\n // gated and ungated between rescans. What it removes is losing the\n // refs already collected. Deciding at purge time (BACKLOG #83) is what\n // actually ends the flap.\n readFailure ??= `unreadable file ${file}: ${String(err)}`;\n continue;\n }\n filesScanned++;\n const ext = extname(file);\n for (const ref of collectChannelVarRefs(content, ext)) refs.add(ref);\n for (const s of collectDynamicChannelSuffixes(content, ext)) {\n wildcardSuffixes.add(s);\n }\n }\n }\n\n if (readFailure !== undefined) return fail(readFailure);\n return { refs, wildcardSuffixes, degraded: false, filesScanned };\n}\n\n/** Inputs to {@link createChannelVarGate}. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelVarGateInput\",\"stability\":\"experimental\",\"signature\":\"interface ChannelVarGateInput\"} */\nexport interface ChannelVarGateInput {\n /** `false` disables gating entirely — the `gateChannelVars` escape hatch. */\n enabled: boolean;\n /** Filesystem scan result; `null` means no scan ran, which keeps everything. */\n scan: ChannelVarScan | null;\n /**\n * Names read by text the plugin holds rather than reads — the generated\n * utility CSS. Defence-in-depth, and empty today: the plugin's own\n * `generator.ts` emits no channel reference at all. The design system's other\n * utility generator (`colors/generate-utilities.ts`) emits exactly this form,\n * so a future route through it is caught rather than silently unstyled.\n */\n extraRefs?: Iterable<string>;\n /** Additional names to keep, on top of {@link DEFAULT_CHANNEL_VAR_SAFELIST}. */\n safelist?: Array<string | RegExp>;\n}\n\n/** A gate ready to hand to `themeToCss`, plus why it decided what it did. */\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"ChannelVarGate\",\"stability\":\"experimental\",\"signature\":\"interface ChannelVarGate\"} */\nexport interface ChannelVarGate {\n /**\n * The scan failed, as opposed to the gate being switched off or correctly\n * deciding to keep everything. Only this warrants a build-time warning.\n */\n degraded?: boolean;\n keep: (varName: string, suffix: ChannelSuffix) => boolean;\n /** `false` when every channel variable ships — disabled, or failed open. */\n active: boolean;\n reason: string;\n /** Names the gate will let through, when active. */\n kept: Set<string>;\n}\n\n/**\n * Build the emission gate from everything known about this build.\n *\n * @example\n * ```typescript\n * const gate = createChannelVarGate({ enabled: true, scan, extraRefs: utilityRefs });\n * const css = themeToCss(theme, { defaultMode, keepChannelVar: gate.keep });\n * ```\n */\n/** A description of any value that cannot itself throw. */\nfunction describe(v: unknown): string {\n try {\n return typeof v === 'object' && v !== null\n ? Object.prototype.toString.call(v)\n : String(v);\n } catch {\n return typeof v;\n }\n}\n\n/** @codexApi {\"parent\":\"pithy.vite-plugin-design-system.channel-vars\",\"name\":\"createChannelVarGate\",\"stability\":\"experimental\",\"signature\":\"(input: ChannelVarGateInput) => ChannelVarGate\"} */\nexport function createChannelVarGate(\n input: ChannelVarGateInput\n): ChannelVarGate {\n const keepAll = (reason: string, degraded = false): ChannelVarGate => ({\n keep: () => true,\n active: false,\n // `active: false` conflates three things: switched off, DEGRADED, and\n // correctly decided to keep everything. Only the middle one is a problem\n // worth warning about, so it is flagged separately.\n degraded,\n reason,\n kept: new Set(),\n });\n\n if (!input.enabled) return keepAll('disabled via gateChannelVars: false');\n if (!input.scan) return keepAll('no source scan ran');\n if (input.scan.degraded)\n return keepAll(input.scan.reason ?? 'scan degraded', true);\n\n const kept = new Set<string>([\n ...DEFAULT_CHANNEL_VAR_SAFELIST,\n ...input.scan.refs,\n ...(input.extraRefs ?? []),\n ]);\n // Validate, then CLONE. `keep()` runs ~800 times per sheet and\n // `patterns.some` short-circuits, so testing the caller's own objects left\n // them at arbitrary `lastIndex` offsets — an app factoring one array into\n // both `safelist` and `channelVarSafelist` got silent cross-contamination.\n // Same rule as the two alias resolvers: never mutate what the caller owns.\n const safelist = input.safelist ?? [];\n if (!Array.isArray(safelist)) {\n return keepAll(\n `channelVarSafelist must be an array, received ${typeof safelist}`,\n true\n );\n }\n const patterns: RegExp[] = [];\n for (const entry of safelist) {\n if (typeof entry === 'string') {\n kept.add(entry);\n } else if (entry instanceof RegExp) {\n // Clone WITHOUT `g`/`y`. The clone alone protects the caller's object;\n // dropping the stateful flags is what makes `test()` correct here, since\n // `lastIndex` on a global pattern makes consecutive matches skip every\n // other name. Neither flag means anything for a boolean membership test.\n patterns.push(new RegExp(entry.source, entry.flags.replace(/[gy]/g, '')));\n } else {\n // A config mistake must not surface as a TypeError from inside `load()`,\n // which has no try/catch. Uncertainty ships everything.\n // `String(...)`, not `JSON.stringify`: the latter throws on a BigInt and\n // on a circular object, from inside the guard whose own purpose is that a\n // config mistake must not surface as an internal failure.\n return keepAll(\n `channelVarSafelist entries must be strings or RegExps, received ${describe(entry)}`,\n true\n );\n }\n }\n\n const wildcards = input.scan.wildcardSuffixes;\n if (wildcards.size === CHANNEL_SUFFIX_COUNT) {\n // `degraded: true` so this is AUDIBLE. `active: false` alone silenced both\n // signals — the warning keys on `degraded`, the banner on `active` — so a\n // single concat anywhere switched the feature off with no output at all.\n // It is not a failure, but it is a surprise worth one line.\n return keepAll(`every suffix read through a built name`, true);\n }\n\n const wildcardNote = wildcards.size\n ? `, all -${[...wildcards].join('/-')} (built names)`\n : '';\n\n return {\n keep: (varName: string, suffix: ChannelSuffix) =>\n wildcards.has(suffix) ||\n kept.has(varName) ||\n patterns.some(re => re.test(varName)),\n active: true,\n reason:\n `${kept.size} name(s) kept from ${input.scan.filesScanned} file(s)` +\n wildcardNote,\n kept,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/routerPlugin/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/routerPlugin/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAUjD;;;GAGG;AACH,4JAA4J;AAC5J,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAsB5D;AA8FD;;GAEG;AACH,6JAA6J;AAC7J,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAkB7D;AAED;;GAEG;AACH,8JAA8J;AAC9J,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAmC9D"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
*/
|
|
16
|
+
import { allRouteNodes } from './scanner.js';
|
|
16
17
|
/**
|
|
17
18
|
* Helper function to get correct filename for route file types
|
|
18
19
|
*/
|
|
@@ -25,12 +26,15 @@ function filenameFor(type) {
|
|
|
25
26
|
*/
|
|
26
27
|
/** @codexApi {"parent":"pithy.vite-plugin-router.manifest","name":"generateManifest","stability":"stable","signature":"(routes: RouteNode[]) => string"} */
|
|
27
28
|
export function generateManifest(routes) {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
29
|
+
const importMap = buildImportMap(routes);
|
|
30
|
+
const imports = [...importMap]
|
|
31
|
+
.map(([fullPath, name]) => `const ${name} = () => import("${fullPath}");`)
|
|
32
|
+
.join('\n');
|
|
33
|
+
const routeTree = generateRouteList(routes, importMap, ' ');
|
|
30
34
|
const manifest = `// Auto-generated route manifest - do not edit manually
|
|
31
35
|
// Generated at: ${new Date().toISOString()}
|
|
32
36
|
|
|
33
|
-
${imports}
|
|
37
|
+
${imports || '// No imports needed'}
|
|
34
38
|
|
|
35
39
|
/** @typedef {import("../../router/src/types").RouteNode} RouteNode */
|
|
36
40
|
/** @type {Array<RouteNode>} */
|
|
@@ -42,86 +46,50 @@ export {};
|
|
|
42
46
|
return manifest;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
49
|
+
* Module path of one of a route's files, relative to the virtual module
|
|
50
|
+
* (route groups and bracketed segments are kept: they are directory names).
|
|
46
51
|
*/
|
|
47
|
-
function
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Collect all unique file paths and generate import names
|
|
52
|
-
for (const route of routes) {
|
|
53
|
-
for (const [type] of Object.entries(route.imports)) {
|
|
54
|
-
// Build the correct import path relative to the virtual module location
|
|
55
|
-
const segments = route.segments.length > 0 ? route.segments : [];
|
|
56
|
-
let importPath = '/src/routes';
|
|
57
|
-
if (segments.length > 0) {
|
|
58
|
-
// Convert segments back to file system format (keep route groups for file paths)
|
|
59
|
-
const fileSegments = segments.map((segment) => {
|
|
60
|
-
if (segment.startsWith(':')) {
|
|
61
|
-
return `[${segment.slice(1)}]`; // :id -> [id]
|
|
62
|
-
}
|
|
63
|
-
if (segment === '*') {
|
|
64
|
-
return '[...slug]'; // * -> [...slug]
|
|
65
|
-
}
|
|
66
|
-
return segment; // Keep route groups like (mkt) for file paths
|
|
67
|
-
});
|
|
68
|
-
if (fileSegments.length > 0) {
|
|
69
|
-
importPath += '/' + fileSegments.join('/');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
const fullPath = `${importPath}/${filenameFor(type)}`;
|
|
73
|
-
if (!importMap.has(fullPath)) {
|
|
74
|
-
const importName = `route_${importCounter++}_${type}`;
|
|
75
|
-
importMap.set(fullPath, importName);
|
|
76
|
-
imports.push(`const ${importName} = () => import("${fullPath}");`);
|
|
77
|
-
}
|
|
52
|
+
function importPathFor(route, type) {
|
|
53
|
+
const fileSegments = route.segments.map((segment) => {
|
|
54
|
+
if (segment.startsWith(':')) {
|
|
55
|
+
return `[${segment.slice(1)}]`; // :id -> [id]
|
|
78
56
|
}
|
|
79
|
-
|
|
80
|
-
|
|
57
|
+
if (segment === '*') {
|
|
58
|
+
return '[...slug]'; // * -> [...slug]
|
|
59
|
+
}
|
|
60
|
+
return segment;
|
|
61
|
+
});
|
|
62
|
+
const dir = ['/src/routes', ...fileSegments].join('/');
|
|
63
|
+
return `${dir}/${filenameFor(type)}`;
|
|
81
64
|
}
|
|
82
|
-
/**
|
|
83
|
-
|
|
84
|
-
*/
|
|
85
|
-
function generateRouteTree(routes) {
|
|
86
|
-
// Build import map first
|
|
65
|
+
/** One import name per route file, in tree order. */
|
|
66
|
+
function buildImportMap(routes) {
|
|
87
67
|
const importMap = new Map();
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const segments = route.segments.length > 0 ? route.segments : [];
|
|
92
|
-
let importPath = '/src/routes';
|
|
93
|
-
if (segments.length > 0) {
|
|
94
|
-
const fileSegments = segments.map((segment) => {
|
|
95
|
-
if (segment.startsWith(':')) {
|
|
96
|
-
return `[${segment.slice(1)}]`;
|
|
97
|
-
}
|
|
98
|
-
if (segment === '*') {
|
|
99
|
-
return '[...slug]';
|
|
100
|
-
}
|
|
101
|
-
return segment;
|
|
102
|
-
});
|
|
103
|
-
if (fileSegments.length > 0) {
|
|
104
|
-
importPath += '/' + fileSegments.join('/');
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
const fullPath = `${importPath}/${filenameFor(type)}`;
|
|
68
|
+
for (const route of allRouteNodes(routes)) {
|
|
69
|
+
for (const type of Object.keys(route.imports)) {
|
|
70
|
+
const fullPath = importPathFor(route, type);
|
|
108
71
|
if (!importMap.has(fullPath)) {
|
|
109
|
-
|
|
110
|
-
importMap.set(fullPath, importName);
|
|
72
|
+
importMap.set(fullPath, `route_${importMap.size}_${type}`);
|
|
111
73
|
}
|
|
112
74
|
}
|
|
113
75
|
}
|
|
114
|
-
|
|
115
|
-
|
|
76
|
+
return importMap;
|
|
77
|
+
}
|
|
78
|
+
function generateRouteList(routes, importMap, indent) {
|
|
79
|
+
if (routes.length === 0)
|
|
80
|
+
return '[]';
|
|
81
|
+
const routeObjects = routes.map(route => `${indent}${generateRouteObject(route, importMap, indent)}`);
|
|
82
|
+
return `[\n${routeObjects.join(',\n')}\n${indent.slice(2)}]`;
|
|
116
83
|
}
|
|
117
84
|
/**
|
|
118
85
|
* Generate a single route object
|
|
119
86
|
*/
|
|
120
|
-
function generateRouteObject(route, importMap) {
|
|
87
|
+
function generateRouteObject(route, importMap, indent) {
|
|
121
88
|
const imports = generateRouteImports(route, importMap);
|
|
122
89
|
const metadata = route.metadata
|
|
123
90
|
? JSON.stringify(route.metadata, null, 2)
|
|
124
91
|
: '{}';
|
|
92
|
+
const children = generateRouteList(route.children ?? [], importMap, `${indent} `);
|
|
125
93
|
return `{
|
|
126
94
|
id: ${JSON.stringify(route.id)},
|
|
127
95
|
pattern: ${JSON.stringify(route.pattern)},
|
|
@@ -129,7 +97,7 @@ function generateRouteObject(route, importMap) {
|
|
|
129
97
|
segments: ${JSON.stringify(route.segments)},
|
|
130
98
|
params: ${JSON.stringify(route.params)},
|
|
131
99
|
imports: ${imports},
|
|
132
|
-
children:
|
|
100
|
+
children: ${children},
|
|
133
101
|
metadata: ${metadata}
|
|
134
102
|
}`;
|
|
135
103
|
}
|
|
@@ -137,38 +105,13 @@ function generateRouteObject(route, importMap) {
|
|
|
137
105
|
* Generate imports object for a route
|
|
138
106
|
*/
|
|
139
107
|
function generateRouteImports(route, importMap) {
|
|
140
|
-
const importEntries =
|
|
141
|
-
|
|
142
|
-
for (const [type] of Object.entries(route.imports)) {
|
|
143
|
-
// Build the correct import path relative to the virtual module location
|
|
144
|
-
const segments = route.segments.length > 0 ? route.segments : [];
|
|
145
|
-
let importPath = '/src/routes';
|
|
146
|
-
if (segments.length > 0) {
|
|
147
|
-
// Convert segments back to file system format (keep route groups for file paths)
|
|
148
|
-
const fileSegments = segments.map((segment) => {
|
|
149
|
-
if (segment.startsWith(':')) {
|
|
150
|
-
return `[${segment.slice(1)}]`; // :id -> [id]
|
|
151
|
-
}
|
|
152
|
-
if (segment === '*') {
|
|
153
|
-
return '[...slug]'; // * -> [...slug]
|
|
154
|
-
}
|
|
155
|
-
return segment; // Keep route groups like (mkt) for file paths
|
|
156
|
-
});
|
|
157
|
-
if (fileSegments.length > 0) {
|
|
158
|
-
importPath += '/' + fileSegments.join('/');
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const fullPath = `${importPath}/${filenameFor(type)}`;
|
|
162
|
-
// Use the generated import constant if available
|
|
108
|
+
const importEntries = Object.keys(route.imports).map(type => {
|
|
109
|
+
const fullPath = importPathFor(route, type);
|
|
163
110
|
const importName = importMap.get(fullPath);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
// Fallback to inline import
|
|
169
|
-
importEntries.push(`${type}: () => import("${fullPath}")`);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
111
|
+
return importName
|
|
112
|
+
? `${type}: ${importName}`
|
|
113
|
+
: `${type}: () => import("${fullPath}")`;
|
|
114
|
+
});
|
|
172
115
|
return `{\n ${importEntries.join(',\n ')}\n }`;
|
|
173
116
|
}
|
|
174
117
|
/**
|
|
@@ -179,8 +122,8 @@ export function generateCliOutput(routes) {
|
|
|
179
122
|
const lines = [];
|
|
180
123
|
lines.push('📁 Route Tree:');
|
|
181
124
|
lines.push('');
|
|
182
|
-
for (const route of routes) {
|
|
183
|
-
lines.push(`🔗 ${route.pattern}`);
|
|
125
|
+
for (const route of allRouteNodes(routes)) {
|
|
126
|
+
lines.push(`🔗 ${route.pattern}${route.imports.page ? '' : ' (layout)'}`);
|
|
184
127
|
lines.push(` ID: ${route.id}`);
|
|
185
128
|
lines.push(` Files: ${Object.keys(route.imports).join(', ')}`);
|
|
186
129
|
if (route.metadata?.isGroup) {
|
|
@@ -198,17 +141,21 @@ export function validateManifest(routes) {
|
|
|
198
141
|
const errors = [];
|
|
199
142
|
const patterns = new Set();
|
|
200
143
|
const ids = new Set();
|
|
201
|
-
for (const route of routes) {
|
|
202
|
-
// Check for duplicate patterns
|
|
203
|
-
if (patterns.has(route.pattern)) {
|
|
204
|
-
errors.push(`Duplicate route pattern: ${route.pattern}`);
|
|
205
|
-
}
|
|
206
|
-
patterns.add(route.pattern);
|
|
144
|
+
for (const route of allRouteNodes(routes)) {
|
|
207
145
|
// Check for duplicate IDs
|
|
208
146
|
if (ids.has(route.id)) {
|
|
209
147
|
errors.push(`Duplicate route ID: ${route.id}`);
|
|
210
148
|
}
|
|
211
149
|
ids.add(route.id);
|
|
150
|
+
// A layout-only node shares its URL with the routes it wraps
|
|
151
|
+
if (route.imports.layout && !route.imports.page && route.children.length) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
// Check for duplicate patterns
|
|
155
|
+
if (patterns.has(route.pattern)) {
|
|
156
|
+
errors.push(`Duplicate route pattern: ${route.pattern}`);
|
|
157
|
+
}
|
|
158
|
+
patterns.add(route.pattern);
|
|
212
159
|
// Validate required page import
|
|
213
160
|
if (!route.imports.page) {
|
|
214
161
|
errors.push(`Route ${route.pattern} missing required page component`);
|