{"version":3,"file":"tempest-styles.cjs","names":[],"sources":["../../src/vite/tempest-styles.ts"],"sourcesContent":["import { readdir, readFile } from \"node:fs/promises\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { narrowTokens } from \"./narrow-tokens\";\nimport type { TempestVitePlugin } from \"./tempest-pwa-manifest\";\n\n/** The stylesheet id an app imports to get exactly the CSS it uses. */\nexport const TEMPEST_STYLES_ID = \"tempest-react-sdk/styles/auto.css\";\n\nconst RESOLVED_ID = \"\\0tempest-styles/auto.css\";\n\n/** Package subpaths whose exports are components with stylesheets. */\nconst SDK_SPECIFIER = /^tempest-react-sdk(\\/(charts|editor|br|icons))?$/;\n\nconst SOURCE_FILE = /\\.[cm]?[jt]sx?$/;\n\n/**\n * The app's own stylesheets, scanned for token reads rather than for imports.\n *\n * An app is documented as free to read `--tempest-*` in CSS of its own, so cutting\n * the token sheet to what the SDK's components reach would drop tokens the app is\n * still reading — and a dropped token is not a smaller sheet, it is an unset\n * property. These files contribute reads to the closure and nothing else.\n */\nconst STYLE_FILE = /\\.(css|scss|sass|less)$/;\nconst SKIP_DIRS = new Set([\"node_modules\", \"dist\", \"build\", \"coverage\"]);\n\n/**\n * How much of the reset an app takes.\n *\n * The components are written against the reset — `.tempest_button` assumes\n * `button { background: none; border: 0; padding: 0 }`, every width assumes\n * `box-sizing: border-box` — so `\"none\"` is not \"unstyled document, styled\n * components\": it is components missing their box model. It exists for the app\n * that already ships an equivalent reset of its own.\n */\nexport type ResetMode = \"scoped\" | \"global\" | \"none\";\n\n/**\n * How much of the token sheet an app takes.\n *\n * `\"used\"` emits only the tokens the selected stylesheets — and the app's own CSS —\n * can reach, following token-to-token references. `\"all\"` emits `tokens.css` whole,\n * which is what to reach for when the app names tokens somewhere the scan cannot\n * see: a token read from a CSS-in-JS library, a sibling package's stylesheet, a\n * `<style>` block in `index.html`.\n */\nexport type TokenMode = \"used\" | \"all\";\n\n/** Shape of `dist/styles/manifest.json`. */\nexport interface StyleManifest {\n    /** The foundation sheet — tokens and reset together, the pre-split default. */\n    core: string;\n    /** Public export name → the stylesheets it needs, transitive closure included. */\n    components: Record<string, readonly string[]>;\n}\n\nexport interface TempestStylesOptions {\n    /** Directory to scan, relative to the Vite root. Default: `\"src\"`. */\n    dir?: string;\n    /**\n     * Which reset to emit alongside the tokens. Default: `\"scoped\"`.\n     *\n     * `\"scoped\"` confines the reset to `:where([class*=\"tempest_\"])`, so components\n     * keep the normalisation they are written against and the app keeps `html`,\n     * `body` and `#root`. `\"global\"` is the pre-split behaviour, correct when the\n     * SDK owns the whole page. `\"none\"` emits tokens only.\n     */\n    reset?: ResetMode;\n    /**\n     * Extra export names to style even when the scan cannot see them — a component\n     * reached only through a namespace import, or rendered by a sibling package.\n     */\n    include?: readonly string[];\n    /** Directory names to skip. Default: `node_modules`, `dist`, `build`, `coverage`. */\n    skipDirs?: readonly string[];\n    /**\n     * How much of the token sheet to emit. Default: `\"used\"`.\n     *\n     * The default falls back to the whole sheet on its own whenever a token name is\n     * assembled at runtime (`` `var(--tempest-${tone})` ``), so `\"all\"` is for the\n     * case the scan cannot see at all — a token read from outside `dir`.\n     */\n    tokens?: TokenMode;\n}\n\n/**\n * Collect the SDK export names a source file imports.\n *\n * Reads the import specifier rather than the JSX, because a bare `<Button>` in the\n * markup says nothing about where it came from — the app may well define its own.\n * Type-only bindings are dropped: they are erased before any component renders, so\n * paying for their CSS would be paying for nothing.\n *\n * @param code - File contents.\n * @returns The imported names, or `null` when the file namespace-imports the SDK\n *   and the set therefore cannot be known.\n */\nexport function scanStyleImports(code: string): string[] | null {\n    const names = new Set<string>();\n\n    for (const match of code.matchAll(\n        /\\bimport\\s+(type\\s+)?([^;'\"]*?)\\s+from\\s*[\"']([^\"']+)[\"']/g,\n    )) {\n        const [, typeOnly, clause, specifier] = match;\n        if (!SDK_SPECIFIER.test(specifier ?? \"\")) continue;\n        if (typeOnly) continue;\n        if (/^\\s*\\*\\s+as\\s/.test(clause ?? \"\")) return null;\n\n        const braces = /\\{([^}]*)\\}/.exec(clause ?? \"\");\n        if (!braces) continue;\n        for (const part of (braces[1] ?? \"\").split(\",\")) {\n            const binding = part.trim();\n            if (!binding || binding.startsWith(\"type \")) continue;\n            const name = binding.split(/\\s+as\\s+/)[0]?.trim();\n            if (name) names.add(name);\n        }\n    }\n    return [...names];\n}\n\n/**\n * Build the stylesheet for a set of export names.\n *\n * Emits `@import` statements rather than inlined rules so Vite's own CSS pipeline\n * resolves, deduplicates and minifies them — the same treatment a hand-written\n * list of imports gets, which is what this replaces.\n *\n * The narrowed token block is the exception, and it goes last for a reason the\n * cascade does not explain: `@import` is only valid before any rule, so a token\n * block written above the imports would make every one of them invalid and the\n * components would arrive with no CSS at all. Putting it last is safe because the\n * block declares custom properties and nothing else — resolving `var()` does not\n * depend on where in the document the declaration sits, only on which selector\n * wins, and no component sheet declares a token to compete with.\n *\n * @param names - Export names the app imports, or `null` to take everything.\n * @param manifest - The published style manifest.\n * @param reset - How much of the reset to emit.\n * @param tokenBlock - The narrowed token sheet, or `null` to `@import` it whole.\n * @returns CSS source.\n */\nexport function buildStyleEntry(\n    names: readonly string[] | null,\n    manifest: StyleManifest,\n    reset: ResetMode = \"scoped\",\n    tokenBlock: string | null = null,\n): string {\n    const banner = \"/* Generated by tempestStyles() — the CSS this app actually uses. */\\n\";\n    const tokenSheets = tokenBlock === null ? [\"tokens.css\"] : [];\n    const foundation =\n        reset === \"global\"\n            ? tokenBlock === null\n                ? [manifest.core]\n                : [...tokenSheets, \"base.css\"]\n            : reset === \"scoped\"\n              ? [...tokenSheets, \"scoped.css\"]\n              : tokenSheets;\n\n    const trailer = tokenBlock === null ? \"\" : `${tokenBlock}\\n`;\n\n    if (names === null) {\n        const whole =\n            reset === \"global\"\n                ? [manifest.core, \"../styles.css\"]\n                : [...foundation, \"../styles.css\"];\n        return `${banner}${whole.map((sheet) => `@import \"tempest-react-sdk/styles/${sheet}\";`).join(\"\\n\")}\\n${trailer}`;\n    }\n\n    const sheets = new Set<string>();\n    for (const name of names) {\n        for (const sheet of manifest.components[name] ?? []) sheets.add(sheet);\n    }\n    const lines = [...foundation, ...[...sheets].sort()].map(\n        (sheet) => `@import \"tempest-react-sdk/styles/${sheet}\";`,\n    );\n    return `${banner}${lines.join(\"\\n\")}\\n${trailer}`;\n}\n\n/**\n * The stylesheets an entry will load, by name, for the token closure to read.\n *\n * @param names - Export names the app imports, or `null` when unknowable.\n * @param manifest - The published style manifest.\n * @param reset - How much of the reset to emit.\n * @returns Stylesheet file names under `dist/styles/`.\n */\nexport function selectedSheets(\n    names: readonly string[] | null,\n    manifest: StyleManifest,\n    reset: ResetMode,\n): string[] {\n    if (names === null) return [\"../styles.css\"];\n    const sheets = new Set<string>();\n    if (reset === \"scoped\") sheets.add(\"scoped.css\");\n    if (reset === \"global\") sheets.add(\"base.css\");\n    for (const name of names) {\n        for (const sheet of manifest.components[name] ?? []) sheets.add(sheet);\n    }\n    return [...sheets].sort();\n}\n\n/**\n * Walk a directory and collect every source and stylesheet path.\n *\n * @param dir - Absolute directory to walk.\n * @param skip - Directory names to skip.\n * @returns Absolute file paths.\n */\nasync function collectSourceFiles(dir: string, skip: ReadonlySet<string>): Promise<string[]> {\n    const out: string[] = [];\n    let entries;\n    try {\n        entries = await readdir(dir, { withFileTypes: true });\n    } catch {\n        return out;\n    }\n    for (const entry of entries) {\n        if (entry.isDirectory()) {\n            if (skip.has(entry.name) || entry.name.startsWith(\".\")) continue;\n            out.push(...(await collectSourceFiles(join(dir, entry.name), skip)));\n        } else if (\n            entry.isFile() &&\n            (SOURCE_FILE.test(entry.name) || STYLE_FILE.test(entry.name))\n        ) {\n            out.push(join(dir, entry.name));\n        }\n    }\n    return out;\n}\n\n/**\n * Read the style manifest the installed package ships.\n *\n * Resolved by walking the filesystem rather than through `createRequire`, which\n * does not survive the trip: Vite bundles `vite.config.ts` into a temporary module\n * before running it, and in that bundle the `node:module` namespace import comes\n * back without the function — `(0, a.createRequire) is not a function`, at load\n * time, inside the build. The same rewrite is why `import.meta.url` is only the\n * fallback here and the app's `node_modules` is tried first.\n *\n * @param root - The Vite root, where the walk for `node_modules` starts.\n * @returns The manifest and the directory it was read from, which is also where the\n *   stylesheets it names live.\n * @throws If no installed copy carries one — an SDK older than the manifest.\n */\nfunction readManifest(root: string): { manifest: StyleManifest; dir: string } {\n    const relative = join(\"tempest-react-sdk\", \"dist\", \"styles\", \"manifest.json\");\n    const candidates: string[] = [];\n\n    let dir = resolve(root);\n    for (;;) {\n        candidates.push(join(dir, \"node_modules\", relative));\n        const parent = dirname(dir);\n        if (parent === dir) break;\n        dir = parent;\n    }\n    candidates.push(join(dirname(fileURLToPath(import.meta.url)), \"..\", \"styles\", \"manifest.json\"));\n\n    for (const candidate of candidates) {\n        try {\n            const manifest = JSON.parse(readFileSync(candidate, \"utf8\")) as StyleManifest;\n            return { manifest, dir: dirname(candidate) };\n        } catch {\n            continue;\n        }\n    }\n    throw new Error(\n        \"tempestStyles(): tempest-react-sdk/dist/styles/manifest.json not found — \" +\n            \"the installed SDK predates it. Upgrade, or drop the plugin and import \" +\n            \"tempest-react-sdk/styles.css.\",\n    );\n}\n\n/**\n * Import only the SDK stylesheets your app can actually reach.\n *\n * `styles.css` carries every component the SDK ships — measured at 236.71 kB raw\n * against the 38.94 kB an app mounting twelve of them can reach. The per-component\n * sheets under `styles/` have always closed that gap, but by hand: the app lists\n * them and keeps the list honest as it grows. This plugin makes the list the build's\n * problem, resolving it from the imports the source already writes.\n *\n * The closure matters more than the scan. A component pays for the CSS of every SDK\n * component it renders internally, so `<DataTable>` alone needs six sheets and\n * `<AIChat>` seven — a hand-kept list of one sheet per component the app names is\n * wrong in a way that only shows up as an unstyled child.\n *\n * The reset is the other half, and the half that breaks apps. `styles.css` claims\n * `html`, `body` and `#root`; an app with its own layout that imports it loses its\n * document surface, and an app that drops the import loses the box model its\n * components are written against — components render unstyled, which is what the\n * \"just remove the import\" fix actually costs. The default `reset: \"scoped\"` is the\n * third option: the same normalisation, confined to\n * `:where([class*=\"tempest_\"])`, so it reaches inside a Tempest component and\n * nowhere else.\n *\n * `tempest-react-sdk/styles/auto.css` is a real file, so it resolves without the\n * plugin too — to the complete sheet. Dropping the plugin costs bytes, never\n * correctness.\n *\n * @param options - Scan configuration.\n * @returns The Vite plugin.\n *\n * @example\n * // vite.config.ts\n * import { createViteConfig, tempestStyles } from \"tempest-react-sdk/vite\";\n *\n * export default createViteConfig({ plugins: [tempestStyles()] });\n *\n * @example\n * // src/main.tsx — the one import, instead of a maintained list\n * import \"tempest-react-sdk/styles/auto.css\";\n */\nexport function tempestStyles(options: TempestStylesOptions = {}): TempestVitePlugin {\n    const { dir = \"src\", include = [], skipDirs, reset = \"scoped\", tokens = \"used\" } = options;\n    const skip = new Set<string>(skipDirs ?? SKIP_DIRS);\n    let root = process.cwd();\n    let names: string[] | null = [...include];\n    let appStyleUsage = \"\";\n\n    /**\n     * Rescan the source tree, keeping the explicitly included names.\n     *\n     * @tempest-limits empty-catch — the scan races the editor and the file system:\n     * a file listed a moment ago can be renamed, deleted, or held by another process\n     * by the time it is read. An unreadable file contributes no names and the build\n     * continues; failing the whole scan would break `vite dev` over a temp file that\n     * no longer exists.\n     */\n    const rescan = async (): Promise<void> => {\n        const found = new Set<string>(include);\n        const usage: string[] = [];\n        let namespaced = false;\n        for (const file of await collectSourceFiles(resolve(root, dir), skip)) {\n            let code: string;\n            try {\n                code = await readFile(file, \"utf8\");\n            } catch {\n                continue;\n            }\n            if (code.includes(\"--tempest-\")) usage.push(code);\n            if (STYLE_FILE.test(file)) continue;\n            const scanned = scanStyleImports(code);\n            if (scanned === null) namespaced = true;\n            else for (const name of scanned) found.add(name);\n        }\n        appStyleUsage = usage.join(\"\\n\");\n        names = namespaced ? null : [...found];\n    };\n\n    /**\n     * The token block for this build, or `null` to `@import` the whole sheet.\n     *\n     * Reads the stylesheets the entry is about to load and closes over the tokens\n     * they consult, plus the ones the app's own CSS consults. Any read it cannot\n     * resolve statically — a name assembled at runtime, an unreadable sheet, a\n     * package too old to ship `tokens.css` — returns `null`, which costs bytes and\n     * never correctness. Serving a token sheet with a hole in it would do the\n     * opposite.\n     *\n     * @param manifest - The published style manifest.\n     * @param styleDir - Directory the manifest and its stylesheets live in.\n     * @returns The narrowed sheet, or `null`.\n     */\n    const narrowedTokens = (manifest: StyleManifest, styleDir: string): string | null => {\n        if (tokens === \"all\" || names === null) return null;\n        let tokensCss: string;\n        try {\n            tokensCss = readFileSync(join(styleDir, \"tokens.css\"), \"utf8\");\n        } catch {\n            return null;\n        }\n        const parts: string[] = [appStyleUsage];\n        for (const sheet of selectedSheets(names, manifest, reset)) {\n            try {\n                parts.push(readFileSync(join(styleDir, sheet), \"utf8\"));\n            } catch {\n                return null;\n            }\n        }\n        return narrowTokens(tokensCss, parts.join(\"\\n\"));\n    };\n\n    return {\n        name: \"tempest-styles\",\n        enforce: \"pre\",\n\n        configResolved(config: { root?: string }) {\n            root = config.root ?? root;\n        },\n\n        async buildStart() {\n            await rescan();\n        },\n\n        resolveId(id: string) {\n            return id === TEMPEST_STYLES_ID ? RESOLVED_ID : null;\n        },\n\n        load(id: string) {\n            if (id !== RESOLVED_ID) return null;\n            const { manifest, dir: styleDir } = readManifest(root);\n            return buildStyleEntry(names, manifest, reset, narrowedTokens(manifest, styleDir));\n        },\n    };\n}\n"],"mappings":"2IASA,IAAa,EAAoB,oCAE3B,EAAc,4BAGd,EAAgB,mDAEhB,EAAc,kBAUd,EAAa,0BACb,EAAY,IAAI,IAAI,CAAC,eAAgB,OAAQ,QAAS,UAAU,CAAC,EAyEvE,SAAgB,EAAiB,EAA+B,CAC5D,IAAM,EAAQ,IAAI,IAElB,IAAK,IAAM,KAAS,EAAK,SACrB,4DACJ,EAAG,CACC,GAAM,EAAG,EAAU,EAAQ,GAAa,EAExC,GADI,CAAC,EAAc,KAAK,GAAa,EAAE,GACnC,EAAU,SACd,GAAI,gBAAgB,KAAK,GAAU,EAAE,EAAG,OA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